:root {
  --bg: #faf9f7; --surface: #ffffff; --surface-2: #f1f0ed; --border: #e3e1dc;
  --text: #1c1c1e; --muted: #77777c; --ink: #1c1c1e; --ink-text: #ffffff;
  --good: #2f7d57; --bad: #a8473b; --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
body.noscroll { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.top { position: sticky; top: 0; z-index: 5; background: rgba(250,249,247,.94); backdrop-filter: blur(8px);
  padding: 10px 16px 8px; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 600; font-size: 17px; letter-spacing: .3px; }
.progress { flex: 1; }
.progress .bars { display: flex; gap: 4px; }
.progress .bars span { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.progress .bars span.on { background: var(--ink); }

.app { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 18px 16px 110px; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; }

/* Choice tiles & chips */
.tiles { display: grid; gap: 10px; }
.tile { display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: right; }
.tile.on { border-color: var(--ink); }
.tile .check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 13px; }
.tile.on .check { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.tile.fixed { cursor: default; background: var(--surface-2); border-color: transparent; }
.tile .hint { color: var(--muted); font-size: 13px; }
.linkish { background: none; border: 0; color: var(--text); padding: 10px 0; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.linkish.small { font-size: 13px; color: var(--muted); padding: 8px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); border: 1.5px solid var(--border); border-radius: 999px; padding: 8px 16px; font-size: 15px; }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--ink-text); }
.chip:disabled { opacity: .4; }
.note { color: var(--muted); font-size: 13px; font-weight: 400; }

/* Bottom action bar */
.bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: rgba(250,249,247,.96);
  border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.bar .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.btn { border: 1.5px solid transparent; border-radius: 12px; padding: 12px 18px; font-weight: 600; font-size: 16px; background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--ink-text); flex: 1; }
.btn.ghost { background: var(--surface); border-color: var(--border); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Onboarding card flow */
.flow { display: flex; flex-direction: column; align-items: center; text-align: center; padding-bottom: 8px; }
.count { width: 100%; max-width: 340px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.count .thin { height: 3px; background: var(--border); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.count .thin i { display: block; height: 100%; background: var(--ink); }
.poster-wrap { width: min(72vw, 320px, calc(50dvh * 2 / 3)); aspect-ratio: 2 / 3; border-radius: 16px; overflow: hidden;
  background: var(--surface-2); box-shadow: 0 6px 24px rgba(0,0,0,.10); }
.poster-big { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctitle { margin-top: 14px; font-size: 20px; font-weight: 600; line-height: 1.3; unicode-bidi: plaintext; padding: 0 8px; }
.cmeta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.cactions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 380px; margin-top: 16px; }
.cactions .ask { grid-column: 1 / -1; font-size: 15px; color: var(--muted); }
.btn.big { padding: 14px 10px; font-size: 17px; }
.clinks { display: flex; justify-content: space-between; width: 100%; max-width: 380px; margin-top: 6px; }

/* Search sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(28,28,30,.35); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-inner { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; height: 88dvh; border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.sheet-head { display: flex; gap: 10px; align-items: center; }
.sheet-head input { flex: 1; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 11px 14px; color: var(--text); font: inherit; outline: none; }
.sheet-head input:focus { border-color: var(--ink); }
#results { overflow-y: auto; margin-top: 8px; }
#added { min-height: 18px; margin-top: 6px; }
.result { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.result img { width: 44px; height: 66px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.rinfo { min-width: 0; unicode-bidi: plaintext; text-align: right; }
.result .y { color: var(--muted); font-size: 13px; }
.rbtns { grid-column: 2; display: flex; gap: 6px; }
.empty { padding: 14px 0; color: var(--muted); }

/* Small buttons (recommendation feedback, search) */
.a { flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 6px; font-size: 13px; }
.state { flex: 1; font-size: 13px; color: var(--muted); padding: 6px 2px; }
.undo { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 6px 2px; }

/* Recommendations */
.rlist { display: grid; gap: 14px; }
.rcard { display: grid; grid-template-columns: 112px 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
@media (min-width: 560px) { .rcard { grid-template-columns: 140px 1fr; } }
.poster { aspect-ratio: 2 / 3; width: 100%; object-fit: cover; display: block; background: var(--surface-2); border-radius: 10px; }
.rcard.dim { opacity: .5; }
.rcard h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; unicode-bidi: plaintext; text-align: right; }
.rmeta { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.badge { font-size: 12px; border-radius: 999px; padding: 2px 10px; background: var(--surface-2); }
.conf-high { color: var(--good); }
.conf-medium { color: var(--text); }
.conf-low { color: var(--muted); }
.ctas { display: flex; gap: 8px; margin-bottom: 10px; }
.ctas a { text-decoration: none; text-align: center; font-size: 14px; padding: 9px 10px; border-radius: 10px; flex: 1; }
.ctas .trailer { border: 1px solid var(--border); }
.ctas .watch { background: var(--ink); color: var(--ink-text); font-weight: 600; }
.fb { display: flex; gap: 6px; flex-wrap: wrap; }
.fb .q { width: 100%; font-size: 13px; color: var(--muted); }
.refresh { margin-top: 18px; background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: 14px; color: var(--muted); }
.refresh .btn { margin-top: 10px; width: 100%; }
.err { background: #f7e9e6; color: #7d2f25; border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: 14px; }
.about { display: block; text-align: center; color: var(--muted); font-size: 11px; margin-top: 28px; text-decoration: none; }
.about-page p { line-height: 1.9; }

/* v3: first screen + one-tap answers */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 10px 4px; font-size: 15px; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }
.chip.off { background: var(--surface-2); border-color: var(--text); text-decoration: line-through; color: var(--muted); }
.answers { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px 8px; align-items: center; width: 100%; max-width: 400px; margin-top: 14px; }
.row-label { font-size: 13px; color: var(--muted); text-align: right; padding-left: 4px; white-space: nowrap; }
.ans { border: 1.5px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px 6px; font-size: 16px; font-weight: 600; }
.ans.love { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.ans.want { border-color: var(--ink); }
.ans:disabled { opacity: .5; }
.insight { font-size: 13px; background: var(--surface-2); border-radius: 999px; padding: 4px 12px; margin: -2px 0 10px; animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.linkish.finish { font-size: 14px; margin-top: 2px; }
.poster-wrap { width: min(66vw, 300px, calc(46dvh * 2 / 3)); }
