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

:root {
  --sand: #e8d5b7;
  --dust: #c4a882;
  --burnt: #8b4513;
  --ember: #d4722a;
  --night: #1a1a2e;
  --deep: #0f0f1a;
  --bone: #f5f0e8;
  --ghost: rgba(255, 255, 255, 0.08);
  --text: #f5f0e8;
  --text-dim: rgba(245, 240, 232, 0.6);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at top center, rgba(218, 120, 43, 0.18), transparent 35%),
    radial-gradient(circle at bottom center, rgba(245, 196, 114, 0.08), transparent 40%),
    #090913;
  color: var(--text);
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

header {
  text-align: center;
  padding: 40px 0 28px;
}

header .archive-label {
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: #d9a85c;
  text-transform: uppercase;
  margin-bottom: 14px;
  font-weight: 500;
}

header h1 {
  font-size: clamp(2.4rem, 5vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #f4dfb8;
  line-height: 1.05;
  text-shadow: 0 0 30px rgba(218, 120, 43, 0.18);
}

header .tagline {
  font-size: 15px;
  color: rgba(216, 199, 168, 0.7);
  margin-top: 14px;
  font-style: italic;
  line-height: 1.5;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

.card {
  background: rgba(35, 33, 42, 0.86);
  border: 1px solid rgba(244, 223, 184, 0.12);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  padding: 28px 24px;
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #e07a2d, #c65a1e);
  box-shadow: 0 14px 35px rgba(224, 122, 45, 0.28);
  color: white;
  border-radius: 18px;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 16px 28px;
  transition: all 0.25s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 45px rgba(224, 122, 45, 0.38);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--ghost);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }

.btn-danger {
  background: #8b2020;
  color: white;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Recording UI */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 0;
}

.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--ember);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.record-btn .inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ember);
  transition: all 0.3s;
}

.record-btn.recording .inner {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #e04040;
}

.record-btn.recording {
  border-color: #e04040;
  animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 64, 64, 0.3); }
  50% { box-shadow: 0 0 0 16px rgba(224, 64, 64, 0); }
}

.timer {
  font-size: 48px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--sand);
}

.timer-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.timer-bar .fill {
  height: 100%;
  background: var(--ember);
  transition: width 0.5s linear;
  border-radius: 2px;
}

.timer-bar .fill.warning { background: #e04040; }

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

/* Countdown overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 100;
}

.countdown-overlay .number {
  font-size: 120px;
  font-weight: 200;
  color: var(--ember);
  animation: countdown-pop 0.6s ease-out;
}

.countdown-overlay .label {
  font-size: 18px;
  color: var(--text-dim);
}

@keyframes countdown-pop {
  0% { transform: scale(1.6); opacity: 0; }
  60% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.form-group input[type="text"],
.form-group input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--ember);
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--ember);
}

.checkbox-group label {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.4;
  cursor: pointer;
}

.checkbox-group label.required { color: var(--text); }

/* Consent scroll box */
.consent-scroll {
  max-height: 180px;
  overflow-y: auto;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}
.consent-scroll h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.consent-scroll p { margin-bottom: 10px; }
.consent-scroll p:last-child { margin-bottom: 0; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Success */
.success-screen {
  text-align: center;
  padding: 40px 0;
}

.success-screen .check {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 40px;
}

.success-screen h2 {
  font-size: 24px;
  color: var(--sand);
  margin-bottom: 8px;
}

.success-screen p {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.category-btn {
  background: rgba(35, 33, 42, 0.86);
  border: 1px solid rgba(244, 223, 184, 0.1);
  border-radius: 14px;
  padding: 16px 14px;
  color: #d8c7a8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}
.category-btn:hover {
  border-color: rgba(244, 223, 184, 0.25);
  background: rgba(45, 43, 52, 0.9);
}
.category-btn.selected {
  border-color: #d9a85c;
  background: rgba(217, 168, 92, 0.12);
  color: #f4dfb8;
  box-shadow: 0 0 20px rgba(217, 168, 92, 0.1);
}

@media (max-width: 380px) {
  .category-grid { grid-template-columns: 1fr; }
}

/* Prompt styles */
.btn-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: rgba(244, 223, 184, 0.06);
  border: 1px dashed rgba(244, 223, 184, 0.2);
  border-radius: 16px;
  color: #d9a85c;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 16px;
  -webkit-tap-highlight-color: transparent;
}
.btn-prompt:hover {
  background: rgba(244, 223, 184, 0.1);
  border-color: rgba(244, 223, 184, 0.3);
}

.selected-prompt {
  background: rgba(244, 223, 184, 0.06);
  border: 1px solid rgba(244, 223, 184, 0.12);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 16px;
}
.selected-prompt .prompt-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #d9a85c;
  margin-bottom: 6px;
  font-weight: 500;
}
.selected-prompt .prompt-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}
.selected-prompt .prompt-change {
  font-size: 12px;
  color: #d9a85c;
  cursor: pointer;
  margin-top: 8px;
  display: inline-block;
}

/* Prompt modal */
.prompt-modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 19, 0.92);
  z-index: 90;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.prompt-modal.open { display: block; }
.prompt-modal-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.prompt-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.prompt-modal-header h2 {
  font-size: 22px;
  color: #f4dfb8;
}
.prompt-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prompt-card {
  background: rgba(35, 33, 42, 0.86);
  border: 1px solid rgba(244, 223, 184, 0.1);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.prompt-card:hover, .prompt-card:active {
  border-color: rgba(244, 223, 184, 0.25);
  background: rgba(45, 43, 52, 0.9);
}
.prompt-card .prompt-title {
  font-size: 15px;
  font-weight: 600;
  color: #f4dfb8;
  margin-bottom: 4px;
}
.prompt-card .prompt-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
.prompt-card.special {
  border-style: dashed;
  text-align: center;
}
.prompt-card.special .prompt-title {
  color: #d9a85c;
}

/* Recording prompt banner */
.recording-prompt {
  background: rgba(244, 223, 184, 0.06);
  border: 1px solid rgba(244, 223, 184, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  text-align: center;
}
.recording-prompt .prompt-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #d9a85c;
  margin-bottom: 4px;
}
.recording-prompt .prompt-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Saving overlay */
.saving-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 100;
}
.saving-overlay .spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--ember);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.saving-overlay .label {
  font-size: 16px;
  color: var(--text-dim);
}

/* Footer */
footer {
  text-align: center;
  padding: 24px 0;
  font-size: 12px;
  color: var(--text-dim);
}

footer a { color: var(--dust); }

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

.admin-header h2 {
  font-size: 20px;
  color: var(--sand);
}

.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat .num {
  font-size: 28px;
  font-weight: 600;
  color: var(--sand);
}

.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--ember);
  color: white;
  border-color: var(--ember);
}

.story-card {
  background: var(--ghost);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.story-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.story-card .meta .name {
  font-weight: 600;
  color: var(--sand);
}

.story-card .meta .date {
  font-size: 12px;
  color: var(--text-dim);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-new { background: rgba(255, 193, 7, 0.2); color: #ffc107; }
.badge-incomplete { background: rgba(158, 158, 158, 0.2); color: #9e9e9e; }
.badge-private_archive { background: rgba(100, 181, 246, 0.2); color: #64b5f6; }
.badge-approved { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.badge-rejected { background: rgba(244, 67, 54, 0.2); color: #f44336; }
.badge-exported { background: rgba(171, 71, 188, 0.2); color: #ab47bc; }

.story-card audio {
  width: 100%;
  margin: 10px 0;
  border-radius: 6px;
}

.story-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.story-card .detail {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.admin-login {
  max-width: 360px;
  margin: 80px auto;
  text-align: center;
}

.admin-login h2 {
  color: var(--sand);
  margin-bottom: 20px;
}

.export-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

@media (min-width: 768px) {
  .container { max-width: 600px; padding: 32px; }
  .admin-container { max-width: 800px; }
}
