/* ============================================================
   Saku — Anime Tracker
   Design system extracted from Anime-Tracker.dc.html
   Dark ground · indigo primary · cyan time/airing · phone-first
   ============================================================ */

:root {
  /* surfaces */
  --bg:        #0a0f1c;   /* screen ground */
  --bg-deep:   #080b14;   /* behind everything */
  --card:      #121a2b;   /* cards / inputs */
  --card-2:    #0a0f1c;   /* recessed (stepper track) */

  /* borders / separators */
  --line:      rgba(148,163,184,0.10);
  --line-2:    rgba(148,163,184,0.16);
  --line-soft: rgba(148,163,184,0.08);

  /* text */
  --t-hi:   #f8fafc;
  --t:      #e8edf6;
  --t-2:    #e2e8f0;
  --t-mut:  #94a3b8;
  --t-mut2: #64748b;
  --t-faint:#475569;

  /* accents */
  --indigo:    #6366f1;
  --indigo-2:  #4f46e5;
  --indigo-lt: #a5b4fc;
  --indigo-mid:#818cf8;
  --cyan:      #22d3ee;
  --cyan-lt:   #67e8f9;
  --emerald:   #10b981;
  --emerald-lt:#6ee7b7;
  --rose:      #f43f5e;
  --rose-lt:   #fb7185;
  --amber:     #fbbf24;

  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Zen Kaku Gothic New', system-ui, -apple-system, sans-serif;

  /* safe-area insets for notched phones in standalone mode */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* bottom padding for the bars: just enough to clear the home indicator,
     without the big empty band the full safe-area inset adds */
  --pb: max(8px, calc(var(--safe-bottom) - 16px));
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; background: var(--bg); }

/* position:fixed + inset:0 pins the app to the real visual viewport, which
   sidesteps the iOS standalone-PWA bug where height:100%/100vh leaves a gap
   at the bottom. Internal scrolling happens inside .screen__scroll, so the
   fixed body never needs to scroll itself. */
body {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--t-2);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }
::selection { background: rgba(99,102,241,0.4); }

/* scrollbars stay subtle */
::-webkit-scrollbar { width: 0; height: 0; }

/* ---- app frame -------------------------------------------- */
#app {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 520px;   /* keep it phone-shaped on desktop too */
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* A screen fills #app and lays out header / scroll / (tabbar is separate) */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.screen__scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen__head   { flex-shrink: 0; padding-top: calc(16px + var(--safe-top)); }

/* page title */
.h-eyebrow { font: 700 10px/1 var(--mono); letter-spacing: 0.18em; color: var(--t-mut2); }
.h-title   { margin: 0; font: 900 27px/1.1 var(--sans); letter-spacing: -0.01em; color: var(--t-hi); }
.h-title-sm{ margin: 0; font: 900 23px/1.1 var(--sans); letter-spacing: -0.01em; color: var(--t-hi); }

/* ---- bottom tab bar --------------------------------------- */
.tabbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 9px 20px var(--pb);
  background: rgba(10,15,28,0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1; background: none; border: none;
  color: var(--t-mut2);
}
.tab span { font-size: 10.5px; }
.tab svg { stroke: var(--t-mut2); }
.tab.is-active { color: var(--indigo-lt); }
.tab.is-active span { font-weight: 700; }
.tab.is-active svg { stroke: var(--indigo-mid); }
.tab.is-active.tab--cyan { color: var(--cyan-lt); }
.tab.is-active.tab--cyan svg { stroke: var(--cyan-lt); }

/* ---- generic bits ----------------------------------------- */
.mono { font-family: var(--mono); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px; background: var(--card);
  border: 1px solid var(--line-2);
}
.icon-btn svg { stroke: var(--t-mut); }

.section-label {
  font: 700 10px/1 var(--mono); letter-spacing: 0.1em;
  color: var(--t-mut2); margin: 22px 4px 9px;
}

/* primary button */
.btn-primary {
  width: 100%; height: 52px; border: none; border-radius: 14px;
  background: linear-gradient(90deg, var(--indigo-2), var(--indigo));
  box-shadow: 0 8px 22px rgba(79,70,229,0.4);
  font: 700 15px var(--sans); color: #fff;
}
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  width: 100%; height: 52px; border-radius: 14px;
  background: var(--card); border: 1px solid rgba(99,102,241,0.4);
  font: 700 15px var(--sans); color: var(--indigo-lt);
}

/* status pill colours */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px; font: 700 11px var(--sans); }
.status .dot { width: 6px; height: 6px; border-radius: 50%; }
.status--watching  { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.35); color: var(--indigo-lt); }
.status--watching  .dot { background: var(--indigo-mid); }
.status--completed { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.32); color: var(--emerald-lt); }
.status--completed .dot { background: var(--emerald); }
.status--plan      { background: rgba(34,211,238,0.14); border: 1px solid rgba(34,211,238,0.32); color: var(--cyan-lt); }
.status--plan      .dot { background: var(--cyan); }
.status--paused    { background: rgba(148,163,184,0.13); border: 1px solid rgba(148,163,184,0.28); color: var(--t-mut); }
.status--paused    .dot { background: var(--t-mut); }
.status--dropped   { background: rgba(148,163,184,0.10); border: 1px solid rgba(148,163,184,0.22); color: var(--t-mut2); }
.status--dropped   .dot { background: var(--t-mut2); }

/* episode stepper */
.stepper {
  display: flex; align-items: center; gap: 2px;
  background: var(--card-2); border: 1px solid var(--line-2);
  border-radius: 11px; padding: 3px;
}
.stepper button {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: var(--t-mut); font-size: 20px; line-height: 1;
}
.stepper button.plus { background: var(--indigo); color: #fff; }
.stepper button:disabled { opacity: .35; }
.stepper .count { min-width: 24px; text-align: center; font: 700 13px var(--mono); color: var(--t); }

/* progress bar */
.bar { height: 6px; border-radius: 3px; background: rgba(148,163,184,0.14); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--indigo-2), var(--indigo)); }
.bar--done > i { background: linear-gradient(90deg, #059669, var(--emerald)); }
.bar--plan > i { background: var(--cyan); }

/* poster placeholder (used until/if cover art loads) */
.poster {
  position: relative; overflow: hidden; border-radius: 14px;
  background-color: #20263f;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.045) 0 8px, transparent 8px 17px);
  display: flex; align-items: center; justify-content: center;
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster .ph { font: 900 40px var(--sans); color: rgba(165,180,252,0.18); }

/* score badge over poster */
.score-badge {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center; gap: 3px; padding: 3px 7px; border-radius: 7px;
  background: rgba(10,15,28,0.65); backdrop-filter: blur(6px);
  font: 700 10px var(--mono); color: var(--cyan-lt);
}

/* add-to-list FAB on a poster */
.poster-add {
  position: absolute; bottom: 8px; right: 8px;
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: var(--indigo); box-shadow: 0 4px 12px rgba(79,70,229,0.5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; line-height: 1;
}
.poster-state {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border-radius: 11px; font: 700 12px var(--sans); color: #fff;
}
.poster-state--inlist { background: rgba(99,102,241,0.92); backdrop-filter: blur(6px); }
.poster-state--adding {
  background: rgba(10,15,28,0.7); backdrop-filter: blur(6px);
  border: 1px solid rgba(148,163,184,0.2); color: var(--t-mut); font-weight: 500;
}

/* chips / filter pills */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line);
  color: #cbd5e1; font: 500 13px var(--sans);
}
.chip b { font: 400 10px var(--mono); color: var(--t-mut2); }
.chip.is-active { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 700; }
.chip.is-active b { color: rgba(255,255,255,0.7); }

/* search input */
.search-box {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 46px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 14px;
}
.search-box input {
  flex: 1; background: none; border: none; outline: none;
  font: 15px var(--sans); color: var(--t);
}
.search-box input::placeholder { color: var(--t-mut2); }

/* spinner */
.spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(148,163,184,0.35); border-top-color: var(--cyan-lt);
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 60px 30px; text-align: center; color: var(--t-mut);
}
.center-state .big { font: 900 40px var(--sans); color: rgba(165,180,252,0.25); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line-2);
  color: var(--t); font: 500 13px var(--sans);
  padding: 11px 18px; border-radius: 12px; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toast-in .2s ease;
  max-width: 88%;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* toggle switch */
.switch { width: 46px; height: 27px; border-radius: 14px; background: rgba(148,163,184,0.22); position: relative; flex-shrink: 0; border: none; transition: background .15s; }
.switch > i { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #cbd5e1; transition: left .15s, background .15s; }
.switch.is-on { background: var(--indigo); }
.switch.is-on > i { left: 22px; background: #fff; }

/* grid */
.poster-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.poster-grid .poster { aspect-ratio: 2/3; width: 100%; }
.poster-grid > div { position: relative; }
.poster.p-list { width: 60px; height: 90px; border-radius: 10px; }
.poster-grid .title { font: 700 13.5px/1.25 var(--sans); color: var(--t); }
.poster-grid .meta  { font: 10px var(--mono); color: var(--t-mut2); margin-top: 3px; }

/* generic row separators inside cards */
.list-rows > * + * { border-top: 1px solid var(--line-soft); }

/* "TRACKED" tag on schedule rows */
.track-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(99,102,241,0.18); border: 1px solid rgba(99,102,241,0.3);
  color: var(--indigo-lt); font: 700 9px var(--mono); letter-spacing: 0.06em;
}
.track-tag .td { width: 5px; height: 5px; border-radius: 50%; background: var(--indigo-mid); }

/* brand logo (gradient rounded square with ア) */
.brand-logo {
  width: 60px; height: 60px; border-radius: 17px;
  background: linear-gradient(135deg, var(--indigo-2), var(--cyan));
  box-shadow: 0 12px 28px rgba(79,70,229,0.45);
  display: flex; align-items: center; justify-content: center;
  font: 900 28px var(--sans); color: #fff;
}

/* welcome field label */
.field-label { display: block; font: 10px var(--mono); letter-spacing: 0.08em; color: var(--t-mut2); margin-bottom: 8px; }

/* detail section heading */
.d-h { margin: 0; font: 700 15px var(--sans); color: var(--t-hi); }

/* kebab button reset */
.kebab { background: none; border: none; padding: 2px; flex-shrink: 0; }

/* glass round button over banners */
.glass-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,15,28,0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; color: #f1f5f9;
}

/* horizontal scrollers hide their bar */
.hscroll::-webkit-scrollbar { display: none; }

/* coloured square icon holders in profile rows */
.row-ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.row-ic--cyan  { background: rgba(34,211,238,0.14); color: var(--cyan-lt); }
.row-ic--slate { background: rgba(148,163,184,0.10); color: var(--t-mut); }
.row-ic--rose  { background: rgba(244,63,94,0.12); color: var(--rose-lt); }
.row-ic--indigo{ background: rgba(99,102,241,0.14); color: var(--indigo-lt); }

/* ---- bottom sheet ----------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4,7,14,0.55); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 520px;
  background: #0e1424; border: 1px solid var(--line-2); border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 10px 14px calc(16px + var(--safe-bottom));
  animation: sheet-up .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: rgba(148,163,184,0.3); margin: 2px auto 12px; }
.sheet-title { font: 700 13px var(--sans); color: var(--t-mut); text-align: center; margin-bottom: 8px; }
.sheet-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; background: none; border: none; border-radius: 12px;
  font: 500 15px var(--sans); color: var(--t-2); text-align: left;
}
.sheet-row:active { background: rgba(148,163,184,0.08); }
.sheet-row.danger { color: var(--rose-lt); }
.sheet-row .status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sheet-cancel {
  width: 100%; margin-top: 6px; height: 50px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--t-mut);
  font: 700 15px var(--sans);
}
