body.subscriptions-page {
  max-width: none;
  width: fit-content;
  min-width: min(100%, 40rem);
  max-width: 100%;
}

body.subscriptions-page:has(#timeline-section:not(.hidden)) {
  width: 100%;
  max-width: 100%;
}

.subs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.view-toggle {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.2rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.view-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.save-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 4.5rem;
}

.save-status.saved { color: var(--success); }
.save-status.error { color: var(--danger); }

.subs-panel {
  padding: 0;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.view-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 0.85rem;
}

.view-summary[hidden] { display: none !important; }

.view-summary-title { font-weight: 700; color: var(--text); }

.view-summary-metric {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.view-summary-metric strong {
  color: var(--text);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 12rem);
  max-width: 100%;
}

.subs-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.subs-table th,
.subs-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  vertical-align: middle;
  white-space: nowrap;
}

.subs-table th:last-child,
.subs-table td:last-child { border-right: none; }

.subs-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
  box-shadow: 0 1px 0 var(--border);
}

.subs-table tbody tr:hover td { background: var(--surface-hover); }

.subs-table tbody tr.is-ended td { opacity: 0.55; }

.subs-table tfoot td {
  background: var(--bg-subtle);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  position: sticky;
  bottom: 0;
  box-shadow: 0 -1px 0 var(--border);
}

.cell-input {
  width: 100%;
  min-width: 5rem;
  max-width: 12rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  padding: 0.25rem 0.3rem;
  color: var(--text);
}

.cell-input.num {
  min-width: 5rem;
  max-width: 7rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cell-input.date {
  min-width: 8.2rem;
  max-width: 9.5rem;
}

.cell-input.link {
  min-width: 10rem;
  max-width: 16rem;
}

.cell-input:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.store-link {
  display: inline-block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
  font-size: 0.78rem;
}

.btn-row-edit,
.btn-row-del {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.btn-row-edit:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-row-del {
  font-size: 0.9rem;
  line-height: 1;
}

.btn-row-del:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.empty-hint {
  padding: 1rem 1.25rem;
  margin: 0;
}

.hidden { display: none !important; }

.btn.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.btn.danger {
  background: var(--danger-bg, #fef2f2);
  border-color: #fecaca;
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: var(--danger);
}

/* Timeline */
.timeline-panel {
  padding: 0.75rem 0.85rem 1rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.timeline-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.timeline-meta { margin: 0; }

.timeline-panel .view-summary {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.timeline-panel .view-summary + .timeline-root {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.timeline-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.timeline-zoom-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.timeline-zoom {
  width: auto;
  min-width: 8rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
}

.timeline-root {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 15.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  overflow: hidden;
}

.tl-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.tl-header-row {
  display: flex;
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.tl-corner {
  flex: 0 0 var(--lane-label-w, 160px);
  width: var(--lane-label-w, 160px);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0.55rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-sizing: border-box;
}

.tl-x-rail {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: #fff;
}

.tl-header-canvas { min-height: 2.9rem; }

.tl-y-rail {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

.tl-months {
  display: flex;
  height: 1.55rem;
  border-bottom: 1px solid var(--border);
}

.tl-month {
  flex: 0 0 auto;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  padding: 0.25rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: #eef2ff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tl-month:nth-child(even) { background: #e0e7ff; }

.tl-days {
  display: flex;
  height: 1.35rem;
  background: #fff;
}

.tl-day {
  flex: 0 0 auto;
  box-sizing: border-box;
  border-right: 1px solid #f1f5f9;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.tl-day.is-weekend {
  background: #f8fafc;
  color: #94a3b8;
}

.tl-day.is-today {
  background: #fee2e2;
  color: var(--danger);
  font-weight: 800;
}

.tl-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 3;
  pointer-events: none;
}

.tl-lane {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 3.5rem;
}

.tl-lane:nth-child(even) .tl-lane-head,
.tl-lane:nth-child(even) .tl-lane-canvas {
  background: #f8fafc;
}

.tl-lane-head {
  flex: 0 0 var(--lane-label-w, 160px);
  width: var(--lane-label-w, 160px);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.tl-lane-title {
  font-size: 0.82rem;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-lane-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-lane-canvas-clip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.tl-lane-canvas {
  position: relative;
  min-height: 3.2rem;
}

.tl-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e2e8f0;
  pointer-events: none;
}

.tl-grid-line.is-month { background: #cbd5e1; }

.tl-card {
  position: absolute;
  height: 44px;
  border: none;
  border-radius: 8px;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tl-card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.12),
    inset 0 0 0 1px rgba(15, 23, 42, 0.1);
  z-index: 2;
}

.tl-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tl-card.is-ended {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.tl-card-body {
  position: absolute;
  top: 0;
  bottom: 0;
  max-width: 100%;
  padding: 0.28rem 0.5rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.05rem;
  pointer-events: none;
}

.tl-card-name {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-card-main {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.tl-card-meta {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Editor */
.sub-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(28rem, 94vw);
  box-shadow: var(--shadow-lg);
}

.sub-editor::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.sub-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem 1.25rem;
}

.sub-form h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.sub-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.sub-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sub-form .field-span { grid-column: 1 / -1; }

.sub-form .field-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.sub-form .field-input {
  width: 100%;
  box-sizing: border-box;
}

.form-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
}

.sub-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.sub-form-actions-end {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

@media (max-width: 520px) {
  .sub-form-grid { grid-template-columns: 1fr; }
}
