:root{
  --paper:#f1f4f1; --surface:#fbfcfb; --ink:#17201d; --muted:#5b6762; --line:#d5ddd8;
  --spot:#2f4fd0;            /* the pointer's blue: the one accent, the same job it has inside lessons */
  --spot-ink:#ffffff;
  --busy:#b7791f;            /* a lesson being built */
  --bad:#b4372f;
  --display:"Bricolage Grotesque",system-ui,sans-serif;
  --body:"Atkinson Hyperlegible",system-ui,-apple-system,"Segoe UI",sans-serif;
  --r-lg:18px; --r-md:12px; --r-sm:8px;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#111614; --surface:#18201d; --ink:#e4ebe7; --muted:#9aa7a1; --line:#2a3531;
    --spot:#7d97ff; --spot-ink:#0d1330; --busy:#e3a948; --bad:#f07c72; color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --paper:#111614; --surface:#18201d; --ink:#e4ebe7; --muted:#9aa7a1; --line:#2a3531;
  --spot:#7d97ff; --spot-ink:#0d1330; --busy:#e3a948; --bad:#f07c72; color-scheme:dark;
}
*{box-sizing:border-box}
html,body{margin:0}
body{background:var(--paper); color:var(--ink); font:17px/1.55 var(--body); -webkit-font-smoothing:antialiased}
a{color:inherit}
button,input,textarea,select{font:inherit; color:inherit}
:focus-visible{outline:2.5px solid var(--spot); outline-offset:2px; border-radius:4px}
[hidden]{display:none!important}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- frame ---------- */
.page{max-width:1080px; margin-inline:auto; padding:20px max(16px,env(safe-area-inset-right)) 96px max(16px,env(safe-area-inset-left))}
.top{display:flex; align-items:center; gap:14px; min-height:44px}
.brand{display:flex; align-items:center; gap:9px; font:700 1.15rem/1 var(--display); text-decoration:none; letter-spacing:-.01em}
.brand svg{width:26px; height:26px}
.top .who{margin-left:auto; color:var(--muted); font-size:.92rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px; cursor:pointer; white-space:nowrap; text-decoration:none;
  border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:9px 16px; font-weight:700; font-size:.95rem;
}
.btn:hover{border-color:color-mix(in srgb,var(--ink) 35%,var(--line))}
.btn.primary{background:var(--spot); border-color:var(--spot); color:var(--spot-ink)}
.btn.primary:hover{filter:brightness(1.07)}
.btn.quiet{background:transparent; border-color:transparent; color:var(--muted)}
.btn.quiet:hover{color:var(--ink)}
.btn:disabled{opacity:.5; cursor:default}
.btn svg{width:18px; height:18px; fill:currentColor}

/* ---------- the ask: "Teach me ___" ---------- */
.ask{position:relative; margin:9vh 0 0}
.ask h1{margin:0; font:800 clamp(2.6rem,8.6vw,6.2rem)/.95 var(--display); font-variation-settings:"opsz" 96; letter-spacing:-.035em}
.ask form{margin-top:18px}
.topic{
  display:block; width:100%; resize:none; overflow:hidden; border:0; background:transparent; padding:0 0 10px;
  font:500 clamp(1.7rem,5.4vw,3.4rem)/1.08 var(--display); letter-spacing:-.025em; color:var(--ink);
  border-bottom:3px solid var(--ink); border-radius:0; min-height:1.2em;
}
.topic::placeholder{color:color-mix(in srgb,var(--muted) 70%,var(--paper))}
.topic:focus{outline:none; border-bottom-color:var(--spot)}
.ask-row{display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; margin-top:18px}
.ask-row .go{margin-left:auto; padding:14px 26px; font-size:1.05rem}
.chip-sel{border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:8px 14px; font-size:.95rem}
.notes-toggle{font-size:.95rem}
.notes{width:100%; margin-top:12px; min-height:84px; border:1px solid var(--line); background:var(--surface); border-radius:var(--r-md); padding:12px 14px; font-size:1rem; resize:vertical}
.hint{color:var(--muted); font-size:.95rem; margin:14px 0 0; max-width:62ch}
.ideas{display:flex; flex-wrap:wrap; gap:8px; margin-top:14px}
.idea{border:1px dashed var(--line); background:transparent; border-radius:999px; padding:6px 13px; font-size:.92rem; color:var(--muted); cursor:pointer}
.idea:hover{color:var(--ink); border-style:solid}
.formerr{color:var(--bad); margin:12px 0 0; font-weight:700}

/* the pointer that introduces the page: one orchestrated moment */
.intro-ptr{position:absolute; width:40px; height:40px; pointer-events:none; z-index:3; left:0; top:0; opacity:0}
.intro-ptr svg{width:40px; height:40px; overflow:visible; filter:drop-shadow(0 4px 6px rgba(0,0,0,.25))}
.intro-ptr path{fill:var(--spot); stroke:var(--surface); stroke-width:1.6; stroke-linejoin:round}
.intro-ptr circle{fill:none; stroke:var(--spot); stroke-width:2.2; transform-origin:3px 3px; opacity:0}
.intro-ptr.go{animation:ptr-in 1.5s cubic-bezier(.3,.9,.3,1) .35s forwards}
.intro-ptr.go circle{animation:ptr-ping .9s ease-out 1.75s 2}
@keyframes ptr-in{from{opacity:0; transform:translate(var(--x0),var(--y0))} 15%{opacity:1} to{opacity:1; transform:translate(var(--x1),var(--y1))}}
@keyframes ptr-ping{from{transform:scale(.4); opacity:.9} to{transform:scale(2.8); opacity:0}}
@media (prefers-reduced-motion:reduce){ .intro-ptr{display:none} }

/* ---------- library ---------- */
.lib{margin-top:13vh}
.lib-head{display:flex; align-items:baseline; gap:12px; border-bottom:1px solid var(--line); padding-bottom:10px}
.lib-head h2{margin:0; font:700 1.5rem/1.1 var(--display); letter-spacing:-.015em}
.lib-head .count{color:var(--muted)}
.lib-head .quota{margin-left:auto; color:var(--muted); font-size:.9rem}
.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:26px 22px; margin-top:22px}
.card{display:flex; flex-direction:column; gap:10px; text-decoration:none; min-width:0}
.thumb{
  position:relative; aspect-ratio:16/10; border-radius:var(--r-md); overflow:hidden; background:var(--surface);
  border:1px solid var(--line);
}
.thumb img{width:100%; height:100%; object-fit:cover; object-position:top left; display:block}
.card:hover .thumb{border-color:color-mix(in srgb,var(--spot) 55%,var(--line))}
.card h3{margin:0; font:650 1.08rem/1.25 var(--display); letter-spacing:-.01em; overflow-wrap:anywhere}
.card .sub{color:var(--muted); font-size:.9rem; display:flex; gap:10px; flex-wrap:wrap}
.thumb .play{
  position:absolute; right:12px; bottom:12px; width:42px; height:42px; border-radius:50%; background:var(--spot); color:var(--spot-ink);
  display:grid; place-items:center; box-shadow:0 4px 14px color-mix(in srgb,var(--spot) 40%,transparent);
}
.thumb .play svg{width:18px; height:18px; fill:currentColor; margin-left:3px}
.thumb.building{display:flex; flex-direction:column; justify-content:flex-end; padding:16px; gap:10px;
  background:repeating-linear-gradient(90deg,transparent 0 23px,color-mix(in srgb,var(--line) 60%,transparent) 23px 24px),
             repeating-linear-gradient(0deg,transparent 0 23px,color-mix(in srgb,var(--line) 60%,transparent) 23px 24px),var(--surface)}
.thumb.building .what{font:700 1.02rem/1.2 var(--display); color:var(--busy)}
.thumb.failed .what{color:var(--bad)}
.meter{height:6px; border-radius:3px; background:color-mix(in srgb,var(--busy) 18%,var(--surface)); overflow:hidden}
.meter span{display:block; height:100%; background:var(--busy); border-radius:3px; transition:width .6s}
.empty{margin-top:22px; color:var(--muted); max-width:52ch}

/* ---------- building view ---------- */
.build{max-width:680px; margin:8vh auto 0}
.build h1{font:800 clamp(1.9rem,5vw,3rem)/1.05 var(--display); letter-spacing:-.03em; margin:0}
.build .topicline{color:var(--muted); margin:10px 0 0}
.steps{list-style:none; padding:0; margin:34px 0 0; counter-reset:s}
.steps li{display:grid; grid-template-columns:34px 1fr; gap:4px 14px; padding:12px 0; border-top:1px solid var(--line); color:var(--muted)}
.steps li::before{counter-increment:s; content:counter(s); width:28px; height:28px; border-radius:50%; display:grid; place-items:center; border:1.5px solid var(--line); font:700 .85rem/1 var(--display)}
.steps li.done{color:var(--ink)}
.steps li.done::before{content:"✓"; background:var(--ink); color:var(--paper); border-color:var(--ink)}
.steps li.now{color:var(--ink); font-weight:700}
.steps li.now::before{border-color:var(--busy); color:var(--busy); animation:pulse 1.4s ease-in-out infinite}
.steps li .d{grid-column:2; font-weight:400; color:var(--muted); font-size:.92rem}
@keyframes pulse{50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--busy) 18%,transparent)}}
.build .note{color:var(--muted); margin-top:24px; font-size:.95rem}
.failbox{margin-top:28px; border:1px solid color-mix(in srgb,var(--bad) 45%,var(--line)); border-radius:var(--r-md); padding:16px 18px; background:color-mix(in srgb,var(--bad) 6%,var(--surface))}
.failbox p{margin:0 0 12px}

/* ---------- watch view ---------- */
.watch{position:fixed; inset:0; display:flex; flex-direction:column; background:var(--paper)}
.wbar{display:flex; align-items:center; gap:8px; padding:8px max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left)); border-bottom:1px solid var(--line); background:var(--surface); min-height:56px}
.wbar h1{margin:0 6px; font:700 1.05rem/1.2 var(--display); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; flex:1}
.wbody{position:relative; flex:1; display:flex; min-height:0}
.wbody iframe{flex:1; border:0; width:100%; height:100%; background:var(--paper); min-width:0}
.drawer{
  width:min(400px,100%); border-left:1px solid var(--line); background:var(--surface); display:flex; flex-direction:column; min-height:0;
}
.drawer[hidden]{display:none}
.drawer header{display:flex; align-items:center; padding:14px 16px 8px}
.drawer header h2{margin:0; font:700 1.15rem/1.2 var(--display); flex:1}
.thread{flex:1; overflow:auto; padding:4px 16px 16px; display:flex; flex-direction:column; gap:16px}
.thread .q{align-self:flex-end; background:var(--spot); color:var(--spot-ink); padding:9px 14px; border-radius:16px 16px 4px 16px; max-width:88%; overflow-wrap:anywhere}
.thread .a{display:flex; flex-direction:column; gap:6px; max-width:94%}
.thread .a p{margin:0}
.thread .a .acts{display:flex; gap:6px}
.thread .a.wait{color:var(--muted); font-style:italic}
.thread .a.err{color:var(--bad)}
.thread .intro{color:var(--muted); font-size:.95rem}
.askform{display:flex; gap:8px; padding:12px 16px calc(12px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); align-items:flex-end}
.askform textarea{flex:1; resize:none; min-height:46px; max-height:140px; border:1px solid var(--line); background:var(--paper); border-radius:14px; padding:11px 13px; font-size:1rem}
.askform .btn{padding:12px 16px}
.signin-to-ask{padding:16px; color:var(--muted)}
@media (max-width:760px){
  .drawer{position:absolute; left:0; right:0; bottom:0; width:100%; max-height:62%; border-left:0; border-top:1px solid var(--line); border-radius:var(--r-lg) var(--r-lg) 0 0; box-shadow:0 -10px 30px rgba(0,0,0,.18); z-index:5}
  .wbar .lbl{display:none}
  .ask-row .go{margin-left:0; width:100%}
}

/* ---------- sign-in / landing ---------- */
.landing{margin-top:12vh; max-width:760px}
.landing h1{margin:0; font:800 clamp(2.6rem,8vw,5.6rem)/.95 var(--display); letter-spacing:-.035em}
.landing p{font-size:1.2rem; color:var(--muted); max-width:46ch; margin:22px 0 28px}
.toast{position:fixed; left:50%; bottom:24px; transform:translateX(-50%); background:var(--ink); color:var(--paper); padding:11px 18px; border-radius:999px; font-weight:700; z-index:20; max-width:calc(100% - 32px)}
.center{display:grid; place-items:center; min-height:60vh; color:var(--muted)}

/* ---------- sharing + private gate ---------- */
.sharewrap{position:relative}
.sharepanel{
  position:absolute; right:0; top:calc(100% + 8px); z-index:10; width:min(360px,calc(100vw - 24px));
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); padding:16px;
  box-shadow:0 12px 32px color-mix(in srgb,var(--ink) 16%,transparent); display:flex; flex-direction:column; gap:12px;
}
.sharepanel[hidden]{display:none}
.sharepanel .who{margin:0; color:var(--muted); font-size:.93rem}
.switch{display:flex; align-items:center; gap:10px; font-weight:700; cursor:pointer}
.switch input{width:20px; height:20px; accent-color:var(--spot)}
.linkrow{display:flex; gap:8px}
.linkrow input{flex:1; min-width:0; border:1px solid var(--line); background:var(--paper); border-radius:999px; padding:8px 12px; font-size:.88rem}
.gate[hidden]{display:none}
.gate{flex:1; display:grid; place-items:center; padding:24px; text-align:center}
.gate h2{font:800 clamp(1.6rem,4vw,2.4rem)/1.1 var(--display); letter-spacing:-.02em; margin:0 0 10px}
.gate p{color:var(--muted); margin:0 0 18px; max-width:44ch}
@media (max-width:760px){ .sharepanel{position:fixed; left:12px; right:12px; top:64px; width:auto} }

/* ---------- members ---------- */
.members{max-width:760px; margin-top:6vh}
.members h1{font:800 clamp(2rem,6vw,3.2rem)/1 var(--display); letter-spacing:-.03em; margin:0}
.invite{display:flex; gap:10px; margin-top:22px; flex-wrap:wrap}
.invite input{flex:1 1 260px; min-width:0; border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:11px 16px; font-size:1rem}
.mlist{list-style:none; padding:0; margin:28px 0 0; border-top:1px solid var(--line)}
.mlist li{display:flex; align-items:center; gap:12px; padding:14px 0; border-bottom:1px solid var(--line); flex-wrap:wrap}
.mlist li.off .mwho b{color:var(--muted); text-decoration:line-through}
.mwho{flex:1 1 260px; min-width:0; display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 10px}
.mwho b{overflow-wrap:anywhere}
.mstat{flex-basis:100%; color:var(--muted); font-size:.9rem}
.tag{font-size:.78rem; font-weight:700; border:1px solid var(--line); border-radius:999px; padding:1px 8px; color:var(--muted)}
.macts{display:flex; gap:6px}

.mailme{display:inline-flex; align-items:center; gap:8px; color:var(--muted); font-size:.95rem; cursor:pointer}
.mailme input{width:18px; height:18px; accent-color:var(--spot)}

.signins{display:flex; flex-wrap:wrap; gap:12px}
.signins .btn{padding:14px 24px; font-size:1.05rem}
.btn.google{background:var(--surface); border-color:color-mix(in srgb,var(--ink) 25%,var(--line))}
.btn.google svg{width:20px; height:20px}

/* ---------- legal pages ---------- */
.legal{max-width:720px}
.legal h1{font:800 clamp(2rem,6vw,3rem)/1 var(--display); letter-spacing:-.03em; margin:8vh 0 6px}
.legal h2{font:700 1.3rem/1.2 var(--display); margin:34px 0 8px}
.legal p,.legal li{max-width:66ch}
.legal ul{padding-left:1.2em}
.legal li{margin:6px 0}
.legal a{color:var(--spot)}
.mlib{flex-basis:100%; padding:4px 0 10px}
.mlib .grid{margin-top:8px; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:18px 16px}
