/* Mirror — a tool, not a reading artifact: compact utility styling, light/dark.
   The stage (your own camera, then the call) is the page; the two other screens are ordinary pages. */
:root{
  --bg:#f6f6f4; --surface:#ffffff; --ink:#17191c; --muted:#5f666d; --line:#dcdad4;
  --accent:#6d28d9; --accent-ink:#ffffff;
  --green:#15803d; --green-bg:#e7f5ec; --amber:#b45309; --amber-bg:#fdf1dc;
  --red:#b91c1c; --red-bg:#fbe9e9; --code-bg:#ecebe7;
  --radius:10px;
  --glass:rgba(20,22,26,.62); --glass-ink:#f4f4f2; --glass-muted:#c3c8ce;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#121417; --surface:#1b1e23; --ink:#e7e5e1; --muted:#9aa1a8; --line:#30353c;
    --accent:#a78bfa; --accent-ink:#14082e;
    --green:#4ade80; --green-bg:#12301c; --amber:#fbbf24; --amber-bg:#332508;
    --red:#f87171; --red-bg:#371616; --code-bg:#23272d;
  }
}
*{box-sizing:border-box}
[hidden]{display:none !important} /* class rules like .screen{display:flex} would otherwise beat the UA [hidden] rule */
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);
  font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  padding-bottom:env(safe-area-inset-bottom)}
body.in-stage{overflow:hidden;background:#000} /* the stage is the page: nothing scrolls behind it */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:.75rem;
  padding:calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;border-bottom:1px solid var(--line);
  background:var(--surface);position:sticky;top:0;z-index:5}
.brand{font-weight:700;letter-spacing:.01em;color:var(--ink);text-decoration:none}
main{max-width:44rem;margin:0 auto;padding:1rem}
.screen{display:flex;flex-direction:column;gap:1rem}
h1{font-size:1.6rem;line-height:1.2;margin:.4rem 0 0}
h2{font-size:1.25rem;line-height:1.3;margin:.2rem 0 0}
p{margin:0}
.lede{color:var(--muted)}
.fine{font-size:.85rem;color:var(--muted)}
.center{text-align:center}
.row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:center}
.row>input{flex:1 1 12rem;min-width:0}

/* buttons & inputs */
.btn{font:inherit;padding:.6rem 1rem;border-radius:var(--radius);border:1px solid var(--line);
  background:var(--surface);color:var(--ink);cursor:pointer;touch-action:manipulation}
.btn:hover{border-color:var(--muted)}
.btn.primary{background:var(--accent);color:var(--accent-ink);border-color:var(--accent);font-weight:600}
.btn.big{padding:.85rem 1.2rem;font-size:1.05rem;flex:1 1 auto}
.btn.danger{background:var(--red-bg);color:var(--red);border-color:transparent}
.btn:disabled{opacity:.5;cursor:default}
input[type=text],textarea{font:inherit;padding:.6rem .7rem;border-radius:var(--radius);
  border:1px solid var(--line);background:var(--surface);color:var(--ink);width:100%}
textarea.linkbox{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.78rem;
  line-height:1.35;resize:none;overflow-wrap:anywhere;word-break:break-all}
.paste{display:flex;flex-direction:column;gap:.4rem;padding:.9rem;border:1px dashed var(--line);
  border-radius:var(--radius);background:var(--surface)}
.paste label{font-size:.9rem;color:var(--muted)}
.error{color:var(--red);background:var(--red-bg);padding:.5rem .7rem;border-radius:var(--radius);font-size:.92rem}
.notice{color:var(--amber);background:var(--amber-bg);padding:.5rem .7rem;border-radius:var(--radius);font-size:.92rem}

/* waiting */
.wait{display:flex;align-items:center;gap:.6rem;color:var(--muted);font-size:.95rem}
.spinner{width:1rem;height:1rem;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);
  animation:spin .9s linear infinite;display:inline-block;vertical-align:-.15em;flex:none}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce){.spinner{animation-duration:2.5s}}

/* connection pill */
.pill{font-size:.78rem;font-weight:600;padding:.15rem .6rem;border-radius:999px;white-space:nowrap;
  background:var(--code-bg);color:var(--muted)}
.pill.connected{background:var(--green-bg);color:var(--green)}
.pill.connecting,.pill.reconnecting{background:var(--amber-bg);color:var(--amber)}
.pill.lost{background:var(--red-bg);color:var(--red)}

/* ============================================================ the stage */
.stage{position:fixed;inset:0;height:100vh;height:100dvh;background:#000;color:var(--glass-ink);
  overflow:hidden;z-index:10;
  --top:max(.75rem, env(safe-area-inset-top));
  --bottom:max(1rem, env(safe-area-inset-bottom));
  --side:max(.75rem, env(safe-area-inset-left), env(safe-area-inset-right))}
.stage video{position:absolute;background:#000;object-fit:cover}
/* which video is the stage, which is the corner, depends on the mode */
#remote-video{inset:0;width:100%;height:100%;display:none}
#local-video{inset:0;width:100%;height:100%;display:none}
#local-video.mirror{transform:scaleX(-1)}
.stage[data-mode="call"] #remote-video{display:block}
.stage[data-mode="call"] #local-video{display:block;inset:auto var(--side) calc(var(--bottom) + 4.6rem) auto;
  width:28vmin;max-width:11rem;min-width:5.5rem;height:auto;aspect-ratio:3/4;border-radius:12px;
  border:1px solid rgba(255,255,255,.6);box-shadow:0 6px 24px rgba(0,0,0,.45);z-index:2}
.stage:not([data-mode="call"]) #local-video.on{display:block}
.stage.remote-off #remote-video{display:none}
.stage.remote-paused #remote-video{filter:brightness(.45) saturate(.6)}
.stage.local-off #local-video{display:none}
.stage-empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:.3rem;color:var(--glass-muted);text-align:center;padding:0 2rem}
.big-icon{display:flex;justify-content:center;margin-bottom:.4rem}
.paused{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);padding:.4rem .9rem;border-radius:999px;
  background:var(--glass);color:var(--glass-ink);font-size:.9rem;z-index:2}

.stage-top{position:absolute;top:var(--top);left:var(--side);right:var(--side);display:flex;justify-content:space-between;
  align-items:flex-start;gap:.5rem;z-index:3;pointer-events:none;transition:opacity .5s}
/* An idle mirror is just a mirror: the chrome fades until the page is touched again. */
.stage.idle .stage-top,.stage.idle .controls{opacity:0}
.stage-top>*{pointer-events:auto}
.verify{font:inherit;font-size:1.15rem;letter-spacing:.15em;padding:.25rem .6rem;border-radius:999px;border:none;
  background:var(--glass);color:#fff;cursor:help;display:flex;align-items:center;gap:.4rem}
.verify-hint{font-size:.7rem;letter-spacing:0;font-weight:600;color:var(--amber)}
.stage .pill{background:var(--glass);color:var(--glass-muted);padding:.35rem .7rem}
.stage .pill.connected{color:var(--green)}
.stage .pill.reconnecting,.stage .pill.connecting{color:var(--amber)}
.stage .pill.lost{color:var(--red)}
.overlay-notice{position:absolute;left:var(--side);right:var(--side);top:calc(var(--top) + 3rem);z-index:3;text-align:center}
.stage.spelling .overlay-notice{top:calc(var(--top) + 7.5rem)} /* below the spell while it is on screen */

/* The spell: "Magic Mirror" written across the top whenever the mirror appears
   (castSpell in main.js). Not in .stage-top, so the idle fade leaves it alone;
   below the overlay (z 4), so a card covers it rather than the reverse. The
   script's letters join up, so uncovering them left to right behind a moving
   pen tip reads as handwriting. Princess Sofia, subset to these glyphs (fonts/OFL.txt). */
@font-face{font-family:"Magic Script";src:url(fonts/magic-script.woff2) format("woff2");font-display:block}
.spell{position:absolute;top:calc(var(--top) + .25rem);left:0;right:0;display:flex;justify-content:center;
  z-index:3;pointer-events:none}
.spell-ink{position:relative;display:inline-block;font-size:clamp(2.6rem,12vw,5rem)} /* one em for the words and the pen's path */
.spell-text{display:block;font-family:"Magic Script",cursive;line-height:1.3;
  /* room for the glow to fade out inside the clipped box (else the reveal cuts it into a visible
     rectangle); the negative margin keeps the words where they were */
  padding:.8em;margin:-.75em -.45em -.65em;color:#fff;white-space:nowrap;
  text-shadow:0 0 .1em rgba(237,233,254,.95),0 0 .3em rgba(167,139,250,.85),0 0 .7em rgba(109,40,217,.75)}
.spell-pen{position:absolute;top:50%;left:0;width:.6rem;height:.6rem;margin:-.3rem 0 0 -.3rem;border-radius:50%;
  background:#fff;opacity:0;
  box-shadow:0 0 6px 2px #fff,0 0 16px 6px rgba(196,181,253,.9),0 0 32px 12px rgba(124,58,237,.55)}
.sparkle{position:absolute;width:var(--s);height:var(--s);background:var(--c);pointer-events:none;
  clip-path:polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%);
  animation:twinkle var(--t) ease-out forwards}
@keyframes twinkle{
  0%{transform:translate(-50%,-50%) scale(0) rotate(0deg);opacity:1}
  25%{transform:translate(-50%,-50%) scale(1) rotate(calc(var(--r) * .3));opacity:1}
  100%{transform:translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) scale(.15) rotate(var(--r));opacity:0}}

/* the waiting / connecting / recovery card */
.overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  padding:calc(var(--top) + 3.2rem) var(--side) calc(var(--bottom) + 5rem);z-index:4;overflow:auto}
.card-o{width:100%;max-width:26rem;display:flex;flex-direction:column;gap:.8rem;padding:1rem 1.1rem;
  border-radius:16px;background:var(--glass);color:var(--glass-ink);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
.card-o h2{font-size:1.05rem;font-weight:600;text-align:center;color:var(--glass-muted)}
.card-head{display:flex;align-items:center;gap:.5rem}
.card-head h2{flex:1 1 auto;margin:0;padding-left:2.2rem} /* centred against the close button */
.btn.small{padding:.15rem .6rem;font-size:1.1rem;line-height:1.2;flex:none}
.card-o .fine,.card-o .wait,.card-o .paste label{color:var(--glass-muted)}
.card-o .paste{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.2)}
.card-o input[type=text],.card-o textarea{background:rgba(255,255,255,.08);color:var(--glass-ink);border-color:rgba(255,255,255,.2)}
.card-o .btn{background:rgba(255,255,255,.12);color:var(--glass-ink);border-color:rgba(255,255,255,.2)}
.card-o .btn.primary{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.card-o .spinner{border-color:rgba(255,255,255,.25);border-top-color:#fff}
.phrase{display:flex;flex-direction:column;gap:.5rem;align-items:center}
.phrase-text{font-size:clamp(1.6rem, 7vmin, 2.4rem);line-height:1.15;font-weight:700;letter-spacing:.01em;text-align:center;
  overflow-wrap:anywhere;min-height:1.2em}
details.link-details{border:1px solid rgba(255,255,255,.18);border-radius:var(--radius);padding:.5rem .8rem}
details.link-details>summary{cursor:pointer;color:var(--glass-muted);font-size:.9rem;text-align:center}
details.link-details[open]>summary{margin-bottom:.7rem}
details.link-details>*:not(summary){margin-top:.55rem}

/* controls */
.controls{position:absolute;left:0;right:0;bottom:var(--bottom);display:flex;justify-content:center;gap:.9rem;z-index:5;
  padding:0 var(--side);transition:opacity .5s}
.ctl{position:relative;font:inherit;width:3.4rem;height:3.4rem;border-radius:50%;border:none;padding:0;
  background:rgba(255,255,255,.18);color:#fff;cursor:pointer;touch-action:manipulation;
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);display:flex;align-items:center;justify-content:center}
.ctl[aria-pressed="false"]{background:rgba(255,255,255,.9);color:#111} /* an OFF device reads as a light button */
.ctl.danger{background:#d92d20}
.ctl.accent{background:var(--accent);color:var(--accent-ink)} /* the one discreet button on the mirror */
/* line icons: monochrome strokes in currentColor, on/off variants toggled by state */
.ic{width:1.45rem;height:1.45rem;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none;flex:none}
.ic.ic-fill{fill:currentColor;stroke:none}
.ctl[aria-pressed="true"] .ic-off,.ctl[aria-pressed="false"] .ic-on{display:none}
.stage-empty .ic{width:2.6rem;height:2.6rem;stroke-width:1.6;display:none;color:var(--glass-muted)}
.stage-empty[data-icon="lock"] .ic-lock,.stage-empty[data-icon="camera-off"] .ic-camera-off,.stage-empty[data-icon="mic"] .ic-mic{display:block}
.badge-dot{position:absolute;top:.35rem;right:.35rem;width:.6rem;height:.6rem;border-radius:50%;background:var(--amber)}
@media (min-width:44rem){.controls{gap:1.2rem}.ctl{width:3.6rem;height:3.6rem}}

/* the files & chat sheet */
.sheet{position:absolute;left:0;right:0;bottom:0;max-height:min(70vh,70dvh);z-index:6;display:flex;flex-direction:column;gap:.7rem;
  padding:.8rem var(--side) calc(var(--bottom) + .4rem);border-radius:18px 18px 0 0;
  background:var(--surface);color:var(--ink);box-shadow:0 -8px 30px rgba(0,0,0,.4);overflow:auto}
.sheet-head{display:flex;justify-content:space-between;align-items:center}
.sheet-title{font-weight:600}
.panel{display:flex;flex-direction:column;gap:.6rem}
.dropzone{display:flex;gap:.4rem;align-items:center;justify-content:center;flex-wrap:wrap;
  padding:.9rem;border:1px dashed var(--line);border-radius:var(--radius);color:var(--muted);background:var(--surface)}
.dropzone.over{border-color:var(--accent);color:var(--accent)}
.filelabel{color:var(--accent);text-decoration:underline;cursor:pointer}
.cards{display:flex;flex-direction:column;gap:.5rem}
.card{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:.6rem .75rem;
  display:flex;flex-direction:column;gap:.35rem}
.card .name{font-weight:600;overflow-wrap:anywhere}
.card .sub{font-size:.82rem;color:var(--muted)}
.card progress{width:100%;height:.5rem;accent-color:var(--accent)}
.card.queued{opacity:.75}
.card.errored{border-color:var(--red)}
.card .btn{padding:.3rem .7rem;font-size:.85rem}
.card.transfer .actions{justify-content:flex-end;gap:.4rem;margin-left:auto}
.card.transfer .name{flex:1 1 auto}
.card.transfer .btn.accept{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.card.transfer .btn.download{background:var(--green-bg);color:var(--green);border-color:transparent;text-decoration:none}
.chat-log{display:flex;flex-direction:column;gap:.3rem;max-height:14rem;overflow-y:auto;padding:.2rem 0}
.msg{max-width:85%;padding:.35rem .7rem;border-radius:12px;background:var(--code-bg);overflow-wrap:anywhere;font-size:.95rem}
.msg.me{align-self:flex-end;background:var(--accent);color:var(--accent-ink)}
.msg.sys{align-self:center;background:none;color:var(--muted);font-size:.82rem}
