/* SISRAM app. Style: "Editorial greeting" (tasteskill app sheet): tonal panels, one teal accent on data,
   near-black primary, no gradients, no shadows at rest. Ground one step toward steel. */
@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans-latin-wght-normal.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(/fonts/instrument-serif-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --ground: #ffffff; --surface: #f3f5f4; --raised: #ffffff; --border: #e3e6e5; --rule: #e9eceb; --control: #d5d9d7;
  --text: #1f201d; --muted: #5f6361; --accent: #1b6e66; --primary: #1f201d; --on-primary: #ffffff;
  --positive: #2e7d32; --negative: #b42318; --warning: #92400e;
  --pill-pos-bg: #dcfae5; --pill-pos-ink: #04250e; --pill-neg-bg: #fdecea; --pill-neg-ink: #7a1d14;
  --pill-warn-bg: #fff4d6; --pill-warn-ink: #7a3a06; --pill-neu-bg: #e9eceb; --pill-neu-ink: #3d403e;
  --pill-acc-bg: #dff1ee; --pill-acc-ink: #0f4a44;
  --user-bubble: #e9eceb; --press: rgba(31, 32, 29, .08);
  --r-card: 22px; --gap: 16px; --pad: 18px; --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground: #0e0f0f; --surface: #181a19; --raised: #202322; --border: #2b2e2d; --rule: #242726; --control: #3a3e3c;
  --text: #eceeed; --muted: #9da19f; --accent: #5cbfb3; --primary: #eceeed; --on-primary: #121413;
  --positive: #7fd08a; --negative: #ff8a7a; --warning: #f1b56a;
  --pill-pos-bg: #173322; --pill-pos-ink: #a8e6b4; --pill-neg-bg: #3b1a16; --pill-neg-ink: #ffb4a8;
  --pill-warn-bg: #3a2a10; --pill-warn-ink: #f5c98a; --pill-neu-bg: #272a29; --pill-neu-ink: #c6c9c7;
  --pill-acc-bg: #143531; --pill-acc-ink: #9fe0d7;
  --user-bubble: #242726; --press: rgba(236, 238, 237, .1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--text); overscroll-behavior-y: none; }
body { font: 400 15px/1.45 "Instrument Sans", Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; touch-action: manipulation; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { height: 100dvh; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; padding: calc(var(--safe-t) + 14px) 18px calc(var(--nav-h) + var(--safe-b) + 28px); -webkit-overflow-scrolling: touch; }
.view.plain { padding-bottom: calc(var(--safe-b) + 28px); }
.stack > * + * { margin-top: var(--gap); }

/* top bar */
.bar { display: flex; align-items: center; gap: 6px; min-height: 44px; margin: 0 -8px 10px; }
.bar h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; flex: 1; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; color: var(--text); flex: none; transition: background .12s, transform .08s; }
.icon-btn:active { background: var(--press); transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; }

/* greeting */
.greet { padding: 6px 0 4px; }
.greet h1 { font: 400 36px/1.08 "Instrument Serif", Georgia, serif; letter-spacing: -.01em; }
.greet p { color: var(--muted); margin-top: 8px; font-size: 15px; }

/* panels and rows */
.panel { background: var(--surface); border-radius: var(--r-card); padding: 6px var(--pad) 8px; }
.panel > header { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.panel > header h2 { font-size: 15px; font-weight: 600; flex: 1; }
.panel > header .count { color: var(--muted); font-weight: 400; margin-left: 6px; }
.link { color: var(--muted); font-size: 14px; min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; border-radius: 10px; }
.link:active { background: var(--press); }
.row { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 13px 0; border-top: 1px solid var(--rule); min-height: 56px; border-radius: 0; transition: background .12s; position: relative; }
.row:first-of-type { border-top: 0; }
.panel > header + .row { border-top: 1px solid var(--rule); }
button.row:active, a.row:active { background: var(--press); box-shadow: 0 0 0 8px var(--press); border-radius: 6px; }
.row .main { flex: 1; min-width: 0; color: var(--text); }
.row .t { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.row .s { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .s.full { -webkit-line-clamp: unset; display: block; }
.row .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; flex: none; padding-top: 2px; text-align: right; }
.row .text { color: var(--text); font-size: 15px; }
.num { width: 22px; flex: none; color: var(--muted); font-size: 13px; padding-top: 2px; }
.empty { color: var(--muted); padding: 14px 0 16px; font-size: 14px; }
.err { color: var(--negative); padding: 10px 0 14px; font-size: 14px; }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--pill-neu-bg); color: var(--pill-neu-ink); }
.pill.pos { background: var(--pill-pos-bg); color: var(--pill-pos-ink); }
.pill.neg { background: var(--pill-neg-bg); color: var(--pill-neg-ink); }
.pill.warn { background: var(--pill-warn-bg); color: var(--pill-warn-ink); }
.pill.acc { background: var(--pill-acc-bg); color: var(--pill-acc-ink); }

/* count tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface); border-radius: var(--r-card); padding: 14px 16px 14px; min-height: 104px; display: flex; flex-direction: column; transition: transform .08s, background .12s; }
.tile:active { transform: scale(.97); background: var(--rule); }
.tile .l { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 30px; font-weight: 400; letter-spacing: -.02em; margin-top: 2px; line-height: 1.15; }
.tile .c { font-size: 12.5px; color: var(--muted); margin-top: auto; }
.tile .v.hot { color: var(--accent); }
.meter { height: 4px; border-radius: 4px; background: var(--rule); overflow: hidden; margin: 8px 0 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter i.warn { background: var(--warning); }
.meter i.neg { background: var(--negative); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 999px; font-weight: 500; font-size: 15px; background: var(--surface); color: var(--text); border: 1px solid var(--border); transition: transform .08s, background .12s, opacity .12s; white-space: nowrap; }
.btn:active { transform: scale(.96); background: var(--rule); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:active { opacity: .82; background: var(--primary); }
.btn.danger { color: var(--negative); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; }
.seg { display: flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { flex: 1; height: 38px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); text-align: center; transition: background .15s, color .15s, transform .08s; }
.seg button:active { transform: scale(.96); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.field { width: 100%; height: 48px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); padding: 0 16px; font-size: 16px; outline: none; }
textarea.field { height: auto; min-height: 96px; padding: 12px 16px; resize: none; line-height: 1.4; }
.field:focus { border-color: var(--control); background: var(--raised); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; color: var(--muted); }
.search .field { padding-left: 44px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; color: var(--text); transition: transform .08s, background .12s; white-space: nowrap; }
.chip:active { transform: scale(.94); background: var(--rule); }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* bottom navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--ground); border-top: 1px solid var(--rule); display: flex; z-index: 20; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 500; position: relative; transition: transform .08s, color .12s; }
.nav a:active { transform: scale(.9); }
.nav a svg { width: 23px; height: 23px; }
.nav a.on { color: var(--text); }
.nav a.on svg { stroke-width: 2.1; }
.nav .badge { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 600; }
:root[data-theme="dark"] .nav .badge { color: #06211e; }

/* sheet and toast (the only things that float) */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 40; opacity: 0; transition: opacity .18s; }
.scrim.in { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--ground); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); max-height: 88dvh; overflow-y: auto; transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -8px 40px rgba(0, 0, 0, .18); }
.sheet.in { transform: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--control); margin: 0 auto 12px; }
.sheet h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.sheet .acts { display: grid; gap: 10px; margin-top: 14px; }
.sheet .acts.two { grid-template-columns: 1fr 1fr; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); background: var(--primary); color: var(--on-primary); padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 60; opacity: 0; transition: opacity .2s, transform .2s; max-width: 88vw; text-align: center; pointer-events: none; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }
.banner { background: var(--pill-warn-bg); color: var(--pill-warn-ink); font-size: 13.5px; padding: 8px 18px; text-align: center; }

/* skeleton */
.sk { height: 14px; border-radius: 8px; background: var(--rule); margin: 16px 0; animation: pulse 1.2s ease-in-out infinite; }
.sk.w60 { width: 60%; } .sk.w40 { width: 40%; } .sk.w80 { width: 80%; }
@keyframes pulse { 50% { opacity: .45; } }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--control); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* markdown */
.md { font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md .tablewrap { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { font-size: 16px; font-weight: 600; margin: 18px 0 8px; line-height: 1.3; }
.md h1 { font-size: 19px; } .md h2 { font-size: 17px; }
.md ul, .md ol { padding-left: 22px; } .md li { margin: 3px 0; } .md li > p { margin: 0; }
.md code { font: 13.5px/1.4 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface); padding: 1.5px 5px; border-radius: 6px; }
.md pre { background: var(--surface); padding: 12px 14px; border-radius: 14px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--control); padding-left: 12px; color: var(--muted); }
.md .tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
.md table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; min-width: 84px; max-width: 320px; }
.md th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.md tr:last-child td { border-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }
.md img { max-width: 100%; border-radius: 12px; }

/* chat */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 2px; padding: calc(var(--safe-t) + 6px) 8px 6px; border-bottom: 1px solid var(--rule); }
.chat-head .who { flex: 1; min-width: 0; padding: 4px 6px; border-radius: 12px; }
.chat-head .who:active { background: var(--press); }
.chat-head .who b { display: block; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--control); flex: none; }
.dot.live { background: var(--accent); animation: pulse 1s infinite; }
.dot.off { background: var(--negative); }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.msg.user { align-self: flex-end; max-width: 86%; background: var(--user-bubble); padding: 10px 14px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; }
.msg.user.pending { opacity: .6; }
.msg.user .att { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.msg.bot { align-self: stretch; }
.msg-tools { display: flex; gap: 12px; margin-top: 8px; }
.msg-tools button { color: var(--muted); font-size: 13px; min-height: 32px; padding: 0 6px; border-radius: 8px; }
.msg-tools button:active { background: var(--press); }
.steps { align-self: stretch; color: var(--muted); font-size: 13.5px; }
.steps > button { display: flex; align-items: center; gap: 8px; min-height: 36px; width: 100%; border-radius: 10px; }
.steps > button:active { background: var(--press); }
.steps > button svg { width: 16px; height: 16px; transition: transform .15s; flex: none; }
.steps.open > button svg { transform: rotate(90deg); }
.steps ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 4px; display: none; }
.steps.open ul { display: block; }
.steps li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; }
.steps li b { font-weight: 500; color: var(--text); flex: none; }
.steps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.steps li.bad b { color: var(--negative); }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; min-height: 28px; }
.working span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret::after { content: ""; display: inline-block; width: 8px; height: 17px; background: var(--accent); margin-left: 2px; vertical-align: -3px; border-radius: 2px; animation: pulse .9s infinite; }
.ask { background: var(--surface); border-radius: var(--r-card); padding: 16px; border: 1px solid var(--border); }
.ask .q { font-weight: 600; font-size: 16px; margin-bottom: 12px; }
.ask .opts { display: grid; gap: 8px; }
.ask .opts .btn { justify-content: flex-start; height: auto; min-height: 48px; padding: 10px 18px; white-space: normal; text-align: left; border-radius: 18px; }
.ask .opts .btn.on { background: var(--pill-acc-bg); border-color: var(--accent); color: var(--pill-acc-ink); }
.ask .other { display: flex; gap: 8px; margin-top: 10px; }
.ask .timer { height: 3px; background: var(--rule); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.ask .timer i { display: block; height: 100%; background: var(--accent); width: 100%; transform-origin: left; }
.note { color: var(--muted); font-size: 13.5px; text-align: center; }
.note.bad { color: var(--negative); }
.composer { border-top: 1px solid var(--rule); padding: 8px 10px calc(8px + var(--safe-b)); background: var(--ground); }
.composer .chips { padding: 0 4px 8px; }
.composer .atts { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 4px 8px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--surface); font-size: 13px; max-width: 100%; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.att-chip button { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); border-radius: 50%; }
.att-chip button svg { width: 14px; height: 14px; }
.composer .line { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; border: 1px solid var(--border); background: var(--surface); border-radius: 22px; padding: 11px 16px; font-size: 16px; line-height: 1.35; resize: none; max-height: 38dvh; outline: none; min-height: 46px; }
.composer textarea:focus { border-color: var(--control); }
.send { width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; transition: transform .08s, opacity .12s; }
.send:active { transform: scale(.88); }
.send[disabled] { opacity: .3; }
.send svg { width: 20px; height: 20px; }
.send.stop { background: var(--negative); color: #fff; }
.rec { display: flex; align-items: center; gap: 10px; flex: 1; min-height: 46px; padding: 0 16px; border-radius: 22px; background: var(--pill-neg-bg); color: var(--pill-neg-ink); font-size: 15px; }
.rec .dot { background: var(--negative); animation: pulse .8s infinite; }

/* misc */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.draft-body { white-space: pre-wrap; font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; }
.day { font-size: 13px; color: var(--muted); padding: 14px 0 2px; font-weight: 500; }
.pair { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 26px calc(28px + var(--safe-b)); gap: 18px; }
.pair h1 { font: 400 40px/1.05 "Instrument Serif", Georgia, serif; }
.pair p { color: var(--muted); }
.pair img { width: 72px; height: 72px; border-radius: 20px; }
.price { text-align: right; white-space: nowrap; font-size: 15px; flex: none; }
.price small { display: block; color: var(--muted); font-size: 12px; }
.h-sec { font-size: 13px; color: var(--muted); font-weight: 500; margin: 22px 0 8px; }
@media (min-width: 720px) { #app { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); } .nav, .sheet { max-width: 520px; margin: 0 auto; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
