/* === Reset & Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-dim: #888;
  --accent: #c8a97e;
  --accent-dim: #9c7d56;
  --success: #4caf84;
  --danger: #e05c5c;
  --queue: #7b9fd4;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f2ee;
    --surface: #ffffff;
    --surface-2: #f0ece7;
    --border: #ddd;
    --text: #1a1a1a;
    --text-dim: #777;
  }
}

html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

/* === Page header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.page-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* === Bottom navigation === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  position: relative;
  min-width: 52px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active { color: var(--accent); }
.nav-item:hover { color: var(--text); }

/* === Day card (home) === */
.day-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.day-card:hover { background: var(--surface-2); }

.day-card-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.day-card-body { flex: 1; }

.day-card-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.day-card-title {
  font-size: 17px;
  font-weight: 600;
}

.day-card-arrow {
  color: var(--accent);
  font-size: 20px;
}

/* === High Times card (home) === */
.ht-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid #5a3a6e;
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.ht-card:hover { background: var(--surface-2); border-color: #8b5ca8; }

.ht-card-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }

.ht-card-body { flex: 1; }

.ht-card-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #c09ad6;
}

.ht-card-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.ht-card-arrow { color: #c09ad6; font-size: 20px; }

/* === High Times page === */
.ht-page { }

.ht-title {
  letter-spacing: 0.08em;
  color: #c09ad6;
}

.ht-mic-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 24px;
  gap: 12px;
}

.ht-mic { border-color: #8b5ca8; }
.ht-mic:hover, .ht-mic.active { background: #3d1f52; border-color: #c09ad6; }

.ht-mic-status {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  min-height: 20px;
}

.ht-textarea { border-color: #5a3a6e; }
.ht-textarea:focus { border-color: #c09ad6; }

.ht-save { background: #8b5ca8; }
.ht-save:hover { background: #73499a; }

/* === Quick actions grid === */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
  position: relative;
}

.quick-btn:hover { background: var(--surface-2); }

.quick-icon { font-size: 18px; }

/* === Entry form === */
.entry-form { display: flex; flex-direction: column; gap: 12px; }

.entry-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.6;
  padding: 14px;
  resize: vertical;
  transition: border-color 0.15s;
}

.entry-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.entry-textarea::placeholder { color: var(--text-dim); }

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* === Selects === */
.select-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  flex: 1;
  min-width: 120px;
}

/* === Buttons === */
.btn-primary {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

.btn-back {
  color: var(--accent);
  font-size: 20px;
  text-decoration: none;
  padding: 4px;
  flex-shrink: 0;
}

/* === Voice bar === */
.voice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-mic-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-mic-inline.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.voice-status { font-size: 13px; color: var(--text-dim); }

/* === Record page === */
.record-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
  gap: 20px;
}

.mic-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.mic-btn svg {
  width: 44px;
  height: 44px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-btn.active {
  background: var(--danger);
  border-color: var(--danger);
  animation: pulse 1.2s infinite;
}

.mic-btn.active svg { stroke: #fff; }

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224,92,92,0.4); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(224,92,92,0); }
}

.mic-status { color: var(--text-dim); font-size: 14px; }

/* Waveform animation */
.waveform {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
}

.waveform span {
  display: block;
  width: 4px;
  background: var(--accent);
  border-radius: 4px;
  animation: wave 0.8s ease-in-out infinite alternate;
}

.waveform span:nth-child(1) { height: 10px; animation-delay: 0s; }
.waveform span:nth-child(2) { height: 24px; animation-delay: 0.1s; }
.waveform span:nth-child(3) { height: 16px; animation-delay: 0.2s; }
.waveform span:nth-child(4) { height: 28px; animation-delay: 0.15s; }
.waveform span:nth-child(5) { height: 12px; animation-delay: 0.05s; }

@keyframes wave {
  from { transform: scaleY(0.4); }
  to { transform: scaleY(1); }
}

/* === Transcript section === */
.transcript-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.subsection-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Upload sections === */
.upload-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.section-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}

.file-drop:hover { border-color: var(--accent); color: var(--accent); }

.upload-status { font-size: 13px; color: var(--text-dim); min-height: 18px; }

.hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint-label {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.image-preview {
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 200px;
}

.image-preview img {
  width: 100%;
  object-fit: cover;
  display: block;
}

/* === Prompt cards === */
.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.queued-card { border-color: var(--queue); }
.prompt-meta { font-size: 11px; color: var(--queue); margin-bottom: 6px; font-weight: 500; }

.prompt-question {
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: 12px;
}

.prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-answer {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 36px;
}

.btn-queue {
  background: transparent;
  border: 1px solid var(--queue);
  border-radius: var(--radius-sm);
  color: var(--queue);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 36px;
}

.btn-reject {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 36px;
}

.answer-area {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answer-area textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px;
  resize: vertical;
}

.answer-controls { display: flex; gap: 8px; }

.btn-save {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.btn-mic {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
}

.answered-label { font-size: 13px; color: var(--success); }
.queued-label { font-size: 13px; color: var(--queue); }

.prompt-card.answered { opacity: 0.5; }
.prompt-card.queued { opacity: 0.7; }

/* === Generate button === */
.btn-generate {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.btn-generate:hover { background: var(--surface-2); }

.gen-label { display: block; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }
.htmx-request .gen-label { display: none; }

/* === Recent / entry cards === */
.recent-section { margin-top: 8px; }

.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.entry-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.entry-text { font-size: 14px; line-height: 1.55; color: var(--text); }

/* === Toast === */
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}

.toast.success { background: rgba(76,175,132,0.15); color: var(--success); border: 1px solid rgba(76,175,132,0.3); }
.toast.error { background: rgba(224,92,92,0.15); color: var(--danger); border: 1px solid rgba(224,92,92,0.3); }

/* === Badge === */
.badge {
  background: var(--accent);
  color: #0f0f0f;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  line-height: 16px;
  position: absolute;
  top: 4px;
  right: 4px;
}

.quick-btn .badge { position: static; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

/* === Login page === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-mark {
  font-size: 40px;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: -8px;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.login-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 14px 16px;
  text-align: center;
  letter-spacing: 2px;
}

.login-input:focus { outline: none; border-color: var(--accent); }

.login-btn {
  width: 100%;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.login-btn:hover { background: var(--accent-dim); }

.login-error {
  width: 100%;
  background: rgba(224,92,92,0.15);
  border: 1px solid rgba(224,92,92,0.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  text-align: center;
}
