/* Jarvis PWA — HAL 9000 Aesthetic */

:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-hover: #141414;
  --border: #1a1a1a;
  --text: #cccccc;
  --text-dim: #888888;
  --red-core: #ff0000;
  --red-glow: #cc0000;
  --eye-color: #ff0000;
  --eye-glow: #cc0000;
  --blue-core: #4a9eff;
  --blue-glow: #2070cc;
  --btn-bg: #1a1a1a;
  --success: #00ff41;
  --danger: #ff0000;
  --radius: 8px;
  --radius-sm: 4px;
  --font: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* --- Scan Lines Overlay --- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* --- Header --- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: transparent;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.personality-label {
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.125rem;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
  line-height: 1;
  font-family: var(--font);
}

.header-btn:hover,
.header-btn:active {
  color: var(--red-core);
}

.header-btn.active {
  color: var(--red-core);
}

/* --- Driving Mode Toggle --- */

.driving-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-family: var(--font);
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #222;
  background: transparent;
  transition: all 0.3s;
  user-select: none;
  letter-spacing: 0.1em;
}

.driving-toggle.active {
  color: var(--red-core);
  border-color: var(--red-core);
  background: rgba(255, 0, 0, 0.08);
}

.driving-toggle-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}

.driving-toggle.active .driving-toggle-dot {
  background: var(--red-core);
  box-shadow: 0 0 6px rgba(255, 0, 0, 0.5);
}

/* --- Main Content --- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ============================================
   THE EYE — Central HAL 9000 Element
   ============================================ */

.hal-eye-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 16px;
  flex-shrink: 0;
  transition: padding 0.5s ease;
}

/* Shrink eye when conversation has content */
.hal-eye-container.compact {
  padding: 16px 20px 8px;
}

.hal-eye {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.5s ease, height 0.5s ease;
}

.hal-eye-container.compact .hal-eye {
  width: 80px;
  height: 80px;
}

/* Outer glow layer */
.hal-eye::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(204, 0, 0, 0.15) 0%,
    rgba(204, 0, 0, 0.05) 50%,
    transparent 70%
  );
  animation: halPulse 4s ease-in-out infinite;
  transition: all 0.5s ease;
}

/* Core of the eye — uses --eye-color for personality-driven colors */
.hal-eye-core {
  position: relative;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    color-mix(in srgb, var(--eye-color) 70%, white) 0%,
    var(--eye-color) 30%,
    var(--eye-glow) 60%,
    color-mix(in srgb, var(--eye-color) 40%, black) 100%
  );
  box-shadow:
    0 0 20px color-mix(in srgb, var(--eye-color) 60%, transparent),
    0 0 40px color-mix(in srgb, var(--eye-color) 30%, transparent),
    0 0 80px color-mix(in srgb, var(--eye-color) 15%, transparent),
    inset 0 0 15px rgba(255, 255, 255, 0.1);
  animation: halPulse 4s ease-in-out infinite;
  transition: all 0.5s ease;
}

/* Lens flare / highlight */
.hal-eye-core::before {
  content: '';
  position: absolute;
  top: 18%;
  left: 22%;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
}

/* Secondary lens flare */
.hal-eye-core::after {
  content: '';
  position: absolute;
  bottom: 25%;
  right: 20%;
  width: 12%;
  height: 12%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  filter: blur(1px);
}

/* Ring around eye */
.hal-eye-ring {
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 1px solid rgba(255, 0, 0, 0.15);
  transition: all 0.5s ease;
}

/* Expanding ring (for listening/speaking) */
.hal-eye-pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid transparent;
  transition: all 0.5s ease;
}

/* Label under the eye */
.hal-eye-label {
  margin-top: 16px;
  font-size: 0.625rem;
  letter-spacing: 0.4em;
  color: var(--text-dim);
  text-transform: uppercase;
  opacity: 0.6;
  transition: all 0.5s ease;
}

.hal-eye-container.compact .hal-eye-label {
  margin-top: 8px;
  font-size: 0.5625rem;
}

/* ============================================
   EYE STATES
   ============================================ */

/* --- Idle State (default) --- */
@keyframes halPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(0.97);
  }
}

/* --- Listening State (Blue) --- */
.hal-eye.eye--listening .hal-eye-core {
  background: radial-gradient(circle at 40% 40%,
    #6ab4ff 0%,
    var(--blue-core) 30%,
    var(--blue-glow) 60%,
    #103866 100%
  );
  box-shadow:
    0 0 20px rgba(74, 158, 255, 0.6),
    0 0 40px rgba(74, 158, 255, 0.3),
    0 0 80px rgba(74, 158, 255, 0.15),
    inset 0 0 15px rgba(255, 255, 255, 0.1);
  animation: halListeningCore 2s ease-in-out infinite;
}

.hal-eye.eye--listening::before {
  background: radial-gradient(circle,
    rgba(74, 158, 255, 0.15) 0%,
    rgba(74, 158, 255, 0.05) 50%,
    transparent 70%
  );
  animation: halListeningCore 2s ease-in-out infinite;
}

.hal-eye.eye--listening .hal-eye-ring {
  border-color: rgba(74, 158, 255, 0.2);
}

.hal-eye.eye--listening .hal-eye-pulse-ring {
  border-color: rgba(74, 158, 255, 0.3);
  animation: halListeningRing 2s ease-out infinite;
}

@keyframes halListeningCore {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.03);
  }
}

@keyframes halListeningRing {
  0% {
    transform: scale(1);
    opacity: 0.6;
    border-color: rgba(74, 158, 255, 0.4);
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
    border-color: rgba(74, 158, 255, 0);
  }
}

/* --- Speaking/Thinking State (Red, faster) --- */
.hal-eye.eye--speaking .hal-eye-core {
  animation: halSpeakingCore 1.2s ease-in-out infinite;
}

.hal-eye.eye--speaking::before {
  animation: halSpeakingCore 1.2s ease-in-out infinite;
}

.hal-eye.eye--speaking .hal-eye-ring {
  border-color: rgba(255, 0, 0, 0.3);
  animation: halSpeakingRingInner 1.2s ease-in-out infinite;
}

.hal-eye.eye--speaking .hal-eye-pulse-ring {
  border-color: rgba(255, 0, 0, 0.3);
  animation: halSpeakingRing 1.8s ease-out infinite;
}

@keyframes halSpeakingCore {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 20px rgba(255, 0, 0, 0.6),
      0 0 40px rgba(255, 0, 0, 0.3),
      0 0 80px rgba(255, 0, 0, 0.15),
      inset 0 0 15px rgba(255, 255, 255, 0.1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow:
      0 0 30px rgba(255, 0, 0, 0.8),
      0 0 60px rgba(255, 0, 0, 0.4),
      0 0 100px rgba(255, 0, 0, 0.2),
      inset 0 0 20px rgba(255, 255, 255, 0.15);
  }
}

@keyframes halSpeakingRing {
  0% {
    transform: scale(1);
    opacity: 0.5;
    border-color: rgba(255, 0, 0, 0.4);
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
    border-color: rgba(255, 0, 0, 0);
  }
}

@keyframes halSpeakingRingInner {
  0%, 100% {
    transform: scale(1);
    border-color: rgba(255, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.05);
    border-color: rgba(255, 0, 0, 0.4);
  }
}

/* ============================================
   Quick Actions
   ============================================ */

.quick-actions {
  padding: 0 16px 8px;
  flex-shrink: 0;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  background: var(--btn-bg);
  border: 1px solid #222;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.6875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.quick-action-btn:active {
  transform: scale(0.95);
  background: var(--surface-hover);
  border-color: var(--red-core);
  color: var(--red-core);
}

.quick-action-btn:hover {
  border-color: #333;
}

.quick-action-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.quick-action-label {
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================
   Conversation Panel
   ============================================ */

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.message {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: messageIn 0.4s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: #111;
  color: var(--text);
  border: 1px solid #222;
  border-bottom-right-radius: 2px;
}

.message.assistant {
  align-self: flex-start;
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
  border-bottom-left-radius: 2px;
}

.message.assistant .msg-content h1,
.message.assistant .msg-content h2,
.message.assistant .msg-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 8px 0 4px;
  color: var(--red-core);
}

.message.assistant .msg-content h1:first-child,
.message.assistant .msg-content h2:first-child,
.message.assistant .msg-content h3:first-child {
  margin-top: 0;
}

.message.assistant .msg-content p {
  margin: 4px 0;
}

.message.assistant .msg-content ul,
.message.assistant .msg-content ol {
  padding-left: 20px;
  margin: 4px 0;
}

.message.assistant .msg-content li {
  margin: 2px 0;
}

.message.assistant .msg-content code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font);
  font-size: 0.8125em;
  color: var(--success);
}

.message.assistant .msg-content pre {
  background: #050505;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 6px 0;
  border: 1px solid #111;
}

.message.assistant .msg-content pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  color: var(--success);
}

.message.assistant .msg-content a {
  color: var(--red-core);
  text-decoration: none;
}

.message.assistant .msg-content a:hover {
  text-decoration: underline;
}

.message.assistant .msg-content strong {
  color: #eee;
  font-weight: 600;
}

/* Feedback buttons */

.msg-feedback {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #1a1a1a;
}

.feedback-btn {
  background: none;
  border: 1px solid #222;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font);
}

.feedback-btn:active {
  transform: scale(0.92);
}

.feedback-btn.selected {
  border-color: var(--red-core);
  color: var(--red-core);
  background: rgba(255, 0, 0, 0.08);
}

/* --- Loading --- */

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  align-self: flex-start;
  color: var(--text-dim);
  font-size: 0.8125rem;
  font-family: var(--font);
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red-core);
  animation: dotPulse 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ============================================
   Now Playing Bar
   ============================================ */

.now-playing-bar {
  flex-shrink: 0;
  background: #0a0a0a;
  border-top: none;
  position: relative;
  overflow: hidden;
}

.now-playing-bar.hidden {
  display: none;
}

.now-playing-accent {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--red-core) 50%, transparent 100%);
  opacity: 0.6;
}

.now-playing-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 12px;
}

.now-playing-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.now-playing-track {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font);
}

.now-playing-artist {
  font-size: 0.625rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font);
  letter-spacing: 0.02em;
}

.now-playing-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.now-playing-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.875rem;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  line-height: 1;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.now-playing-btn:hover,
.now-playing-btn:active {
  color: var(--red-core);
}

.now-playing-btn.np-play-pause {
  font-size: 1rem;
  color: var(--text);
}

.now-playing-btn.np-play-pause:hover,
.now-playing-btn.np-play-pause:active {
  color: var(--red-core);
}

body.driving-mode .now-playing-bar {
  display: none;
}

/* ============================================
   Input Area
   ============================================ */

.input-area {
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #050505;
  border-top: 1px solid #111;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-field {
  flex: 1;
  background: var(--bg);
  border: 1px solid #222;
  border-radius: 20px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 10px 16px;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-field::placeholder {
  color: #555;
  font-family: var(--font);
}

.input-field:focus {
  border-color: #444;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.1);
}

.input-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.send-btn {
  background: var(--red-core);
  color: #000;
  font-size: 1rem;
  font-weight: bold;
}

.send-btn:active {
  transform: scale(0.9);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: #333;
  color: #666;
}

.mic-btn {
  background: #111;
  color: var(--text-dim);
  font-size: 1.125rem;
  border: 1px solid #222;
}

.mic-btn:active {
  transform: scale(0.9);
}

.mic-btn.recording {
  background: rgba(255, 0, 0, 0.15);
  color: var(--red-core);
  border-color: var(--red-core);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(255, 0, 0, 0); }
}

/* ============================================
   Driving Mode
   ============================================ */

body.driving-mode .quick-actions {
  display: none;
}

body.driving-mode .hal-eye-container {
  flex: 1;
  padding: 20px;
}

body.driving-mode .hal-eye {
  width: min(70vw, 300px);
  height: min(70vw, 300px);
}

body.driving-mode .hal-eye-container.compact .hal-eye {
  width: min(40vw, 160px);
  height: min(40vw, 160px);
}

body.driving-mode .header {
  padding: 6px 16px;
  padding-top: calc(6px + env(safe-area-inset-top));
}

body.driving-mode .input-area {
  display: none;
}

body.driving-mode .conversation {
  font-size: 1.0625rem;
}

body.driving-mode .message {
  font-size: 1.0625rem;
  padding: 14px 16px;
}

/* Driving mode mic section */
.driving-mic-section {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 10px;
  flex-shrink: 0;
}

body.driving-mode .driving-mic-section {
  display: flex;
}

.driving-mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--red-core);
  background: rgba(255, 0, 0, 0.05);
  color: var(--red-core);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.driving-mic-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid transparent;
  transition: border-color 0.3s;
}

.driving-mic-btn.recording {
  background: rgba(74, 158, 255, 0.1);
  border-color: var(--blue-core);
  color: var(--blue-core);
  animation: drivingMicPulse 1.5s ease-in-out infinite;
}

.driving-mic-btn.recording::before {
  border-color: rgba(74, 158, 255, 0.3);
  animation: drivingRingPulse 1.5s ease-in-out infinite;
}

@keyframes drivingMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 158, 255, 0.3); }
  50% { box-shadow: 0 0 0 15px rgba(74, 158, 255, 0); }
}

@keyframes drivingRingPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.5; }
}

.driving-mic-label {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  font-family: var(--font);
}

.driving-bottom-actions {
  display: none;
  padding: 10px 20px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  gap: 12px;
  justify-content: center;
}

body.driving-mode .driving-bottom-actions {
  display: flex;
}

.driving-action-btn {
  padding: 12px 24px;
  border-radius: 24px;
  border: 1px solid #222;
  background: rgba(26, 26, 26, 0.8);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}

.driving-action-btn:active {
  transform: scale(0.95);
  background: var(--surface-hover);
}

.driving-action-btn.primary {
  background: rgba(255, 0, 0, 0.08);
  border-color: rgba(255, 0, 0, 0.3);
  color: var(--red-core);
}

/* TTS indicator */
.tts-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  color: var(--red-core);
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 0, 0, 0.05);
  margin-top: 8px;
  font-family: var(--font);
  letter-spacing: 0.05em;
}

body.driving-mode .tts-indicator {
  display: flex;
}

.tts-indicator-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red-core);
  animation: ttsBlink 1s infinite;
}

@keyframes ttsBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================
   Login Page
   ============================================ */

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.login-eye-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.login-eye {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-eye::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(204, 0, 0, 0.15) 0%,
    rgba(204, 0, 0, 0.05) 50%,
    transparent 70%
  );
  animation: halPulse 4s ease-in-out infinite;
}

.login-eye-core {
  position: relative;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    #ff4444 0%,
    var(--red-core) 30%,
    var(--red-glow) 60%,
    #660000 100%
  );
  box-shadow:
    0 0 20px rgba(255, 0, 0, 0.6),
    0 0 40px rgba(255, 0, 0, 0.3),
    0 0 80px rgba(255, 0, 0, 0.15),
    inset 0 0 15px rgba(255, 255, 255, 0.1);
  animation: halPulse 4s ease-in-out infinite;
}

.login-eye-core::before {
  content: '';
  position: absolute;
  top: 18%;
  left: 22%;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
}

.login-eye-ring {
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 1px solid rgba(255, 0, 0, 0.15);
}

.login-title {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.4em;
  color: var(--text-dim);
  text-transform: uppercase;
  font-family: var(--font);
  margin-top: 20px;
}

.login-subtitle {
  font-size: 0.6875rem;
  color: #555;
  margin-top: -16px;
  font-family: var(--font);
  letter-spacing: 0.1em;
}

.login-field {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 14px 16px;
  text-align: center;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  letter-spacing: 0.2em;
}

.login-field:focus {
  border-color: #444;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--red-core);
  background: transparent;
  color: var(--red-core);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.login-btn:hover {
  background: rgba(255, 0, 0, 0.08);
}

.login-btn:active {
  background: rgba(255, 0, 0, 0.15);
  transform: scale(0.98);
}

.login-btn-faceid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--blue-core);
  background: rgba(74, 158, 255, 0.08);
  color: var(--blue-core);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}

.login-btn-faceid:hover {
  background: rgba(74, 158, 255, 0.15);
}

.login-btn-faceid:active {
  transform: scale(0.98);
}

.login-btn-icon {
  font-size: 1.125rem;
}

.login-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid #333;
  background: #111;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
}

.login-btn-google:hover {
  border-color: #555;
  background: #1a1a1a;
}

.login-btn-google:active {
  transform: scale(0.98);
}

.login-divider {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  color: #444;
  font-size: 0.6875rem;
  font-family: var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #222;
}

.login-legacy {
  width: 100%;
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.login-legacy summary {
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.1em;
  padding: 8px;
}

.login-legacy summary:hover {
  color: var(--text);
}

.login-legacy form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.login-error {
  color: var(--red-core);
  font-size: 0.8125rem;
  min-height: 1.25em;
  font-family: var(--font);
}

/* ============================================
   Utilities
   ============================================ */

.hidden { display: none !important; }

/* Scrollbar styling */
.conversation::-webkit-scrollbar {
  width: 3px;
}

.conversation::-webkit-scrollbar-track {
  background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
  background: #1a1a1a;
  border-radius: 2px;
}

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 1px solid var(--red-core);
  outline-offset: 2px;
}

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  .input-field,
  .login-field {
    font-size: 16px;
  }
}

/* Larger eye on bigger screens */
@media screen and (min-width: 768px) {
  .hal-eye {
    width: 200px;
    height: 200px;
  }

  .hal-eye-container.compact .hal-eye {
    width: 100px;
    height: 100px;
  }
}
