:root {
  --bg: #f7f8fb; --surface: #fff; --ink: #0d1136; --ink-2: #4c526f; --muted: #7a7f99; --line: #e5e7f0;
  --brand: #4636ff; --brand-soft: #ecebff; --green: #0fa968; --red: #d92d20; --amber: #b86e00;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0d1c; --surface: #12152e; --ink: #eceeff; --ink-2: #b6bad6; --muted: #8b90b3; --line: #242850; --brand: #6f63ff; --brand-soft: #1e1f4f; --green: #35d08f; --red: #ff7a70; --amber: #f5b547; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; border-radius: 6px; }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side { display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; height: 100dvh; }
.logo img { border-radius: 8px; margin: 0 6px 14px; }
.site { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 9px 10px; margin-bottom: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-weight: 500; font-size: 14px; cursor: pointer; }
.site span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.side nav a i { font-size: 19px; }
.side nav a:hover { background: var(--bg); color: var(--ink); }
.side nav a.on { background: var(--brand-soft); color: var(--brand); }
.count { margin-left: auto; font-size: 12px; background: var(--brand); color: #fff; padding: 1px 7px; border-radius: 999px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 6px; font-size: 13px; color: var(--muted); }
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 12px; }
.credits b { color: var(--ink); }

.main { min-width: 0; }
.view { max-width: 820px; margin: 0 auto; padding: 36px 28px 28px; }
.view[hidden] { display: none; }
#v-chat { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: 20px; }
#v-chat[hidden] { display: none; }
.vh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.vh h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }

.thread { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-bottom: 20px; }
.u { align-self: flex-end; max-width: 78%; background: var(--brand-soft); padding: 11px 15px; border-radius: 14px 14px 4px 14px; }
.a { max-width: 92%; }
.a p { margin: 8px 0; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tools span { display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; background: var(--surface); }
.tools i { color: var(--green); }
.act { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.dots { display: inline-flex; gap: 4px; padding: 8px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; } }
.ask { position: sticky; bottom: 16px; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 10px 16px; box-shadow: 0 10px 30px -14px rgba(20, 20, 80, .3); }
.ask textarea { flex: 1; border: 0; background: none; resize: none; outline: none; padding: 6px 0; max-height: 160px; }
.ask textarea::placeholder { color: var(--muted); }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 9px; padding: 7px 13px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-p { background: var(--brand); color: #fff; }
.btn-p:hover { filter: brightness(1.08); }
.btn-p:disabled { background: var(--line); color: var(--muted); cursor: default; }
.btn-g { border-color: var(--line); background: var(--surface); }

.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.rows li { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows b { font-weight: 500; display: block; }
.rows small { color: var(--muted); font-size: 13px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; text-align: center; }
.tag.hi { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.tag.md { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.tag.lo { background: var(--bg); color: var(--muted); }
.tag.ok { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.done { opacity: .5; }

.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 11px 16px; background: var(--bg); }
.tbl td { padding: 13px 16px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; width: 90px; }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 14px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .logo, .site, .me { display: none; }
  .side nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .side nav a { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 4px; justify-content: center; position: relative; }
  .count { position: absolute; top: 2px; right: 22%; margin: 0; }
  .view { padding: 22px 14px 90px; }
  #v-chat { min-height: calc(100dvh - 70px); }
  .ask { bottom: 78px; }
  .rows li { grid-template-columns: 1fr auto; }
  .rows .tag { grid-column: 1 / -1; justify-self: start; }
  .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
  .tbl td:not(:first-child), .tbl th:not(:first-child) { width: 64px; }
}
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
