/* Portal look: warm paper, one hero per page, cards, bottom sheets. Colour is information:
   course = green, YouTube = red, people = violet; the warm brand gradient is only for the Portal mark. */
:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1b18; --muted: #7a746a; --line: #e8e3d9; --soft: #efece5;
  --brand: #d9674e; --brand-2: #f2a65a; --on-brand: #ffffff;
  --course: #3d6b5a; --yt: #c8463d; --people: #7b5cc4;
  --bad: #b4443a; --ok: #3d8f5f; --shadow: 0 10px 40px rgb(0 0 0 / 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --card: #201e1b; --ink: #ece8e1; --muted: #958e83; --line: #2e2b27; --soft: #262420;
    --brand: #ec8a6d; --brand-2: #f4b778; --on-brand: #1d1210;
    --course: #7fb8a1; --yt: #ec7b70; --people: #b39ae8;
    --bad: #e07a70; --ok: #6fc093; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, input { font: inherit; }
[hidden] { display: none !important; }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- shared bits */
.mark { width: 34px; height: 34px; border-radius: 10px; background: url("/icon.svg") center / cover; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 22px; border-radius: 14px; border: 0; background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.course { background: var(--course); color: var(--card); }
.btn.yt { background: var(--yt); color: #fff; }
.btn.people { background: var(--people); color: var(--card); }
.err { color: var(--bad); min-height: 1.5em; font-size: 15px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; font-weight: 700; color: var(--muted); }
h3.section { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 32px 0 12px; }

/* top bar: title and status up top, nothing to press but the account button */
.top { position: sticky; top: 0; z-index: 10; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-size: 15px; padding: 8px 10px 8px 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; background: var(--soft); color: var(--ink); border: 0; }
.top .avatar { margin-left: auto; cursor: pointer; }
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------------------------------------------------------------- home */
.greet { margin: 8px 0 20px; }
.greet h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.greet p { margin: 6px 0 0; color: var(--muted); }

.hero { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; padding: 22px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--course) 14%, transparent), transparent 60%); pointer-events: none; }
.hero > * { position: relative; }
.hero:hover { border-color: var(--course); }
.ring { width: 112px; height: 112px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: color-mix(in srgb, var(--course) 16%, var(--soft)); }
.ring .fill { stroke: var(--course); stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.ring b { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 28px; line-height: 1.05; }
.ring b small { font-size: 13px; font-weight: 500; color: var(--muted); }
.hero .eyebrow { color: var(--course); }
.hero h2 { margin: 4px 0 2px; font-size: 22px; line-height: 1.25; }
.hero .next { color: var(--muted); margin-bottom: 14px; font-size: 15px; }
.hero .btn { margin-top: 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .art { aspect-ratio: 16 / 8; background: var(--accent) center / cover; display: grid; place-items: center; }
.tile .art svg { width: 54px; height: 54px; }
.tile .body { padding: 14px 16px 16px; }
.tile b { display: block; font-size: 18px; line-height: 1.3; }
.tile span { color: var(--muted); font-size: 15px; }

/* ---------------------------------------------------------------- bottom sheet (actions live in the thumb zone) */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.4); opacity: 0; transition: opacity 0.2s; }
.scrim.on { opacity: 1; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column; background: var(--card); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 0.2); transform: translateY(105%); transition: transform 0.25s ease; }
.sheet.on { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; flex: none; }
.sheet .inner { overflow-y: auto; padding: 14px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 4px 0 4px; font-size: 22px; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.sheet .stack { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.sheet .facts { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.field { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.field:focus { outline: 2px solid var(--people); outline-offset: 1px; }
.linkbox { display: block; width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--soft); font: 14px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; user-select: all; margin-bottom: 4px; }

/* ---------------------------------------------------------------- people page: list scrolls, action row is pinned */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.shell > main { flex: 1; overflow-y: auto; }
.actionbar { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); }
.actionbar .btn { width: 100%; max-width: 560px; margin: 0 auto; display: flex; }
.count { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 4px; }
.count b { font-size: 56px; line-height: 1; color: var(--people); }
.count span { font-size: 20px; font-weight: 600; }
.count + p { margin: 0; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.row:hover { border-color: var(--people); }
.row .avatar { width: 44px; height: 44px; background: color-mix(in srgb, var(--people) 18%, transparent); color: var(--people); }
.row .who { min-width: 0; }
.row .who b, .row .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row small { color: var(--muted); font-size: 14px; }
.row .tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.row.off { opacity: 0.6; }
.empty { color: var(--muted); padding: 14px 2px; }

/* ---------------------------------------------------------------- YouTube guide */
.yt-hero { text-align: center; padding: 18px 0 8px; }
.yt-hero .play { width: 84px; height: 84px; border-radius: 26px; background: var(--yt); display: grid; place-items: center; margin: 0 auto 16px; box-shadow: 0 12px 30px color-mix(in srgb, var(--yt) 35%, transparent); }
.yt-hero h1 { margin: 0; font-size: 30px; }
.yt-hero p { margin: 8px auto 0; color: var(--muted); max-width: 440px; }
.guide { max-width: 560px; margin: 24px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.guide .for { color: var(--yt); }
.guide h2 { margin: 4px 0 16px; font-size: 22px; }
.guide ol { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.guide li { counter-increment: s; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
.guide li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--yt) 15%, transparent); color: var(--yt); font-weight: 700; display: grid; place-items: center; font-size: 15px; }
.guide small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
.guide > .btn { position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 8px 24px color-mix(in srgb, var(--yt) 30%, transparent); } /* stays in thumb reach while reading the steps */
.guide .alt { margin: 14px 0 0; font-size: 15px; color: var(--muted); text-align: center; }
.guide .alt a { color: var(--yt); }
.devices { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 22px 0 0; }
.devices button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 15px; }
.devices button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fineprint { max-width: 560px; margin: 18px auto 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- sign-in, welcome, reset */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.authcard { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 32px 24px; text-align: center; box-shadow: var(--shadow); }
.authcard .mark { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; }
.authcard h1 { margin: 0 0 6px; font-size: 26px; }
.authcard p { margin: 0 0 22px; color: var(--muted); }
.authcard .field { margin-bottom: 10px; }
.authcard .field:focus { outline-color: var(--brand); }
.authcard .btn { width: 100%; margin-top: 6px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: var(--on-brand); }
.authcard .err { margin-top: 12px; }
.pw { position: relative; margin-bottom: 10px; }
.authcard .pw .field { margin-bottom: 0; padding-right: 54px; }
.pw .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.pw .eye:hover, .pw .eye[aria-pressed="true"] { background: var(--soft); color: var(--ink); }
.pw .eye svg { width: 22px; height: 22px; }
.match { min-height: 1.4em; margin: -2px 4px 8px; text-align: left; font-size: 14px; color: var(--muted); }
.match.ok { color: var(--ok); }
.match.no { color: var(--bad); }
.authcard .hint { margin: 14px 0 0; font-size: 14px; }

@media (min-width: 720px) {
  .page { padding: 32px 24px 80px; }
  .greet h1 { font-size: 36px; }
  .hero { padding: 28px; gap: 28px; }
  .ring { width: 136px; height: 136px; }
  .hero h2 { font-size: 26px; }
}
@media (max-width: 420px) {
  .hero { grid-template-columns: 1fr; justify-items: start; }
  .ring { width: 96px; height: 96px; }
  .hero .btn { width: 100%; }
}
