* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

body.sheet-open {
  overflow: hidden;
}

#app {
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header ------------------------------------------------------------------ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-header__titles {
  flex: 1;
  min-width: 0;
}

.app-header__title {
  margin: 0;
  font-size: var(--text-20);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}

.app-header__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-12);
  line-height: var(--leading-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stale-badge {
  flex: 0 0 auto;
}

.stale-badge .icon {
  width: 12px;
  height: 12px;
}

.stale-bar {
  background: var(--amber-dim);
  border-top: 1px solid var(--border);
}

.stale-bar__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 8px var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--amber);
  font-size: var(--text-12);
}

.stale-bar__inner .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.stale-bar__text {
  flex: 1;
  min-width: 0;
}

.stale-bar__code {
  font-size: var(--text-11);
  opacity: 0.8;
}

/* View + tab bar ---------------------------------------------------------- */

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4) var(--gutter) calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--space-8));
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tab {
  position: relative;
  min-height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: var(--text-11);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tab .icon {
  width: 22px;
  height: 22px;
}

.tab[aria-current="page"] {
  color: var(--text);
}

.tab[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  width: 20px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--text);
}

.tab:active {
  background: var(--surface);
}

[data-mode="auth"] .app-header,
[data-mode="auth"] .tabbar,
[data-mode="boot"] .app-header,
[data-mode="boot"] .tabbar {
  display: none;
}

[data-mode="auth"] .view,
[data-mode="boot"] .view {
  padding: 0;
  max-width: none;
}

/* Primitives -------------------------------------------------------------- */

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.icon--chevron {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.label {
  display: block;
  color: var(--muted);
  font-size: var(--text-11);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label--faint {
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge .dot {
  width: 6px;
  height: 6px;
}

.badge--green,
.badge--available {
  color: var(--green);
  background: var(--green-dim);
}

.badge--amber,
.badge--degraded {
  color: var(--amber);
  background: var(--amber-dim);
}

.badge--red,
.badge--failed {
  color: var(--red);
  background: var(--red-dim);
}

.badge--grey,
.badge--queued {
  color: var(--grey);
  background: var(--grey-dim);
}

.dot.streaming {
  background: var(--green);
}

.dot.paused {
  background: var(--amber);
}

.dot.idle {
  background: var(--grey);
}

.tag {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 9.5px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.05em;
  line-height: 1.5;
  text-transform: uppercase;
  vertical-align: 1px;
}

.bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grey);
}

.bar--green > span {
  background: var(--green);
}

.bar--amber > span {
  background: var(--amber);
}

.bar--red > span {
  background: var(--red);
}

.bar--grey > span {
  background: var(--grey);
}

.bar--neutral > span {
  background: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  background: var(--surface-3);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn--primary {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
  font-weight: var(--weight-semibold);
}

.btn--primary:active {
  background: var(--text-secondary);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--sm {
  min-height: 44px;
  font-size: var(--text-13);
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: var(--surface-2);
}

.icon-btn.is-spinning .icon {
  animation: spin 600ms linear;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.notice {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.notice--red {
  border-color: var(--red-dim);
  background: var(--red-dim);
}

.notice--red .notice__title {
  color: var(--red);
}

.notice--amber {
  border-color: var(--amber-dim);
  background: var(--amber-dim);
}

.notice--amber .notice__title {
  color: var(--amber);
}

.notice__title {
  margin: 0;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
}

.notice__meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-11);
}

.notice .btn {
  margin-top: var(--space-3);
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton-list {
  display: grid;
  gap: 1px;
  padding: var(--space-2) 0;
}

.skeleton--row {
  height: 56px;
  border-radius: 8px;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.empty__icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--faint);
}

.empty__icon .icon {
  width: 18px;
  height: 18px;
}

.empty__title {
  margin: 0;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.empty__body {
  margin: 4px auto 0;
  max-width: 32ch;
  color: var(--muted);
  font-size: var(--text-12);
}

/* Overview ---------------------------------------------------------------- */

.overview-loading {
  display: grid;
  gap: var(--space-3);
}

.hero {
  padding: var(--space-4);
  background: var(--bg-elevated);
}

.hero__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.hero__value {
  margin: 2px 0 0;
  font-size: var(--text-32);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
}

.hero__meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-12);
}

.chart {
  margin-top: var(--space-3);
}

.chart--empty {
  height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: var(--text-12);
}

.chart--empty p {
  margin: 0;
}

.chart__svg {
  display: block;
  width: 100%;
  height: 96px;
  overflow: visible;
}

.chart__grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart__area {
  fill: var(--chart-fill);
}

.chart__line {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart__peak {
  fill: var(--chart-line);
}

.chart__axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.stat {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.stat .label {
  font-size: 10px;
  letter-spacing: 0.06em;
}

.stat__value {
  font-size: var(--text-17);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  white-space: nowrap;
}

.stat .badge {
  margin-top: 4px;
  padding: 2px 6px;
  font-size: 9px;
}

.section {
  margin-top: var(--space-5);
}

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 32px;
}

.section__title {
  margin: 0;
  font-size: var(--text-15);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

.section__link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding-left: var(--space-2);
  color: var(--muted);
  font-size: var(--text-12);
  text-decoration: none;
}

.section__link .icon {
  width: 14px;
  height: 14px;
}

.section__sub {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-12);
}

.live-list {
  display: grid;
  gap: var(--space-2);
}

.live-card {
  padding: var(--space-3) var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.live-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.live-card__activity .dot {
  width: 6px;
  height: 6px;
}

.live-card__speed {
  color: var(--text-secondary);
  font-size: var(--text-12);
}

.live-card__title {
  margin: 0;
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
}

.live-card__file {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-11);
}

.indexers {
  padding: 0 var(--space-4);
}

.indexer {
  padding: var(--space-3) 0;
}

.indexer + .indexer {
  border-top: 1px solid var(--border);
}

.indexer__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 6px;
}

.indexer__name {
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.indexer__rate {
  color: var(--text-secondary);
  font-size: var(--text-12);
}

.indexer__meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-11);
}

.recent-list {
  padding: 0 var(--space-3);
}

.recent {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: var(--space-3) 0;
  color: var(--text);
  text-decoration: none;
}

.recent + .recent {
  border-top: 1px solid var(--border);
}

.recent__icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
}

.recent__icon .icon {
  width: 16px;
  height: 16px;
}

.recent__main {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.recent__title {
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent__meta {
  color: var(--muted);
  font-size: var(--text-11);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent__size {
  justify-self: end;
  color: var(--text-secondary);
  font-size: var(--text-12);
  text-align: right;
}

/* Library ----------------------------------------------------------------- */

.library-tools {
  display: grid;
  gap: var(--space-3);
}

.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-2) 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.search > .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--text-15);
  outline: none;
  -webkit-appearance: none;
}

.search input::placeholder {
  color: var(--muted);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search__clear {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search__clear .icon {
  width: 16px;
  height: 16px;
}

.search__clear:active {
  background: var(--surface-2);
}

.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-13);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip[aria-pressed="true"],
.chip[aria-current="page"] {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}

.chip__count {
  color: var(--muted);
  font-size: var(--text-11);
}

.chip[aria-pressed="true"] .chip__count,
.chip[aria-current="page"] .chip__count {
  color: var(--text-secondary);
}

.sortbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sortbar__label {
  color: var(--muted);
  font-size: var(--text-11);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sortbar__select {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-13);
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.sortbar__dir {
  border-color: var(--border);
}

.library-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-12);
}

.library-status__shown {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.list {
  overflow: hidden;
}

.release {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 64px;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.release:first-child {
  border-top: 0;
}

.release:active {
  background: var(--surface-2);
}

.release .dot {
  margin-top: 1px;
}

.release__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.release__title {
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.release__season {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  vertical-align: 1px;
}

.release__meta {
  color: var(--muted);
  font-size: var(--text-11);
  line-height: var(--leading-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.release__side {
  display: grid;
  gap: 1px;
  justify-items: end;
  min-width: 72px;
  text-align: right;
  white-space: nowrap;
}

.release__size {
  color: var(--text-secondary);
  font-size: var(--text-13);
}

.release__time {
  color: var(--muted);
  font-size: 10px;
}

.loadmore {
  margin-top: var(--space-4);
}

.loadmore__btn {
  width: 100%;
}

.loadmore__end {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-11);
  text-align: center;
}

/* Detail sheet ------------------------------------------------------------ */

.sheet-layer {
  position: relative;
  z-index: 40;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.62);
  animation: fade-in var(--dur) var(--ease);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: var(--content-max);
  margin: 0 auto;
  max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: sheet-in var(--dur-slow) var(--ease);
}

.sheet__grab {
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-2);
}

.sheet__titles {
  flex: 1;
  min-width: 0;
}

.sheet__title {
  margin: 0;
  padding-right: var(--space-2);
  font-size: var(--text-20);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.sheet__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-12);
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}

.sheet__statusline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-3);
}

.sheet__name {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-11);
  line-height: var(--leading-normal);
  word-break: break-word;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.meta-cell {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.meta-cell .label {
  font-size: 10px;
}

.meta-cell__value {
  display: block;
  margin-top: 2px;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.sheet__section {
  margin-top: var(--space-5);
}

.sheet__section .label {
  margin-bottom: var(--space-2);
}

.sheet__none {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-12);
}

.files,
.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.file {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
}

.file + .file {
  border-top: 1px solid var(--border);
}

.file__icon {
  color: var(--muted);
}

.file__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.file__name {
  font-family: var(--font-mono);
  font-size: var(--text-11);
  line-height: var(--leading-normal);
  word-break: break-all;
}

.file__meta {
  color: var(--muted);
  font-size: var(--text-11);
}

.history {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--space-3);
  padding: var(--space-3);
  font-size: var(--text-12);
}

.history + .history {
  border-top: 1px solid var(--border);
}

.history__when {
  font-weight: var(--weight-medium);
}

.history__meta {
  color: var(--muted);
  font-size: var(--text-11);
}

.history__reason {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-size: var(--text-11);
  text-align: right;
}

.secret {
  display: block;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-13);
  word-break: break-all;
}

.sheet__actions {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.sheet__actions .btn {
  width: 100%;
  min-height: 48px;
}

.sheet__note {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--text-11);
  text-align: center;
}

@keyframes sheet-in {
  from {
    transform: translateY(28px);
    opacity: 0.5;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* Placeholder screens ----------------------------------------------------- */

.placeholder {
  padding: var(--space-6) var(--space-5);
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.placeholder__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-2);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.placeholder__title {
  margin: 0;
  font-size: var(--text-24);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
}

.placeholder__body {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-13);
  line-height: var(--leading-relaxed);
}

.placeholder__list {
  margin: var(--space-2) 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: var(--text-13);
  line-height: var(--leading-relaxed);
}

.placeholder__list strong {
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.placeholder__note {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-size: var(--text-11);
}

.placeholder .btn {
  min-height: 44px;
}

/* Auth + boot ------------------------------------------------------------- */

.auth,
.boot {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--space-8) + env(safe-area-inset-top)) var(--space-4)
    calc(var(--space-8) + env(safe-area-inset-bottom));
  text-align: center;
}

.auth__brand {
  margin-bottom: var(--space-3);
}

.mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.14em;
}

.auth__title,
.boot h1 {
  margin: 0;
  font-size: var(--text-24);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
}

.auth__lede {
  margin: var(--space-2) 0 var(--space-5);
  max-width: 36ch;
  color: var(--muted);
  font-size: var(--text-13);
  line-height: var(--leading-relaxed);
}

.auth__lede code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.auth__card {
  width: 100%;
  max-width: 340px;
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
  text-align: left;
}

.field {
  display: grid;
  gap: 4px;
}

.field__label {
  color: var(--muted);
  font-size: var(--text-11);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field__input {
  height: 48px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.field__input:focus {
  border-color: var(--text-secondary);
}

.auth__error {
  margin: 0;
  color: var(--red);
  font-size: var(--text-12);
  line-height: var(--leading-normal);
}

.auth__submit {
  width: 100%;
  min-height: 48px;
}

.auth__foot {
  margin: var(--space-5) 0 0;
  color: var(--muted);
  font-size: var(--text-11);
}

.boot {
  gap: var(--space-3);
}

.boot__line {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-13);
}

.noscript {
  padding: var(--space-4);
  color: var(--amber);
  text-align: center;
}

/* Wide screens ------------------------------------------------------------ */
@media (min-width: 600px) {
  .view {
    padding-top: var(--space-6);
  }

  .stats {
    gap: var(--space-3);
  }
}

/* Streams ----------------------------------------------------------------- */

.streams {
  display: block;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.segmented__item {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.segmented__item[aria-current="page"] {
  background: var(--surface-3);
  color: var(--text);
}

.segmented__item:active {
  background: var(--surface-2);
}

.stream-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.stream-summary__line {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: var(--text-13);
}

.stream-summary__speed {
  text-align: right;
  flex: 0 0 auto;
}

.stream-summary__speed strong {
  display: block;
  font-size: var(--text-20);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  white-space: nowrap;
}

.stream-summary__speed span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stream-list {
  display: grid;
  gap: var(--space-2);
}

.stream-card {
  padding: var(--space-3) var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.stream-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.stream-card__speed {
  color: var(--text-secondary);
  font-size: var(--text-12);
}

.stream-card__title {
  margin: 0;
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
}

.stream-card__file {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-3);
  color: var(--muted);
  font-size: var(--text-11);
}

.stream-card__served {
  flex: 1 1 100%;
  color: var(--text-secondary);
  font-size: var(--text-12);
}

.stream-card__served .label {
  display: inline;
  margin-right: 4px;
  font-size: 10px;
}

/* History ----------------------------------------------------------------- */

.history-tools {
  margin-bottom: var(--space-3);
}

.history-groups {
  display: grid;
  gap: var(--space-4);
}

.day-group {
  display: grid;
  gap: var(--space-2);
}

.day-heading {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-11);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  overflow: hidden;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
}

.history-row + .history-row {
  border-top: 1px solid var(--border);
}

.history-row__main {
  min-width: 0;
}

.history-row__titleline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.history-row__title {
  margin: 0;
  min-width: 0;
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-row__meta {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: var(--text-11);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-row__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-11);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nzb-chip {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.nzb-chip:active {
  background: var(--surface-3);
}

/* Bandwidth --------------------------------------------------------------- */

.window-switch {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.window-switch::-webkit-scrollbar {
  display: none;
}

.bw-hero {
  padding: var(--space-4);
  background: var(--bg-elevated);
}

.bw-hero__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.bw-hero__value {
  margin: 2px 0 0;
  font-size: var(--text-32);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
}

.bw-hero__meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-12);
}

.transport {
  padding: 0 var(--space-4);
}

.transport-row {
  padding: var(--space-3) 0;
}

.transport-row + .transport-row {
  border-top: 1px solid var(--border);
}

.transport-row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 6px;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.transport-row__head .tabular {
  color: var(--text-secondary);
}

.transport-row__meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-11);
}

/* Indexers ---------------------------------------------------------------- */

.indexers-screen {
  display: block;
}

.aggregate-note {
  margin: var(--space-3) 0 0;
  color: var(--muted);
  font-size: var(--text-11);
  line-height: var(--leading-relaxed);
}

.indexer-list,
.provider-list {
  padding: 0 var(--space-4);
}

.indexer-row {
  padding: var(--space-4) 0;
  display: grid;
  gap: var(--space-2);
}

.indexer-row + .indexer-row {
  border-top: 1px solid var(--border);
}

.indexer-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.indexer-row__name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-15);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.indexer-row__rate {
  flex: 0 0 auto;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.indexer-row__meta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-11);
}

.indexer-row__failures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.indexer-row__failures-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.indexer-row__none {
  color: var(--muted);
  font-size: 10px;
}

.failure {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
}

.failure strong {
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.failure--bad strong {
  color: var(--red);
}

.indexer-row__error {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: var(--leading-normal);
}

.indexer-row__error-date {
  display: block;
  color: var(--text-secondary);
  font-size: 10px;
}

.indexer-row__error-message {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 10px;
}

.indexer-row__error.is-empty {
  color: var(--muted);
  font-size: 10px;
}

.indexer-error {
  margin-top: 2px;
}

.indexer-error__summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.indexer-error__summary::-webkit-details-marker {
  display: none;
}

.indexer-error__summary::before {
  content: "+";
  width: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  text-align: center;
}

.indexer-error[open] .indexer-error__summary::before {
  content: "-";
}

.indexer-error__date {
  color: var(--text-secondary);
}

.indexer-error__message {
  margin: 0 0 var(--space-2) 20px;
  color: var(--muted);
  font-size: 10px;
  line-height: var(--leading-relaxed);
  word-break: break-word;
}

.provider-row {
  padding: var(--space-4) 0;
  display: grid;
  gap: 6px;
}

.provider-row + .provider-row {
  border-top: 1px solid var(--border);
}

.provider-row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.provider-row__name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
}

.provider-row__meta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-11);
  line-height: var(--leading-normal);
}

.provider-row__share {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.tag--idle {
  color: var(--grey);
}

