:root {
  --bg: #FBF6EF; --surface: #FFFFFF; --surface-2: #F3EBE0; --text: #2B2320; --muted: #7A6B62; --line: #E7DCCD;
  --coral: #D9714E; --coral-deep: #B9583C; --spark: #F2A65A; --good: #3F8F5A; --bad: #B84A3A; --focus: #2F6FDB;
  --radius: 16px; --shadow: 0 6px 24px rgba(60, 35, 20, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1715; --surface: #27201D; --surface-2: #322925; --text: #F4ECE4; --muted: #B3A398; --line: #3D332E;
    --coral: #E3805D; --coral-deep: #C8664A; --good: #6CC08A; --bad: #E07B6B; --focus: #8DB4FF; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1715; --surface: #27201D; --surface-2: #322925; --text: #F4ECE4; --muted: #B3A398; --line: #3D332E;
  --coral: #E3805D; --coral-deep: #C8664A; --good: #6CC08A; --bad: #E07B6B; --focus: #8DB4FF; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--coral-deep); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h2 { font-size: 1.35rem; margin: .5rem 0 1rem; }

/* sign in */
.signin { min-height: 100dvh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px 16px; gap: 10px; }
.signin h1 { margin: .25rem 0 0; font-size: 2rem; letter-spacing: -.01em; }
.signin p { max-width: 22rem; margin: 0 0 1rem; }
.signin-robot { animation: bob 3.2s ease-in-out infinite; }
.apple-btn { display: inline-flex; align-items: center; gap: 10px; background: #000; color: #fff; text-decoration: none; font-weight: 600; padding: 14px 26px; border-radius: 12px; font-size: 1.05rem; }
.apple-btn svg { width: 17px; height: 20px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .apple-btn { background: #fff; color: #000; } }

/* chrome */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); max-width: 720px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.signout { font-size: .875rem; color: var(--muted); }
.gear { color: var(--muted); display: grid; place-items: center; width: 40px; height: 40px; margin-right: -8px; }
.gear svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; }
.tabs .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs .count:not(:empty)::before { content: " ("; } .tabs .count:not(:empty)::after { content: ")"; }
.tabs a[aria-current="page"] { color: var(--coral-deep); }
@media (min-width: 720px) {
  .tabs { position: static; max-width: 720px; margin: 0 auto 8px; border: 1px solid var(--line); border-radius: 14px; }
  .tabs a { grid-auto-flow: column; justify-content: center; gap: 8px; font-size: .95rem; padding: 10px; }
  .tabs a { align-items: center; } .tabs .ico { width: 19px; height: 19px; }
}
.content { max-width: 720px; margin: 0 auto; padding: 4px 16px 110px; }

/* film card */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; touch-action: pan-y; transition: transform .25s ease, opacity .25s ease; }
.card.gone-left { transform: translateX(-120%) rotate(-8deg); opacity: 0; }
.card.gone-right { transform: translateX(120%) rotate(8deg); opacity: 0; }
.card-body { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 14px; }
.poster { width: 120px; aspect-ratio: 2 / 3; border-radius: 10px; background: var(--surface-2); object-fit: cover; }
.poster.blank { display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.card h3 { margin: 0 0 4px; font-size: 1.25rem; line-height: 1.2; }
.meta { color: var(--muted); font-size: .875rem; margin: 0 0 6px; }
.why { margin: 0 14px 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; font-size: .95rem; }
.why b { color: var(--coral-deep); }
.plot { margin: 6px 0 0; font-size: .925rem; }
@media (min-width: 560px) { .card-body { grid-template-columns: 170px 1fr; } .poster { width: 170px; } }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 14px 14px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 13px 6px; font-weight: 600; font-size: .925rem; }
.btn.want { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn:active { transform: scale(.97); }
.left { text-align: center; margin: 10px 0 0; }
.stars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 14px 14px; }
.stars button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 2px; font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.stars button small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.rate-panel { padding: 0 0 4px; }
.rate-panel p { margin: 0 14px; }

/* lists */
.list { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; background: var(--surface); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.row img, .row .thumb { width: 56px; aspect-ratio: 2 / 3; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.row .face { aspect-ratio: 1; border-radius: 50%; }
.row h4 { margin: 0; font-size: 1rem; }
.row p { margin: 2px 0 0; font-size: .875rem; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: .85rem; font-weight: 600; }
.chip.on { background: var(--coral); color: #fff; border-color: var(--coral); }
.chip.no.on { background: var(--bad); border-color: var(--bad); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--coral-deep); }
.group-title { margin: 22px 0 8px; font-size: 1rem; }
.search { display: block; margin: 0 0 12px; }
.search input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1rem; }
.stats { margin-top: 18px; }
.empty { text-align: center; padding: 28px 8px; }
.empty img { opacity: .9; }
.watching { margin-bottom: 16px; }
.watching .card-body { grid-template-columns: 64px 1fr; }
.watching .poster { width: 64px; }
.note { width: calc(100% - 28px); margin: 0 14px 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; display: flex; gap: 14px; align-items: center; z-index: 10; box-shadow: var(--shadow); font-size: .925rem; max-width: calc(100% - 32px); }
.toast button { background: none; border: 0; color: var(--spark); font-weight: 700; }

/* robot search animation */
.searching { text-align: center; padding: 8px 0 24px; }
.scene { width: 100%; max-width: 420px; height: auto; }
.shelf-board { fill: var(--line); }
.spine { stroke: rgba(0, 0, 0, .08); }
.s1 { fill: #7FA7C9; } .s2 { fill: #E7B85B; } .s3 { fill: #9DBB8A; } .s4 { fill: #C98AA6; }
.reel { fill: #4A403B; } .reel-hub { fill: var(--line); }
.label { fill: #F6EEE3; }
.wheel { fill: #4A403B; }
.status { font-weight: 600; min-height: 1.5em; margin: 6px 0 2px; }
.bot { animation: roll 9s ease-in-out infinite; }
.bot-inner { animation: bob 1.1s ease-in-out infinite; }
.beam { animation: beam 2.2s ease-in-out infinite; transform-origin: 0 18px; }
.spark { animation: spin 6s linear infinite; transform-box: fill-box; transform-origin: center; }
.glow { animation: pulse 1.6s ease-in-out infinite; }
.arm { animation: wave 2.2s ease-in-out infinite; transform-origin: 24px 4px; }
.inspect { animation: inspect 9s ease-in-out infinite; }
.wheels .wheel { animation: pulse 0.6s ease-in-out infinite; }
@keyframes roll { 0%, 100% { transform: translate(60px, 52px); } 18% { transform: translate(60px, 52px); } 45% { transform: translate(250px, 52px); } 62% { transform: translate(250px, 52px); } 85% { transform: translate(150px, 52px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes beam { 0%, 100% { opacity: .25; transform: translate(0, 18px) skewX(-14deg); } 50% { opacity: .8; transform: translate(0, 18px) skewX(14deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-18deg); } }
@keyframes inspect {
  0%, 48% { transform: translate(262px, 126px) rotate(0); opacity: 0; }
  52% { transform: translate(262px, 60px) rotate(-8deg); opacity: 1; }
  58% { transform: translate(262px, 52px) rotate(8deg); opacity: 1; }
  64% { transform: translate(300px, 30px) rotate(40deg); opacity: 0; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bot, .bot-inner, .beam, .spark, .arm, .inspect, .wheels .wheel, .signin-robot { animation: none; }
  .bot { transform: translate(160px, 52px); }
  .glow { animation: pulse 2.5s ease-in-out infinite; }
  .card { transition: none; }
}
.row .blank { display: grid; place-items: center; font-size: 1.4rem; color: var(--muted); }
.row .why-line { color: var(--text); margin-top: 4px; }
.row .why-line b { color: var(--coral-deep); font-weight: 700; }
.syn { margin-top: 4px; font-size: .875rem; }
.syn summary { cursor: pointer; color: var(--muted); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; }
.syn summary::-webkit-details-marker { display: none; }
.syn summary::after { content: "›"; transition: transform .15s ease; display: inline-block; }
.syn[open] summary::after { transform: rotate(90deg); }
.syn p { margin: 4px 0 0; }

/* full film view */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-inner { max-width: 720px; margin: 0 auto; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.sheet .hero { position: relative; aspect-ratio: 16 / 8; background: var(--surface-2) center / cover no-repeat; }
.sheet .hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 35%, var(--bg)); }
.sheet .close { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 21; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 1.4rem; line-height: 40px; }
.sheet .head { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 0 16px; margin-top: -60px; position: relative; z-index: 1; }
.sheet .head .poster { width: 110px; box-shadow: var(--shadow); }
.sheet h2 { margin: 54px 0 4px; font-size: 1.45rem; line-height: 1.15; }
.sheet .body { padding: 6px 16px 0; }
.sheet h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
.scores { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.score { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: .85rem; }
.score b { font-size: 1rem; margin-right: 4px; }
.cast { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.cast figure { margin: 0; width: 76px; flex: 0 0 auto; text-align: center; font-size: .78rem; }
.cast img, .cast .blank { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-2); display: block; margin: 0 auto 4px; }
.cast small { display: block; color: var(--muted); }
.providers { display: flex; flex-wrap: wrap; gap: 10px; }
.provider { display: grid; justify-items: center; gap: 4px; width: 68px; text-decoration: none; color: var(--text); font-size: .72rem; text-align: center; line-height: 1.2; }
.provider img { width: 48px; height: 48px; border-radius: 12px; box-shadow: var(--shadow); }
.ptype:first-child { margin-top: 0; }
.providers + .muted.small + .ptype { margin-top: 16px; }
.ptype { font-size: .8rem; color: var(--muted); margin: 10px 0 6px; }
.jelly-form { display: flex; gap: 8px; }
.jelly-form input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.jelly-form button { border: 0; background: var(--coral); color: #fff; border-radius: 10px; padding: 0 14px; font-weight: 600; }
.sheet .actions { padding: 18px 0 0; grid-template-columns: repeat(3, 1fr); }
.row .open { cursor: pointer; }

/* pull to refresh */
.ptr { position: fixed; top: env(safe-area-inset-top); left: 50%; z-index: 30; transform: translate(-50%, -70px); opacity: 0; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 999px; padding: 6px 14px 6px 6px; font-size: .85rem; font-weight: 600; pointer-events: none; }
.ptr img { width: 30px; height: 30px; }
.ptr.back { transition: transform .25s ease, opacity .25s ease; }
.ptr.busy { opacity: 1; transition: transform .2s ease; }
.ptr.busy img { animation: spin 1s linear infinite; }

/* service highlights, RT, Wikipedia */
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.svc { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 3px 9px; background: var(--coral); color: #fff; }
.svc.server { background: #6B4FBB; }
.rtchip { display: inline-block; font-size: .78rem; font-weight: 700; border: 1px solid var(--line); border-radius: 8px; padding: 2px 7px; margin-right: 6px; }
.wiki { font-size: .85rem; font-weight: 600; }
.provider.mine img { outline: 3px solid var(--coral); outline-offset: 2px; }
/* To Watch toolbar */
.toolbar { margin: -4px 0 12px; display: grid; gap: 8px; }
.toolrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolrow.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.toolrow.scroll::-webkit-scrollbar { display: none; }
.toolrow .chip { white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }
.sel select { font: inherit; font-size: .85rem; font-weight: 600; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
#tw-shown { margin: 0; }
/* Settings */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.svc-tile { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: .72rem; font-weight: 600; text-align: center; line-height: 1.2; }
.svc-tile img { width: 44px; height: 44px; border-radius: 10px; }
.svc-tile[aria-pressed="true"] { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral) inset; }
.svc-tile[aria-pressed="true"]::after { content: "✓"; color: var(--coral-deep); font-weight: 800; }
code { font-size: .85em; }
