/* ============================================================
   DinBrudi BRUDI-Chat on Meta Ray-Ban Display — TE-Style
   Same dark-inverted TE-design wie die News-App: schwarzer BG =
   transparente Lens, weisses "Ink", Orange-Akzent (OP-1).
   ============================================================ */

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

:root {
  --bg-page: #000000;
  --bg-surface: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --ink: #ffffff;
  --ink-soft: rgba(255,255,255,0.72);
  --ink-mute: rgba(255,255,255,0.45);
  --te-orange: #FF6B00;
  --te-cream: #F5C200;
  --te-mint: #86E8B5;
  --danger: #ff4466;
  --shadow-default: 2px 2px 0 0 var(--ink);
  --shadow-orange:  2px 2px 0 0 var(--te-orange);
  --shadow-active:  0 0 0 0 var(--ink);
  --radius-sm: 0;
  --radius-md: 4px;
  --font: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --curve-focus: cubic-bezier(0.6, 0, 0.4, 1);
}

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

html, body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--ink);
  width: 600px;
  height: 600px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  padding: 8px;
}

/* ===== Screens ===== */
.screen {
  position: absolute;
  top: 8px;
  left: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-page);
}
.screen.hidden { display: none; }

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-surface);
  gap: 10px;
  flex-shrink: 0;
  height: 56px;
  border-bottom: 2px solid var(--ink);
}
.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
}
.header-meta {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-page);
}

/* ===== Empty / Idle State ===== */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 14px 8px;
  text-align: center;
}
.chat-empty-title {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-top: 4px;
}
.chat-empty-sub {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 8px;
}

/* Quick-Action-Grid — 2 Spalten, D-Pad-navigierbare Preset-Prompts.
   Voice geht auf der Brille nicht (Meta blockt getUserMedia in Web Apps).
   Dieser Grid ist der primaere Eingabe-Pfad fuer Brudi auf der Brille. */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.quick-item {
  background: var(--bg-surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 16px 10px;
  cursor: pointer;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  line-height: 1.25;
}
.quick-item:focus {
  outline: none;
  background: var(--te-orange);
  color: #000;
  box-shadow: var(--shadow-default);
}

/* ===== Chat-Messages ===== */
.msg {
  max-width: 90%;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  word-wrap: break-word;
  flex-shrink: 0;
}
.msg.user {
  align-self: flex-end;
  background: var(--te-orange);
  color: #000;
  box-shadow: var(--shadow-default);
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  color: var(--ink);
}
.msg.live {
  /* Live STT-Preview, leicht transparent damit klar dass es noch laeuft */
  align-self: flex-end;
  background: rgba(255, 107, 0, 0.35);
  color: var(--ink);
  border-style: dashed;
}
.msg-meta {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 5px;
  opacity: 0.8;
}
.msg.assistant .msg-meta { color: var(--te-cream); }
.msg.user .msg-meta { color: rgba(0,0,0,0.6); }
.msg-tools {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--te-mint);
  margin-top: 7px;
  opacity: 0.95;
}

/* ===== Gerenderte Markdown-Elemente in Brudi-Antworten ===== */
.msg-content { display: block; }
.msg-content > p { margin: 0 0 8px; }
.msg-content > p:last-child { margin-bottom: 0; }
.msg-content > ol,
.msg-content > ul {
  margin: 6px 0;
  padding-left: 22px;
}
.msg-content > ol + p,
.msg-content > ul + p,
.msg-content > p + ol,
.msg-content > p + ul { margin-top: 8px; }
.msg-content li {
  margin: 4px 0;
  line-height: 1.4;
}
.msg-content li::marker {
  font-family: var(--mono);
  font-weight: 700;
}
.msg-content strong {
  font-weight: 700;
  /* Im fokussierten orange-State: schwarzer Strong-Text wirkt staerker */
}
.msg-content em {
  font-style: italic;
  opacity: 0.92;
}
.msg-content code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
.msg.user .msg-content code {
  background: rgba(0,0,0,0.15);
}
.msg-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

/* "Brudi denkt..." Loading-Indicator */
.thinking {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--te-cream);
  padding: 10px 16px;
  border: 2px dashed var(--ink);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  animation: thinkingPulse 1.2s ease-in-out infinite;
}
@keyframes thinkingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== Nav-Bar ===== */
.nav-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface);
  flex-shrink: 0;
  border-top: 2px solid var(--ink);
}
.nav-chat {
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.nav-item {
  padding: 0 10px;
  background: var(--bg-page);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  cursor: pointer;
  /* KEINE Transition — Brille hat begrenzte Render-Performance, smoothes
     Animations laggen sicht-und tap-baren. Snap-State ist TE-on-Brand. */
}
.nav-arrow {
  flex: 0 0 60px;
  font-size: 20px;
  font-weight: 700;
}
.nav-item:focus {
  outline: none;
  background: var(--te-orange);
  color: #000;
  box-shadow: var(--shadow-default);
}

/* Mic-Button: BIG, primary, signature TE-OP-1-Style */
.mic-btn {
  flex: 1;
  height: 60px;
  background: var(--te-orange);
  color: #000;
  border: 2px solid var(--ink);
  font-size: 26px;
  font-weight: 700;
  box-shadow: var(--shadow-default);
}
.mic-btn:focus {
  background: var(--te-cream);
  color: #000;
}
.mic-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: var(--shadow-default); transform: translate(0, 0); }
  50% { box-shadow: 0 0 0 6px rgba(255, 68, 102, 0.35), 2px 2px 0 0 var(--ink); }
}
.mic-btn.loading {
  background: var(--te-cream);
  color: #000;
}

/* ===== Pair-Screen ===== */
.pair-content {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 22px;
  gap: 12px;
}
.pair-icon { font-size: 48px; }
.pair-text {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.3;
}
.pair-text-secondary {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ===== Status-Banner ===== */
.status-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 0;
  border: 2px solid var(--ink);
  background: var(--bg-page);
  color: var(--ink);
  flex-shrink: 0;
}
.status-banner::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--ink);
}
.status-banner.live::before {
  background: var(--te-orange);
  animation: tePulse 1.4s steps(2) infinite;
}
@keyframes tePulse { 50% { background: transparent; } }
.status-banner.mock { border-style: dashed; }
.status-banner.error {
  background: var(--danger);
  color: #000;
  border-color: var(--danger);
}
.status-banner.error::before { background: #000; }

/* ===== Toast ===== */
.toast {
  position: absolute;
  bottom: 80px;
  left: 20px;
  right: 20px;
  background: var(--te-orange);
  color: #000;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 16px;
  border-radius: 0;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-default);
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  z-index: 100;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--te-cream); color: #000; }

/* ===== Key-Debug ===== */
.key-debug {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: #000;
  border: 1px solid var(--ink);
  padding: 2px 6px;
  z-index: 200;
}

/* ===== Util ===== */
.hidden { display: none !important; }
