/* Aster web app — shell, chat, judge, voice, settings */

html, body { height: 100%; }
body.app { overflow: hidden; }
/* our component CSS sets display on things we hide via the hidden attribute */
[hidden] { display: none !important; }

.app-shell { display: flex; height: 100dvh; }

/* ── sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 292px; flex: 0 0 292px; background: var(--card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  transition: margin-left .22s ease;
}
.sidebar-header { padding: 14px 14px 10px; }
.sidebar .brand { padding: 2px 6px 12px; }
.new-btn { width: 100%; }
.search-row { padding: 4px 14px 10px; display: flex; gap: 8px; align-items: center; }
.search-input {
  flex: 1; min-width: 0; height: 36px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--fill); padding: 0 14px; font-size: 14px; outline: none;
}
.search-input:focus { border-color: var(--accent); background: #fff; }
.filter-chip {
  flex: 0 0 auto;
  height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-size: 13px; font-weight: 600; color: var(--text2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.filter-chip.on { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 10px; }
.conv-group-label { font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 10px 4px; letter-spacing: .3px; }
.conv-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.conv-item:hover { background: var(--fill); }
.conv-item.active { background: var(--accent-tint); }
.conv-item .c-title { flex: 1; font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .c-kind { color: var(--accent); flex: 0 0 auto; display: grid; place-items: center; }
.conv-item .c-pin { color: var(--muted); }
.conv-item .c-actions { display: none; gap: 2px; }
.conv-item:hover .c-actions { display: flex; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  color: var(--text2); display: grid; place-items: center; flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(29,29,31,.07); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.sidebar-footer { border-top: 1px solid var(--border); padding: 8px; display: flex; gap: 4px; }
.sidebar-footer .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600;
  color: var(--text2); cursor: pointer; border: none; background: none;
}
.sidebar-footer .nav-item:hover { background: var(--fill); }
.sidebar-footer .nav-item.active { color: var(--accent); background: var(--accent-tint); }

/* ── main column ─────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-header {
  height: 56px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: rgba(255,255,255,.86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); z-index: 5;
}
.chat-header .title { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .model-pill {
  margin-left: auto; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-size: 13px; font-weight: 600; color: var(--text2);
  display: inline-flex; align-items: center; gap: 6px; max-width: 46%;
}
.chat-header .model-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the pill is chat-only; the display rule above beats the hidden attribute without this */
.chat-header .model-pill[hidden] { display: none; }
.menu-btn { display: none; }
.drawer-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40; }

/* view panes */
.view { flex: 1; display: none; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* ── message list ────────────────────────────────────────── */
.msg-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.msg-list { max-width: 760px; margin: 0 auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: grid;
  place-items: center; font-size: 11px; font-weight: 800; margin-top: 2px;
}
.msg.user .avatar { background: var(--accent); color: #fff; }
.msg.assistant .avatar { background: var(--fill); color: var(--text2); border: 1px solid var(--border); overflow: hidden; }
.msg.assistant .avatar img { width: 100%; height: 100%; }
.bubble-wrap { min-width: 0; max-width: 82%; }
.bubble {
  padding: 11px 15px; border-radius: 16px; font-size: 15px;
  background: var(--card); border: 1px solid var(--border); overflow-wrap: break-word;
}
.msg.user .bubble { background: var(--accent); color: #fff; border-color: transparent; }
.bubble p + p { margin-top: 10px; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 8px 0; }
.bubble h1,.bubble h2,.bubble h3 { margin: 14px 0 6px; }
.bubble blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--text2); margin: 8px 0; }
.bubble table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; }
.bubble code.inline { background: var(--fill); border-radius: 6px; padding: 1.5px 6px; font-family: var(--mono); font-size: 13px; }
pre.code-block {
  background: var(--code-bg); color: #ABB2BF; border-radius: 12px; padding: 14px 16px;
  font-family: var(--mono); font-size: 13px; overflow-x: auto; margin: 10px 0; position: relative;
}
pre.code-block .copy-code {
  position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 10px; border-radius: 7px;
  background: rgba(255,255,255,.09); color: #B9BAC3; border: none; font-size: 11.5px; font-weight: 600;
}
pre.code-block .copy-code:hover { background: rgba(255,255,255,.16); }
.msg-meta { display: flex; align-items: center; gap: 4px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.msg.user .msg-meta { justify-content: flex-end; }
.msg-actions { display: none; gap: 2px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 26px; height: 26px; }
.stream-cursor::after { content: "▍"; color: var(--accent); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.error-note { color: var(--danger); font-size: 13.5px; background: var(--danger-tint); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }

/* empty state */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.empty-state .e-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-tint); display: grid; place-items: center; color: var(--accent); }
.empty-state h3 { font-size: 19px; }
.empty-state p { color: var(--text2); font-size: 14.5px; max-width: 380px; }
.quick-prompts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 560px; margin-top: 6px; }
.quick-prompts button {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-size: 13.5px; color: var(--text2);
}
.quick-prompts button:hover { border-color: var(--accent); color: var(--accent); }

/* ── composer ────────────────────────────────────────────── */
.composer-wrap { padding: 10px 20px 18px; background: linear-gradient(transparent, var(--bg) 30%); }
.composer {
  max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 24px;
  padding: 8px 8px 8px 16px; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint), var(--shadow); }
.composer textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-size: 15px; line-height: 1.5; max-height: 160px; padding: 8px 0;
}
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}
.send-btn:disabled { background: var(--fill); color: var(--muted); }
.send-btn.stop { background: var(--text); }
.composer-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ── judge view ──────────────────────────────────────────── */
.judge-panel-row {
  display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--card); flex-wrap: wrap; align-items: center;
}
.seat-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border-radius: 12px; border: 1px dashed var(--border); background: var(--fill);
  font-size: 13.5px; font-weight: 600; color: var(--text2); cursor: pointer;
}
.seat-chip.filled { border-style: solid; background: var(--card); color: var(--text); }
.seat-chip .seat-label { width: 22px; height: 22px; border-radius: 7px; background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; font-size: 11.5px; font-weight: 800; }
.seat-chip.judge-of { box-shadow: 0 0 0 2px var(--accent); }
.seat-chip .gavel { color: var(--warning); display: grid; place-items: center; }

/* stage pills */
.stage-row { display: flex; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--fill); color: var(--text2); border: 1px solid var(--border);
}
.pill .p-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.doing { background: var(--accent-tint); color: var(--accent); border-color: var(--accent); }
.pill.doing .p-dot { background: var(--accent); animation: blink 1.2s ease infinite; }
.pill.done { background: var(--success-tint); color: var(--success); border-color: transparent; }
.pill.done .p-dot { background: var(--success); }
.pill.fail { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.pill.fail .p-dot { background: var(--danger); }

.turn-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.turn-q { padding: 14px 18px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); }
details.sect { border-bottom: 1px solid var(--border); }
details.sect:last-child { border-bottom: none; }
details.sect > summary {
  list-style: none; cursor: pointer; padding: 12px 18px; display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 700; color: var(--text2);
}
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary .chev { transition: transform .15s; color: var(--muted); }
details.sect[open] > summary .chev { transform: rotate(90deg); }
details.sect > summary .s-count { margin-left: auto; font-weight: 600; color: var(--muted); font-size: 12.5px; }
.sect-body { padding: 2px 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.seat-block { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seat-block .sb-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--fill); font-size: 12.5px; font-weight: 700; }
.seat-block .sb-head .seat-label { width: 20px; height: 20px; border-radius: 6px; background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.seat-block .sb-head .model-name { color: var(--text2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-block .sb-head .lat { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.seat-block .sb-body { padding: 10px 14px; font-size: 14px; }
.consensus { background: var(--accent-tint); border: 1px solid #DADAF4; border-radius: 16px; padding: 16px 18px; }
.consensus .c-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: var(--accent); margin-bottom: 8px; }
.consensus .c-body { font-size: 15px; }
.consensus .c-body p + p { margin-top: 10px; }
.disagree-note { margin-top: 10px; font-size: 13.5px; color: var(--text2); border-left: 3px solid var(--warning); padding: 4px 0 4px 12px; }

/* ── voice view ──────────────────────────────────────────── */
.voice-view {
  background: radial-gradient(120% 90% at 50% 0%, #1E1E28 0%, #121215 55%, #0E0E11 100%);
  color: #F2F2EF; align-items: center; justify-content: center; position: relative;
}
.voice-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px; width: 100%; max-width: 560px; }
.orb-wrap { position: relative; width: 190px; height: 190px; display: grid; place-items: center; }
.orb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.orb-core {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8B8BEF, var(--accent) 55%, #3D3DA8);
  box-shadow: 0 0 60px rgba(91,91,214,.55); animation: breathe 3.2s ease-in-out infinite;
}
.orb-core.think { animation: breathe 1.1s ease-in-out infinite; filter: hue-rotate(-18deg); }
.orb-core.speak { animation: breathe .55s ease-in-out infinite; box-shadow: 0 0 90px rgba(91,91,214,.8); }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.voice-status { font-size: 14px; font-weight: 600; color: #9B9BA6; letter-spacing: .2px; min-height: 20px; text-align: center; }
.voice-caption { text-align: center; font-size: 19px; min-height: 58px; max-width: 480px; color: #EDEDF2; font-weight: 500; }
.voice-controls { display: flex; gap: 16px; align-items: center; }
.v-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid #2C2C33; background: #1B1B20;
  color: #C9C9D2; display: grid; place-items: center;
}
.v-btn:hover { background: #232329; }
.v-btn.end { background: var(--danger); border-color: var(--danger); color: #fff; }
.voice-log { width: 100%; max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.voice-log .vl { font-size: 14px; padding: 8px 12px; border-radius: 12px; max-width: 85%; }
.voice-log .vl.u { align-self: flex-end; background: rgba(91,91,214,.28); color: #D6D6F5; }
.voice-log .vl.a { align-self: flex-start; background: #1B1B20; border: 1px solid #2C2C33; color: #D8D8DE; }
.voice-note { font-size: 12.5px; color: #7C7C86; }

/* ── settings view ───────────────────────────────────────── */
.settings-scroll { flex: 1; overflow-y: auto; }
.settings-inner { max-width: 680px; margin: 0 auto; padding: 26px 20px 60px; display: flex; flex-direction: column; gap: 26px; }
.settings-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 4px 8px; font-weight: 700; }
.setting-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--card);
  border: 1px solid var(--border);
}
.setting-row:first-of-type { border-radius: 12px 12px 0 0; border-bottom: none; }
.setting-row + .setting-row { border-radius: 0; border-bottom: none; }
.setting-row.last, .setting-row:only-of-type { border-radius: 0 0 12px 12px !important; border-bottom: 1px solid var(--border) !important; }
.setting-row .s-label { flex: 1; font-size: 15px; }
.setting-row .s-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
input.field, select.field, textarea.field {
  height: 42px; border: 1px solid var(--border); border-radius: 11px; background: var(--card);
  padding: 0 13px; font-size: 14.5px; outline: none; width: 100%;
}
textarea.field { height: auto; min-height: 74px; padding: 10px 13px; font-family: var(--mono); font-size: 13px; resize: vertical; }
input.field:focus, select.field:focus, textarea.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.form-grid { display: grid; gap: 12px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 5px; display: block; }

/* toggle */
.toggle { width: 46px; height: 28px; border-radius: 999px; background: var(--fill); border: 1px solid var(--border); position: relative; transition: background .15s; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .15s; }
.toggle.on { background: var(--success); border-color: var(--success); }
.toggle.on::after { left: 20px; }

/* ── modal sheets ────────────────────────────────────────── */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-scrim.open { display: flex; }
.sheet { width: 100%; max-width: 520px; max-height: 86dvh; overflow-y: auto; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px; }
.sheet h3 { font-size: 18px; margin-bottom: 16px; }
.sheet .sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.model-pick { display: flex; flex-direction: column; gap: 4px; }
.model-pick .mp-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 14.5px; }
.model-pick .mp-row:hover { background: var(--fill); }
.model-pick .mp-row.sel { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.model-pick .mp-conn { font-size: 12px; color: var(--muted); margin-left: auto; }

/* toasts */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: #fff; border-radius: 999px; padding: 10px 18px; font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .18s ease; }
.toast.err { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* code token colors (hljs one-dark-ish) */
.hljs-keyword,.hljs-selector-tag { color: #C678DD; }
.hljs-string,.hljs-attr { color: #98C379; }
.hljs-number,.hljs-literal { color: #D19A66; }
.hljs-comment { color: #5C6370; font-style: italic; }
.hljs-function .hljs-title,.hljs-title { color: #61AFEF; }
.hljs-built_in,.hljs-type { color: #E5C07B; }
.hljs-variable,.hljs-property { color: #E06C75; }
.hljs-tag { color: #E06C75; }

/* ── responsive ──────────────────────────────────────────── */
.app-ver { text-align: center; font-size: 11px; color: var(--muted); padding: 0 0 7px; }

@media (max-width: 880px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 45; margin-left: -292px; box-shadow: var(--shadow-lg); }
  .sidebar.open { margin-left: 0; }
  .drawer-scrim.show { display: block; }
  .menu-btn { display: grid; }
  .chat-header { padding: 0 10px; }
  .chat-header .title { font-size: 15px; }
  .msg-list { padding: 16px 12px 8px; gap: 14px; }
  .bubble-wrap { max-width: 86%; }
  .avatar { width: 26px; height: 26px; border-radius: 8px; }
  .composer-wrap { padding: 6px 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .composer { border-radius: 20px; }
  .judge-panel-row { flex-wrap: nowrap; overflow-x: auto; padding: 10px 12px; }
  .seat-chip { height: 36px; padding: 0 10px; }
  .turn-q { padding: 12px 14px; font-size: 14.5px; }
  details.sect > summary { padding: 10px 14px; }
  .sect-body { padding: 2px 14px 14px; }
  .consensus { padding: 14px; }
  .voice-stage { gap: 16px; padding: 16px; }
  .orb-wrap { width: 164px; height: 164px; }
  .orb-core { width: 104px; height: 104px; }
  .voice-log { max-height: 24vh; }
  .settings-inner { padding: 18px 14px 40px; }
  .setting-row { padding: 12px; gap: 8px; }
  .modal-scrim { align-items: flex-end; padding: 0; }
  .sheet { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92dvh; padding: 20px 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .sidebar-footer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
