/* Tarka Assistant — uses the tokens of the deployed tarkahq.com stylesheet. */
:root {
  --bg: #fbfbfc;
  --bg-alt: #f3f5f7;
  --surface: #ffffff;
  --rule: #dde3e9;
  --rule-strong: #ced5dd;
  --text-strong: #14181f;
  --text: #4a5563;
  --text-soft: #6b7686;
  --summit: #fb5b34;
  --granite: #14181f;
  --granite-raised: #1e242d;
  --night-rule: #2e3641;
  --code-text: #d8dee4;
  --code-dim: #8f9aa8;
  --cyan: #59dbe1;
  --yellow: #f2d533;
  --slate: #6a829e;
  --green: #7ea685;
  --card-blue: #dae4ea;
  --card-green: #dce5dd;
  --card-red: #ecccbf;
  --card-yellow: #ece2b6;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 3px;
  --shell: 1120px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { overflow-x: clip; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--summit); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); color: var(--text-strong); font-weight: 500; line-height: 1.15; margin: 0; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.shell { width: min(var(--shell), calc(100% - 32px)); margin: 0 auto; }

/* Logo: same geometry as frontend/src/components/ui/TarkaLogo.astro */
.brand { display: inline-flex; align-items: baseline; gap: 10px; color: var(--text-strong); text-decoration: none; line-height: 1; }
.brand svg { height: 17px; width: auto; flex: none; }
.brand-name { font-family: "Sora", var(--font-display); font-weight: 800; letter-spacing: 0.1em; font-size: 1.32rem; }
.brand-product { font-family: var(--font-display); font-weight: 500; color: var(--text-soft); font-size: 1rem; letter-spacing: 0; margin-left: 2px; }

/* Ridge motif: outer edge only, never under text */
.ridge { height: 44px; overflow: hidden; border-bottom: 1px solid var(--rule); background: var(--bg); }
.ridge svg { display: block; height: 44px; width: auto; min-width: 100%; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--rule); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.topbar .shell { display: flex; align-items: center; gap: 28px; min-height: 60px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; padding: 6px 10px; border-radius: var(--radius); color: var(--text); font-weight: 500; font-size: 0.95rem; }
.nav a:hover { background: var(--bg-alt); color: var(--text-strong); }
.nav a[aria-current="page"] { color: var(--text-strong); box-shadow: inset 0 -2px 0 var(--text-strong); border-radius: 0; }
.topbar form { margin: 0; }
.link-button { background: none; border: 0; padding: 6px 4px; cursor: pointer; color: var(--text-soft); font-size: 0.92rem; }
.link-button:hover { color: var(--text-strong); }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--text-strong); background: var(--text-strong); color: #fff; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer; }
.btn:hover { background: #262c35; }
.btn.secondary { background: var(--surface); color: var(--text-strong); border-color: var(--rule-strong); }
.btn.secondary:hover { border-color: var(--text-strong); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 0.88rem; }
.btn.danger { background: var(--surface); color: #a3341a; border-color: #e7b8a9; }
.btn[disabled] { opacity: 0.5; cursor: progress; }
input[type="text"], input[type="email"], input[type="search"], input[type="time"], input[type="password"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); color: var(--text-strong);
}
textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--summit); outline-offset: 0; border-color: transparent; }
label { display: block; font-weight: 600; color: var(--text-strong); font-size: 0.92rem; margin-bottom: 6px; }
.hint { color: var(--text-soft); font-size: 0.88rem; margin-top: 4px; }
.field { margin-bottom: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Page scaffolding */
main.page { padding: 36px 0 96px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); }
.page-head p { color: var(--text-soft); max-width: 62ch; margin-top: 6px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head h2 { font-size: 1.05rem; }
.panel-body { padding: 16px 18px; }
.empty { color: var(--text-soft); font-size: 0.94rem; }
.notice { padding: 12px 16px; border-radius: var(--radius); background: var(--card-blue); color: var(--text-strong); margin-bottom: 20px; }
.notice.warn { background: var(--card-yellow); }
.notice.ok { background: var(--card-green); }

/* Home: conversation + rail */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 920px) { .home { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 520px; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px 20px 8px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 76ch; }
.msg .meta { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 3px; display: flex; gap: 10px; align-items: baseline; }
.msg .who { font-weight: 700; color: var(--text-strong); }
.msg .tag { font-size: 0.76rem; padding: 1px 6px; border-radius: 2px; background: var(--bg-alt); color: var(--text); }
.msg .body { color: var(--text-strong); overflow-wrap: anywhere; }
.msg .body p + p, .msg .body ul, .msg .body ol { margin-top: 8px; }
.msg .body ul, .msg .body ol { padding-left: 1.2em; margin-bottom: 0; }
.msg .body li + li { margin-top: 2px; }
.msg.user { align-self: flex-end; background: #eceff3; padding: 10px 14px; border-radius: var(--radius); }
.msg.user .meta { justify-content: flex-end; }
.msg.event .body { color: var(--text-soft); font-size: 0.9rem; }
.trace { margin-top: 6px; }
.trace summary { cursor: pointer; font-size: 0.78rem; color: var(--text-soft); list-style: none; }
.trace summary::-webkit-details-marker { display: none; }
.trace summary:hover { color: var(--text-strong); }
.trace dl { margin: 6px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-family: var(--font-mono); font-size: 0.76rem; color: var(--text); }
.trace dt { color: var(--text-soft); }
.trace dd { margin: 0; }
.chat-status { min-height: 26px; padding: 0 20px; font-size: 0.86rem; color: var(--text-soft); }
.chat-status.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--summit); margin-right: 8px; vertical-align: 1px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .chat-status.live::before { animation: none; } }
.composer { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--rule); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 180px; }
.approval-inline { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.rail { display: flex; flex-direction: column; gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--rule); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .title { color: var(--text-strong); font-weight: 600; }
.list .sub { color: var(--text-soft); font-size: 0.86rem; }
.approval .summary { white-space: pre-wrap; color: var(--text-strong); font-size: 0.94rem; }
.approval .actions { margin-top: 8px; display: flex; gap: 8px; }
.channel-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong); margin-right: 8px; }
.status-dot.on { background: var(--green); }

/* Tables (memory, activity) */
.table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.table th { text-align: left; font-weight: 600; color: var(--text-soft); font-size: 0.84rem; padding: 10px 12px; border-bottom: 1px solid var(--rule-strong); }
.table td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: top; color: var(--text-strong); }
.table td.soft { color: var(--text-soft); white-space: nowrap; font-size: 0.86rem; }
.table tr:last-child td { border-bottom: 0; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { max-width: 360px; }
.profile { white-space: pre-wrap; color: var(--text-strong); }

/* Under the hood: the one dark anchor */
.hood { background: var(--granite); color: var(--code-text); border-radius: var(--radius); padding: 28px; }
.hood h2 { color: #fff; font-size: 1.3rem; }
.hood p.lead { color: var(--code-dim); margin-top: 6px; max-width: 70ch; }
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 26px; border: 1px solid var(--night-rule); border-radius: var(--radius); }
.flow .step { padding: 18px; border-left: 1px solid var(--night-rule); position: relative; }
.flow .step:first-child { border-left: 0; }
.flow .step:not(:last-child)::after { content: ""; position: absolute; right: -7px; top: 26px; width: 12px; height: 12px; background: var(--granite); border-top: 1px solid var(--night-rule); border-right: 1px solid var(--night-rule); transform: rotate(45deg); z-index: 1; }
.flow .k { font-size: 0.8rem; color: var(--code-dim); }
.flow .v { font-family: var(--font-display); font-size: 1.35rem; color: #fff; margin-top: 4px; }
.flow .d { font-family: var(--font-mono); font-size: 0.76rem; color: var(--cyan); margin-top: 6px; overflow-wrap: anywhere; }
@media (max-width: 760px) { .flow { grid-template-columns: 1fr 1fr; } .flow .step:nth-child(3) { border-left: 0; } .flow .step { border-top: 1px solid var(--night-rule); } .flow .step::after { display: none; } }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { padding: 16px 18px; }
.stat .n { font-family: var(--font-display); font-size: 1.6rem; color: var(--text-strong); }
.stat .l { color: var(--text-soft); font-size: 0.86rem; }
.models { display: grid; gap: 10px; }
.model-option { font-weight: 400; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.model-option:has(input:checked) { border-color: var(--text-strong); box-shadow: inset 3px 0 0 var(--summit); }
.model-option input { margin-top: 5px; }
.model-option .name { font-weight: 700; color: var(--text-strong); }
.model-option .price { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-soft); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 72px; margin-top: 10px; }
.bars span { flex: 1; background: var(--slate); min-height: 2px; border-radius: 1px 1px 0 0; opacity: 0.85; }

/* Settings */
.settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .settings { grid-template-columns: 1fr; } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Landing */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 56px; align-items: center; padding: 64px 0 56px; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 40px; } }
.hero h1 { font-size: clamp(2.3rem, 5.2vw, 3.7rem); font-weight: 700; letter-spacing: -0.02em; }
.hero .lede { font-size: 1.15rem; margin-top: 18px; max-width: 46ch; }
.hero .ctas { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero .fine { margin-top: 14px; color: var(--text-soft); font-size: 0.9rem; }
.phone { background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 18px; padding: 18px 16px; max-width: 400px; justify-self: end; width: 100%; }
@media (max-width: 900px) { .phone { justify-self: start; } }
.phone .bar { text-align: center; font-size: 0.82rem; color: var(--text-soft); padding-bottom: 10px; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.bubble { width: fit-content; max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 0.93rem; line-height: 1.45; margin-bottom: 8px; color: var(--text-strong); }
.bubble.me { margin-left: auto; background: var(--text-strong); color: #fff; border-bottom-right-radius: 4px; }
.bubble.it { background: var(--bg-alt); border-bottom-left-radius: 4px; }
.bubble.time { background: none; padding: 2px 0 6px; text-align: center; max-width: none; font-size: 0.76rem; color: var(--text-soft); }
.points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule); }
@media (max-width: 820px) { .points { grid-template-columns: 1fr; } }
.point { padding: 28px 28px 32px 0; }
.point + .point { padding-left: 28px; border-left: 1px solid var(--rule); }
@media (max-width: 820px) { .point + .point { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); } }
.point h3 { font-size: 1.2rem; }
.point p { margin-top: 8px; }
.band { margin: 56px 0; }
.price-line { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: 28px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.price-line h2 { font-size: 1.6rem; }
footer.foot { color: var(--text-soft); font-size: 0.88rem; padding: 28px 0 48px; }

/* Login */
.auth { max-width: 440px; margin: 72px auto; }
.auth h1 { font-size: 2rem; }
.auth p { margin: 8px 0 24px; }
