/* Master Bot Mini App — look of the approved mockup (navy, turquoise rule, rounded corners). */
:root {
  --bg: #0B1626; --surface: #12233A; --surface-2: #183152; --line: #23405F; --row: #1B3350;
  --text: #EAF2FA; --soft: #CFDCEA; --muted: #A7BBD1; --faint: #8EA5BF;
  --accent: #3DD6C6; --accent-ink: #06202A; --warn: #F4B860; --bad: #FF9A8B;
  --radius: 14px; --pad: 16px;
  --display: "Sora", system-ui, sans-serif; --body: "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--body); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

.screen { max-width: 560px; margin: 0 auto; padding: 16px var(--pad) calc(24px + env(safe-area-inset-bottom)); }
.screen.has-bar { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

/* header */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.top .titles { flex: 1; min-width: 0; }
.top h1 { margin: 0; font: 700 20px/1.2 var(--display); overflow-wrap: anywhere; }
.top .sub { font-size: 13px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.rule { height: 2px; border-radius: 1px; background: var(--accent); margin: 8px 0 4px; }

/* category chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.group-title { margin: 18px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* site rows */
.site-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px; margin-bottom: 8px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left; }
.mono { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font: 700 16px var(--display); color: var(--accent); }
.site-row .name { font-weight: 600; }
.site-row .kind { font-size: 13px; color: var(--muted); }
.site-row .grow { flex: 1; min-width: 0; }
.chev { color: var(--muted); width: 18px; height: 18px; }

/* search */
.search { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.search label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.search .box { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 6px 0 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-size: 16px; }
.search input::placeholder { color: var(--faint); }
.search .box svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search .clear { width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { height: 44px; padding: 0 14px; margin-bottom: -1px; background: transparent; border: 0;
  border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tab[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.results-title { font: 600 15px var(--display); margin: 0 0 12px; color: var(--soft); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { display: flex; flex-direction: column; gap: 8px; padding: 0; border: 0; background: transparent; text-align: left; }
.cover { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); }
.cover.wide { aspect-ratio: 16 / 10; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 12px; font: 700 28px var(--display); color: var(--accent); }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .m { font-size: 12px; color: var(--muted); }

/* fiche */
.hero { display: flex; gap: 14px; margin-bottom: 14px; }
.hero .cover { width: 112px; flex-shrink: 0; }
.hero.video { flex-direction: column; }
.hero.video .cover { width: 100%; }
.hero h1 { margin: 0 0 8px; font: 700 22px/1.2 var(--display); overflow-wrap: anywhere; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--soft); }
.facts { font-size: 13px; color: var(--muted); }
.synopsis { margin: 0 0 4px; color: var(--soft); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.synopsis.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { padding: 6px 0; background: transparent; border: 0; color: var(--accent); font-weight: 600; font-size: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 14px; }
.section-head h2 { margin: 0; font: 600 17px var(--display); }
.section-head .range { font-size: 12px; color: var(--muted); text-align: right; }
.sort-btn { font-size: 13px; }

/* chapter / episode rows */
.rows { margin-top: 4px; }
.row { border-bottom: 1px solid var(--row); }
.row-btn { width: 100%; min-height: 52px; padding: 0 2px; display: flex; align-items: center; gap: 12px; background: transparent; border: 0; text-align: left; }
.row-btn .lbl { flex: 1; min-width: 0; font-size: 15px; }
.row-btn .lbl small { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-num { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; font: 600 13px var(--display); color: var(--soft); }
.check { width: 24px; height: 24px; flex-shrink: 0; border-radius: 12px; border: 1.5px solid #3A5878; display: grid; place-items: center; }
.check svg { width: 14px; height: 14px; display: none; }
[aria-pressed="true"] .check { background: var(--accent); border-color: var(--accent); }
[aria-pressed="true"] .check svg { display: block; }
.quick { display: flex; align-items: center; gap: 8px; padding: 0 2px 12px; }
.quick span { font-size: 13px; color: var(--muted); margin-right: 4px; }
.ghost { height: 36px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-weight: 600; font-size: 14px; }

/* bottom bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom)); }
.bar-in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.bar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar-top .count { font-size: 14px; font-weight: 600; }
.bar-actions { display: flex; gap: 10px; }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.seg button { height: 40px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--line); color: var(--text); font-weight: 600; }
.primary { flex: 1; height: 48px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.bar .note { font-size: 12px; color: var(--muted); text-align: center; }

/* queue */
.job { border-radius: 16px; background: var(--surface); border: 1px solid var(--line); padding: 14px; margin-bottom: 10px;
  display: flex; gap: 12px; align-items: flex-start; }
.job.done { background: #0F1E32; border-color: var(--row); }
.job.retry { border-color: #5C4A2A; }
.job .grow { flex: 1; min-width: 0; }
.job .t { font-weight: 600; overflow-wrap: anywhere; }
.job .s { font-size: 13px; color: var(--muted); }
.job .s.warn { color: var(--warn); } .job .s.bad { color: var(--bad); }
.job .cancel { width: 44px; height: 44px; margin: -8px -8px 0 0; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.progress { margin-top: 10px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; position: relative; }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.done-dot { width: 22px; height: 22px; flex-shrink: 0; border-radius: 11px; background: var(--accent); display: grid; place-items: center; }
.done-dot svg { width: 13px; height: 13px; }

/* states */
.state { padding: 28px 16px; text-align: center; color: var(--muted); }
.state .msg { margin-bottom: 14px; color: var(--soft); }
.state.err .msg { color: var(--warn); }
.more { margin-top: 18px; }
.skel { 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.3s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(160px + env(safe-area-inset-bottom)); z-index: 10;
  width: min(520px, calc(100% - 32px)); padding: 12px 14px; border-radius: 12px; background: #1E3A5C; border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.toast .grow { flex: 1; }
.toast.low { bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .skel, .progress::after { animation: none; } }
