@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: 'Space Mono', monospace;
  height: 100vh;
  overflow: hidden;
  display: flex;
  box-shadow: inset 0 0 150px rgba(0,0,0,0.3);
}

/* ===== SCANLINES ===== */
.scanlines {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px);
  z-index: 100;
}

/* ===== LEFT PANEL ===== */
.left-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  position: relative;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              border 0.3s;
}
.dashboard .left-panel {
  width: 320px;
  min-width: 320px;
  justify-content: flex-start;
  padding-top: 60px;
  border-right: 1px solid #1a1a1a;
}

/* ===== MODE TOGGLE ===== */
.mode-toggle {
  position: absolute;
  top: 22px;
  right: 28px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 5px 12px;
  color: #777;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 1px;
  z-index: 10;
}
.mode-toggle:hover { border-color: rgba(255,255,255,0.25); color: #999; }
.dashboard .mode-toggle { left: 16px; right: auto; top: 16px; }

/* ===== CONNECTION STATUS ===== */
.status {
  position: absolute;
  top: 24px;
  left: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #666;
  letter-spacing: 1px;
  transition: opacity 0.3s;
  z-index: 10;
}
.dashboard .status { opacity: 0; pointer-events: none; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #555;
  transition: all 0.5s;
}
.status-dot.connected {
  background: #e0d4c8;
  box-shadow: 0 0 8px rgba(224,212,200,0.5);
  animation: dot-pulse 2s ease-in-out infinite;
}
.status-dot.connecting {
  background: #ff6b35;
  box-shadow: 0 0 8px rgba(255,107,53,0.5);
  animation: dot-pulse 1s ease-in-out infinite;
}
@keyframes dot-pulse { 0%,100%{opacity:1}50%{opacity:0.6} }

/* ===== HAL EYE ===== */
.eye-container {
  position: relative;
  width: 200px; height: 200px;
  filter: drop-shadow(0 0 80px rgba(200,80,20,0.08));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.5s, filter 0.5s;
  cursor: pointer;
}
.dashboard .eye-container { width: 150px; height: 150px; margin-top: 16px; cursor: default; }

.eye-outer {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3.5px solid #333;
  background: radial-gradient(circle, #1a0a00, #0d0500);
  position: relative;
  box-shadow: 0 0 40px rgba(200,80,20,0.15), inset 0 0 30px rgba(0,0,0,0.8);
  transition: all 0.5s;
}
.eye-mid {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 66%; height: 66%;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 42%, #ff6b35, #cc4400 25%, #882200 50%, #441100 75%, transparent);
  box-shadow: 0 0 30px rgba(255,107,53,0.3);
  transition: all 0.4s;
  will-change: transform;
  animation: eye-breathe 4s ease-in-out infinite;
}
@keyframes eye-breathe {
  0%,100% { transform: translate(-50%,-50%) scale(1); opacity: 0.9; }
  50% { transform: translate(-50%,-50%) scale(1.04); opacity: 1; }
}
.eye-iris {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 33%; height: 33%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, #ffdd44 15%, #ff8800 40%, #cc4400 70%, transparent);
  box-shadow: 0 0 20px rgba(255,136,0,0.6);
  transition: all 0.3s;
}
.eye-shine {
  position: absolute; top: 32%; left: 58%;
  width: 9%; height: 9%;
  border-radius: 50%;
  background: rgba(255,255,255,0.65);
  filter: blur(1px);
  animation: shine-bob 3s ease-in-out infinite;
}
.eye-shine-small {
  position: absolute; top: 55%; left: 35%;
  width: 4%; height: 4%;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
}
@keyframes shine-bob {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(-2px, 2px); }
}

/* -- Eye States -- */

/* Disconnected */
.disconnected .eye-outer { border-color: #222; box-shadow: none; }
.disconnected .eye-mid {
  background: radial-gradient(circle at 45% 42%, #444, #333 25%, #222 50%, #1a1a1a 75%, transparent);
  box-shadow: none; animation: none; opacity: 0.5;
}
.disconnected .eye-iris {
  background: radial-gradient(circle at 40% 35%, #888, #666 15%, #444 40%, #333 70%, transparent);
  box-shadow: none;
}
.disconnected .eye-shine, .disconnected .eye-shine-small { opacity: 0.2; }
.disconnected .eye-container { filter: none; }

/* Listening */
.listening .eye-mid { width: 72%; height: 72%; }
.listening .eye-iris { width: 36%; height: 36%; }

/* Thinking */
.thinking .eye-mid { width: 60%; height: 52%; animation: think-squint 1.5s ease-in-out infinite; }
.thinking .eye-iris { width: 28%; height: 24%; }
@keyframes think-squint {
  0%,100% { transform: translate(-50%,-50%) scaleY(1); }
  50% { transform: translate(-50%,-50%) scaleY(0.85); }
}

/* Speaking */
.speaking .eye-mid {
  box-shadow: 0 0 50px rgba(255,107,53,0.5), 0 0 100px rgba(204,68,0,0.2);
  animation: speak-glow 1.2s ease-in-out infinite;
}
.speaking .eye-iris { width: 36%; height: 36%; box-shadow: 0 0 30px rgba(255,136,0,0.8); }
@keyframes speak-glow {
  0%,100% { transform: translate(-50%,-50%) scale(1); }
  50% { transform: translate(-50%,-50%) scale(1.06); }
}

/* Error */
.error .eye-mid {
  animation: error-flash 0.5s ease-in-out 2;
}
@keyframes error-flash {
  0%,100% { opacity: 0.5; }
  50% { opacity: 1; box-shadow: 0 0 40px rgba(255,50,50,0.4); }
}

/* ===== STATE & NAME LABELS ===== */
.state-label {
  margin-top: 24px;
  font-size: 12px;
  color: #555;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  transition: all 0.3s;
}
.listening .state-label { color: #cc6633; }
.thinking .state-label { color: #cc8833; }
.speaking .state-label { color: #dd7733; }

.name-label {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #ddd;
  letter-spacing: 2px;
  text-align: center;
}

/* ===== CONTROLS (dashboard only) ===== */
.controls {
  width: 100%;
  padding: 0 12px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.4s 0.1s, max-height 0.5s;
  pointer-events: none;
}
.dashboard .controls {
  opacity: 1;
  max-height: 480px;
  pointer-events: auto;
}

.connect-btn {
  margin-top: 24px;
  width: 100%;
  padding: 12px 0;
  border-radius: 8px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}
.connect-btn.live {
  background: rgba(255,80,40,0.1);
  border: 2px solid rgba(255,80,40,0.3);
  color: #ff6b35;
}
.connect-btn.live:hover { background: rgba(255,80,40,0.15); border-color: rgba(255,80,40,0.5); }
.connect-btn.off {
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.12);
  color: #888;
}
.connect-btn.off:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.2); color: #bbb; }

/* Model selector */
.model-selector { width: 100%; margin-top: 16px; }
.model-selector label {
  display: block; font-size: 10px; color: #666; letter-spacing: 2px; margin-bottom: 6px;
}
.model-selector select {
  width: 100%;
  background: #111;
  border: 1.5px solid #282828;
  border-radius: 8px;
  padding: 8px 10px;
  color: #999;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.model-selector select:hover { border-color: #444; color: #ccc; }
.model-selector select:focus { outline: none; border-color: rgba(255,107,53,0.4); }
.model-selector select option { background: #151515; color: #999; }

/* Session info */
.session-info { margin-top: 16px; width: 100%; }
.info-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #151515;
  font-size: 11px;
}
.info-row .label { color: #666; letter-spacing: 1px; }
.info-row .value { color: #777; }

/* Selector note */
.selector-note {
  margin-top: 10px;
  font-size: 10px;
  color: #886644;
  letter-spacing: 1px;
  text-align: center;
  padding: 5px 8px;
  border: 1px solid rgba(255,107,53,0.15);
  border-radius: 6px;
  background: rgba(255,107,53,0.05);
  animation: note-fade-in 0.3s ease;
}
@keyframes note-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Hold music toggle */
.hold-music-toggle {
  margin-top: 16px;
  display: flex; align-items: center;
  gap: 10px;
  font-size: 11px;
  color: #555;
  letter-spacing: 1px;
}
.toggle-switch {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: #222;
  border: 1.5px solid #333;
  position: relative;
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
}
.toggle-switch.on {
  background: rgba(255,107,53,0.2);
  border-color: rgba(255,107,53,0.4);
}
.toggle-switch::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #555;
  transition: all 0.3s;
}
.toggle-switch.on::after { left: 18px; background: #ff6b35; }

/* Kbd hints */
kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid #333;
  border-radius: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #555;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===== RIGHT PANEL ===== */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s 0.15s;
}
.dashboard .right-panel {
  max-width: 2000px;
  opacity: 1;
}

.feed-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #1a1a1a;
  min-height: 0;
}
.feed-section:last-child { border-bottom: none; }
.feed-sessions  { flex: 1; }
.feed-transcript { flex: 3; }
.feed-activity { flex: 2; }

/* Session list items */
.session-item {
  padding: 7px 0;
  border-bottom: 1px solid #111;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
  border-radius: 4px;
  padding-left: 4px;
  padding-right: 4px;
}
.session-item:last-child { border-bottom: none; }
.session-item:hover { background: rgba(255,255,255,0.03); }
.session-item.active { background: rgba(255,107,53,0.06); }
.session-time { color: #666; letter-spacing: 0.5px; }
.session-count { color: #444; font-size: 10px; text-align: right; }

.feed-header {
  padding: 16px 20px 10px;
  font-size: 10px;
  color: #666;
  letter-spacing: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.feed-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 16px;
}

.clear-btn {
  background: none;
  border: 1px solid #252525;
  border-radius: 5px;
  padding: 2px 8px;
  color: #444;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}
.clear-btn:hover { border-color: rgba(255,107,53,0.3); color: #886644; }
.feed-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 16px;
}
.feed-content::-webkit-scrollbar { width: 4px; }
.feed-content::-webkit-scrollbar-thumb { background: #222; border-radius: 2px; }
.feed-content::-webkit-scrollbar-track { background: transparent; }

/* Transcript messages */
.msg {
  padding: 10px 0;
  border-bottom: 1px solid #111;
  display: flex;
  gap: 12px;
  font-size: 12px;
  line-height: 1.6;
  animation: msg-fade-in 0.3s ease;
}
.msg:last-child { border-bottom: none; }
@keyframes msg-fade-in { from { opacity: 0; } to { opacity: 1; } }

.msg-who {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 1px;
  color: #666;
  width: 40px;
  text-align: right;
  padding-top: 1px;
}
.msg-who.you { color: #666; }
.msg-who.ash { color: #aa5533; }
.msg-text { color: #999; }

/* Activity items */
.activity-item {
  padding: 8px 0;
  border-bottom: 1px solid #111;
  font-size: 11px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { flex-shrink: 0; width: 18px; text-align: center; color: #555; padding-top: 1px; }
.activity-text { color: #666; line-height: 1.5; }
.activity-time { color: #555; font-size: 10px; margin-left: auto; flex-shrink: 0; padding-top: 1px; }
.activity-item.running .activity-icon { color: #cc6633; animation: blink 1.5s infinite; }
.activity-item.running .activity-text { color: #999; }
@keyframes blink { 0%,100%{opacity:1}50%{opacity:0.3} }

/* ===== BOTTOM HINT ===== */
.hint {
  position: absolute;
  bottom: 28px;
  font-size: 11px;
  color: #555;
  letter-spacing: 1px;
  transition: opacity 0.3s;
  left: 50%;
  transform: translateX(-50%);
}
.dashboard .hint { opacity: 0; pointer-events: none; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.dashboard .toast-container {
  left: auto;
  right: 20px;
  transform: none;
  bottom: 20px;
  align-items: flex-end;
}

.toast {
  background: #1a1a1a;
  border: 1px solid #282828;
  border-radius: 8px;
  padding: 10px 16px;
  color: #999;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  animation: toast-in 0.3s ease;
  max-width: 400px;
}
.toast.error { border-color: rgba(255,80,40,0.3); color: #cc6633; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== FOCUS STATES ===== */
button:focus-visible, select:focus-visible, .toggle-switch:focus-visible, .eye-container:focus-visible {
  outline: 1px solid rgba(255,107,53,0.5);
  outline-offset: 2px;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .dashboard .left-panel {
    width: 100%;
    min-width: unset;
    border-right: none;
    padding-top: 60px;
    padding-bottom: 16px;
  }
  .dashboard .eye-container { width: 120px; height: 120px; }

  body.dashboard { flex-direction: column; overflow-y: auto; }

  .dashboard .right-panel {
    max-width: 100%;
    flex-direction: column;
  }
  .dashboard .feed-section { min-height: 200px; }
}

@media (max-width: 480px) {
  .eye-container { width: 140px; height: 140px; }
  .hint { display: none; }
  .connect-btn, .mode-toggle { min-height: 44px; min-width: 44px; }
  .toggle-switch { min-height: 44px; width: 44px; }
}
