/* ==========================================================================
   OMNIVOX — design tokens
   A starship-computer HUD: deep navy void, cyan "source" channel, warm
   coral "target" channel, LCARS-adjacent corner brackets, wireframe globe
   core. Subtly Trek/Wars-coded without copying either directly.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;600;700;800&family=Rajdhani:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root{
  --void:        #050a12;
  --void-2:      #081420;
  --panel:       #0b1928;
  --panel-2:     #0f2133;
  --line:        #1c3a52;
  --line-bright: #2c5a78;
  --ink:         #e8f4fb;
  --ink-dim:     #8fb3c9;
  --ink-faint:   #4d6b80;

  --core:        #3ecbf5;   /* source / FROM channel */
  --core-dim:    #145a73;
  --core-glow:   rgba(62,203,245,.35);

  --target:      #ff6a4d;   /* target / TO channel */
  --target-dim:  #7a2a20;
  --target-glow: rgba(255,106,77,.32);

  --canon:       #3ddc84;   /* canonical — green */
  --canon-dim:   #1f6b45;
  --expand:      #ffca4b;   /* expanded — gold */
  --expand-dim:  #8a6d1f;
  --low:         #b18cff;   /* low confidence — violet */
  --low-dim:     #5e4c8f;
  --danger:      #ff5b5b;

  --font-display: 'Orbitron', sans-serif;
  --font-body:    'Rajdhani', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --ease: cubic-bezier(.16,.84,.44,1);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #0e2338 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 100%, #1a1030 0%, transparent 55%),
    var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

button{ font-family: inherit; }
:focus-visible{ outline: 2px solid var(--core); outline-offset: 2px; }
::selection{ background: var(--core-dim); color: #fff; }
a{ color: var(--core); }

h1,h2,h3{ font-family: var(--font-display); font-weight: 600; letter-spacing: .02em; }

/* faint starfield + grid + scanline backdrop */
.starfield{
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(233,244,251,.5), transparent),
    radial-gradient(1px 1px at 78% 14%, rgba(233,244,251,.35), transparent),
    radial-gradient(1.5px 1.5px at 34% 68%, rgba(233,244,251,.4), transparent),
    radial-gradient(1px 1px at 88% 76%, rgba(233,244,251,.3), transparent),
    radial-gradient(1px 1px at 55% 88%, rgba(233,244,251,.3), transparent),
    radial-gradient(1.5px 1.5px at 6% 82%, rgba(233,244,251,.3), transparent);
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: .55;
}
.gridlines{
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(62,203,245,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62,203,245,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent 75%);
}
.scanlines{
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.015) 0px, rgba(255,255,255,.015) 1px, transparent 2px, transparent 4px);
  opacity: .4;
  mix-blend-mode: overlay;
}

/* generic HUD corner-bracket frame */
.hud-frame{ position: relative; }
.hud-frame::before, .hud-frame::after{
  content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none; opacity: .85;
}
.hud-frame::before{ top: -1px; left: -1px; border-top: 2px solid var(--core); border-left: 2px solid var(--core); border-radius: 8px 0 0 0; }
.hud-frame::after{ bottom: -1px; right: -1px; border-bottom: 2px solid var(--core); border-right: 2px solid var(--core); border-radius: 0 0 8px 0; }

/* ==========================================================================
   App shell
   ========================================================================== */

#app{
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 92px;
  position: relative;
}

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.brand{ display: flex; align-items: center; gap: 10px; }
.brand-icon{ width: 34px; height: 34px; flex-shrink: 0; }
.brand-icon svg{ width: 100%; height: 100%; display: block; }
.brand-text{ display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .12em;
  background: linear-gradient(120deg, var(--ink) 30%, var(--core) 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub{
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-faint);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: 2px;
}
.brand-tag{
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--core-dim);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 1px;
}
.topbar-center{
  display: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .3em;
  color: var(--ink-faint);
  text-transform: uppercase;
  text-align: center;
}
.status-chip{
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}
.status-chip.online{ color: var(--canon); border-color: var(--canon-dim); box-shadow: 0 0 12px rgba(61,220,132,.15); }

.view{
  flex: 1;
  display: none;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 4px 16px 0;
  animation: view-in .35s var(--ease);
}
.view.active{ display: block; }
@keyframes view-in{ from{ opacity: 0; transform: translateY(6px); } to{ opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Translate view — 3 column dashboard grid (collapses to 1 col on mobile)
   ========================================================================== */

.dash-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 1040px){
  .dash-grid{ grid-template-columns: 260px minmax(0,1fr) 280px; align-items: start; }
}

.rail{ display: flex; flex-direction: column; gap: 14px; }
.rail-order-2{ order: 2; }
@media (min-width: 1040px){ .rail-order-2{ order: initial; } }

.panel{
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.panel-title{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 6px;
}
.panel-title::before{ content: '◆'; font-size: 7px; color: var(--core); }

/* mode cards */
.mode-card{
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
  background: var(--void-2);
}
.mode-card:last-child{ margin-bottom: 0; }
.mode-card:hover{ border-color: var(--line-bright); }
.mode-card.active{
  border-color: var(--core);
  background: linear-gradient(120deg, rgba(62,203,245,.1), rgba(62,203,245,.02));
  box-shadow: 0 0 16px rgba(62,203,245,.12);
}
.mode-card .m-icon{
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  color: var(--ink-dim);
  border: 1px solid var(--line);
}
.mode-card.active .m-icon{ color: var(--core); border-color: var(--core-dim); }
.mode-card .m-icon svg{ width: 17px; height: 17px; }
.mode-card .m-label{ font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.mode-card .m-desc{ font-size: 11.5px; color: var(--ink-faint); line-height: 1.2; margin-top: 1px; }

/* roleplay role/style */
.role-select{
  width: 100%;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  padding: 11px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}
.trait-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trait-list li{
  font-size: 12.5px; color: var(--ink-dim);
  display: flex; align-items: center; gap: 8px;
}
.trait-list li::before{ content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--target); flex-shrink: 0; }

/* voice profile icon buttons */
.voice-grid{ display: flex; gap: 8px; margin-bottom: 12px; }
.voice-opt{
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--void-2);
  color: var(--ink-faint);
  cursor: pointer;
  transition: all .2s var(--ease);
}
.voice-opt svg{ width: 20px; height: 20px; }
.voice-opt span{ font-size: 11px; font-weight: 600; }
.voice-opt.active{ border-color: var(--target); color: var(--target); background: rgba(255,106,77,.08); box-shadow: 0 0 12px rgba(255,106,77,.15); }

.field-select{
  width: 100%;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
}

/* speed slider */
.slider-row{ display: flex; flex-direction: column; gap: 8px; }
input[type=range]{
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--line); border-radius: 3px; outline: none;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--core); border: 2px solid var(--void); box-shadow: 0 0 10px var(--core-glow);
  cursor: pointer; margin-top: -6px;
}
input[type=range]::-moz-range-thumb{
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--core); border: 2px solid var(--void); box-shadow: 0 0 10px var(--core-glow);
  cursor: pointer;
}
.slider-labels{ display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }

.rail-settings-btn{
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--void-2);
  color: var(--ink-dim);
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.rail-settings-btn:hover{ border-color: var(--core); color: var(--core); }
.rail-settings-btn svg{ width: 16px; height: 16px; }

/* ==========================================================================
   Center stage
   ========================================================================== */

.stage{ display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.lang-bar{
  display: flex; align-items: center; gap: 10px;
}
.lang-slot{
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  cursor: pointer;
  transition: border-color .2s var(--ease);
  min-width: 0;
}
.lang-slot:hover{ border-color: var(--line-bright); }
.lang-slot.from{ border-left: 3px solid var(--core); }
.lang-slot.to{ border-left: 3px solid var(--target); }
.lang-slot .l-icon{
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  background: var(--void-2); border: 1px solid var(--line);
}
.lang-slot.from .l-icon{ color: var(--core); }
.lang-slot.to .l-icon{ color: var(--target); }
.lang-slot .l-text{ min-width: 0; }
.lang-slot .eyebrow{
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .12em;
  color: var(--ink-faint); text-transform: uppercase; display: block;
}
.lang-slot .lang-name{ font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-slot .lang-sub{ font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.swap-btn{
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--void-2);
  color: var(--core);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .3s var(--ease), border-color .2s var(--ease);
}
.swap-btn:hover{ border-color: var(--core); transform: rotate(180deg); }
.swap-btn svg{ width: 17px; height: 17px; }

/* ---- core visualization ---- */
.core-panel{
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 70% 70% at 50% 40%, rgba(62,203,245,.06), transparent 70%),
    linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 10px 10px 18px;
  overflow: hidden;
}
.core-eyebrow{
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .25em;
  color: var(--ink-faint);
  text-transform: uppercase;
  padding: 10px 0 2px;
}

.core-stage{
  position: relative;
  width: 100%;
  height: 240px;
  display: flex; align-items: center; justify-content: center;
}
@media (min-width: 640px){ .core-stage{ height: 300px; } }

.core-ring{ position: absolute; border-radius: 50%; border: 1px solid var(--line); }
.core-ring.r1{ width: 150px; height: 150px; animation: spin 26s linear infinite; border-color: rgba(62,203,245,.28); border-style: dashed; }
.core-ring.r2{ width: 200px; height: 200px; animation: spin 40s linear infinite reverse; border-color: rgba(255,106,77,.18); }
.core-ring.r3{ width: 244px; height: 244px; animation: spin 60s linear infinite; border-color: rgba(177,140,255,.14); border-style: dotted; }
@media (min-width: 640px){
  .core-ring.r1{ width: 190px; height: 190px; }
  .core-ring.r2{ width: 250px; height: 250px; }
  .core-ring.r3{ width: 304px; height: 304px; }
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.core-ticks span{
  position: absolute; color: var(--core); font-size: 8px; opacity: .7;
}

/* wireframe globe */
.core-globe{
  position: relative;
  width: 96px; height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #123246, #050d16 75%);
  border: 1px solid rgba(62,203,245,.5);
  box-shadow: 0 0 30px 6px var(--core-glow), inset 0 0 20px rgba(62,203,245,.15);
  transition: box-shadow .25s var(--ease);
}
@media (min-width: 640px){ .core-globe{ width: 116px; height: 116px; } }
.core-globe .meridian{
  position: absolute; inset: 6%;
  border: 1px solid rgba(62,203,245,.35);
  border-radius: 50%;
}
.core-globe .meridian.m1{ transform: scaleX(.35); }
.core-globe .meridian.m2{ transform: scaleX(.35) rotate(60deg); }
.core-globe .meridian.m3{ transform: scaleX(.35) rotate(120deg); }
.core-globe .lat{
  position: absolute; left: 6%; right: 6%;
  border-top: 1px solid rgba(62,203,245,.25);
}
.core-globe .lat.l1{ top: 30%; }
.core-globe .lat.l2{ top: 50%; border-top-color: rgba(62,203,245,.35); }
.core-globe .lat.l3{ top: 70%; }

.mic-btn{
  position: absolute;
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 1px solid var(--core);
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #163f52, #050d16);
  color: var(--core);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s var(--ease), box-shadow .25s var(--ease);
  box-shadow: 0 0 22px rgba(62,203,245,.3);
}
@media (min-width: 640px){ .mic-btn{ width: 76px; height: 76px; } }
.mic-btn svg{ width: 26px; height: 26px; }
.mic-btn:hover{ transform: scale(1.04); }
.mic-btn:active{ transform: scale(.96); }
.mic-btn.recording{
  border-color: var(--danger); color: var(--danger);
  background: radial-gradient(circle at 35% 30%, #401515, #0d0505);
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse{
  0%, 100%{ box-shadow: 0 0 0 0 rgba(255,91,91,.4); }
  50%{ box-shadow: 0 0 0 16px rgba(255,91,91,0); }
}
.core-stage.thinking .core-globe{
  box-shadow: 0 0 40px 8px var(--target-glow), inset 0 0 24px rgba(255,106,77,.2);
  animation: think 1.3s ease-in-out infinite;
}
@keyframes think{ 0%,100%{ transform: scale(1); } 50%{ transform: scale(.95) rotate(4deg); } }

.core-glyphs{ position: absolute; inset: 0; pointer-events: none; animation: spin 90s linear infinite; }
.core-glyphs span{
  position: absolute; font-family: var(--font-mono); font-size: 10px;
  color: rgba(143,179,201,.55);
  transform: translate(-50%, -50%);
}

.mic-hint{
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .15em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-top: 2px;
}

.waveform{
  display: flex; align-items: center; justify-content: center; gap: 3px;
  height: 26px; margin: 8px 0 2px;
}
.waveform span{ width: 3px; border-radius: 2px; background: var(--core-dim); height: 5px; transition: height .12s ease, background .2s ease; }
.waveform.active span{ background: var(--core); animation: wave .9s ease-in-out infinite; }
.waveform span:nth-child(1){ animation-delay: -0.6s; } .waveform span:nth-child(2){ animation-delay: -0.3s; }
.waveform span:nth-child(3){ animation-delay: 0s; } .waveform span:nth-child(4){ animation-delay: -0.45s; }
.waveform span:nth-child(5){ animation-delay: -0.15s; } .waveform span:nth-child(6){ animation-delay: -0.5s; }
.waveform span:nth-child(7){ animation-delay: -0.2s; }
@keyframes wave{ 0%,100%{ height: 5px; } 50%{ height: 24px; } }

/* text alt input */
.text-alt{ display: flex; gap: 8px; align-items: flex-end; padding: 0 4px; }
.text-alt textarea{
  flex: 1; resize: none;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 12px 14px;
  min-height: 46px; max-height: 120px;
  transition: border-color .2s var(--ease);
}
.text-alt textarea:focus{ border-color: var(--core); }
.send-btn{
  width: 46px; height: 46px; border-radius: var(--radius-md); flex-shrink: 0;
  border: 1px solid var(--core-dim);
  background: rgba(62,203,245,.1);
  color: var(--core);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s var(--ease);
}
.send-btn:hover{ background: rgba(62,203,245,.2); }
.send-btn:disabled{ opacity: .4; cursor: not-allowed; }
.send-btn svg{ width: 18px; height: 18px; }

/* ---- original / translation panels ---- */
.exchange-panel{
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--panel);
}
.exchange-panel.original{ border-left: 3px solid var(--core); }
.exchange-panel.translation{ border-left: 3px solid var(--target); background: linear-gradient(120deg, rgba(255,106,77,.06), transparent 60%), var(--panel); }
.exchange-head{
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.exchange-label{
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.exchange-panel.translation .exchange-label{ color: var(--target); }
.speak-icon{
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--void-2);
  color: var(--ink-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.speak-icon:hover{ border-color: var(--core); color: var(--core); }
.speak-icon svg{ width: 14px; height: 14px; }
.exchange-body{ font-size: 16px; line-height: 1.4; }
.exchange-panel.translation .exchange-body{ font-family: var(--font-display); font-weight: 600; font-size: 19px; color: var(--target); }

.meta-row{
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-dim);
}
.badge{
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .05em;
  text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid transparent;
}
.badge.canonical{ background: rgba(61,220,132,.12); color: var(--canon); border-color: var(--canon-dim); }
.badge.expanded{ background: rgba(255,202,75,.12); color: var(--expand); border-color: var(--expand-dim); box-shadow: 0 0 10px rgba(255,202,75,.2); }
.badge.low_confidence{ background: rgba(177,140,255,.14); color: var(--low); border-color: var(--low-dim); }
.meta-sep{ color: var(--ink-faint); }
.meta-pron{ font-family: var(--font-mono); }

/* notes accordion */
.notes-accordion{ border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); overflow: hidden; }
.notes-toggle{
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; color: var(--ink-dim);
  padding: 13px 16px; cursor: pointer;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
}
.notes-toggle svg{ width: 15px; height: 15px; transition: transform .25s var(--ease); }
.notes-toggle.open svg{ transform: rotate(180deg); }
.notes-body{ max-height: 0; overflow: hidden; transition: max-height .3s var(--ease); }
.notes-body.open{ max-height: 600px; }
.notes-inner{ padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.notes-section .label{ font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.notes-section p{ margin: 0; font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.expanded-term{
  border: 1px solid var(--expand-dim); border-radius: var(--radius-sm);
  padding: 9px 11px; background: rgba(255,202,75,.05);
  box-shadow: 0 0 12px rgba(255,202,75,.08);
}
.expanded-term .term{ font-family: var(--font-mono); color: var(--expand); font-size: 12.5px; }
.expanded-term .note{ font-size: 11.5px; color: var(--ink-dim); margin-top: 2px; }

.empty-state{
  text-align: center; color: var(--ink-faint); font-size: 13px; padding: 30px 10px;
}
.empty-state .glyph-big{ font-family: var(--font-mono); font-size: 26px; color: var(--ink-faint); opacity: .5; margin-bottom: 8px; }

/* ==========================================================================
   Right rail — status / insights / recent
   ========================================================================== */

.status-orb-wrap{ display: flex; align-items: center; justify-content: center; padding: 6px 0 10px; }
.status-orb{ position: relative; width: 110px; height: 110px; }
.status-orb svg{ width: 100%; height: 100%; }
.status-core-dot{
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #cdeeff, var(--core) 60%);
  box-shadow: 0 0 18px 5px var(--core-glow);
}
.status-label{ text-align: center; }
.status-label .s-main{ font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--canon); letter-spacing: .04em; }
.status-label.offline .s-main{ color: var(--ink-faint); }
.status-label .s-sub{ font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }

.insight-row{ display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; }
.insight-row + .insight-row{ border-top: 1px solid var(--line); }
.insight-dot{ width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.insight-dot svg{ width: 100%; height: 100%; }
.insight-text .i-title{ font-weight: 700; font-size: 12.5px; letter-spacing: .03em; }
.insight-text .i-sub{ font-size: 11px; color: var(--ink-faint); }
.insight-row.canonical .i-title{ color: var(--canon); }
.insight-row.expanded .i-title{ color: var(--expand); }
.insight-row.low_confidence .i-title{ color: var(--low); }

.recent-item{
  padding: 10px 0;
  cursor: pointer;
}
.recent-item + .recent-item{ border-top: 1px solid var(--line); }
.recent-item .r-src{ font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item .r-meta{ display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }

.view-archive-btn{
  display: block; width: 100%; text-align: center;
  margin-top: 12px; padding: 10px; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: var(--void-2);
  color: var(--ink-dim); cursor: pointer; font-size: 12.5px; font-weight: 600;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.view-archive-btn:hover{ border-color: var(--core); color: var(--core); }

/* ==========================================================================
   Languages library view
   ========================================================================== */
.lib-grid{ display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 4px; }
@media (min-width: 640px){ .lib-grid{ grid-template-columns: 1fr 1fr; } }
.lib-card{
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); padding: 16px;
}
.lib-card-head{ display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.lib-glyph{
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  background: var(--void-2); border: 1px solid var(--line); color: var(--core);
}
.lib-card-head .lib-name{ font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.lib-tag{ font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.lib-desc{ font-size: 12.5px; color: var(--ink-dim); line-height: 1.5; margin: 8px 0 12px; }
.lib-actions{ display: flex; gap: 8px; }
.lib-actions button{
  flex: 1; border: 1px solid var(--line); background: var(--void-2); color: var(--ink-dim);
  padding: 8px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all .2s var(--ease);
}
.lib-actions button.set-from:hover{ border-color: var(--core); color: var(--core); }
.lib-actions button.set-to:hover{ border-color: var(--target); color: var(--target); }

/* ==========================================================================
   Communicate view (conversation mode)
   ========================================================================== */
.convo-log{ display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 14px; min-height: 120px; }
.convo-bubble{ max-width: 88%; border-radius: var(--radius-lg); padding: 10px 14px; border: 1px solid var(--line); }
.convo-bubble.a{ align-self: flex-start; border-left: 3px solid var(--core); background: var(--panel); }
.convo-bubble.b{ align-self: flex-end; border-right: 3px solid var(--target); background: var(--panel); text-align: right; }
.convo-bubble .c-lang{ font-family: var(--font-mono); font-size: 9px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
.convo-bubble .c-text{ font-size: 14.5px; }
.convo-bubble.b .c-text{ font-family: var(--font-display); font-weight: 600; color: var(--target); }
.convo-turn-indicator{
  text-align: center; font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  color: var(--ink-faint); text-transform: uppercase; margin-bottom: 10px;
}
.convo-turn-indicator b{ color: var(--core); }

/* ==========================================================================
   Archive view
   ========================================================================== */
.history-item{
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer; transition: border-color .2s var(--ease);
}
.history-item:hover{ border-color: var(--core-dim); }
.history-item .hi-top{
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em;
}
.history-item .hi-src{ font-size: 12.5px; color: var(--ink-dim); margin-bottom: 3px; }
.history-item .hi-out{ font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--target); }

/* ==========================================================================
   Settings view
   ========================================================================== */
.settings-group{ margin-bottom: 22px; }
.settings-group h3{
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 10px;
}
.field{ margin-bottom: 12px; }
.field label{ display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px; }
.field input[type=text], .field input[type=password], .field select{
  width: 100%; background: var(--void-2); border: 1px solid var(--line); border-radius: var(--radius-md);
  color: var(--ink); padding: 12px 14px; font-size: 14px; font-family: var(--font-mono);
  transition: border-color .2s var(--ease);
}
.field select{ font-family: var(--font-body); }
.field input:focus, .field select:focus{ border-color: var(--core); }
.field-hint{ font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; }
.field-hint.ok{ color: var(--canon); }
.field-row{ display: flex; gap: 8px; }
.field-row .field{ flex: 1; }
.key-row{ display: flex; gap: 8px; }
.key-row input{ flex: 1; }
.btn{
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  border-radius: var(--radius-md); padding: 12px 16px; font-size: 13.5px; cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease); white-space: nowrap; font-weight: 600;
}
.btn:hover{ border-color: var(--core); }
.btn.primary{ background: linear-gradient(120deg, var(--core-dim), var(--target-dim)); border-color: transparent; color: #fff; }
.btn.danger{ color: var(--danger); border-color: var(--danger); background: rgba(255,91,91,.08); }
.btn.block{ width: 100%; }
.theme-swatches{ display: flex; gap: 10px; }
.swatch{ width: 42px; height: 42px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all .2s var(--ease); }
.swatch:hover{ transform: scale(1.08); }
.swatch.active{ border-color: #fff; }
.swatch.void{ background: radial-gradient(circle at 35% 30%, #3ecbf5, #0e1c1b); }
.swatch.nebula{ background: radial-gradient(circle at 35% 30%, #b18cff, #241a3d); }
.swatch.solar{ background: radial-gradient(circle at 35% 30%, #ffca4b, #3a260c); }

/* ==========================================================================
   Tab bar
   ========================================================================== */
.tabbar{
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--void) 55%, transparent);
  pointer-events: none; z-index: 20;
}
.tabbar-inner{
  pointer-events: all; display: flex; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px; width: 100%; max-width: 640px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.tab-btn{
  flex: 1; border: none; background: transparent; color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px; border-radius: 999px; cursor: pointer;
  font-size: 9px; font-family: var(--font-mono); letter-spacing: .03em; text-transform: uppercase;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.tab-btn svg{ width: 17px; height: 17px; }
.tab-btn.active{ color: var(--core); background: var(--panel-2); }

/* ==========================================================================
   Modal + toast
   ========================================================================== */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(3,6,10,.78); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade-in .25s var(--ease);
}
@keyframes fade-in{ from{ opacity: 0; } to{ opacity: 1; } }
.modal-backdrop.hidden{ display: none; }
.modal{
  width: 100%; max-width: 520px; background: var(--void-2); border: 1px solid var(--line);
  border-radius: 24px 24px 0 0; padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  animation: modal-up .35s var(--ease);
}
@media (min-width: 640px){ .modal-backdrop{ align-items: center; } .modal{ border-radius: 20px; } }
@keyframes modal-up{ from{ transform: translateY(30px); opacity: 0; } to{ transform: translateY(0); opacity: 1; } }
.modal h2{ margin: 0 0 6px; font-size: 19px; }
.modal p.lead{ color: var(--ink-dim); font-size: 13.5px; margin: 0 0 20px; line-height: 1.5; }

.toast{
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--panel-2); border: 1px solid var(--core-dim); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 12.5px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   Misc
   ========================================================================== */
.section-title{ font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 4px 0 2px; }
.section-lead{ font-size: 12.5px; color: var(--ink-faint); margin: 0 0 14px; }
.hidden{ display: none !important; }
::-webkit-scrollbar{ width: 8px; }
::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 4px; }

@media (min-width: 1040px){
  .topbar-center{ display: block; }
}
