/* ============================================================
   MIRAGE — Letters to your future self
   Palette: midnight-pearl + copper
   © Ofir Baranes 2026
============================================================ */

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

:root {
  /* Backgrounds */
  --ink: #0b0d1a;
  --ink-2: #131628;
  --ink-3: #1a1d34;
  --plum: #2a1f3d;
  --plum-deep: #1a1228;
  --plum-soft: #3a2a52;

  /* Foreground */
  --pearl: #ede4d3;
  --pearl-2: #d4cbb8;
  --pearl-dim: #8a8472;
  --pearl-muted: #5a5648;

  /* Accents */
  --copper: #c08552;
  --copper-glow: #e8a872;
  --copper-deep: #8d5a32;
  --copper-soft: #d4a37a;

  /* Glass / borders */
  --glass-1: rgba(42, 31, 61, 0.45);
  --glass-2: rgba(26, 18, 40, 0.65);
  --glass-3: rgba(58, 42, 82, 0.35);
  --border: rgba(232, 168, 114, 0.16);
  --border-strong: rgba(232, 168, 114, 0.32);
  --line: rgba(237, 228, 211, 0.06);

  /* Semantic */
  --ok: #6ec6a1;
  --warn: #e3b95a;
  --err: #d97a6c;
  --info: #8b9eb8;

  /* Springs */
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --easeio: cubic-bezier(.4, 0, .2, 1);

  /* Type */
  --serif: 'Frank Ruhl Libre', 'Heebo', serif;
  --serif-i: 'Instrument Serif', serif;
  --sans: 'Heebo', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

html, body {
  background: var(--ink);
  color: var(--pearl);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse at 80% -10%, rgba(192, 133, 82, 0.10), transparent 50%),
    radial-gradient(ellipse at -10% 30%, rgba(58, 42, 82, 0.45), transparent 50%),
    radial-gradient(ellipse at 50% 110%, rgba(192, 133, 82, 0.06), transparent 50%),
    var(--ink);
  background-attachment: fixed;
  padding-bottom: 100px;
}

img { max-width: 100%; display: block; }
button { background: none; border: none; color: inherit; cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; color: inherit; }

/* ============================================================
   AMBIENT — orbs + grain
============================================================ */
.ambient {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.5;
  animation: orbFloat 22s ease-in-out infinite;
}
.orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(192, 133, 82, 0.28), transparent 70%);
  top: -200px; right: -150px;
}
.orb-2 {
  width: 540px; height: 540px;
  background: radial-gradient(circle, rgba(58, 42, 82, 0.55), transparent 70%);
  bottom: 10%; left: -200px;
  animation-delay: -8s;
}
.orb-3 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(232, 168, 114, 0.18), transparent 70%);
  top: 45%; right: -120px;
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-30px, 40px) scale(1.05); }
  66% { transform: translate(40px, -30px) scale(0.95); }
}

.grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.85  0 0 0 0 0.7  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  background: linear-gradient(180deg, rgba(11, 13, 26, 0.88) 0%, rgba(11, 13, 26, 0.4) 100%);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  filter: drop-shadow(0 4px 12px rgba(192, 133, 82, 0.4));
}
.brand-text {
  display: flex; flex-direction: column; line-height: 1;
}
.brand-name {
  font-family: var(--serif);
  font-size: 22px; font-weight: 500;
  color: var(--pearl);
  letter-spacing: 0.5px;
}
.brand-tag {
  font-family: var(--serif-i);
  font-style: italic;
  font-size: 14px;
  color: var(--copper);
  margin-top: 2px;
}
.top-actions { display: flex; gap: 8px; }
.ic-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--glass-1);
  backdrop-filter: blur(10px);
  color: var(--pearl-2);
  transition: all 0.3s var(--spring);
}
.ic-btn:hover {
  background: var(--glass-3);
  border-color: var(--border-strong);
  color: var(--copper-glow);
  transform: translateY(-1px);
}
.ic-btn:active { transform: scale(0.95); }
.ic-btn.small { width: 32px; height: 32px; border-radius: 10px; }
.ic-btn svg { width: 18px; height: 18px; }

/* ============================================================
   MAIN
============================================================ */
#app {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
}

.view { animation: viewIn 0.5s var(--easeio); }
.view.hidden { display: none; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head {
  padding: 24px 4px 18px;
  text-align: right;
}
.view-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: 0.3px;
  color: var(--pearl);
}
.view-sub {
  color: var(--pearl-dim);
  font-size: 14px;
  margin-top: 4px;
}

/* ============================================================
   HERO
============================================================ */
.hero {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid var(--border);
  box-shadow: 0 28px 64px -24px rgba(0, 0, 0, 0.6);
}
.hero-img-wrap {
  position: absolute; inset: 0; z-index: 0;
}
.hero-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  filter: saturate(95%) brightness(0.6);
}
.hero-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(115deg, rgba(11, 13, 26, 0.85) 0%, rgba(11, 13, 26, 0.45) 60%, rgba(192, 133, 82, 0.08) 100%),
    linear-gradient(to top, rgba(11, 13, 26, 0.7), transparent 60%);
}

.hero-stars { position: absolute; inset: 0; pointer-events: none; }
.hero-stars::before, .hero-stars::after {
  content: ''; position: absolute;
  background-image:
    radial-gradient(1px 1px at 20% 30%, var(--pearl), transparent),
    radial-gradient(1px 1px at 80% 50%, var(--copper-glow), transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, var(--pearl-2), transparent),
    radial-gradient(1px 1px at 60% 20%, var(--pearl-dim), transparent),
    radial-gradient(1px 1px at 90% 80%, var(--copper-soft), transparent);
  inset: 0;
  opacity: 0.7;
  animation: starShimmer 4s ease-in-out infinite alternate;
}
.hero-stars::after { animation-delay: -2s; opacity: 0.4; }

@keyframes starShimmer {
  from { opacity: 0.3; }
  to { opacity: 0.8; }
}

.hero-content {
  position: relative; z-index: 1;
  padding: 56px 28px 36px;
  min-height: 360px;
  display: flex; flex-direction: column; justify-content: flex-end;
}

.kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--copper-glow);
  margin-bottom: 14px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  width: fit-content;
  background: rgba(11, 13, 26, 0.4);
  backdrop-filter: blur(4px);
}

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.5px;
  color: var(--pearl);
  margin-bottom: 18px;
}
.serif-italic {
  font-family: var(--serif-i);
  font-style: italic;
  color: var(--copper-soft);
  font-weight: 400;
}
.copper { color: var(--copper-glow); }

.hero-sub {
  font-size: 15px;
  line-height: 1.6;
  color: var(--pearl-2);
  margin-bottom: 24px;
  max-width: 440px;
}
.dim { color: var(--pearl-dim); }

.hero-cta-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px;
  font-family: var(--sans);
  font-size: 14px; font-weight: 500;
  color: var(--ink);
  background: linear-gradient(135deg, var(--copper-glow) 0%, var(--copper) 60%, var(--copper-deep) 100%);
  border-radius: 14px;
  box-shadow:
    0 12px 28px -8px rgba(192, 133, 82, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: all 0.3s var(--spring);
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 18px 36px -8px rgba(192, 133, 82, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary svg { width: 16px; height: 16px; stroke-width: 1.8; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px;
  font-size: 14px; font-weight: 500;
  color: var(--pearl-2);
  background: var(--glass-1);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  transition: all 0.3s var(--spring);
}
.btn-ghost:hover {
  background: var(--glass-3);
  border-color: var(--border-strong);
  color: var(--pearl);
  transform: translateY(-1px);
}
.btn-ghost:active { transform: scale(0.98); }

.link-btn {
  font-size: 13px;
  color: var(--copper-glow);
  font-weight: 400;
  letter-spacing: 0.3px;
  transition: color 0.2s;
}
.link-btn:hover { color: var(--copper-soft); }

/* ============================================================
   STATS ROW
============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.stat-card {
  position: relative;
  padding: 14px 12px 12px;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  text-align: right;
  transition: all 0.4s var(--easeio);
}
.stat-card:hover {
  background: var(--glass-3);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.stat-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--pearl-dim);
  margin-bottom: 6px;
}
.stat-num {
  display: flex; align-items: baseline; gap: 5px;
  font-family: var(--serif);
  font-size: 26px; font-weight: 500;
  color: var(--pearl);
  line-height: 1;
}
.stat-mini {
  font-size: 10px;
  color: var(--pearl-dim);
  font-family: var(--sans);
  font-weight: 300;
}
.stat-spark {
  position: absolute;
  bottom: 6px; left: 8px; right: 8px;
  width: calc(100% - 16px);
  height: 14px;
  opacity: 0.7;
}

/* ============================================================
   PANELS
============================================================ */
.dual-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.panel {
  padding: 18px 18px 16px;
  background: var(--glass-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  backdrop-filter: blur(14px);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--pearl);
}
.head-hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--pearl-dim);
  text-transform: uppercase;
}

.soon-list, .recent-list {
  display: flex; flex-direction: column; gap: 9px;
}
.soon-item, .recent-item {
  padding: 11px 12px;
  background: rgba(11, 13, 26, 0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: all 0.3s var(--spring);
  cursor: pointer;
}
.soon-item:hover, .recent-item:hover {
  background: rgba(42, 31, 61, 0.6);
  border-color: var(--border);
  transform: translateX(-2px);
}
.soon-item-title, .recent-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--pearl);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.soon-item-meta, .recent-item-meta {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--pearl-dim);
}
.soon-item-meta .copper-text {
  color: var(--copper-glow);
  font-weight: 500;
}
.empty-mini {
  padding: 16px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--pearl-dim);
}

/* Prompt panel */
.panel-prompt {
  margin-top: 16px;
  background: linear-gradient(135deg, rgba(192, 133, 82, 0.10) 0%, rgba(42, 31, 61, 0.55) 100%);
  border: 1px solid var(--border-strong);
}
.prompt-text {
  font-family: var(--serif-i);
  font-style: italic;
  font-size: 19px;
  line-height: 1.5;
  color: var(--pearl);
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.btn-prompt-use {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--copper-glow);
  padding: 6px 0;
  transition: color 0.2s;
}
.btn-prompt-use:hover { color: var(--copper-soft); }
.btn-prompt-use svg { width: 14px; height: 14px; }

/* ============================================================
   COMPOSE
============================================================ */
.compose-card {
  background: var(--glass-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.paper {
  background:
    linear-gradient(135deg, rgba(237, 228, 211, 0.04) 0%, rgba(237, 228, 211, 0.02) 100%),
    repeating-linear-gradient(
      transparent,
      transparent 30px,
      rgba(237, 228, 211, 0.04) 30px,
      rgba(237, 228, 211, 0.04) 31px
    );
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.paper::before {
  content: ''; position: absolute;
  top: 0; right: 22px;
  width: 1px; height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(217, 122, 108, 0.25), transparent);
}
.paper-meta {
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
  margin-bottom: 12px;
}
.paper-from .serif-italic { font-size: 14px; }
.paper-title {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  color: var(--pearl);
  padding: 6px 0 8px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
  direction: rtl;
}
.paper-title::placeholder { color: var(--pearl-muted); font-style: italic; font-family: var(--serif-i); font-weight: 400; }
#composeBody {
  width: 100%;
  min-height: 160px;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  color: var(--pearl);
  padding: 4px 0;
  direction: rtl;
}
#composeBody::placeholder { color: var(--pearl-muted); }
.paper-footer {
  margin-top: 8px;
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
}

.compose-meta {
  padding: 18px 22px 4px;
  display: flex; flex-direction: column; gap: 16px;
}
.meta-block {}
.meta-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--pearl-dim);
  margin-bottom: 9px;
}
.meta-hint { letter-spacing: 0.5px; font-weight: 300; text-transform: none; opacity: 0.7; }

.mood-row, .when-row {
  display: flex; flex-wrap: wrap; gap: 7px;
}
.mood-chip, .when-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--pearl-2);
  background: rgba(11, 13, 26, 0.4);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.3s var(--spring);
}
.mood-chip:hover, .when-chip:hover {
  background: var(--glass-3);
  border-color: var(--border);
  transform: translateY(-1px);
}
.mood-chip.selected, .when-chip.selected {
  background: linear-gradient(135deg, rgba(192, 133, 82, 0.22) 0%, rgba(192, 133, 82, 0.1) 100%);
  border-color: var(--copper);
  color: var(--copper-glow);
  box-shadow: 0 0 0 1px rgba(192, 133, 82, 0.3), 0 6px 14px -4px rgba(192, 133, 82, 0.35);
}
.mood-chip svg { width: 14px; height: 14px; }

.custom-date {
  margin-top: 9px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(11, 13, 26, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--pearl);
  font-family: var(--mono);
  font-size: 13px;
  color-scheme: dark;
}
.custom-date.hidden { display: none; }

.open-on {
  margin-top: 10px;
  font-family: var(--serif-i);
  font-style: italic;
  font-size: 14px;
  color: var(--copper-soft);
}

.tag-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(11, 13, 26, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--pearl);
  font-size: 13px;
  outline: none;
  direction: rtl;
  transition: border-color 0.2s;
}
.tag-input:focus { border-color: var(--copper); }
.tag-input::placeholder { color: var(--pearl-muted); }

.compose-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 22px 22px;
  border-top: 1px solid var(--line);
  background: rgba(11, 13, 26, 0.3);
}

/* ============================================================
   VAULT / SEALED
============================================================ */
.filter-row {
  display: flex; gap: 7px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.filter-chip {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--pearl-dim);
  background: var(--glass-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.3s var(--spring);
}
.filter-chip:hover { color: var(--pearl); border-color: var(--border); }
.filter-chip.selected {
  background: linear-gradient(135deg, rgba(192, 133, 82, 0.2), rgba(192, 133, 82, 0.08));
  color: var(--copper-glow);
  border-color: var(--copper);
}

.vault-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.envelope {
  position: relative;
  padding: 16px 16px 14px;
  background: linear-gradient(135deg, rgba(42, 31, 61, 0.65) 0%, rgba(26, 18, 40, 0.55) 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: all 0.4s var(--spring);
  cursor: pointer;
  min-height: 170px;
}
.envelope::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 40%;
  background: linear-gradient(180deg, rgba(192, 133, 82, 0.10) 0%, transparent 100%);
  pointer-events: none;
}
.envelope::after {
  content: ''; position: absolute;
  top: -16px; right: -16px;
  width: 60px; height: 60px;
  background: radial-gradient(circle, var(--copper) 0%, var(--copper-deep) 50%, transparent 80%);
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.3;
}
.envelope:hover {
  transform: translateY(-3px) rotate(-0.5deg);
  border-color: var(--copper);
  box-shadow: 0 20px 40px -16px rgba(192, 133, 82, 0.4), 0 0 0 1px rgba(192, 133, 82, 0.2);
}
.envelope:hover::after { opacity: 0.55; }
.env-seal {
  position: absolute;
  top: 12px; right: 12px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--copper-glow), var(--copper), var(--copper-deep));
  box-shadow: 0 3px 8px rgba(192, 133, 82, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  display: grid; place-items: center;
}
.env-seal svg { width: 14px; height: 14px; color: var(--ink); }

.env-mood {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--copper-glow);
  margin-bottom: 8px;
  padding-left: 30px;
}
.env-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.3;
  color: var(--pearl);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}
.env-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--line), transparent);
  margin: 10px 0;
}
.env-countdown {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
  display: flex; flex-direction: column; gap: 2px;
}
.env-days {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  color: var(--copper-glow);
  letter-spacing: 0.5px;
}
.env-days-label { font-size: 11px; color: var(--pearl-dim); font-family: var(--mono); }
.env-date {
  font-size: 10px;
  color: var(--pearl-muted);
  font-family: var(--mono);
  margin-top: 3px;
}

/* ============================================================
   DELIVERED / INBOX
============================================================ */
.inbox-list {
  display: flex; flex-direction: column; gap: 10px;
}
.inbox-item {
  padding: 16px 18px;
  background: var(--glass-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  transition: all 0.3s var(--spring);
  cursor: pointer;
  display: flex; gap: 14px; align-items: flex-start;
}
.inbox-item:hover {
  background: var(--glass-3);
  border-color: var(--border-strong);
  transform: translateX(-2px);
}
.inbox-item.unread { border-left: 3px solid var(--copper); }
.inbox-glyph {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--plum-soft), var(--plum));
  display: grid; place-items: center;
  color: var(--copper-glow);
  border: 1px solid var(--border);
}
.inbox-glyph svg { width: 16px; height: 16px; }
.inbox-content { flex: 1; min-width: 0; }
.inbox-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  color: var(--pearl);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.inbox-preview {
  font-size: 12px;
  color: var(--pearl-dim);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inbox-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--pearl-muted);
}
.inbox-mood-badge {
  color: var(--copper-glow);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* ============================================================
   EMPTY STATES
============================================================ */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  background: var(--glass-1);
  border: 1px dashed var(--border);
  border-radius: 22px;
  backdrop-filter: blur(10px);
}
.empty-svg {
  width: 100px; height: 100px;
  margin: 0 auto 16px;
  opacity: 0.85;
  animation: orbFloat 6s ease-in-out infinite;
}
.empty-state h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  color: var(--pearl);
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 13px;
  color: var(--pearl-dim);
  margin-bottom: 18px;
}

/* ============================================================
   INSIGHTS
============================================================ */
.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.insight-card {
  padding: 20px 22px;
  background: var(--glass-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  backdrop-filter: blur(14px);
}

/* Timeline */
.timeline-wrap {
  position: relative;
  height: 130px;
  margin: 8px 0 14px;
  background: linear-gradient(180deg, rgba(11, 13, 26, 0.4) 0%, transparent 100%);
  border-radius: 12px;
  overflow: hidden;
}
.timeline-wrap svg { width: 100%; height: 100%; display: block; }
.timeline-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
}
.timeline-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-past { background: var(--pearl-2); }
.dot-now { background: var(--copper-glow); }
.dot-future { background: var(--copper); opacity: 0.6; }

/* Donut */
.donut-wrap {
  position: relative;
  width: 180px; height: 180px;
  margin: 8px auto 16px;
}
.donut-wrap svg { width: 100%; height: 100%; }
.donut-center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  align-content: center;
  text-align: center;
  pointer-events: none;
}
.donut-center #donutTotal {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 38px;
  color: var(--pearl);
  line-height: 1;
}
.donut-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--pearl-dim);
  margin-top: 4px;
}
.mood-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--pearl-2);
}
.mood-legend > span {
  display: flex; align-items: center; gap: 7px;
}
.mood-legend i {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.legend-num {
  margin-right: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
}

/* Heatmap */
.heat-wrap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin: 10px 0 12px;
}
.heat-col {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
}
.heat-cell {
  display: block;
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(237, 228, 211, 0.06);
  border: 1px solid var(--line);
}
.heat-1 { background: rgba(192, 133, 82, 0.25); }
.heat-2 { background: rgba(192, 133, 82, 0.45); }
.heat-3 { background: rgba(192, 133, 82, 0.7); }
.heat-4 { background: var(--copper-glow); box-shadow: 0 0 8px rgba(232, 168, 114, 0.4); }
.heat-scale {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--pearl-dim);
}
.heat-scale .heat-cell { width: 12px; height: 12px; aspect-ratio: auto; }

/* Numbers panel */
.num-rows { display: flex; flex-direction: column; gap: 10px; }
.num-row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.num-row:last-child { border: none; }
.num-key {
  font-size: 13px;
  color: var(--pearl-dim);
}
.num-val {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  color: var(--copper-glow);
}

/* ============================================================
   BOTTOM NAV
============================================================ */
.bottom-nav {
  position: fixed; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(11, 13, 26, 0.78);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 100px;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.02) inset;
  min-width: 320px;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 14px;
  color: var(--pearl-dim);
  border-radius: 18px;
  transition: all 0.3s var(--spring);
  position: relative;
  flex: 1;
}
.nav-btn svg { width: 20px; height: 20px; transition: all 0.3s var(--spring); }
.nav-btn span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.nav-btn:hover { color: var(--pearl); }
.nav-btn.selected {
  color: var(--copper-glow);
}
.nav-btn.selected svg {
  filter: drop-shadow(0 2px 8px rgba(232, 168, 114, 0.5));
  transform: translateY(-1px);
}

.nav-fab {
  position: relative;
  width: 52px; height: 52px;
  margin: 0 4px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--copper-glow) 0%, var(--copper) 60%, var(--copper-deep) 100%);
  color: var(--ink);
  box-shadow:
    0 8px 24px -4px rgba(192, 133, 82, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.4s var(--spring);
  flex-shrink: 0;
  transform: translateY(-8px);
}
.nav-fab:hover {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 0 14px 28px -4px rgba(192, 133, 82, 0.7);
}
.nav-fab:active { transform: translateY(-6px) scale(0.95); }
.nav-fab svg {
  width: 22px; height: 22px;
  position: relative; z-index: 2;
}
.fab-glow {
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 168, 114, 0.4), transparent 70%);
  filter: blur(8px);
  z-index: -1;
  animation: fabPulse 2.5s ease-in-out infinite;
}
@keyframes fabPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

/* ============================================================
   MODALS
============================================================ */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: grid; place-items: center;
  padding: 20px;
  animation: modalFade 0.3s ease;
}
.modal[hidden] { display: none; }
.modal-back {
  position: absolute; inset: 0;
  background: rgba(11, 13, 26, 0.75);
  backdrop-filter: blur(12px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px 28px 24px;
  background: linear-gradient(135deg, rgba(42, 31, 61, 0.9) 0%, rgba(26, 18, 40, 0.95) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.8);
  animation: modalUp 0.4s var(--spring);
}
.modal-x {
  position: absolute; top: 12px; left: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(11, 13, 26, 0.5);
  border: 1px solid var(--line);
  color: var(--pearl-2);
  font-size: 22px;
  line-height: 1;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.modal-x:hover { background: var(--glass-3); color: var(--copper-glow); }

.modal-logo {
  width: 64px; height: 64px;
  margin-bottom: 14px;
  filter: drop-shadow(0 6px 16px rgba(192, 133, 82, 0.4));
}
.modal-card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  color: var(--pearl);
  margin-bottom: 6px;
}
.modal-sub {
  font-family: var(--serif-i);
  font-style: italic;
  color: var(--copper-glow);
  font-size: 14px;
  margin-bottom: 14px;
}
.modal-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--pearl-2);
  margin-bottom: 14px;
}

@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Settings */
.settings-block {
  margin: 18px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.settings-block:last-of-type { border: none; }
.settings-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--pearl-dim);
  margin-bottom: 8px;
}
.settings-block input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(11, 13, 26, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--pearl);
  font-size: 14px;
  direction: rtl;
}
.settings-block input:focus { border-color: var(--copper); outline: none; }
.settings-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--pearl-muted);
}
.btn-line {
  display: block;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 8px;
  background: rgba(11, 13, 26, 0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--pearl-2);
  font-size: 13px;
  text-align: right;
  transition: all 0.2s;
}
.btn-line:hover { background: var(--glass-3); color: var(--pearl); border-color: var(--border-strong); }
.btn-line.danger:hover { color: var(--err); border-color: var(--err); }

/* Letter Modal */
.letter-modal {
  max-width: 540px;
  padding: 0;
  overflow: hidden;
}
.letter-paper {
  padding: 36px 32px 24px;
  background:
    linear-gradient(135deg, rgba(237, 228, 211, 0.05) 0%, rgba(237, 228, 211, 0.02) 100%),
    repeating-linear-gradient(
      transparent,
      transparent 32px,
      rgba(237, 228, 211, 0.04) 32px,
      rgba(237, 228, 211, 0.04) 33px
    );
  position: relative;
}
.letter-paper::before {
  content: ''; position: absolute;
  top: 0; right: 32px;
  width: 1px; height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(217, 122, 108, 0.2), transparent);
}
.letter-from {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pearl-dim);
  margin-bottom: 12px;
}
.letter-from em { font-family: var(--serif-i); font-style: italic; font-size: 14px; color: var(--copper-soft); }
.letter-mood {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--copper-glow);
  margin-bottom: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(192, 133, 82, 0.08);
}
.letter-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.25;
  color: var(--pearl);
  margin-bottom: 16px;
}
.letter-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--pearl);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 18px;
}
.letter-signoff {
  font-family: var(--serif-i);
  font-style: italic;
  font-size: 14px;
  color: var(--copper-soft);
  text-align: left;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.letter-tags {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 12px;
}
.letter-tags span {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  color: var(--pearl-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.letter-actions {
  display: flex; gap: 8px; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(11, 13, 26, 0.5);
  border-top: 1px solid var(--line);
}
.letter-actions button {
  flex: 1;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(11, 13, 26, 0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--pearl-2);
  transition: all 0.3s var(--spring);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.letter-actions button:hover { background: var(--glass-3); color: var(--copper-glow); border-color: var(--border); }
.letter-actions button.danger:hover { color: var(--err); border-color: var(--err); }
.letter-actions svg { width: 14px; height: 14px; }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  bottom: 100px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--copper-glow), var(--copper-deep));
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: 0 12px 28px -8px rgba(192, 133, 82, 0.55);
  animation: toastIn 0.4s var(--spring);
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 540px) {
  .topbar { padding: 14px 16px 10px; }
  #app { padding: 8px 12px; }
  .hero-content { padding: 44px 22px 28px; min-height: 320px; }
  .hero-title { font-size: 36px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dual-panel { grid-template-columns: 1fr; }
  .vault-grid { grid-template-columns: 1fr; }
  .nav-btn { padding: 8px 10px; }
  .nav-btn span { font-size: 9px; }
  .compose-actions { flex-direction: column-reverse; }
  .compose-actions button { width: 100%; justify-content: center; }
}
@media (max-width: 380px) {
  .hero-title { font-size: 30px; }
  .hero-cta-row { flex-direction: column; align-items: stretch; }
  .hero-cta-row button { width: 100%; justify-content: center; }
}
@media (min-width: 720px) {
  .insights-grid { grid-template-columns: 1fr 1fr; }
  .insight-timeline { grid-column: span 2; }
}
