/* ForeverWords — Cream, White, Gold palette */

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

:root {
  --cream:   #F5F0E8;
  --white:   #FFFFFF;
  --gold:    #D4AF37;
  --gold-dk: #B8962F;
  --text:    #2C2416;
  --muted:   #7A7060;
  --border:  #E0D9CC;
  --shadow:  0 2px 8px rgba(44,36,22,.10);
  --radius:  8px;
  font-size: 16px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Typography ───────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; }
a { color: var(--gold-dk); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--gold);
  color: var(--white);
}
.btn-primary:hover { background: var(--gold-dk); text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold-dk);
}
.btn-outline:hover { background: var(--gold); color: var(--white); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); text-decoration: none; }

.btn-danger {
  background: #c0392b;
  color: var(--white);
}
.btn-danger:hover { background: #a93226; }

.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }

/* ── Form elements ────────────────────────────────── */
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  transition: border-color .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
}
label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: .9rem;
  color: var(--text);
}
.form-group { margin-bottom: 20px; }
.form-error { color: #c0392b; font-size: .85rem; margin-top: 4px; }

/* ── Navbar ────────────────────────────────────────── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-dk);
  letter-spacing: -.5px;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-nav { display: flex; align-items: center; gap: 12px; }
.navbar-user { font-size: .85rem; color: var(--muted); }

/* ── Layout containers ─────────────────────────────── */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}
.container-narrow {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ── Letter list ───────────────────────────────────── */
.letter-list { display: flex; flex-direction: column; gap: 12px; }
.letter-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  transition: box-shadow .2s, border-color .2s;
  cursor: pointer;
}
.letter-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(212,175,55,.12);
}
.letter-card-body { flex: 1; min-width: 0; }
.letter-card-subject {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.letter-card-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.letter-card-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.status-draft    { background: #F0EBE0; color: #8A7355; }
.status-published { background: #E8F5E0; color: #4A7C3F; }

/* ── Auth pages ────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 24px;
}
.auth-card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(44,36,22,.10);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo h1 {
  font-size: 1.8rem;
  color: var(--gold-dk);
}
.auth-logo p {
  color: var(--muted);
  margin-top: 4px;
  font-size: .9rem;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: .85rem;
  color: var(--muted);
}

/* ── Letter editor ─────────────────────────────────── */
.editor-page {
  min-height: 100vh;
  background: var(--cream);
  padding: 32px 24px 80px;
}
.editor-header {
  max-width: 740px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.editor-subject-wrap { margin-bottom: 16px; }
.editor-subject {
  font-size: 1.4rem;
  font-weight: 600;
  border: none;
  background: transparent;
  width: 100%;
  padding: 8px 0;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}
.editor-subject:focus { outline: none; border-bottom-color: var(--gold); }
.editor-subject::placeholder { color: var(--muted); }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}
.toolbar-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.toolbar-btn:hover { background: var(--cream); color: var(--text); }
.toolbar-btn.active { background: var(--gold); color: var(--white); }

.toolbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.editor-body {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 420px;
  padding: 24px;
  font-size: 1.05rem;
  line-height: 1.8;
}
.editor-content {
  min-height: 380px;
  outline: none;
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}
.editor-content p { margin-bottom: 1em; }
.editor-content b, .editor-content strong { font-weight: 700; }
.editor-content i, .editor-content em { font-style: italic; }
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.editor-footer {
  max-width: 740px;
  margin: 20px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.autosave-indicator {
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.autosave-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ccc;
  transition: background .3s;
}
.autosave-dot.saving { background: var(--gold); }
.autosave-dot.saved  { background: #6aaa6e; }

/* ── Photo attachments ──────────────────────────────── */
.attachments-area { margin-top: 20px; }
.attachments-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.attachment-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color .2s;
}
.attachment-thumb:hover { border-color: var(--gold); }
.attachment-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(192,57,43,.85);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.attachment-remove:hover { background: #c0392b; }

.add-photo-btn {
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--muted);
  font-size: .75rem;
  transition: border-color .2s, color .2s;
  background: transparent;
  font-family: inherit;
}
.add-photo-btn:hover { border-color: var(--gold); color: var(--gold-dk); }
.add-photo-btn .icon { font-size: 1.4rem; }

.hidden-input { display: none; }

/* ── Preview page ──────────────────────────────────── */
.preview-page {
  min-height: 100vh;
  background: var(--cream);
  padding: 32px 24px 80px;
}
.letter-paper {
  max-width: 680px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(44,36,22,.10);
  padding: 56px 64px;
  font-size: 1.1rem;
  line-height: 1.9;
}
.letter-paper h1 {
  font-size: 1.6rem;
  margin-bottom: 24px;
  color: var(--text);
}
.letter-paper .content { white-space: pre-wrap; }
.letter-paper .content b { font-weight: 700; }
.letter-paper .content i { font-style: italic; }
.letter-paper-images {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.letter-paper-images img {
  max-width: 260px;
  max-height: 260px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.letter-paper-recordings {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.recordings-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 12px;
}
.preview-recording {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.rec-duration {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-top: 4px;
}
.preview-actions {
  max-width: 680px;
  margin: 24px auto 0;
  display: flex;
  gap: 12px;
}

/* ── Empty states ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: .9rem; max-width: 360px; margin: 0 auto 24px; }

/* ── Dashboard header ──────────────────────────────── */
.dashboard-header {
  max-width: 800px;
  margin: 40px auto 32px;
  padding: 0 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.dashboard-header h2 { font-size: 1.6rem; color: var(--text); }
.dashboard-welcome { font-size: .9rem; color: var(--muted); margin-bottom: 4px; }

/* ── Utilities ─────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }

/* ── Voice Recording ────────────────────────────────────── */
.vr-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.vr-add-btn:hover { border-color: var(--gold); color: var(--gold-dk); }

.voice-recordings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-recording-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .2s;
}
.voice-recording-item:hover { border-color: var(--gold); }

.vr-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
.vr-play-btn:hover { background: var(--gold-dk); transform: scale(1.08); }
.vr-play-btn.playing { background: var(--text); }

.vr-info { flex: 1; min-width: 0; }
.vr-label { font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.vr-waveform-mini { margin-top: 4px; }

.vr-duration { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.vr-remove {
  width: 24px; height: 24px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, color .2s, background .2s;
  flex-shrink: 0;
}
.vr-remove:hover { border-color: #c0392b; color: #c0392b; background: #fde8e8; }

/* ── Voice Recording Modal ───────────────────────────────── */
.voice-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44,36,22,.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.voice-modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 16px 48px rgba(44,36,22,.18);
  overflow: hidden;
}

.voice-modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.voice-modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.voice-modal-close {
  width: 30px; height: 30px;
  border: none; background: var(--cream);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.voice-modal-close:hover { color: var(--text); }

.voice-recorder-body { padding: 28px 24px; }

.vr-state {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.vr-idle { display: flex; }
.vr-idle-icon { margin-bottom: 8px; }
.vr-idle-hint { font-size: .88rem; color: var(--muted); }

.vr-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 40px;
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .15s;
  margin-top: 8px;
}
.vr-start-btn:hover { background: var(--gold-dk); transform: scale(1.03); }
.vr-start-icon {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
}

.vr-recording { display: flex; }

.vr-recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.vr-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #c0392b;
  animation: pulse-red 1s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.85); }
}
.vr-rec-text { font-size: .82rem; font-weight: 700; color: #c0392b; text-transform: uppercase; letter-spacing: .5px; }

.vr-timer {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  font-family: 'Georgia', serif;
}

.vr-waveform-container {
  width: 100%;
  background: var(--cream);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.vr-waveform-container canvas { display: block; width: 100%; height: 80px; }

.vr-stop-btn {
  padding: 12px 28px;
  background: #c0392b;
  color: var(--white);
  border: none;
  border-radius: 40px;
  font-size: .9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.vr-stop-btn:hover { background: #a93226; transform: scale(1.03); }

.vr-max-hint { font-size: .78rem; color: var(--muted); }

.vr-preview { display: flex; }
.vr-preview-label { font-size: .85rem; font-weight: 700; color: var(--text); }
.vr-preview-actions { display: flex; gap: 12px; justify-content: center; margin-top: 4px; }

.vr-error { display: flex; }
.vr-error-msg { font-size: .88rem; color: #c0392b; max-width: 340px; }

.voice-modal-footer {
  padding: 12px 24px;
  background: var(--cream);
  border-top: 1px solid var(--border);
}
.vr-help-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--muted);
}