/* ═══════════════════════════════════════════════════════
   AURELIUS — style.css
   Mobile-first. Light mode default. Stoic Mode = dark.
   Breakpoints: base = mobile, 480px, 640px, 860px
   ═══════════════════════════════════════════════════════ */

/* ── Custom properties ── */
:root {
  --bg: #f5f0e8;
  --bg-mid: #ede6d8;
  --bg-card: #ede6d8;
  --ash: #7a7065;
  --ash-dim: #a89e90;
  --stone: #5a5248;
  --bone: #2e2820;
  --parchment: #1e1a14;
  --white-soft: #0f0d09;
  --accent: #4a4038;
  --border: rgba(90, 82, 72, 0.18);
  --border-mid: rgba(90, 82, 72, 0.3);
  --glow: rgba(90, 82, 72, 0.06);
  --shadow: rgba(30, 24, 16, 0.08);

  --font-display: "Cinzel", Georgia, serif;
  --font-serif: "IM Fell English", Georgia, serif;
  --font-body: "Cormorant Garamond", Georgia, serif;
  --tr: 0.3s ease;

  /* Safe area insets for notched phones */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* ── Stoic Mode (dark) ── */
body.stoic-mode {
  --bg: #080706;
  --bg-mid: #0f0e0c;
  --bg-card: #0f0e0c;
  --ash: #6b6560;
  --ash-dim: #3d3a36;
  --stone: #918c85;
  --bone: #cec8bc;
  --parchment: #e8e2d5;
  --white-soft: #f2ede4;
  --accent: #b8b0a0;
  --border: rgba(180, 170, 155, 0.15);
  --border-mid: rgba(180, 170, 155, 0.25);
  --glow: rgba(200, 190, 170, 0.08);
  --shadow: rgba(0, 0, 0, 0.5);
}

/* ════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html {
  scroll-behavior: smooth;
  /* Prevent iOS font-size inflation on orientation change */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--bg);
  color: var(--bone);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport on mobile */
  overflow-x: hidden;
  cursor: none;
  transition:
    background 0.8s ease,
    color 0.8s ease;
  /* Smooth momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}
/* Restore normal cursor on touch devices */
@media (hover: none) {
  body {
    cursor: auto;
  }
  #cursor,
  #cursor-ring {
    display: none;
  }
}

/* ── Grain ── */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
  background-size: 200px;
  mix-blend-mode: multiply;
  opacity: 0.6;
  transition: opacity 0.8s;
}
body.stoic-mode .grain {
  mix-blend-mode: overlay;
  opacity: 1;
}

/* ── Canvas & vignette ── */
#canvas-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.25;
  transition: opacity 0.8s;
}
body.stoic-mode #canvas-bg {
  opacity: 0.88;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 90% 80% at 50% 48%,
    transparent 0%,
    rgba(220, 210, 195, 0.1) 65%,
    rgba(200, 188, 168, 0.22) 100%
  );
  transition: background 0.8s;
}
body.stoic-mode #vignette {
  background: radial-gradient(
    ellipse 70% 65% at 50% 48%,
    transparent 0%,
    rgba(8, 7, 5, 0.45) 65%,
    rgba(4, 3, 2, 0.88) 100%
  );
}

/* ── Custom cursor (desktop only) ── */
#cursor {
  position: fixed;
  width: 8px;
  height: 8px;
  background: var(--bone);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: background 0.8s;
}
#cursor-ring {
  position: fixed;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ash);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
  transition:
    width 0.25s,
    height 0.25s,
    border-color 0.25s,
    opacity 0.25s;
  opacity: 0.5;
}
body:has(button:hover) #cursor-ring,
body:has(a:hover) #cursor-ring {
  width: 46px;
  height: 46px;
  border-color: var(--bone);
  opacity: 0.9;
}

/* ── App wrapper ── */
#app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

/* ════════════════════════════════════════
   HEADER
   ════════════════════════════════════════ */
header {
  width: 100%;
  max-width: 900px;
  padding: calc(2rem + var(--safe-t)) 1.25rem 1.25rem;
  text-align: center;
}

.header-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.ornament-line {
  height: 1px;
  width: 50px;
  background: linear-gradient(to right, transparent, var(--ash-dim));
}
.ornament-line.right {
  background: linear-gradient(to left, transparent, var(--ash-dim));
}
.ornament-mark {
  color: var(--ash-dim);
  font-size: 0.85rem;
  animation: pulse-mark 5s ease-in-out infinite;
}
@keyframes pulse-mark {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.8;
  }
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.4em;
  color: var(--white-soft);
  line-height: 1;
  margin-left: 0.4em; /* compensate letter-spacing */
  transition: color 0.8s;
}

.subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(0.7rem, 2.2vw, 0.95rem);
  color: var(--ash);
  letter-spacing: 0.25em;
  margin-top: 0.6rem;
  transition: color 0.8s;
}

/* ── Navigation ── */
nav {
  display: flex;
  margin: 1.5rem auto 0;
  border: 1px solid var(--border);
  width: fit-content;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  transition: border-color 0.8s;
}
nav button {
  background: transparent;
  border: none;
  color: var(--ash);
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  padding: 0.65rem 1rem;
  cursor: none;
  /* Make tap targets a comfortable size on touch */
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all var(--tr);
  position: relative;
  white-space: nowrap;
}
nav button::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0;
  background: var(--bone);
  transition: width var(--tr);
}
nav button:hover,
nav button.active {
  color: var(--bone);
  background: var(--glow);
}
nav button:hover::after,
nav button.active::after {
  width: 100%;
}
nav button + button {
  border-left: 1px solid var(--border);
}

/* ════════════════════════════════════════
   PANELS
   ════════════════════════════════════════ */
.panel {
  display: none;
  width: 100%;
  max-width: 860px;
  padding: 0.25rem 1.25rem 5rem;
  animation: fadeUp 0.5s ease;
}
.panel.active {
  display: block;
}

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

.section-title {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.3em;
  color: var(--ash-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.7rem;
  margin-top: 2.2rem;
  margin-bottom: 1.3rem;
  transition:
    color 0.8s,
    border-color 0.8s;
}

/* ════════════════════════════════════════
   QUOTE PANEL
   ════════════════════════════════════════ */
#quote-stage {
  padding: 1.8rem 0 1.2rem;
  display: flex;
  flex-direction: column;
}

.quote-frame {
  position: relative;
  padding: 2.2rem 1.6rem 2rem;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--border);
  box-shadow: 0 2px 20px var(--shadow);
  transition:
    background 0.8s,
    border-color 0.8s,
    box-shadow 0.8s;
}
body.stoic-mode .quote-frame {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.018) 0%,
    transparent 60%,
    rgba(255, 255, 255, 0.012) 100%
  );
  box-shadow: none;
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
}
.corner.tl {
  top: -1px;
  left: -1px;
  border-top: 1px solid var(--stone);
  border-left: 1px solid var(--stone);
}
.corner.tr {
  top: -1px;
  right: -1px;
  border-top: 1px solid var(--stone);
  border-right: 1px solid var(--stone);
}
.corner.bl {
  bottom: -1px;
  left: -1px;
  border-bottom: 1px solid var(--stone);
  border-left: 1px solid var(--stone);
}
.corner.br {
  bottom: -1px;
  right: -1px;
  border-bottom: 1px solid var(--stone);
  border-right: 1px solid var(--stone);
}

.open-mark {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  line-height: 0.6;
  color: var(--ash-dim);
  opacity: 0.28;
  position: absolute;
  top: 1rem;
  left: 1.1rem;
  user-select: none;
  pointer-events: none;
}

#quote-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1rem, 4vw, 1.55rem);
  line-height: 1.85;
  color: var(--parchment);
  letter-spacing: 0.01em;
  text-align: center;
  transition:
    opacity 0.45s,
    transform 0.45s,
    color 0.8s;
  min-height: 3.5em;
}
#quote-text.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

.quote-word {
  display: inline;
  transition: color 0.2s;
}
.quote-word:hover {
  color: var(--white-soft);
}

.tw-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--stone);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

#book-ref {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.28em;
  color: var(--ash);
  text-align: center;
  margin-top: 1.6rem;
  transition:
    opacity 0.45s,
    color 0.8s;
}
#book-ref.fade-out {
  opacity: 0;
}

/* Progress bar */
.progress-wrap {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.progress-track {
  width: 100%;
  height: 1px;
  background: var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--ash-dim), var(--stone));
  transition:
    width 0.8s,
    background 0.8s;
}
.progress-label {
  font-family: var(--font-display);
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  color: var(--ash-dim);
  text-align: right;
  opacity: 0.6;
}

/* Streak */
.streak-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.streak-flame {
  font-size: 0.8rem;
}
.streak-badge {
  font-family: var(--font-display);
  font-size: 0.54rem;
  letter-spacing: 0.16em;
  color: var(--stone);
  border: 1px solid var(--border);
  padding: 0.18rem 0.7rem;
  transition:
    color 0.8s,
    border-color 0.8s;
}

/* Action buttons row */
.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.8rem;
}

/* Swipe / keyboard hints */
.swipe-hint {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.72rem;
  color: var(--ash-dim);
  text-align: center;
  margin-top: 1.2rem;
  letter-spacing: 0.08em;
  animation: hint-fade 5s ease 2.5s forwards;
  opacity: 0.5;
}
@keyframes hint-fade {
  0%,
  60% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
  }
}

.shortcuts-hint {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}
.shortcut-key {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  color: var(--ash-dim);
  opacity: 0.5;
}
.shortcut-key kbd {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 0.1rem 0.3rem;
  font-family: var(--font-display);
  font-size: 0.5rem;
  color: var(--ash-dim);
  margin-right: 0.25rem;
}

/* View from above */
body.view-above #app {
  transform: scale(0.18);
  transform-origin: top center;
  transition: transform 2.5s cubic-bezier(0.22, 1, 0.36, 1);
}
body.view-above-reset #app {
  transform: scale(1);
  transform-origin: top center;
  transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */
.btn {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  /* Comfortable tap target height on mobile */
  padding: 0.75rem 1.4rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--ash);
  cursor: none;
  transition: all var(--tr);
  position: relative;
  overflow: hidden;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--glow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--tr);
}
.btn:hover {
  color: var(--bone);
  border-color: var(--stone);
}
.btn:hover::before {
  transform: scaleX(1);
}
.btn span {
  position: relative;
  z-index: 1;
}
.btn.primary {
  border-color: var(--stone);
  color: var(--bone);
}
.btn.primary:hover {
  background: var(--glow);
  border-color: var(--accent);
}

/* ════════════════════════════════════════
   DAILY WISDOM PANEL
   ════════════════════════════════════════ */
.wisdom-hero {
  padding: 1.5rem 0 1rem;
}

.wisdom-date-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  color: var(--ash-dim);
  text-align: center;
  margin-bottom: 1.8rem;
}

.wisdom-quote-frame {
  position: relative;
  padding: 2.2rem 1.6rem 2rem;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--border);
  box-shadow: 0 2px 20px var(--shadow);
  transition:
    background 0.8s,
    border-color 0.8s;
}
body.stoic-mode .wisdom-quote-frame {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.018) 0%,
    transparent 60%,
    rgba(255, 255, 255, 0.012) 100%
  );
  box-shadow: none;
}

.wisdom-quote-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.05rem, 4vw, 1.7rem);
  line-height: 1.85;
  color: var(--parchment);
  text-align: center;
  letter-spacing: 0.01em;
  transition: color 0.8s;
}
.wisdom-book-ref {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.28em;
  color: var(--ash);
  text-align: center;
  margin-top: 1.6rem;
  transition: color 0.8s;
}
.wisdom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.8rem;
}

/* Streak card */
.streak-card {
  border: 1px solid var(--border);
  padding: 1.8rem 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.25);
  transition:
    background 0.8s,
    border-color 0.8s;
}
body.stoic-mode .streak-card {
  background: rgba(200, 190, 170, 0.02);
}
.streak-card-flame {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}
.streak-card-num {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 10vw, 4rem);
  color: var(--stone);
  line-height: 1;
  margin-bottom: 0.3rem;
  transition: color 0.8s;
}
.streak-card-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  color: var(--ash-dim);
  margin-bottom: 0.7rem;
}
.streak-card-sub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ash);
  opacity: 0.7;
}

/* ════════════════════════════════════════
   BOOKS PANEL
   ════════════════════════════════════════ */
.books-intro {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ash);
  line-height: 1.72;
  margin-bottom: 1.6rem;
  opacity: 0.85;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.7rem;
}

.book-card {
  border: 1px solid var(--border);
  padding: 1rem 0.7rem;
  text-align: center;
  cursor: none;
  min-height: 44px;
  transition: all var(--tr);
  background: rgba(255, 255, 255, 0.3);
}
body.stoic-mode .book-card {
  background: rgba(255, 255, 255, 0.01);
}
.book-card:hover {
  border-color: var(--stone);
  background: rgba(255, 255, 255, 0.5);
}
body.stoic-mode .book-card:hover {
  background: rgba(200, 190, 170, 0.04);
}
.book-card .book-num {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--bone);
  display: block;
}
.book-card .book-label {
  font-family: var(--font-display);
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  color: var(--ash-dim);
  margin-top: 0.3rem;
  display: block;
}

.back-btn {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: var(--ash);
  background: none;
  border: none;
  cursor: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.3rem;
  opacity: 0.6;
  min-height: 44px;
  transition: opacity var(--tr);
}
.back-btn:hover {
  opacity: 1;
}

.book-quote-item {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 0.4rem;
  cursor: none;
  /* Generous tap target */
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.25s;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.93rem;
  color: var(--ash);
  line-height: 1.65;
}
.book-quote-item:hover {
  color: var(--parchment);
  padding-left: 0.9rem;
}

/* ════════════════════════════════════════
   JOURNAL PANEL
   ════════════════════════════════════════ */
.journal-prompt {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--ash);
  line-height: 1.72;
  padding: 1.2rem 1.3rem;
  border-left: 2px solid var(--stone);
  background: rgba(255, 255, 255, 0.35);
  transition:
    border-color 0.5s,
    background 0.5s;
}
body.stoic-mode .journal-prompt {
  background: rgba(200, 190, 170, 0.025);
}
.journal-prompt.evening-audit {
  border-left-color: var(--bone);
  background: rgba(255, 255, 255, 0.5);
}
body.stoic-mode .journal-prompt.evening-audit {
  background: rgba(200, 190, 170, 0.05);
}

.prompt-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  color: var(--ash-dim);
  font-style: normal;
  display: block;
  margin-bottom: 0.6rem;
  transition: color 0.5s;
}
.prompt-label.evening-label {
  color: var(--bone) !important;
}

/* Markdown toolbar */
.md-toolbar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.md-btn {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ash-dim);
  cursor: none;
  transition: all 0.2s;
}
.md-btn:hover {
  color: var(--bone);
  border-color: var(--stone);
}

/* Write / Preview tabs */
#journal-tabs {
  display: flex;
  margin-bottom: 0.5rem;
}
.jtab {
  font-family: var(--font-display);
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  padding: 0.5rem 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ash-dim);
  cursor: none;
  transition: all 0.2s;
}
.jtab.active {
  color: var(--bone);
  border-color: var(--stone);
  background: var(--glow);
}
.jtab + .jtab {
  border-left: none;
}

textarea#journal-entry {
  width: 100%;
  min-height: 180px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  padding: 1rem 1.2rem;
  resize: vertical;
  outline: none;
  /* iOS: prevent auto-zoom on focus (font must be ≥16px to avoid it) */
  font-size: max(1rem, 16px);
  transition:
    border-color var(--tr),
    background 0.8s;
  cursor: text;
  /* Smooth scrolling inside textarea on iOS */
  -webkit-overflow-scrolling: touch;
}
body.stoic-mode textarea#journal-entry {
  background: rgba(200, 190, 170, 0.025);
}
textarea#journal-entry:focus {
  border-color: var(--stone);
}
textarea#journal-entry::placeholder {
  color: var(--ash-dim);
  font-style: italic;
}

.journal-preview {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--parchment);
  padding: 1rem 1.2rem;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--border);
  min-height: 60px;
  display: none;
  transition: background 0.8s;
}
body.stoic-mode .journal-preview {
  background: rgba(200, 190, 170, 0.02);
}
.journal-preview strong {
  color: var(--white-soft);
  font-weight: 600;
}

/* Journal meta row */
.journal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.8rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.journal-btns {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.word-count {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.13em;
  color: var(--ash-dim);
  opacity: 0.6;
}

/* Saved entries */
.saved-entries {
  margin-top: 2.2rem;
}
.saved-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.25em;
  color: var(--ash-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
  margin-bottom: 0.9rem;
}
.entry-card {
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
  margin-bottom: 0.65rem;
  background: rgba(255, 255, 255, 0.3);
  position: relative;
  transition:
    border-color var(--tr),
    background 0.8s;
}
body.stoic-mode .entry-card {
  background: rgba(200, 190, 170, 0.015);
}
.entry-card:hover {
  border-color: var(--stone);
}
.entry-date {
  font-family: var(--font-display);
  font-size: 0.53rem;
  letter-spacing: 0.18em;
  color: var(--ash-dim);
  margin-bottom: 0.35rem;
}
.entry-quote-ref {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ash);
  margin-bottom: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-text {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ash);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* padding-right so text doesn't sit under the × button */
  padding-right: 2rem;
}
.delete-entry {
  position: absolute;
  top: 0.8rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--ash-dim);
  cursor: none;
  font-size: 1.1rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--tr);
}
.delete-entry:hover {
  color: var(--bone);
}

/* ════════════════════════════════════════
   PRACTICE PANEL
   ════════════════════════════════════════ */
.practice-header {
  text-align: center;
  padding: 1.5rem 0 0.8rem;
}
.challenge-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 4vw, 1.7rem);
  letter-spacing: 0.18em;
  color: var(--bone);
  margin-bottom: 0.45rem;
}
.challenge-sub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ash);
  opacity: 0.75;
}

/* Daily mission */
.daily-mission {
  border: 1px solid var(--border-mid);
  padding: 1.3rem 1.5rem;
  background: rgba(255, 255, 255, 0.3);
  position: relative;
  transition: background 0.8s;
}
body.stoic-mode .daily-mission {
  background: rgba(200, 190, 170, 0.025);
}
.daily-mission::before {
  content: "TODAY'S MISSION";
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  color: var(--stone);
  display: block;
  margin-bottom: 0.7rem;
}
.mission-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--parchment);
  line-height: 1.72;
}
.mission-date {
  font-family: var(--font-display);
  font-size: 0.52rem;
  letter-spacing: 0.13em;
  color: var(--ash-dim);
  margin-top: 0.7rem;
  opacity: 0.6;
}

/* Challenges grid — single column mobile, 2 col on wider screens */
.challenges-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.challenge-card {
  border: 1px solid var(--border);
  padding: 1.3rem;
  cursor: none;
  transition: all var(--tr);
  background: rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}
body.stoic-mode .challenge-card {
  background: rgba(255, 255, 255, 0.01);
}
.challenge-card::before {
  content: attr(data-num);
  position: absolute;
  top: -0.5rem;
  right: 0.7rem;
  font-family: var(--font-display);
  font-size: 3.5rem;
  color: rgba(90, 82, 72, 0.06);
  line-height: 1;
  pointer-events: none;
}
body.stoic-mode .challenge-card::before {
  color: rgba(200, 190, 170, 0.04);
}
.challenge-card:hover {
  border-color: var(--stone);
  background: rgba(255, 255, 255, 0.5);
}
body.stoic-mode .challenge-card:hover {
  background: rgba(200, 190, 170, 0.035);
}
.challenge-card h3 {
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  color: var(--bone);
  margin-bottom: 0.6rem;
}
.challenge-card p {
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ash);
}
.badge {
  display: inline-block;
  margin-top: 0.9rem;
  font-family: var(--font-display);
  font-size: 0.52rem;
  letter-spacing: 0.16em;
  color: var(--ash-dim);
  border: 1px solid var(--border);
  padding: 0.18rem 0.55rem;
}

/* ── Meditation Timer ── */
.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.3rem 0.8rem 1.8rem;
}
.timer-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  color: var(--ash);
  text-align: center;
  max-width: 520px;
  line-height: 1.75;
  margin-bottom: 1.8rem;
  min-height: 2.2rem;
}
.timer-circle {
  position: relative;
  width: 160px;
  height: 160px;
}
.timer-svg {
  transform: rotate(-90deg);
}
.timer-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}
.timer-prog {
  fill: none;
  stroke: var(--stone);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 502.65; /* 2π × r80 — matches SVG viewBox */
  stroke-dashoffset: 502.65;
  transition:
    stroke-dashoffset 1s linear,
    stroke 0.8s;
}
.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--parchment);
  letter-spacing: 0.05em;
  transition: color 0.8s;
}
.timer-controls {
  display: flex;
  gap: 0.9rem;
  margin-top: 1.6rem;
}
.timer-presets {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.preset-btn {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.13em;
  padding: 0.45rem 0.85rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ash);
  cursor: none;
  transition: all var(--tr);
}
.preset-btn:hover,
.preset-btn.active {
  border-color: var(--stone);
  color: var(--bone);
  background: var(--glow);
}

/* ── Box Breathing ── */
.breath-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.3rem 0.8rem 2rem;
  text-align: center;
}
.breath-orb {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(90, 82, 72, 0.15) 0%,
    rgba(90, 82, 72, 0.04) 60%,
    transparent 100%
  );
  border: 1px solid rgba(90, 82, 72, 0.25);
  box-shadow: 0 0 28px rgba(90, 82, 72, 0.06);
  /* centered by flex parent — no margin:auto needed */
  transition:
    transform 4s ease-in-out,
    box-shadow 4s ease-in-out,
    background 0.8s;
}
body.stoic-mode .breath-orb {
  background: radial-gradient(
    circle,
    rgba(200, 190, 170, 0.12) 0%,
    rgba(200, 190, 170, 0.02) 60%,
    transparent 100%
  );
  border-color: rgba(200, 190, 170, 0.2);
  box-shadow: 0 0 36px rgba(200, 190, 170, 0.04);
}
.breath-orb.expand {
  transform: scale(1.45);
  box-shadow: 0 0 55px rgba(90, 82, 72, 0.14);
}
.breath-orb.hold-in {
  transform: scale(1.45);
  box-shadow: 0 0 55px rgba(90, 82, 72, 0.14);
}
.breath-orb.shrink {
  transform: scale(1);
  box-shadow: 0 0 18px rgba(90, 82, 72, 0.05);
}
.breath-orb.hold-out {
  transform: scale(1);
  box-shadow: 0 0 18px rgba(90, 82, 72, 0.05);
}
body.stoic-mode .breath-orb.expand,
body.stoic-mode .breath-orb.hold-in {
  box-shadow: 0 0 65px rgba(200, 190, 170, 0.12);
}
body.stoic-mode .breath-orb.shrink,
body.stoic-mode .breath-orb.hold-out {
  box-shadow: 0 0 18px rgba(200, 190, 170, 0.04);
}

.breath-instruction {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ash);
  letter-spacing: 0.07em;
  margin-top: 1.3rem;
  transition: color 0.8s;
}
.breath-countdown {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--ash-dim);
  margin-top: 0.4rem;
  min-height: 1.3em;
  transition: color 0.8s;
}

/* ════════════════════════════════════════
   GLOSSARY PANEL
   ════════════════════════════════════════ */
.glossary-intro {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ash);
  line-height: 1.72;
  margin-bottom: 1.8rem;
  opacity: 0.85;
}
.glossary-grid {
  display: grid;
  gap: 0.9rem;
}
.gloss-card {
  border: 1px solid var(--border);
  padding: 1.1rem 1.3rem;
  background: rgba(255, 255, 255, 0.3);
  transition:
    border-color var(--tr),
    background 0.8s;
  cursor: default;
}
body.stoic-mode .gloss-card {
  background: rgba(255, 255, 255, 0.01);
}
.gloss-card:hover {
  border-color: var(--stone);
  background: rgba(255, 255, 255, 0.5);
}
body.stoic-mode .gloss-card:hover {
  background: rgba(200, 190, 170, 0.04);
}
.gloss-term {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--bone);
  margin-bottom: 0.12rem;
}
.gloss-latin {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ash);
  margin-bottom: 0.55rem;
  opacity: 0.7;
}
.gloss-def {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ash);
  line-height: 1.68;
}

/* ════════════════════════════════════════
   SHARE MODAL
   ════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(30, 24, 16, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
  padding: 1rem;
  /* account for notch */
  padding-top: calc(1rem + var(--safe-t));
  padding-bottom: calc(1rem + var(--safe-b));
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}
body.stoic-mode .modal-overlay {
  background: rgba(8, 7, 5, 0.85);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-box {
  background: var(--bg-mid);
  border: 1px solid var(--border-mid);
  padding: 1.6rem;
  max-width: 520px;
  width: 100%;
  position: relative;
  animation: slideUp 0.35s;
  box-shadow: 0 8px 40px var(--shadow);
}
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--ash);
  font-size: 1.4rem;
  cursor: none;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--tr);
}
.modal-close:hover {
  color: var(--bone);
}
.modal-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  color: var(--ash-dim);
  margin-bottom: 1.1rem;
}
#share-canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
}
.modal-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════
   TOAST
   ════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-b));
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg-mid);
  border: 1px solid var(--stone);
  color: var(--bone);
  padding: 0.65rem 1.6rem;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  z-index: 500;
  transition:
    transform 0.4s,
    opacity 0.4s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px var(--shadow);
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ════════════════════════════════════════
   RIPPLE
   ════════════════════════════════════════ */
.ripple {
  position: fixed;
  border-radius: 50%;
  border: 1px solid rgba(90, 82, 72, 0.35);
  pointer-events: none;
  z-index: 3;
  transform: translate(-50%, -50%);
  animation: ripple-out 1s ease-out forwards;
}
body.stoic-mode .ripple {
  border-color: rgba(180, 170, 155, 0.35);
}
@keyframes ripple-out {
  from {
    width: 0;
    height: 0;
    opacity: 0.5;
  }
  to {
    width: 100px;
    height: 100px;
    opacity: 0;
  }
}

/* ════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════ */
footer {
  text-align: center;
  padding: 2rem 1.25rem calc(1.5rem + var(--safe-b));
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--ash-dim);
  opacity: 0.5;
  letter-spacing: 0.07em;
}

/* ════════════════════════════════════════
   RESPONSIVE — tablet up (≥ 480px)
   ════════════════════════════════════════ */
@media (min-width: 480px) {
  header {
    padding: calc(2.5rem + var(--safe-t)) 1.75rem 1.5rem;
  }
  .panel {
    padding: 0.25rem 1.75rem 5rem;
  }
  .quote-frame,
  .wisdom-quote-frame {
    padding: 2.5rem 2.2rem;
  }
  .challenges-grid {
    grid-template-columns: 1fr 1fr;
  }
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  .timer-circle {
    width: 180px;
    height: 180px;
  }
  .timer-svg {
    transform: rotate(-90deg);
  }
  .timer-prog {
    stroke-dasharray: 502.65;
    stroke-dashoffset: 502.65;
  }
  .timer-display {
    font-size: 2.2rem;
  }
}

/* ════════════════════════════════════════
   RESPONSIVE — desktop (≥ 640px)
   ════════════════════════════════════════ */
@media (min-width: 640px) {
  header {
    padding: calc(3.5rem + var(--safe-t)) 2rem 1.5rem;
  }
  .panel {
    padding: 0.5rem 2rem 5rem;
  }
  .quote-frame,
  .wisdom-quote-frame {
    padding: 2.8rem 3rem;
  }
  nav button {
    font-size: 0.6rem;
    letter-spacing: 0.22em;
    padding: 0.7rem 1.25rem;
  }
  .open-mark {
    font-size: 5rem;
    top: 1.4rem;
    left: 1.8rem;
  }
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
  .shortcuts-hint {
    display: flex;
  }
}

/* ════════════════════════════════════════
   SMALL PHONES (< 380px)
   ════════════════════════════════════════ */
@media (max-width: 379px) {
  h1 {
    font-size: 1.65rem;
    letter-spacing: 0.3em;
  }
  nav button {
    padding: 0.55rem 0.7rem;
    font-size: 0.54rem;
    letter-spacing: 0.12em;
  }
  .quote-frame {
    padding: 1.8rem 1.1rem;
  }
  .btn {
    padding: 0.65rem 1.1rem;
    font-size: 0.55rem;
  }
  .quote-actions {
    gap: 0.45rem;
  }
  .challenges-grid {
    grid-template-columns: 1fr;
  }
  .timer-circle {
    width: 140px;
    height: 140px;
  }
  .timer-display {
    font-size: 1.7rem;
  }
  .breath-orb {
    width: 90px;
    height: 90px;
  }
}

/* ════════════════════════════════════════
   LANDSCAPE MOBILE — keep breathing room
   ════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding-top: 1.2rem;
  }
  h1 {
    font-size: 1.6rem;
  }
  .header-ornament {
    margin-bottom: 0.6rem;
  }
  nav {
    margin-top: 0.8rem;
  }
  #quote-stage {
    padding: 1rem 0 0.8rem;
  }
  .quote-frame {
    padding: 1.5rem 1.6rem;
  }
  .panel {
    padding-bottom: 2.5rem;
  }
}
