/* Yoda — dark theme PWA shell. Mobile-first. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0a0a;
  color: #e8e8e8;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

#app { flex: 1; display: flex; flex-direction: column; min-height: 100%; }

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.visible { display: flex; }
.hidden { display: none !important; }

/* ── Login ── */

#login-screen { align-items: center; justify-content: center; }
.login-card {
  width: 88%;
  max-width: 320px;
  text-align: center;
}
.logo {
  font-size: 2.4rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  margin: 0 0 2rem;
  color: #f5f5f5;
}
#login-form { display: flex; flex-direction: column; gap: 0.75rem; }
#password {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #f5f5f5;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
}
#password:focus { border-color: #4a4a4a; }
#login-btn {
  background: #f5f5f5;
  color: #0a0a0a;
  border: none;
  padding: 0.9rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}
#login-btn:active { transform: scale(0.98); }
.error { color: #ff6b6b; font-size: 0.85rem; min-height: 1em; margin: 0.5rem 0 0; }

/* ── Session ── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  font-size: 1.1rem;
}
.icon-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.3rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:hover { color: #ddd; }
.icon-btn:active { background: #1a1a1a; }

#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scroll-behavior: smooth;
}
.turn {
  max-width: 92%;
  line-height: 1.45;
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.turn.user {
  align-self: flex-end;
  color: #b9b9b9;
  font-style: italic;
}
.turn.user::before { content: "› "; opacity: 0.5; }
.turn.assistant {
  align-self: flex-start;
  color: #f0f0f0;
}
.turn.flagged {
  background: linear-gradient(90deg, rgba(255,200,0,0.08), transparent);
  border-left: 2px solid rgba(255,200,0,0.4);
  padding-left: 0.5rem;
}
.turn.pending { opacity: 0.45; }

.banner {
  margin: 0 1.2rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255,255,255,0.04);
  border-left: 2px solid #4a4a4a;
  font-size: 0.85rem;
  color: #aaa;
  border-radius: 4px;
}

.controls {
  padding: 0.6rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.mic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.mic {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #f5f5f5;
  color: #0a0a0a;
  border: none;
  font-size: 1.6rem;
  margin: 0 auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, background 0.15s;
  box-shadow: 0 0 0 0 rgba(245,245,245,0.4);
}
.mic.recording {
  background: #ff5252;
  color: #fff;
  animation: pulse 1.2s infinite;
}
.mic.thinking {
  background: #555;
  color: #fff;
  animation: thinking 1.4s linear infinite;
}
.mic:active { transform: scale(0.95); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,82,82,0.6); }
  50% { box-shadow: 0 0 0 18px rgba(255,82,82,0); }
}
@keyframes thinking {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.icon-btn.flag { font-size: 1.4rem; color: #888; }
.icon-btn.flag.active { color: #ffcc4d; }

.text-form {
  display: flex;
  gap: 0.5rem;
}
.text-form input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #f5f5f5;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
}
.text-form input:focus { border-color: #4a4a4a; }
.text-form button {
  background: #f5f5f5;
  color: #0a0a0a;
  border: none;
  padding: 0 1.2rem;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
}
.status {
  color: #666;
  font-size: 0.78rem;
  min-height: 1em;
  text-align: center;
  margin: 0;
}

/* ── History drawer ── */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(85%, 380px);
  background: #111;
  border-left: 1px solid #222;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.drawer.open { transform: translateX(0); }
.drawer header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #222;
}
.drawer h2 { margin: 0; font-size: 1rem; font-weight: 400; color: #ddd; }
#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
#history-list li {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #1a1a1a;
  font-size: 0.9rem;
  color: #ccc;
}
#history-list li .date { color: #666; font-size: 0.75rem; display: block; margin-bottom: 0.2rem; }
