/* Saku web — the iOS Theme tokens (ios/Journal/Theme.swift), dark default, light via prefers-color-scheme. */
:root {
  --bg: #0A0C10; --surface: #14181F; --raised: #1B212B; --border: #232833;
  --text: #F3F5F8; --muted: #99A2B1; --subtle: #6F7787;
  --accent: #4A90F7; --done: #34D399; --danger: #F0484F; --warning: #F2B134; --purple: #9B6BF2; --teal: #34D3B0;
  --accent-soft: rgba(74,144,247,.14); --done-soft: rgba(52,211,153,.13); --purple-soft: rgba(155,107,242,.14);
  --warning-soft: rgba(242,177,52,.14); --teal-soft: rgba(52,211,176,.14);
  --card-r: 16px; --ctl-r: 12px; --rail-w: 84px;
  --app: var(--accent); --app-soft: var(--accent-soft);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F6F7F9; --surface: #FFFFFF; --raised: #EEF1F5; --border: #DFE3EA;
    --text: #12151B; --muted: #59616F; --subtle: #8A92A0;
    --accent: #2E6FE0; --done: #0F9D6B; --danger: #D92D34; --warning: #B5810F; --purple: #7A4FD6; --teal: #0E9E86;
    --accent-soft: rgba(46,111,224,.14); --done-soft: rgba(15,157,107,.13); --purple-soft: rgba(122,79,214,.14);
    --warning-soft: rgba(181,129,15,.14); --teal-soft: rgba(14,158,134,.14);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); font-size: 13px; }

/* ── sign-in ──────────────────────────────────────────────────────────────── */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-r); padding: 28px; }
.signin h1 { font-size: 22px; margin: 18px 0 4px; }
.signin form { display: grid; gap: 10px; margin-top: 16px; }
.signin input { background: var(--raised); border: 1px solid var(--border); border-radius: var(--ctl-r); padding: 12px 14px; outline: none; }
.signin input:focus { border-color: var(--accent); }
.primary { background: var(--accent); color: #fff; border-radius: var(--ctl-r); padding: 12px 16px; font-weight: 600; }
.primary:disabled { opacity: .6; cursor: default; }
.ghost { color: var(--muted); padding: 8px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.logo { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 14px; font-weight: 800; }
.logo.sm { width: 38px; height: 38px; font-size: 15px; }

/* ── shell / rail ─────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100%; }
.rail { background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 0; overflow: visible; }
.rail-logo { margin-bottom: 4px; }
.rail-apps { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1; width: 100%; overflow-y: auto; overflow-x: visible; }
.rail-apps::-webkit-scrollbar { width: 0; }
.rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }
.rail-tile { position: relative; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; background: var(--raised); border: 1px solid var(--border); color: var(--text); transition: transform .12s ease, box-shadow .12s ease; }
.rail-tile:hover { transform: translateY(-1px); }
.rail-tile.active { background: var(--app-soft); border-color: color-mix(in srgb, var(--app) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--app) 40%, transparent), 0 6px 18px color-mix(in srgb, var(--app) 22%, transparent); }
.rail-tile.grid { font-size: 18px; color: var(--muted); }
/* hover tooltip */
.rail-tile[data-name]:hover::after { content: attr(data-name); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); z-index: 30; pointer-events: none; }
.rail-user { padding: 0; border: 0; }
.rail-user .avatar { width: 40px; height: 40px; font-size: 14px; }
.rail-user-wrap { position: relative; }
.menu { position: absolute; left: calc(100% + 8px); bottom: 0; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--ctl-r); overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 40; }
.menu-item { display: block; width: 100%; text-align: left; padding: 11px 14px; }
.menu-item:hover { background: var(--raised); }
.muted-item { color: var(--muted); cursor: default; }
.danger-item { color: var(--danger); }
.icon-btn { width: 40px; height: 40px; border-radius: var(--ctl-r); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 18px; }
.icon-btn.small { width: 28px; height: 28px; font-size: 16px; }
.icon-btn:hover { background: var(--raised); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); font-weight: 700; font-size: 12.5px; flex: none; }
.avatar.saku { background: var(--accent); color: #fff; }

/* ── main / topbar ────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; position: relative; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.top-left { position: relative; justify-self: start; }
.chats-btn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
.chats-btn:hover { background: var(--raised); }
.chats-btn .chev { color: var(--muted); }
.chats-panel { position: absolute; top: calc(100% + 8px); left: 0; width: 320px; max-height: 70vh; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-r); padding: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.45); z-index: 35; }
.search { display: flex; align-items: center; gap: 8px; background: var(--raised); border: 1px solid var(--border); border-radius: 22px; padding: 9px 14px; }
.search input { flex: 1; background: none; border: 0; outline: none; min-width: 0; }
.search-ic { color: var(--muted); font-size: 18px; }
.threads { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.thread-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; border-radius: var(--ctl-r); color: var(--text); font-weight: 500; }
.thread-row:hover { background: var(--raised); }
.thread-row.active { background: var(--accent-soft); }
.thread-row .row-ic { width: 22px; text-align: center; opacity: .9; }
.row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-del { opacity: 0; color: var(--subtle); font-size: 14px; padding: 0 2px; }
.thread-row:hover .row-del { opacity: 1; }
.side-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13.5px; padding: 12px 6px 4px; }

.who { display: flex; align-items: center; gap: 10px; justify-self: center; }
.who .avatar.saku { width: 30px; height: 30px; }
.who-name { font-weight: 800; font-size: 18px; }
.online { width: 9px; height: 9px; border-radius: 50%; background: var(--done); margin-left: -6px; align-self: flex-end; margin-bottom: 6px; }
.seg { display: inline-flex; background: var(--raised); border: 1px solid var(--border); border-radius: 22px; padding: 3px; margin-left: 8px; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg-btn.active { background: var(--accent); color: #fff; }
.seg-btn.active.work { background: var(--purple); }

.top-actions { display: flex; gap: 10px; justify-self: end; }
.pill { padding: 9px 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
.pill:hover { background: var(--raised); }

/* ── chat view ────────────────────────────────────────────────────────────── */
.scroll { flex: 1; overflow: auto; padding: 18px clamp(12px, 5vw, 80px); }
.messages { display: flex; flex-direction: column; gap: 12px; max-width: 920px; margin: 0 auto; }
.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.ceo, .row.assistant { justify-content: flex-start; }
.bubble { max-width: min(78%, 760px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-r); padding: 12px 16px; position: relative; }
.row.user .bubble { background: var(--accent-soft); border-color: transparent; }
.row.system { justify-content: center; }
.row.system .sys { color: var(--subtle); font-size: 12.5px; text-align: center; max-width: 80%; }
.daysep { text-align: center; color: var(--subtle); font-size: 12.5px; margin: 8px 0; }
.stamp { color: var(--subtle); font-size: 11.5px; margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.react { opacity: .55; }
.react.on { opacity: 1; color: var(--accent); }
.row .tools { position: absolute; right: -4px; bottom: -14px; display: none; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px 6px; }
.row:hover .tools, .row.ceo:focus-within .tools { display: flex; }
.tools button { font-size: 13px; padding: 2px 4px; opacity: .8; }
.quick { max-width: 920px; margin: 10px auto 0; display: grid; gap: 8px; }
.quick button, .card-actions button, .card-actions a { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: var(--ctl-r); background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500; text-decoration: none; }
.quick button:hover, .card-actions button:hover { background: var(--raised); }
.working { max-width: 920px; margin: 10px auto 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.working .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }

/* markdown */
.md { word-wrap: break-word; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 6px; font-size: 15.5px; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code { background: var(--raised); padding: 1px 5px; border-radius: 6px; font-size: 13px; }
.md pre { background: var(--raised); padding: 10px 12px; border-radius: var(--ctl-r); overflow: auto; }
.md table { border-collapse: collapse; margin: 6px 0; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--raised); }
.md img { max-width: 100%; max-height: 260px; border-radius: var(--ctl-r); border: 1px solid var(--border); cursor: zoom-in; display: block; margin: 6px 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.md blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--border); color: var(--muted); }

/* cards */
.card { margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-r); padding: 14px; max-width: 760px; }
.row.ceo .bubble + .card, .card.lead { margin-top: 10px; }
.card .headline { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.card .basis { color: var(--muted); font-size: 13.5px; margin: 0 0 8px; }
.card .caveat { color: var(--warning); font-size: 13px; background: rgba(242,177,52,.12); border-radius: var(--ctl-r); padding: 8px 10px; margin: 8px 0 0; }
.card-actions { display: grid; gap: 8px; margin-top: 10px; }
.tiles { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 6px; scroll-snap-type: x mandatory; }
.tile { flex: 0 0 180px; background: var(--raised); border: 1px solid var(--border); border-radius: var(--ctl-r); padding: 10px; text-decoration: none; color: var(--text); scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; }
.tile .img { height: 110px; border-radius: 8px; background: var(--surface); display: grid; place-items: center; overflow: hidden; }
.tile .img img { width: 100%; height: 100%; object-fit: cover; }
.tile .img img.logo { width: 44px; height: 44px; object-fit: contain; }
.tile .t { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .p { font-weight: 700; } .tile .p s { color: var(--subtle); font-weight: 400; font-size: 12px; margin-left: 4px; }
.tile .r, .tile .w { font-size: 12px; color: var(--muted); }
.tile .w { color: var(--warning); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--done-soft); color: var(--done); }
.group-title { font-weight: 600; font-size: 13.5px; margin: 8px 0 2px; color: var(--muted); }
.cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cmp th, .cmp td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.cmp tr.best td { background: var(--done-soft); }
.cmp .src { font-weight: 600; }
.findings { margin: 6px 0; padding-left: 20px; }
.findings li { margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12.5px; padding: 5px 10px; border-radius: 14px; background: var(--raised); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.flight { background: var(--raised); border: 1px solid var(--border); border-radius: var(--ctl-r); padding: 10px 12px; margin-top: 8px; }
.flight .legs { display: grid; gap: 6px; }
.leg { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-size: 13.5px; }
.leg .code { font-weight: 700; font-size: 16px; } .leg .ct { color: var(--muted); font-size: 11.5px; }
.leg .mid { color: var(--subtle); font-size: 12px; text-align: center; }
.leg .right { text-align: right; }
.flight .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.flight .price { color: var(--text); font-weight: 700; font-size: 15px; }
.ftag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--done-soft); color: var(--done); margin-left: 6px; }
.connector { display: flex; flex-direction: column; gap: 10px; max-width: 320px; }
.connector .head { display: flex; align-items: center; gap: 10px; }
.connector .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--raised); display: grid; place-items: center; font-size: 20px; }
.connector .ttl { font-weight: 700; } .connector .sub { color: var(--muted); font-size: 13px; }
.insight .col { margin-top: 6px; } .insight .col b { color: var(--muted); font-size: 12.5px; }
.voice { display: flex; align-items: center; gap: 10px; }
.voice audio { height: 32px; }
.quick-mark { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }

/* ── app home (hero) ──────────────────────────────────────────────────────── */
.apphome { flex: 1; overflow: auto; display: grid; place-items: start center; padding: clamp(24px, 6vh, 72px) 20px 24px; }
.hero { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero-ic { width: 74px; height: 74px; border-radius: 20px; display: grid; place-items: center; font-size: 34px; background: var(--app-soft); border: 1px solid color-mix(in srgb, var(--app) 45%, transparent); box-shadow: 0 0 40px color-mix(in srgb, var(--app) 30%, transparent); margin-bottom: 18px; }
.hero-h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; line-height: 1.12; }
.hero-h1 .kw { color: var(--app); }
.hero-sub { color: var(--muted); font-size: 15.5px; margin: 0 0 22px; }
.hero-composer-slot { width: 100%; }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.hero-chips.sub { margin-top: 10px; }
.chip-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13.5px; }
.chip-btn:hover { background: var(--raised); border-color: color-mix(in srgb, var(--app) 40%, var(--border)); }
.chip-btn.active { background: var(--app-soft); border-color: color-mix(in srgb, var(--app) 50%, transparent); color: var(--text); }
.chip-btn .ci { font-size: 15px; }
.hero-ask { width: 100%; margin-top: 30px; }
.hero-ask-h { color: var(--subtle); font-size: 13px; font-weight: 600; text-align: left; margin-bottom: 2px; }

/* ── composer ─────────────────────────────────────────────────────────────── */
#composer-dock { border-top: 1px solid var(--border); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px clamp(12px, 5vw, 80px) 18px; }
.composer textarea { flex: 1; resize: none; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 12px 16px; outline: none; max-height: 180px; line-height: 1.4; }
.composer textarea:focus { border-color: var(--accent); }
.icon-btn.send { background: var(--accent); color: #fff; border-color: transparent; }
.icon-btn.send:disabled { opacity: .5; cursor: default; }
#mic.rec { background: var(--danger); color: #fff; border-color: transparent; animation: pulse 1s infinite; }
/* composer relocated into the hero */
.hero-composer-slot .composer { padding: 0; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 6px 6px 6px 8px; align-items: center; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.hero-composer-slot .composer:focus-within { border-color: color-mix(in srgb, var(--app) 55%, var(--border)); }
.hero-composer-slot .composer textarea { border: 0; background: none; padding: 11px 6px; font-size: 16px; }
.hero-composer-slot .composer textarea:focus { border: 0; }
.hero-composer-slot .icon-btn.send { background: var(--app); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--ctl-r); padding: 10px 16px; font-size: 13.5px; box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 50; max-width: 90vw; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* ── mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  :root { --rail-w: 64px; }
  .rail-tile { width: 44px; height: 44px; font-size: 19px; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 10px 12px; }
  .who { gap: 8px; }
  .who-name { font-size: 16px; }
  .seg .sl { display: none; }
  .seg-btn { padding: 6px 10px; }
  .top-actions .pill { padding: 8px 12px; }
  .chats-panel { width: min(88vw, 320px); }
  .bubble { max-width: 90%; }
  .hero-h1 { font-size: 26px; }
}
@media (max-width: 560px) {
  .top-actions .pill span { }
  .call-label { display: none; }
}
