/* Yippee Chat — ported from deep-threads-proto-v46.html. Test scaffolding (phone frame, fake
   keyboard, control chips, tree/cols/chat views) removed; everything else is the prototype's. */
:root{
  --bg:#f6f4ef; --panel:#ffffff; --fg:#1f1d1a; --muted:#7a746a; --line:#dcd7cc;
  --me:#2d6a4f; --me-bg:#e3f1e9; --her:#8a4b2b; --her-bg:#f6e9e0;
  --accent:#2d6a4f; --focus:#f2b705; --due:#b7a4e6; --due-glow:rgba(183,164,230,.35);
  --font:"Manrope",system-ui,-apple-system,sans-serif; --mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#17160f; --panel:#201e16; --fg:#ece7da; --muted:#9a9384; --line:#3a372c;
  --me:#7fc9a1; --me-bg:#1e3a2c; --her:#e2a07c; --her-bg:#3b2a20; --accent:#7fc9a1;
  --due:#9f8bd8; --due-glow:rgba(159,139,216,.3); color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#17160f; --panel:#201e16; --fg:#ece7da; --muted:#9a9384; --line:#3a372c;
  --me:#7fc9a1; --me-bg:#1e3a2c; --her:#e2a07c; --her-bg:#3b2a20; --accent:#7fc9a1;
  --due:#9f8bd8; --due-glow:rgba(159,139,216,.3); color-scheme:dark}

*{box-sizing:border-box}
/* A class that sets `display` beats the UA sheet's [hidden] rule, and several of the ported
   elements (the picker, the zoom control, each bubble's vestigial action bar) rely on the
   hidden attribute. Make the attribute win everywhere. */
[hidden]{display:none!important}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--fg);font-family:var(--font);font-size:15px;line-height:1.45;
  overscroll-behavior:none;-webkit-text-size-adjust:100%}

/* The app is sized from window.visualViewport, so the real keyboard shrinks it instead of covering it. */
#app{position:fixed;left:0;top:0;width:100%;height:100%;display:flex;flex-direction:column;
  padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px);overflow:hidden}

/* ---- title bar: the OTHER person's name, the map toggle, settings ---- */
.titlebar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:calc(6px + env(safe-area-inset-top,0px)) 14px 6px;min-height:40px;background:var(--bg);
  border-bottom:1px solid var(--line);position:relative;z-index:6}
.titlebar .ptitle{font-size:16px;font-weight:700;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.titlebar button{background:var(--panel);border:1px solid var(--line);border-radius:999px;color:var(--accent);
  font:inherit;font-size:12px;font-weight:700;padding:4px 11px;cursor:pointer;flex:none;-webkit-tap-highlight-color:transparent}
.titlebar button[aria-pressed="true"]{background:var(--accent);color:var(--bg);border-color:var(--accent)}
.titlebar .dot{width:7px;height:7px;border-radius:50%;background:var(--accent);flex:none;opacity:0}
.titlebar .dot.off{background:var(--her);opacity:1}

#stage{flex:1;min-height:0;overflow:auto;padding:10px 14px;user-select:none;-webkit-user-select:none;
  scrollbar-width:none;overscroll-behavior:contain;touch-action:pan-x pan-y}
#stage::-webkit-scrollbar{display:none}

/* ---- message card ---- */
.msg{border-radius:14px;padding:8px 11px;position:relative;touch-action:pan-y;-webkit-touch-callout:none}
.msg.swiping::before{content:"↳ thread";position:absolute;right:calc(100% + 10px);top:50%;transform:translateY(-50%);
  font-size:11px;font-weight:700;color:var(--muted);white-space:nowrap}
.msg.swipe-ready::before{color:var(--accent)} .msg.swipe-ready{box-shadow:-4px 0 0 var(--accent)}
.msg.snapback{transition:transform 180ms ease}
.msg.me{background:var(--me-bg)} .msg.her{background:var(--her-bg)}
.msg .who{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.msg.me .who{color:var(--me)} .msg.her .who{color:var(--her)}
.msg .txt{margin:2px 0 4px;word-wrap:break-word;overflow-wrap:anywhere;white-space:pre-wrap}
.msg.flash{outline:2px solid var(--focus);transition:outline-color 1.2s} .msg.flash.off{outline-color:transparent}
.msg.sending{opacity:.6}

/* ---- reactions: iMessage tapbacks on the corner that faces the middle of the screen ---- */
.picker{position:absolute;z-index:20;display:flex;gap:4px;background:var(--panel);border:1px solid var(--line);
  border-radius:999px;padding:5px 8px;box-shadow:0 8px 24px rgba(0,0,0,.22);animation:pop 160ms cubic-bezier(.2,.8,.2,1)}
.picker button{background:none;border:0;font-size:22px;line-height:1;padding:6px 7px;border-radius:50%;cursor:pointer}
.picker button:hover{background:var(--bg)}
@keyframes pop{from{transform:scale(.7);opacity:0}}
.msg:has(> .reacts){margin-top:16px}
.reacts{position:absolute;top:-14px;display:flex;gap:2px;z-index:2}
.msg.her > .reacts{right:-6px} .msg.me > .reacts{left:-6px;flex-direction:row-reverse}
.rx{position:relative;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;padding:4px 7px;
  font-size:15px;line-height:1;cursor:pointer;user-select:none;-webkit-user-select:none;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.rx.me{background:var(--me)} .rx.her{background:var(--line)}
.rx::after{content:"";position:absolute;width:7px;height:7px;border-radius:50%;background:inherit;bottom:-3px}
.msg.her > .reacts .rx::after{left:2px} .msg.me > .reacts .rx::after{right:2px}
.rx i{display:none}
.rx .subs{position:absolute;left:calc(100% - 8px);top:-12px;display:flex;gap:2px;font-size:.8em}
.rx .subs .rx{padding:3px 5px} .rx .subs .rx::after{display:none}

/* ---- chat column ---- */
.chat{display:flex;flex-direction:column;gap:12px;min-height:100%}
.row{display:flex;flex-direction:column;align-items:flex-start;min-width:0}
.row.me{align-items:flex-end}
.row .msg{max-width:84%}
.row.me .msg{border-bottom-right-radius:4px} .row.her .msg{border-bottom-left-radius:4px}
/* a run of consecutive replies to the same message sits under a dim ghost of it, with a bracket down the left */
.group{position:relative;display:flex;flex-direction:column;gap:12px;padding-left:22px;min-width:0}
.group .bracket{position:absolute;left:4px;width:14px;border:2px solid var(--line);border-right:0;
  border-radius:12px 0 0 12px;pointer-events:none}
.ghostwrap{display:flex;flex-direction:column;align-items:flex-start;gap:3px;cursor:pointer;min-width:0}
.ghostwrap.me{align-items:flex-end}
.ghost{max-width:82%;border:1.5px solid var(--line);border-radius:14px;padding:5px 10px;font-size:12px;line-height:1.35;
  color:var(--muted);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;background:var(--bg)}
.ghost.me{border-color:var(--me);color:var(--me);opacity:.8} .ghost.her{border-color:var(--her);color:var(--her);opacity:.8}
.rcount{font-size:11px;font-weight:600;color:var(--accent);padding:0 6px}
.row .rcount.under{margin-top:2px}
/* the quoted original on the composer's "replying to" line */
.trail{display:flex;flex-direction:column;gap:1px;margin-bottom:10px;max-width:72%;min-width:0;position:relative}
.trail button{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:4px 9px;font:inherit;
  font-size:12px;color:var(--muted);text-align:left;cursor:pointer;max-width:100%;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;line-height:1.35;opacity:.85}
.trail button b{font-weight:700;letter-spacing:.04em;font-size:10px;text-transform:uppercase;margin-right:4px}
.trail button:hover,.trail button:focus-visible{color:var(--accent);outline:none}
.trail::after{content:"";position:absolute;top:100%;left:14px;width:12px;height:12px;
  border-left:2px solid var(--line);border-bottom:2px solid var(--line);border-bottom-left-radius:8px}
.row.me .trail{align-items:flex-end} .row.me .trail button{text-align:right}
.row.me .trail::after{left:auto;right:14px;border-left:0;border-right:2px solid var(--line);
  border-bottom-left-radius:0;border-bottom-right-radius:8px}
.composer .target .trail::after{display:none}
.row{transition:opacity 180ms ease,transform 180ms ease}
.row.pinned{align-items:flex-start} .row.pinned .msg{max-width:100%;border:1px solid var(--line)}
@media (prefers-reduced-motion:reduce){ .row{transition:none} }

.replybox{display:flex;gap:6px;margin-top:6px}
.replybox input{flex:1;min-width:0;font:inherit;font-size:16px;padding:9px 12px;border:1px solid var(--line);
  border-radius:999px;background:var(--panel);color:var(--fg);user-select:text;-webkit-user-select:text}
.replybox button{font:inherit;font-weight:600;border:0;border-radius:999px;padding:9px 15px;background:var(--accent);
  color:var(--bg);cursor:pointer}
.composer{position:sticky;bottom:0;margin:auto -10px 0;padding:8px 10px calc(10px + env(safe-area-inset-bottom,0px));
  background:var(--panel);border-top:1px solid var(--line);z-index:3}
.composer .target{font-size:12px;color:var(--muted);display:flex;gap:8px;align-items:flex-start;margin-bottom:6px}
.composer .target .trail{margin:0;max-width:none;flex:1}
.composer .target button.x{background:none;border:0;color:var(--muted);font:inherit;cursor:pointer;padding:0 4px}
.composer .replybox{margin:0}

/* ---- columns: one per opened thread, side by side, the whole stage scrolls as one ---- */
.cols{display:flex;gap:10px;align-items:flex-start;min-height:100%;width:max-content}
.col{flex:0 0 var(--colw,336px);width:var(--colw,336px);background:var(--panel);border:1px solid var(--line);
  border-radius:16px;padding:10px;display:flex;flex-direction:column;gap:8px;min-width:0}
.col .head{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.05em;text-transform:uppercase;
  display:flex;justify-content:space-between;align-items:center}
.hybrid{align-items:stretch}
.hybrid .chatcol{padding:0;scrollbar-width:none}
.hybrid .chatcol::-webkit-scrollbar{display:none}
.hybrid .chatcol .chat{padding:10px 10px 0;gap:12px}
.hybrid .chatcol .composer{margin:auto -10px 0;padding-inline:10px;border-radius:0 0 16px 16px}
.hybrid .msg.open{outline:2px solid var(--accent)}
/* linked = the whole stage scrolls as one, so the columns move together natively */
.hybrid.linked{height:auto;min-height:100%;align-items:flex-start}
.hybrid.linked .chatcol{height:auto;min-height:100%;overflow:visible}
.hybrid.linked .chatcol .chat{min-height:100%}
.col.enter{animation:colIn 520ms cubic-bezier(.2,.8,.2,1) both}
@keyframes colIn{from{opacity:0;transform:translateX(28px)}}
@keyframes fadeIn{from{opacity:0}}
/* "moves over": the opened bubble leaves an empty dashed slot behind (tap it to bring the thread back) */
.hybrid.move .msg.open{background:transparent;color:transparent;outline:1.5px dashed var(--line);cursor:pointer}
.hybrid.move .msg.open *{visibility:hidden}
.hybrid.move .row:has(> .msg.open) .trail{opacity:.35}
.hybrid.move .col.enter{animation:none} .hybrid.move .col.enter > .chat > :not(.pinned){animation:fadeIn 520ms both}
.col.closing{overflow:visible} .col.closing > .chat > :not(.pinned){opacity:0;transition:opacity 300ms}
@media (prefers-reduced-motion:reduce){ .col.enter{animation:none} }

/* ---- the canvas map ---- */
.zoomctl{position:absolute;right:14px;bottom:calc(24px + env(safe-area-inset-bottom,0px));display:flex;align-items:center;
  gap:4px;background:var(--panel);border:1px solid var(--line);border-radius:999px;padding:3px 6px;font-size:12px;
  font-variant-numeric:tabular-nums;z-index:5}
.zoomctl button{width:30px;height:30px;border:0;border-radius:50%;background:var(--bg);color:var(--fg);font:inherit;font-size:18px;cursor:pointer}
.zoomctl span{min-width:38px;text-align:center;color:var(--muted)}
.canvas{position:relative;min-height:100%}
.canvas .cz{position:absolute;left:0;top:0;transform-origin:0 0}
.canvas svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible}
.canvas path{fill:none;stroke:var(--line);stroke-width:2}
.canvas .msg{position:absolute;width:220px;cursor:pointer}
.canvas path.hot{stroke:var(--accent);stroke-width:2.5}
.canvas .msg.open{outline:2px solid var(--accent)}
.canvas .msg.kid{box-shadow:inset 3px 0 0 var(--accent)}
/* "on you to answer": a soft lavender ring plus a dot; tap to wave it off */
.canvas .msg.due{box-shadow:0 0 0 2.5px var(--due), 0 4px 14px var(--due-glow)}
.canvas .msg.due::after{content:"";position:absolute;right:-5px;top:-5px;width:11px;height:11px;border-radius:50%;
  background:var(--due);border:2px solid var(--bg)}
.canvas .msg.due.kid{box-shadow:inset 3px 0 0 var(--accent), 0 0 0 2.5px var(--due)}
.canvas .msg.grow{animation:grow 420ms cubic-bezier(.2,.8,.2,1);transform-origin:50% 50%;z-index:4}
@keyframes grow{0%{transform:scale(1)}45%{transform:scale(1.06)}100%{transform:scale(1)}}
@media (prefers-reduced-motion:reduce){ .canvas .msg.grow{animation:none} }

/* ---- settings sheet ---- */
.sheet-back{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:30;display:flex;align-items:flex-end;justify-content:center;
  animation:fadeIn 180ms both}
.sheet{background:var(--panel);border-radius:18px 18px 0 0;border-top:1px solid var(--line);width:100%;max-width:520px;
  padding:16px 18px calc(20px + env(safe-area-inset-bottom,0px));animation:sheetUp 260ms cubic-bezier(.2,.8,.2,1) both;
  max-height:85%;overflow:auto}
@keyframes sheetUp{from{transform:translateY(100%)}}
.sheet h2{font-size:17px;margin:0 0 4px}
.sheet p{color:var(--muted);font-size:13px;margin:6px 0}
.sheet .row2{display:flex;gap:10px;align-items:center;justify-content:space-between;margin:14px 0;flex-wrap:wrap}
.sheet button{font:inherit;font-weight:600;border:1px solid var(--line);border-radius:999px;padding:9px 15px;
  background:var(--bg);color:var(--accent);cursor:pointer}
.sheet button.primary{background:var(--accent);color:var(--bg);border-color:var(--accent)}
.sheet button.quiet{color:var(--muted)}
.sheet code{font-family:var(--mono);font-size:12px;background:var(--bg);padding:1px 5px;border-radius:5px}
.sheet .ok{color:var(--accent);font-weight:600;font-size:13px}
.sheet .warn{color:var(--her);font-weight:600;font-size:13px}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(26px + env(safe-area-inset-bottom,0px));
  background:var(--fg);color:var(--bg);font-size:13px;font-weight:600;padding:9px 15px;border-radius:999px;z-index:40;
  animation:fadeIn 160ms both;max-width:86%;text-align:center}
