/* self.aryeh.win — one stylesheet, no framework.
   Layout rule for the whole app: nothing is desktop-first or mobile-first. Every
   surface is fluid, and the only real breakpoint (720px) swaps the two-column
   panes (chat list + thread) for a stacked, one-at-a-time view. */

:root {
  --bg: #0e1014;
  --bg-2: #161a21;
  --bg-3: #1e242e;
  --line: #2a3240;
  --fg: #e8edf5;
  --fg-dim: #98a4b8;
  --accent: #6ea8fe;
  --accent-2: #8b7cf6;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --fab: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa; --bg-2: #fff; --bg-3: #eef1f6; --line: #dde3ec;
    --fg: #131720; --fg-dim: #5b6678;
  }
}

* { box-sizing: border-box; }
/* The background belongs on html, not just body: a short page leaves body at its
   content height and the viewport below it paints the UA's white. */
html { height: 100%; background: var(--bg); }
body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--fg-dim); }
.small { font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.primary {
  background: var(--accent); color: #06101f; border: 0;
  border-radius: 10px; padding: 10px 16px; font-weight: 600;
}
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .5; }
.primary.big { width: 100%; padding: 14px; font-size: 16px; }
.primary.full { width: 100%; }
.ghost {
  background: transparent; color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.ghost:hover { color: var(--fg); border-color: var(--fg-dim); }
.ghost.danger, .danger { color: var(--bad); }
.ghost.small, .primary.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -.5px; }
.login-card label { display: block; margin: 16px 0 6px; font-size: 13px; color: var(--fg-dim); }
.login-card input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; margin-bottom: 12px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#codeInput { letter-spacing: 8px; text-align: center; font-size: 22px; }
.login-card .ghost { width: 100%; margin-top: 8px; }
.login-card .primary.big { margin-top: 8px; }
.login-card .primary.big:disabled { cursor: not-allowed; }
/* WhatsApp code lives behind a disclosure so the fingerprint is unambiguously
   the primary action; it opens itself when no passkey is enrolled. */
#waWrap { margin-top: 16px; }
#waWrap summary {
  cursor: pointer; color: var(--fg-dim); font-size: 13px;
  list-style: none; padding: 6px 0;
}
#waWrap summary::-webkit-details-marker { display: none; }
#waWrap summary::before { content: "▸ "; }
#waWrap[open] summary::before { content: "▾ "; }
#waWrap summary:hover { color: var(--fg); }
.wa-body { padding-top: 4px; }
.msg { min-height: 20px; margin: 12px 0 0; font-size: 13px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }

/* ── Shell ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -.3px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent; border: 0; color: var(--fg-dim);
  padding: 8px 12px; border-radius: 9px; white-space: nowrap; font-weight: 500;
}
.tab.active { background: var(--bg-3); color: var(--fg); }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.ver { padding: 6px 9px; font-size: 12px; }
.refresh.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 16px 14px calc(var(--fab) + 44px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.reload-banner {
  position: sticky; top: 0; z-index: 40; display: flex; gap: 12px;
  align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 10px 14px; background: var(--accent-2); color: #fff; font-size: 14px;
}

/* ── Bubbles (the Me tab) ────────────────────────────────────────────────── */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.filters input[type=search] {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--fg-dim);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; color: var(--fg-dim); font-size: 12.5px; margin-bottom: 12px; }

/* Bubbles are a flowing pile, not a grid — different-length facts should look
   like different-sized objects, which is what makes the page scannable. */
.bubbles { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.bubble {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 10px 14px; max-width: 100%;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, transform .1s;
}
.bubble:hover { border-color: var(--fg-dim); }
.bubble.draft { border-style: dashed; border-color: var(--warn); }
.bubble.rejected { opacity: .45; }
.bubble.pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.bubble .b-text { white-space: pre-wrap; word-break: break-word; }
.bubble .b-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--fg-dim); }
.b-kind { background: var(--bg-3); border-radius: 999px; padding: 2px 8px; }
.b-conf { font-variant-numeric: tabular-nums; }
.bubble .b-actions { display: none; gap: 4px; flex-wrap: wrap; }
.bubble:hover .b-actions, .bubble.open .b-actions, .review .bubble .b-actions { display: flex; }
.b-actions button { background: var(--bg-3); border: 0; border-radius: 7px; padding: 4px 8px; font-size: 12px; color: var(--fg-dim); }
.b-actions button:hover { color: var(--fg); }
.b-actions button.ok:hover { color: var(--good); }
.b-actions button.no:hover { color: var(--bad); }
.bubble textarea {
  width: 100%; min-width: min(70vw, 420px); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; resize: vertical;
}

.review-bar { background: var(--bg-2); border: 1px solid var(--warn); border-radius: var(--radius); padding: 14px; margin-bottom: 18px; }
.review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.review-actions { margin-left: auto; display: flex; gap: 6px; }

.empty { text-align: center; padding: 48px 12px; }
.raw-entries { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 12px; }
.raw-entries summary { cursor: pointer; color: var(--fg-dim); font-size: 13px; }
.entries { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.entry {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.entry .e-body { flex: 1; min-width: 0; }
.entry .e-title { font-weight: 600; }
.entry .e-sub { font-size: 12px; color: var(--fg-dim); word-break: break-word; }
.entry .e-status { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--bg-3); }
.entry .e-status.processing { color: var(--warn); }
.entry .e-status.error { color: var(--bad); }
.entry .e-status.done { color: var(--good); }
.entry video, .entry img { max-width: 160px; border-radius: 8px; display: block; }

/* ── Ask ─────────────────────────────────────────────────────────────────── */
.ask-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; min-height: 60dvh; }
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-item {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 11px; cursor: pointer;
}
.chat-item.active { border-color: var(--accent); }
.chat-item .ci-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .ci-sub { font-size: 11.5px; color: var(--fg-dim); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.chat-title { flex: 1; min-width: 120px; background: transparent; border: 0; font-size: 17px; font-weight: 600; padding: 4px; }
.chat-title:focus { outline: 1px solid var(--line); border-radius: 8px; }
select.ghost { padding: 6px 8px; }

.messages { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 0 12px; }
.msg-row { display: flex; flex-direction: column; gap: 5px; max-width: 92%; }
.msg-row.user { align-self: flex-end; align-items: flex-end; }
.bubble-msg {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 11px 14px; white-space: pre-wrap; word-break: break-word;
}
.msg-row.user .bubble-msg { background: var(--accent); color: #06101f; border-color: transparent; }
.msg-row.error .bubble-msg { border-color: var(--bad); color: var(--bad); }
.thoughts { font-size: 12.5px; color: var(--fg-dim); }
.thoughts summary { cursor: pointer; }
.thoughts .t-body { white-space: pre-wrap; padding: 8px; background: var(--bg-2); border-radius: 10px; margin-top: 5px; }
.used-atoms { display: flex; flex-wrap: wrap; gap: 5px; }
.used-atom {
  font-size: 11.5px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px; color: var(--fg-dim); cursor: pointer;
}
.used-atom:hover { color: var(--fg); border-color: var(--fg-dim); }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.ask-form { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 0; padding: 10px 0 0; background: linear-gradient(transparent, var(--bg) 30%); }
.ask-form textarea {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 14px; resize: none; max-height: 180px;
}
.mobile-only { display: none; }

/* ── Claude terminal ─────────────────────────────────────────────────────── */
.term-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.sandbox-note { margin-left: auto; }
.term { height: min(70dvh, 640px); background: #000; border: 1px solid var(--line); border-radius: 12px; padding: 8px; overflow: hidden; }

/* ── Live ────────────────────────────────────────────────────────────────── */
.live-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 12px; }
.live-orb-wrap { text-align: center; }
.live-orb {
  width: 132px; height: 132px; border-radius: 50%; font-size: 46px;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2));
  border: 0; color: #fff; box-shadow: 0 8px 40px -8px var(--accent);
}
.live-orb.on { animation: pulse 1.6s ease-in-out infinite; }
.live-orb.speaking { animation: pulse .7s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); box-shadow: 0 8px 60px -4px var(--accent-2); } }
.live-captions { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 8px; }
.cap { padding: 9px 13px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.cap.user { align-self: flex-end; background: var(--accent); color: #06101f; border-color: transparent; }
.live-save { width: 100%; max-width: 640px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.live-save-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.live-turns { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.live-turn { display: flex; gap: 9px; align-items: flex-start; padding: 7px; border-radius: 9px; background: var(--bg-3); }
.live-turn input { margin-top: 4px; }
.live-save-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Plus button + radial menu ───────────────────────────────────────────── */
/* The menu fans out AROUND the button rather than opening a sheet: each item is
   placed on an arc by index (--i), so it works identically at any width. */
/* Scrim: the arc opens over whatever is on screen, and on a phone the labels
   landed on top of bubbles and became unreadable. Dimming the page behind also
   makes it obvious the app is in "adding" mode. */
.fab-scrim {
  position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(2px);
}
.fab-scrim.on { opacity: 1; pointer-events: auto; }

.fab-wrap { position: fixed; right: 20px; bottom: calc(20px + var(--safe-b)); z-index: 50; }
.fab {
  width: var(--fab); height: var(--fab); border-radius: 50%; border: 0;
  background: var(--accent); color: #06101f; font-size: 32px; line-height: 1;
  box-shadow: 0 10px 30px -6px rgba(0,0,0,.5);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
}
.fab.open { transform: rotate(135deg); }
.fab-menu { position: absolute; inset: 0; pointer-events: none; }
.fab-item {
  position: absolute; right: 6px; bottom: 6px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--fg);
  display: grid; place-items: center; font-size: 20px;
  opacity: 0; transform: translate(0, 0) scale(.4);
  transition: transform .26s cubic-bezier(.34,1.56,.64,1), opacity .18s;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.6);
}
.fab-item em {
  position: absolute; right: 56px; font-style: normal; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; opacity: 0;
  transition: opacity .18s; pointer-events: none;
}
.fab-menu.open { pointer-events: auto; }
/* Arc: 5 items spread over 90°, radius 108px. Item i sits at 90° - i*22.5°. */
.fab-menu.open .fab-item {
  opacity: 1;
  transform:
    translate(calc(-108px * cos(calc(90deg - var(--i) * 22.5deg))),
              calc(-108px * sin(calc(90deg - var(--i) * 22.5deg))))
    scale(1);
  transition-delay: calc(var(--i) * 28ms);
}
.fab-menu.open .fab-item em { opacity: 1; transition-delay: calc(var(--i) * 28ms + 90ms); }
.fab-item:active { background: var(--accent); color: #06101f; }
/* Tight screens: shorten the radius so the arc can't leave the viewport. */
@media (max-width: 380px), (max-height: 520px) {
  .fab-menu.open .fab-item {
    transform:
      translate(calc(-86px * cos(calc(90deg - var(--i) * 22.5deg))),
                calc(-86px * sin(calc(90deg - var(--i) * 22.5deg))))
      scale(1);
  }
}

/* ── Recorder sheet ──────────────────────────────────────────────────────── */
.rec-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; }
.rec-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 24px; width: min(340px, 100%); text-align: center; }
.rec-time { font-size: 34px; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.rec-wave { height: 44px; display: flex; align-items: center; justify-content: center; gap: 3px; margin-bottom: 18px; }
.rec-wave i { width: 4px; background: var(--accent); border-radius: 2px; height: 6px; transition: height .08s; }
.rec-actions { display: flex; gap: 8px; }
.rec-actions button { flex: 1; }

/* ── Uploads, modal, toasts ──────────────────────────────────────────────── */
.uploads { position: fixed; left: 14px; bottom: calc(20px + var(--safe-b)); z-index: 45; display: flex; flex-direction: column; gap: 6px; max-width: min(300px, 70vw); }
.upload {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 8px 11px; font-size: 12.5px;
}
.upload .bar { height: 3px; background: var(--bg-3); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.upload .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 18px; overflow-y: auto; }
.modal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(560px, 100%); max-height: 86dvh; overflow-y: auto; }
.modal-card.wide { width: min(760px, 100%); }
.modal-card h3 { margin-top: 0; }
.modal-card textarea, .modal-card input, .modal-card select {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; margin-bottom: 10px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.changelog-entry { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.changelog-entry h4 { margin: 0 0 6px; font-size: 14px; }
.changelog-entry ul { margin: 0; padding-left: 18px; color: var(--fg-dim); font-size: 13px; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-3); border: 1px solid var(--line); border-radius: 11px; padding: 9px 15px; font-size: 13.5px; box-shadow: 0 10px 30px -10px #000; }
.toast.error { border-color: var(--bad); color: var(--bad); }
.toast.success { border-color: var(--good); }

/* ── The one breakpoint ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  main { padding-left: 12px; padding-right: 12px; }
  .ask-layout { grid-template-columns: 1fr; }
  /* One pane at a time: the list, or the thread — never a squeezed pair. */
  .ask-layout.viewing-chat .chat-list { display: none; }
  .ask-layout:not(.viewing-chat) .chat-main { display: none; }
  .mobile-only { display: inline-block; }
  .sandbox-note { margin-left: 0; flex-basis: 100%; }
  .msg-row { max-width: 100%; }
  .term { height: 62dvh; }
  .brand { display: none; }
}
