:root {
  /* exact palette from Mark-LIII's ui.py class C */
  --bg:        #00060a;
  --panel:     #010d14;
  --panel2:    #010f18;
  --border:    #0d3347;
  --border-b:  #1a5c7a;
  --border-a:  #0f4060;
  --pri:       #00d4ff;
  --pri-dim:   #007a99;
  --pri-ghost: #001f2e;
  --acc:       #ff6b00;
  --acc2:      #ffcc00;
  --green:     #00ff88;
  --red:       #ff3355;
  --text:      #8ffcff;
  --text-dim:  #3a8a9a;
  --text-med:  #5ab8cc;
  --white:     #d8f8ff;
  --dark:      #000d14;
  --bar-bg:    #011520;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle, var(--pri-ghost) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--bg);
  color: var(--text);
  font-family: "Courier New", Consolas, monospace;
  overflow: hidden;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 2px;
}

header h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  color: var(--pri);
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.65);
}

header h1 span {
  font-size: 11px;
  color: var(--acc2);
  margin-left: 10px;
  letter-spacing: 3px;
}

#status-chip {
  font-size: 11px;
  font-weight: bold;
  color: var(--pri);
  border: 1px solid var(--pri-dim);
  border-radius: 3px;
  padding: 3px 8px;
  letter-spacing: 1px;
}

main {
  height: calc(100% - 54px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px 14px;
  gap: 6px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.chat-col {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  flex: 1;
  min-height: 0;
}

/* Standard tablet in landscape: reactor sits in a fixed left column, the
   chat gets the rest of the width instead of being capped at phone width. */
@media (min-width: 860px) and (orientation: landscape) {
  main {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 28px;
    padding: 18px 28px;
  }
  .sidebar {
    width: 230px;
    justify-content: flex-start;
    padding-top: 6px;
  }
  .chat-col {
    max-width: 1100px;
  }
  #log {
    font-size: 13px;
  }
}

/* ── Reactor HUD ─────────────────────────────────────────────────────── */

.reactor-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  margin: 4px 0 2px;
  flex-shrink: 0;
}

#reactor {
  width: 172px;
  height: 172px;
  overflow: visible;
  flex-shrink: 0;
}

.ring-slow  { animation: spin 14s linear infinite; }
.ring-med   { animation: spin 9s  linear infinite reverse; }
.ring-fast  { animation: spin 5s  linear infinite; }
.scanner-a  { animation: spin 3.2s linear infinite; }
.scanner-b  { animation: spin 2.1s linear infinite reverse; }
.ticks      { opacity: 0.65; }

@keyframes spin { to { transform: rotate(360deg); } }

.halo {
  animation: halo-pulse 2.6s ease-in-out infinite;
  transform-origin: 150px 150px;
}
@keyframes halo-pulse {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 0.7; }
}

#reactor.thinking  .halo   { stroke: var(--acc2); }
#reactor.listening .halo   { stroke: var(--green); }
#reactor.speaking  .halo   { stroke: var(--acc); }

#reactor.thinking .scanner-a,
#reactor.thinking .scanner-b,
#reactor.listening .scanner-a,
#reactor.listening .scanner-b,
#reactor.speaking .scanner-a,
#reactor.speaking .scanner-b { animation-duration: 1.1s; }

.core-orb {
  fill: url(#orbGrad);
}
.core-label {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 15px;
  fill: var(--pri);
  text-anchor: middle;
  letter-spacing: 1px;
}

#state-label {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  color: var(--pri);
  margin-top: 2px;
}
#state-label.thinking  { color: var(--acc2); }
#state-label.listening { color: var(--green); }
#state-label.speaking  { color: var(--acc); }

#waveform {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 26px;
  margin: 4px 0 2px;
}
#waveform .bar {
  width: 3px;
  min-height: 2px;
  background: var(--border-b);
  border-radius: 1px;
  transition: height 60ms linear, background 120ms linear;
}

.mic-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

#mic-btn {
  background: #00091a;
  color: var(--pri);
  border: 1px solid var(--pri-dim);
  border-radius: 3px;
  font-family: inherit;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 7px 22px;
  cursor: pointer;
}
#mic-btn:hover { background: var(--pri-ghost); border-color: var(--pri); }
#mic-btn.listening {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.35);
}
#mic-btn:disabled {
  color: var(--text-dim);
  border-color: var(--border);
  cursor: not-allowed;
  box-shadow: none;
}

#sound-btn {
  background: #00091a;
  color: var(--text-med);
  border: 1px solid var(--border-a);
  border-radius: 3px;
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
  padding: 7px 14px;
  cursor: pointer;
}
#sound-btn:hover { border-color: var(--text-med); }
#sound-btn.muted {
  color: var(--red);
  border-color: var(--red);
}

/* ── Log panel (mirrors Mark-LIII's LogWidget) ──────────────────────── */

#log {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
#log::-webkit-scrollbar { width: 8px; }
#log::-webkit-scrollbar-track { background: var(--bg); }
#log::-webkit-scrollbar-thumb { background: var(--border-b); border-radius: 4px; }

.line-you  { color: var(--white); }
.line-ai   { color: var(--pri); }
.line-sys  { color: var(--acc2); }
.line-err  { color: var(--red); }
.line-file {
  display: block;
  color: var(--green);
  text-decoration: underline;
  cursor: pointer;
  margin: 2px 0;
}
.line-file:hover { color: var(--white); }

#attachment-preview {
  width: 100%;
  font-size: 11px;
  color: var(--acc2);
  padding: 3px 4px 0;
}

.input-row {
  width: 100%;
  display: flex;
  gap: 6px;
  padding-top: 8px;
}

#text-input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
}
#text-input:focus { outline: none; border-color: var(--pri); }
#text-input::placeholder { color: var(--text-dim); }

#photo-btn,
#file-btn {
  background: #00091a;
  border: 1px solid var(--border-a);
  color: var(--text);
  border-radius: 3px;
  font-size: 15px;
  width: 40px;
  cursor: pointer;
  flex-shrink: 0;
}
#photo-btn:hover,
#file-btn:hover { border-color: var(--pri); }

#send-btn {
  background: var(--pri-ghost);
  border: 1px solid var(--pri);
  color: var(--pri);
  padding: 0 16px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 1px;
}
#send-btn:hover { background: var(--pri); color: #001015; }
