:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-panel: #162033;
  --border: #243049;
  --text: #e8eef9;
  --muted: #93a0b8;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --radius: 14px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59,130,246,.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(34,211,238,.10), transparent 50%),
    linear-gradient(180deg, #070b14, var(--bg));
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.25rem; border-bottom: 1px solid var(--border);
  background: rgba(11,18,32,.85); backdrop-filter: blur(10px);
  flex-shrink: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 700; letter-spacing: .02em; min-width: 0; }
.brand-text { min-width: 0; white-space: nowrap; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 24px rgba(59,130,246,.35);
  flex-shrink: 0;
}
.brand-text span { color: var(--muted); font-weight: 500; margin-left: .35rem; }
.topbar-refresh {
  width: 2.25rem; height: 2.25rem; min-height: 0; padding: 0;
  flex-shrink: 0; font-size: 1.05rem; line-height: 1;
}
.topbar-refresh:active { transform: rotate(-45deg); }
.topbar-refresh.spin { animation: topbar-spin .65s ease-in-out; }
@keyframes topbar-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.topbar-left { display: flex; align-items: center; gap: 1.25rem; min-width: 0; }
.host-metrics {
  display: flex; align-items: center; gap: .85rem;
  padding-left: 1rem; border-left: 1px solid var(--border);
}
.metric-ring {
  position: relative; width: 44px; height: 44px; flex-shrink: 0;
}
.metric-ring svg {
  width: 100%; height: 100%; transform: rotate(-90deg);
}
.metric-ring .ring-bg {
  fill: none; stroke: rgba(36,48,73,.85); stroke-width: 3.2;
}
.metric-ring .ring-fill {
  fill: none; stroke: var(--accent-2); stroke-width: 3.2;
  stroke-linecap: round; transition: stroke-dasharray .45s ease, stroke .25s ease;
}
.metric-ring[data-level="warn"] .ring-fill { stroke: #fbbf24; }
.metric-ring[data-level="high"] .ring-fill { stroke: var(--danger); }
.metric-ring .metric-val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: .58rem; font-weight: 600; color: var(--text);
  pointer-events: none;
}
.metric-ring .metric-lbl {
  position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; pointer-events: none;
}
.metric-specs {
  display: flex; align-items: stretch; gap: .65rem;
  padding: .2rem .55rem; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(13,21,36,.75);
}
.metric-spec {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 44px;
}
.metric-spec .spec-val {
  font-family: var(--mono); font-size: .78rem; font-weight: 600; line-height: 1.1; color: var(--text);
  white-space: nowrap;
}
.metric-spec .spec-lbl {
  font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.userchip { color: var(--muted); font-size: .92rem; flex-shrink: 0; }
.layout {
  flex: 1; display: grid; grid-template-columns: 360px 1fr 300px;
  min-height: 0; overflow: hidden;
}
.sidebar {
  border-right: 1px solid var(--border); background: rgba(18,26,43,.7);
  padding: 1rem; overflow: auto; min-height: 0;
}
.main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.label { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .06em; }
.select, .input, .textarea, .btn {
  width: 100%; border-radius: 10px; border: 1px solid var(--border);
  background: #0d1524; color: var(--text); font: inherit; padding: .7rem .85rem;
}
.select:focus, .input:focus, .textarea:focus { outline: 2px solid rgba(59,130,246,.45); border-color: var(--accent); }
.btn {
  cursor: pointer; background: linear-gradient(135deg, #2563eb, #0891b2);
  border: none; font-weight: 650; width: auto; padding: .7rem 1rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: #1a2438; border: 1px solid var(--border); }
.btn:disabled { opacity: .55; cursor: wait; }
.meta { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.meta code { font-family: var(--mono); color: #c7d2fe; font-size: .82rem; }
.meta-idle { color: var(--muted); }
.sidebar-accordion {
  margin-top: 1rem; padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.sidebar-accordion > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: .4rem; min-width: 0;
}
.sidebar-accordion > summary::-webkit-details-marker { display: none; }
.sidebar-accordion > summary::marker { content: ''; }
.sidebar-accordion > summary::before {
  content: '▸'; flex-shrink: 0;
  font-size: .68rem; color: var(--muted);
  transition: transform .15s ease;
}
.sidebar-accordion[open] > summary::before { transform: rotate(90deg); }
.sidebar-accordion-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); flex-shrink: 0;
}
.sidebar-accordion-body {
  margin-top: .55rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.sidebar-accordion-action {
  flex-shrink: 0; margin-left: auto; width: auto; padding: .35rem .5rem;
}
.sidebar-accordion > summary .sidebar-accordion-hint {
  flex: 1; min-width: 0;
  color: var(--muted); font-size: .72rem; line-height: 1.35;
  text-transform: none; letter-spacing: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sessions-panel-body,
.notes-panel-body {
  margin-top: .45rem;
}
.conn {
  display: flex; align-items: center; gap: .55rem;
  margin-top: .75rem; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: #0d1524; font-size: .85rem; color: var(--muted);
}
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: #64748b;
}
.conn[data-state="connecting"] .conn-dot {
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(34,211,238,.55);
  animation: pulse 1.4s ease-out infinite;
}
.conn[data-state="connecting"] { color: var(--accent-2); border-color: rgba(34,211,238,.35); }
.conn[data-state="connected"] .conn-dot { background: var(--ok); }
.conn[data-state="connected"] { color: var(--ok); border-color: rgba(52,211,153,.35); }
.conn[data-state="error"] .conn-dot { background: var(--danger); }
.conn[data-state="error"] { color: var(--danger); border-color: rgba(248,113,113,.35); }

.persona-dock {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1rem; margin-bottom: .65rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(22,32,51,.92), rgba(13,21,36,.88));
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  flex-shrink: 0;
}
.persona-avatar {
  width: 72px; height: 72px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.persona-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.persona-info { min-width: 0; flex: 1; }
.persona-name {
  font-weight: 700; font-size: 1rem; letter-spacing: .03em;
  background: linear-gradient(90deg, var(--text), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.persona-status {
  margin-top: .2rem; color: var(--muted); font-size: .88rem; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.persona-head { transform-origin: 40px 41px; }
.persona-eye { transform-origin: center; }
.persona-mouth { transform-origin: 40px 50px; }
.persona-ring { transform-origin: 40px 40px; }
.persona-antenna-tip { transform-origin: 40px 10px; }

.persona-dock[data-state="idle"] .persona-head {
  animation: persona-float 4s ease-in-out infinite;
}
.persona-dock[data-state="idle"] .persona-eye-l,
.persona-dock[data-state="idle"] .persona-eye-r,
.persona-dock[data-state="ready"] .persona-eye-l,
.persona-dock[data-state="ready"] .persona-eye-r {
  animation: persona-blink 4.5s ease-in-out infinite;
}
.persona-dock[data-state="ready"] .persona-antenna-tip {
  animation: persona-pulse-tip 2.4s ease-in-out infinite;
}

.persona-dock[data-state="connecting"] .persona-ring {
  animation: persona-spin 1.4s linear infinite;
  opacity: .75;
}
.persona-dock[data-state="connecting"] .persona-antenna-tip {
  animation: persona-pulse-tip .9s ease-in-out infinite;
}

.persona-dock[data-state="listening"] {
  border-color: rgba(248,113,113,.45);
  box-shadow: 0 0 0 1px rgba(248,113,113,.18), 0 10px 28px rgba(0,0,0,.22);
}
.persona-dock[data-state="listening"] .persona-ring {
  stroke: #f87171; opacity: .65;
  animation: persona-pulse-ring 1.1s ease-in-out infinite;
}
.persona-dock[data-state="listening"] .persona-eye-l,
.persona-dock[data-state="listening"] .persona-eye-r {
  fill: #fca5a5;
  animation: persona-listen-eyes 1.2s ease-in-out infinite;
}
.persona-dock[data-state="listening"] .persona-mouth {
  animation: persona-listen-mouth .55s ease-in-out infinite alternate;
}

.persona-dock[data-state="thinking"] .persona-eye-l { transform: translate(-1px, -2px); }
.persona-dock[data-state="thinking"] .persona-eye-r { transform: translate(1px, -2px); }
.persona-dock[data-state="thinking"] .persona-mouth {
  transform: scale(.72, 1);
  animation: persona-think-mouth 1.1s ease-in-out infinite;
}
.persona-dock[data-state="thinking"] .persona-ring {
  animation: persona-spin 2.8s linear infinite;
  opacity: .55;
}

.persona-dock[data-state="speaking"] .persona-mouth {
  animation: persona-speak 280ms ease-in-out infinite alternate;
}
.persona-dock[data-state="speaking"] .persona-head {
  animation: persona-nod 900ms ease-in-out infinite;
}

.persona-dock[data-state="error"] {
  border-color: rgba(248,113,113,.4);
}
.persona-dock[data-state="error"] .persona-ring { stroke: var(--danger); opacity: .7; }
.persona-dock[data-state="error"] .persona-eye-l,
.persona-dock[data-state="error"] .persona-eye-r { fill: var(--danger); }
.persona-dock[data-state="error"] .persona-mouth {
  fill: var(--danger);
  transform: scale(.85, .45);
}

@keyframes persona-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes persona-blink {
  0%, 44%, 48%, 100% { transform: scaleY(1); }
  46% { transform: scaleY(.12); }
}
@keyframes persona-pulse-tip {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: .75; }
}
@keyframes persona-spin {
  to { transform: rotate(360deg); }
}
@keyframes persona-pulse-ring {
  0%, 100% { opacity: .45; }
  50% { opacity: .85; }
}
@keyframes persona-listen-eyes {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes persona-listen-mouth {
  from { transform: scale(1, 1); }
  to { transform: scale(1.15, 1.8); }
}
@keyframes persona-think-mouth {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
@keyframes persona-speak {
  from { transform: scale(1, 1); }
  to { transform: scale(1.2, 2.4); }
}
@keyframes persona-nod {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(2deg); }
}

.chat {
  flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  padding: 1rem 1.25rem 1.25rem;
}
.messages {
  flex: 1; overflow: auto; display: flex; flex-direction: column; gap: .85rem;
  padding: .25rem .15rem 1rem; min-height: 0;
}
.bubble {
  max-width: 900px; padding: .9rem 1rem; border-radius: 12px; border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: .95rem;
}
.bubble.user { align-self: flex-end; background: #1a2740; border-color: #2d3f63; }
.bubble.assistant { align-self: flex-start; background: #101827; }
.bubble .who { display: block; color: var(--muted); font-size: .72rem; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .08em; }
.chat-emphasis {
  font-weight: 700;
  color: #facc15;
}
.chat-heading {
  font-size: inherit;
  font-weight: 700;
  margin: .55rem 0 .15rem;
  line-height: inherit;
  color: var(--text);
}
.chat-code {
  display: block;
  width: 80%;
  max-width: 80%;
  margin: .45rem 0;
  padding: .4rem .55rem;
  border: 1px solid rgba(147, 160, 184, .28);
  border-radius: 6px;
  background: rgba(10, 16, 28, .55);
  font-family: var(--mono);
  font-size: .76rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  color: #c7d2fe;
}
.bubble .chat-link {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bubble .chat-link:hover { color: #67e8f9; }
.composer {
  display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: stretch;
  border-top: 1px solid var(--border); padding-top: 1rem;
  flex-shrink: 0; background: transparent;
}
.composer.drag {
  outline: 2px dashed rgba(59,130,246,.55);
  outline-offset: 4px;
  border-radius: 10px;
}
.composer-main { display: flex; flex-direction: column; gap: .5rem; min-width: 0; min-height: 0; }
.second-opinion-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .85rem 1.1rem;
}
.second-opinion-toggle {
  display: flex; align-items: center; gap: .45rem;
  font-size: .78rem; color: var(--muted); cursor: pointer; user-select: none;
}
.second-opinion-toggle.disabled { opacity: .55; cursor: not-allowed; }
.second-opinion-toggle input { accent-color: #ea580c; }
.second-opinion-toggle:has(#secondOpinionOpus) input { accent-color: #8b5cf6; }
.second-opinion-model.grok-model { color: #fb923c; }
.second-opinion-model.opus-model { color: #c4b5fd; }
.grok-review {
  margin: .55rem 0 .75rem; padding: .55rem .7rem;
  border: 1px solid rgba(234, 88, 12, .35); border-radius: 8px;
  background: rgba(234, 88, 12, .08);
}
.opus-review {
  margin: .55rem 0 .75rem; padding: .55rem .7rem;
  border: 1px solid rgba(139, 92, 246, .35); border-radius: 8px;
  background: rgba(139, 92, 246, .08);
}
.grok-review summary {
  cursor: pointer; font-size: .78rem; font-weight: 600;
  color: #fdba74; list-style: none;
}
.opus-review summary {
  cursor: pointer; font-size: .78rem; font-weight: 600;
  color: #ddd6fe; list-style: none;
}
.grok-review summary::-webkit-details-marker,
.opus-review summary::-webkit-details-marker { display: none; }
.grok-review summary::before,
.opus-review summary::before { content: '▸ '; }
.grok-review[open] summary::before,
.opus-review[open] summary::before { content: '▾ '; }
.grok-review-body {
  margin-top: .55rem; font-size: .86rem; line-height: 1.5; color: #fed7aa;
}
.opus-review-body {
  margin-top: .55rem; font-size: .86rem; line-height: 1.5; color: #ede9fe;
}
.grok-review-err,
.opus-review-err {
  font-size: .82rem; color: #fca5a5; border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .08); padding: .45rem .6rem; border-radius: 8px;
}
.reviews-live .grok-review,
.reviews-live .opus-review { margin-top: .45rem; }
.composer-actions {
  display: flex; flex-direction: column; gap: .5rem;
  justify-content: stretch;
}
.composer-actions .btn { flex: 1 1 0; min-height: 2.75rem; }
.btn-mic { font-size: 1.15rem; line-height: 1; }
.btn-mic.listening {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  border-color: #f87171;
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .03em;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}
.composer-main .textarea {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  height: 100%;
}
.textarea { min-height: 88px; max-height: 160px; resize: vertical; }
.attach-btn { cursor: pointer; text-align: center; white-space: nowrap; }
.attach-btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.attach-row {
  display: flex; flex-wrap: wrap; gap: .5rem;
}
.attach-chip {
  position: relative; width: 72px; height: 72px; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--border); background: #0d1524;
}
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip.file {
  width: auto; min-width: 88px; max-width: 160px; height: 72px;
  padding: .45rem .55rem 1.4rem; display: flex; flex-direction: column; gap: .2rem;
}
.attach-chip .attach-ext {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: #93c5fd;
}
.attach-chip .attach-name {
  font-size: .72rem; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.attach-chip button {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
  border: 0; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff;
  cursor: pointer; line-height: 1; font-size: 14px;
}
.bubble-imgs {
  display: flex; flex-wrap: wrap; gap: .45rem; margin: .15rem 0 .55rem;
}
.bubble-files {
  display: flex; flex-wrap: wrap; gap: .4rem; margin: .15rem 0 .55rem;
}
.bubble-file {
  display: inline-block; padding: .2rem .5rem; border-radius: 6px;
  border: 1px solid var(--border); background: #0a101c;
  font-size: .78rem; color: #93c5fd;
}
.bubble-imgs img {
  max-width: min(280px, 100%); max-height: 180px; border-radius: 8px;
  border: 1px solid var(--border); object-fit: contain; background: #0a101c;
}
.bubble.thinking {
  border-color: rgba(59,130,246,.45);
  background: linear-gradient(180deg, #121c30, #101827);
}
.think-status {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  color: var(--accent-2); font-weight: 500; margin-bottom: .45rem;
}
.think-cancel { margin-left: auto; color: var(--text); }
.think-stop { margin-left: auto; background: #7f1d1d; border: 1px solid #991b1b; color: #fecaca; }
.think-stop:hover { filter: brightness(1.12); }
.think-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(34,211,238,.55);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,211,238,.55); }
  70% { box-shadow: 0 0 0 10px rgba(34,211,238,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
}
.think-tools {
  display: flex; flex-direction: column; gap: .25rem;
  margin: .25rem 0 .4rem; font-family: var(--mono); font-size: .78rem; color: var(--muted);
}
.think-tool[data-status="completed"] { color: var(--ok); }
.think-tool[data-status="error"] { color: var(--danger); }
.think-body {
  margin: .35rem 0 0; padding: .55rem .65rem; max-height: 160px; overflow: auto;
  border-radius: 8px; border: 1px solid var(--border); background: #0a101c;
  color: var(--muted); font-family: var(--mono); font-size: .78rem; white-space: pre-wrap;
  line-height: 1.4;
}
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card { width: min(420px, 100%); padding: 1.6rem; }
.login-card h1 { margin: 0 0 .35rem; font-size: 1.45rem; }
.login-card p { margin: 0 0 1.25rem; color: var(--muted); }
.field { margin-bottom: .9rem; }
.err { color: var(--danger); margin: .75rem 0; font-size: .92rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .75rem; }

.tenant-server-badge {
  padding: .75rem .85rem;
  margin-bottom: .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(18, 26, 43, .85);
}
.tenant-server-badge .label { margin-bottom: .25rem; }
.tenant-server-name {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
}
.tenant-server-badge .hint { margin-top: .35rem; margin-bottom: 0; }

.fileside {
  border-left: 1px solid var(--border); background: rgba(18,26,43,.7);
  padding: .85rem; display: flex; flex-direction: column; gap: .65rem;
  min-height: 0; overflow: hidden;
}
.filehead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
  flex-shrink: 0;
}
.filehead-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.filepath {
  font-family: var(--mono); font-size: .72rem; color: #c7d2fe;
  word-break: break-all; line-height: 1.35; margin-top: .15rem;
}
.btn-sm { padding: .35rem .55rem; font-size: .85rem; }
.filedrop {
  border: 1px dashed var(--border); border-radius: 10px; padding: .65rem;
  background: #0d1524; text-align: center; transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
.filedrop.drag {
  border-color: rgba(59,130,246,.7);
  background: rgba(59,130,246,.08);
}
.filedrop-hint { color: var(--muted); font-size: .78rem; margin-bottom: .45rem; }
.filelist {
  flex: 1 1 auto; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border); border-radius: 10px;
  background: #0d1524; min-height: 0;
}
.fileempty, .fileerr {
  padding: .85rem; color: var(--muted); font-size: .85rem;
}
.fileerr { color: var(--danger); }
.filerow {
  display: grid; grid-template-columns: 18px 1fr auto auto; gap: .45rem; align-items: center;
  padding: .4rem .55rem; border-bottom: 1px solid rgba(36,48,73,.65);
  font-size: .82rem; cursor: default;
}
.filerow:last-child { border-bottom: none; }
.filerow.dir { cursor: pointer; }
.filerow.dir:hover { background: rgba(59,130,246,.1); }
.filerow .ico { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.filerow.dir .ico { color: var(--accent-2); }
.filerow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .meta { color: var(--muted); font-family: var(--mono); font-size: .68rem; }
.file-btns {
  display: flex; gap: .15rem; flex-shrink: 0; opacity: .55;
}
.filerow:hover .file-btns { opacity: 1; }
.file-act {
  border: 0; background: transparent; color: var(--muted);
  width: 1.35rem; height: 1.35rem; border-radius: 6px; cursor: pointer;
  font-size: .78rem; line-height: 1; padding: 0;
}
.file-act:hover { background: rgba(59,130,246,.15); color: var(--text); }
.file-act.file-del:hover { background: rgba(239,68,68,.15); color: var(--danger); }
.filestatus {
  color: var(--muted); font-size: .75rem; min-height: 1.1em; flex-shrink: 0;
}
.filestatus.ok { color: var(--ok); }
.filestatus.err { color: var(--danger); }

.login-audit-list {
  display: flex; flex-direction: column; gap: .35rem;
  margin-top: .45rem;
  max-height: 180px; overflow-y: auto;
}
.login-audit-row {
  display: grid; grid-template-columns: 5.2rem 1fr auto; gap: .35rem .5rem;
  font-size: .78rem; line-height: 1.35; padding: .25rem 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.login-audit-when { color: var(--muted); white-space: nowrap; }
.login-audit-main { min-width: 0; word-break: break-word; }
.login-audit-type {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); align-self: start;
}
.login-audit-type.success { color: var(--ok); }
.login-audit-type.failed { color: var(--danger); }
.login-audit-type.logout { color: var(--muted); }
.sessions-search {
  font-size: .82rem; padding: .45rem .6rem;
}
.sessions-list {
  display: flex; flex-direction: column; gap: .35rem;
  max-height: 200px; overflow-y: auto; overflow-x: hidden;
}
.sessions-list > .noterow { flex-shrink: 0; }
.sessions-empty {
  color: var(--muted); font-size: .82rem; line-height: 1.4; padding: .2rem 0;
}
.sessions-empty.sessions-err { color: var(--danger); }
.session-chat { min-width: 0; }
.session-chat.active {
  border-color: rgba(59,130,246,.55); background: rgba(59,130,246,.14);
}

.notes-list {
  display: flex; flex-direction: column; gap: .35rem;
  max-height: 220px; overflow-y: auto;
}
.notes-list > .noterow { flex-shrink: 0; }
.notes-empty {
  color: var(--muted); font-size: .82rem; line-height: 1.4; padding: .2rem 0;
}
.notes-empty.notes-err { color: var(--danger); }
.noterow {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem; align-items: stretch;
  border: 1px solid var(--border); border-radius: 10px; background: #0d1524;
  overflow: hidden;
}
.note-use {
  display: flex; flex-direction: column; gap: .15rem; align-items: flex-start;
  padding: .45rem .55rem; border: 0; background: transparent; color: var(--text);
  cursor: pointer; text-align: left; font: inherit; min-width: 0;
}
.note-use:hover { background: rgba(59,130,246,.1); }
.note-title {
  font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.note-preview {
  font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.note-btns {
  display: flex; flex-direction: column; border-left: 1px solid var(--border);
}
.note-btns button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: .85rem; padding: 0 .45rem; min-width: 28px;
}
.note-btns button:hover { background: rgba(59,130,246,.12); color: var(--text); }
.note-btns .note-del:hover { color: var(--danger); }
.notes-editor {
  display: flex; flex-direction: column; gap: .45rem;
  padding: .55rem; border: 1px solid var(--border); border-radius: 10px; background: #0d1524;
}
.notes-title { font-size: .88rem; padding: .5rem .65rem; }
.notes-body { min-height: 72px; max-height: 140px; font-size: .88rem; resize: vertical; }
.notes-actions { display: flex; justify-content: flex-end; gap: .4rem; }

.polish-english-btn {
  white-space: nowrap; flex-shrink: 0;
  font-size: .78rem; padding: .35rem .65rem;
}
.polish-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(2, 6, 23, .78); backdrop-filter: blur(4px);
}
.polish-backdrop[hidden] { display: none !important; }
.polish-modal {
  width: min(640px, 100%); max-height: min(92vh, 900px); overflow: auto;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.polish-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem .35rem; border-bottom: 1px solid var(--border);
}
.polish-modal-head h2 {
  margin: 0; font-size: 1.15rem; font-weight: 650;
}
.polish-close {
  width: 2rem; height: 2rem; min-height: 0; padding: 0;
  font-size: 1.35rem; line-height: 1;
}
.polish-modal-body { padding: 1rem 1.15rem 1.15rem; }
.polish-input-row {
  display: flex; gap: .55rem; align-items: stretch;
}
.polish-input { flex: 1; min-height: 8rem; resize: vertical; }
.polish-mic { flex-shrink: 0; align-self: flex-start; width: auto; }
.polish-controls {
  display: flex; align-items: flex-end; gap: .75rem; margin-top: .85rem;
}
.polish-style-wrap { flex: 1; min-width: 0; }
.polish-style { width: 100%; }
.polish-submit { flex-shrink: 0; min-width: 6.5rem; }
.polish-status {
  margin-top: .75rem; font-size: .88rem; color: var(--muted);
}
.polish-status[data-state="error"] { color: var(--danger); }
.polish-result { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.polish-output { min-height: 8rem; resize: vertical; }
.polish-result-actions {
  display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 320px 1fr 260px; }
}
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .layout { grid-template-columns: 1fr; overflow: visible; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
  .persona-dock { margin-bottom: .5rem; padding: .75rem .85rem; }
  .persona-avatar { width: 60px; height: 60px; }
  .chat { min-height: 60vh; }
  .messages { min-height: 220px; }
  .fileside {
    border-left: none; border-top: 1px solid var(--border);
    height: 420px; max-height: 420px;
  }
}
