/* =============================================================
   ASHLEY PAMELA TABARES INC. — site stylesheet
   E D I T O R I A L   B R O A D S H E E T   E D I T I O N
   --------------------------------------------------------------
   Newsprint cream · ink · single off-rust accent · double rules
   Every class name and JS hook preserved from the previous
   tan-and-red edition. Only the visual layer changed.
   ============================================================= */

:root {
  /* Newsprint paper system */
  --paper:        #f1ece2;
  --paper-light:  #fdf8ec;   /* "bone" — cards float on this */
  --paper-mid:    #ebe5d8;
  --paper-dark:   #e3dccb;
  --paper-edge:   rgba(10,10,10,.18);
  --paper-edge-soft: rgba(10,10,10,.10);

  /* Inks */
  --ink:          #0a0a0a;
  --ink-soft:     #2a2a2a;
  --ink-mute:     #6a6a6a;
  --ink-faint:    #95908a;

  /* Single rust accent — used as sparingly as red ink in a real broadsheet */
  --rust-50:      #f5e8e2;
  --rust-100:    #e8c8b8;
  --rust-200:    #d49a82;
  --rust-300:    #b96a4a;
  --rust-400:    #9a3a1f;
  --rust-500:    #7a2a14;
  --rust-600:    #5a1c0c;
  --rust-700:    #3a1006;

  /* Quiet inks for occasional accents (tone bands, summary chips) */
  --ink-green:    #3a5a2a;
  --ink-green-tint: #dde2d2;
  --ink-blue:     #2a4a6a;
  --ink-blue-tint:  #d6dde6;

  /* Back-compat aliases — every variable from the old palette
     is mapped to a broadsheet-safe value so any inline code that
     still references the old names keeps rendering correctly. */
  --tan:          var(--paper);
  --tan-light:    var(--paper-light);
  --tan-dark:     var(--paper-mid);
  --tan-edge:     var(--paper-edge);

  --red-50:       var(--rust-50);
  --red-100:      var(--rust-100);
  --red-200:      var(--rust-200);
  --red-300:      var(--rust-300);
  --red-400:      var(--rust-400);
  --red-500:      var(--rust-400);
  --red-600:      var(--rust-500);
  --red-700:      var(--ink);          /* deepest "red" reads as ink */

  --green-tint:   var(--ink-green-tint);
  --green-ink:    var(--ink-green);
  --green-edge:   var(--ink-green);

  --bg:           var(--paper);
  --surface:      var(--paper-light);
  --surface-2:    var(--paper-mid);
  --line:         var(--paper-edge);
  --text:         var(--ink);
  --muted:        var(--ink-mute);
  --brand:        var(--ink);
  --brand-2:      var(--ink-soft);
  --brand-3:      var(--rust-400);
  --positive:     var(--ink-green);
  --neutral:      var(--paper-edge);
  --negative:     var(--rust-400);

  /* Paper-stack shadows (hard 1px offset, no soft blur) */
  --shadow:       1px 1px 0 var(--ink), 4px 4px 0 rgba(10,10,10,.06);
  --shadow-soft:  1px 1px 0 rgba(10,10,10,.85);
  --shadow-strong:1px 1px 0 var(--ink), 6px 6px 0 rgba(10,10,10,.10);
  --shadow-ring:  rgba(10,10,10,.14);

  /* Crisp radii — broadsheet, not rounded glass */
  --radius:       2px;
  --radius-sm:    1px;
  --radius-pill:  1px;

  --max:          1240px;

  --serif:        "Times New Roman", Times, Georgia, serif;
  --ui:           "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body { margin: 0; padding: 0; }

body {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-mid) 100%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}

/* Faint newsprint grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .14;
  background-image:
    linear-gradient(rgba(10,10,10,.40) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10,10,10,.40) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000, transparent 78%);
          mask-image: radial-gradient(circle at 50% 30%, #000, transparent 78%);
}
body > * { position: relative; z-index: 1; }
body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
em { font-style: italic; color: var(--rust-400); }
button, input, textarea, select { font: inherit; color: inherit; }

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =============================================================
   SITE HEADER — broadsheet masthead
   ============================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper-light);
  border-top: 4px double var(--ink);
  border-bottom: 1px solid var(--ink);
  box-shadow: 0 1px 0 var(--ink), 0 4px 0 rgba(10,10,10,.05);
  color: var(--ink);
}

.site-header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.site-header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--paper-edge);
}

.site-brand-group {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.site-brand {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.site-brand-mark {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  font-style: normal;
  white-space: nowrap;
}

.site-auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid var(--ink);
  border-radius: 1px;
  background: var(--paper-light);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 0.64rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.site-auth-link:hover,
.site-auth-link:focus-visible {
  background: var(--ink);
  color: var(--paper-light);
}
.site-auth-link:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}
.site-auth-link.is-account {
  border-color: var(--rust-400);
  color: var(--rust-400);
}
.site-auth-link.is-account:hover,
.site-auth-link.is-account:focus-visible {
  background: var(--rust-400);
  color: var(--paper-light);
}

.site-tagline {
  justify-self: center;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  font-style: normal;
  font-weight: 400;
  letter-spacing: -.005em;
  color: var(--ink);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* Underline tab nav — full-width second row */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 22px;
  padding-top: 4px;
}
.site-nav-link {
  position: relative;
  padding: 6px 2px 8px;
  color: var(--ink-mute);
  font-family: var(--ui);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.18s ease;
  white-space: nowrap;
}
.site-nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 2px;
  background: var(--ink);
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.site-nav-link:hover { color: var(--ink); }
.site-nav-link:hover::after { right: 0; }
.site-nav-link:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}
.site-nav-link.is-active {
  color: var(--ink);
  font-weight: 700;
}
.site-nav-link.is-active::after {
  right: 0;
  background: var(--rust-400);
  height: 2px;
}

/* Date/time block */
.site-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}
.site-meta-dt {
  text-align: right;
  line-height: 1.25;
}
.site-meta-date {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-style: normal;
  font-weight: 500;
}
.site-meta-time {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.005em;
}

.site-menu-toggle {
  display: none;
  min-width: 58px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper-light);
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 0;
  cursor: pointer;
  padding: 0 12px;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1;
}
.site-menu-toggle::before { content: 'Menu'; }
.site-menu-toggle[aria-expanded="true"]::before { content: 'Close'; }
.site-menu-toggle span { display: none; }
.site-menu-toggle:hover,
.site-menu-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper-light);
}
.site-menu-toggle:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* =============================================================
   MAIN PAGE
   ============================================================= */
.page-main {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 24px 70px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* HERO */
.hero {
  padding: 18px 0 14px;
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
  border-bottom: 1px solid var(--paper-edge);
}
.hero-eyebrow,
.panel-eyebrow,
.life-line-eyebrow {
  font-family: var(--ui);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--rust-400);
  font-weight: 600;
  font-style: normal;
}
.hero-title {
  margin: 10px 0 8px;
  font-size: clamp(2rem, 4.8vw, 3.6rem);
  line-height: 1;
  color: var(--ink);
  font-weight: 400;
  font-style: normal;
  letter-spacing: -.02em;
  font-family: var(--serif);
}
.hero-title em {
  font-style: italic;
  color: var(--ink);
  border-bottom: 2px solid var(--rust-400);
  padding-bottom: 1px;
}
.hero-copy {
  max-width: 620px;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--serif);
}
.hero-live {
  margin-top: 12px;
  color: var(--rust-400);
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  font-style: normal;
}
.hero-live-divider {
  padding: 0 8px;
  color: var(--paper-edge);
}

/* =============================================================
   PANEL (shared card container)
   ============================================================= */
.panel {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 14px 22px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  border-bottom: 3px double var(--ink);
  margin-bottom: 6px;
}
.panel-title {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: -.005em;
  color: var(--ink);
}
.panel-title em {
  color: var(--ink);
  border-bottom: 1px solid var(--rust-400);
  padding-bottom: 1px;
  font-style: italic;
}
.panel-sub {
  margin: 4px 0 0;
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  font-style: normal;
}

/* =============================================================
   LIFETIME TIMELINE
   ============================================================= */
.life-line { padding: 16px 22px 14px; }
.life-line-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--paper-edge);
}
.life-line-caption {
  flex: 1;
  font-family: var(--serif);
  font-size: 0.92rem;
  font-style: italic;
  color: var(--ink-soft);
}
.life-line-caption em {
  color: var(--ink);
  font-weight: 700;
  font-style: italic;
  border-bottom: 1px solid var(--rust-400);
  padding-bottom: 1px;
}
.life-line-year {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -.005em;
  border-bottom: 2px solid var(--rust-400);
  padding-bottom: 2px;
}

.life-line-track {
  position: relative;
  height: 90px;
  margin: 32px 8px 10px;
}
.life-line-decades {
  position: absolute;
  left: 0; right: 0;
  top: 50px;
  height: 10px;
  pointer-events: none;
}
.life-decade-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 8px;
  background: var(--ink-mute);
  opacity: 0.5;
  transform: translateX(-50%);
}
.life-decade-tick.major {
  height: 12px;
  background: var(--ink);
  opacity: 0.8;
  width: 1px;
  top: -2px;
}
.life-decade-label {
  position: absolute;
  top: 14px;
  font-family: var(--ui);
  font-size: 9px;
  font-style: normal;
  color: var(--ink-mute);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: translateX(-50%);
}
.life-decade-label.major { color: var(--ink); font-weight: 700; }

.life-line-bar {
  position: absolute;
  left: 0; right: 0;
  top: 32px;
  height: 8px;
  background: var(--paper-mid);
  border-radius: 0;
  border: 1px solid var(--ink);
  overflow: hidden;
}
.life-line-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: var(--ink);
  transition: width 0.4s ease-out;
}
.life-line-future {
  position: absolute;
  top: 32px;
  right: 0;
  height: 8px;
  background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(10,10,10,.20) 4px 5px);
  pointer-events: none;
}

.life-line-today {
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 4;
}
.life-line-today-pin {
  width: 22px;
  height: 22px;
  margin-top: 24px;
  background: var(--rust-400);
  border: 2px solid var(--paper-light);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--ink), 1px 2px 0 rgba(10,10,10,.4);
  position: relative;
}
.life-line-today-pin::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  background: var(--paper-light);
  border-radius: 50%;
}
.life-line-today-pin::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(154,58,31,0.5);
  border-radius: 50%;
  animation: todayPulse 2.4s ease-in-out infinite;
}
@keyframes todayPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 0;   transform: scale(1.4); }
}
.life-line-today-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper-light);
  padding: 3px 10px 3px;
  border-radius: 0;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1.1;
  box-shadow: 1px 1px 0 var(--paper-light), 2px 2px 0 rgba(10,10,10,.35);
}
.life-line-today-label::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--ink);
}
.life-line-today-word {
  font-family: var(--ui);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--paper-mid);
  font-style: normal;
}
.life-line-today-date {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  color: var(--paper-light);
  font-variant-numeric: tabular-nums;
}

.life-line-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.life-line-marker {
  position: absolute;
  top: 32px;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
}
.life-line-marker-pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--paper-light);
  box-shadow: 0 0 0 1px var(--ink);
  transition: transform 0.15s;
  display: block;
}
.life-line-marker:hover .life-line-marker-pin { transform: scale(1.3); }
.life-line-marker-pin.life-marker-hard         { background: var(--rust-400); }
.life-line-marker-pin.life-marker-breakthrough { background: var(--ink-green); }
.life-line-marker-pin.life-marker-turning      { background: var(--ink); }

.life-line-ends {
  position: absolute;
  left: 0; right: 0;
  top: 60px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.life-line-end { position: relative; }
.life-line-end::before {
  content: '';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 14px;
  background: var(--ink);
  opacity: 0.7;
}
.life-line-end-label {
  font-family: var(--ui);
  font-size: 9px;
  font-style: normal;
  color: var(--ink-mute);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Age prompt */
.life-line-age-prompt {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
.life-line.no-age .life-line-age-prompt {
  display: flex;
  pointer-events: auto;
}
.life-line.no-age .life-line-bar,
.life-line.no-age .life-line-future,
.life-line.no-age .life-line-today,
.life-line.no-age .life-line-markers,
.life-line.no-age .life-line-ends,
.life-line.no-age .life-line-decades {
  opacity: 0.25;
}
.age-prompt-bubble {
  background: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 1px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 380px;
  text-align: center;
  animation: agePromptFloat 4s ease-in-out infinite;
}
@keyframes agePromptFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.age-prompt-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
}
.age-prompt-sub {
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  margin-bottom: 4px;
  text-transform: uppercase;
  font-style: normal;
}
.age-prompt-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.age-prompt-row input {
  width: 70px;
  padding: 6px 10px;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  border: 1px solid var(--ink);
  border-radius: 1px;
  background: var(--paper-light);
  outline: none;
}
.age-prompt-row input:focus { border-color: var(--rust-400); box-shadow: 0 0 0 2px rgba(154,58,31,.15); }
.age-prompt-row button {
  padding: 6px 14px;
  font-family: var(--ui);
  font-size: 0.74rem;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 1px;
  cursor: pointer;
  transition: background 0.15s;
}
.age-prompt-row button:hover {
  background: var(--rust-400);
  border-color: var(--rust-400);
}

.life-line-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
  border-top: 1px solid var(--paper-edge);
  padding-top: 12px;
}
.life-marker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 5px 12px;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-radius: 1px;
  cursor: pointer;
  transition: all 0.15s;
}
.life-marker-btn:hover {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}
.life-marker-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid var(--paper-light);
  box-shadow: 0 0 0 1px var(--ink);
}
.life-marker-dot.life-marker-hard         { background: var(--rust-400); }
.life-marker-dot.life-marker-breakthrough { background: var(--ink-green); }
.life-marker-dot.life-marker-turning      { background: var(--ink); }

/* =============================================================
   DASHBOARD GRID
   ============================================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  align-items: start;
}

/* CALENDAR */
.panel-calendar { padding-bottom: 16px; }
.calendar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.calendar-nav {
  width: 32px; height: 32px;
  border: 1px solid var(--ink);
  border-radius: 1px;
  background: var(--paper-light);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.calendar-nav:hover {
  background: var(--ink);
  color: var(--paper-light);
}
.calendar-label {
  min-width: 130px;
  text-align: center;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-style: normal;
  font-size: 1rem;
  letter-spacing: -.005em;
}

.calendar-legend {
  padding: 0 22px 8px;
}
.calendar-legend-hint {
  font-family: var(--ui);
  font-size: 0.7rem;
  color: var(--rust-400);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.calendar-weekdays,
.calendar-grid {
  padding: 0 22px;
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--paper-edge);
}
.calendar-weekdays span {
  font-family: var(--ui);
  font-size: 0.66rem;
  color: var(--ink-mute);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-style: normal;
  font-weight: 600;
  padding: 6px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border: 1px solid var(--paper-edge);
  border-top: none;
}

.calendar-cell {
  min-height: 72px;
  border: none;
  border-right: 1px solid var(--paper-edge-soft);
  border-bottom: 1px solid var(--paper-edge-soft);
  border-radius: 0;
  background: var(--paper-light);
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  font-family: var(--serif);
  color: var(--ink);
}
.calendar-cell:nth-child(7n) { border-right: none; }
.calendar-cell:hover {
  background: var(--paper-mid);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.calendar-cell.is-empty {
  background: transparent;
  cursor: default;
  pointer-events: none;
}
.calendar-cell.is-future {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(10,10,10,.04) 5px 6px);
  opacity: 0.85;
  position: relative;
}
.calendar-cell.is-future.has-todos {
  background-color: rgba(154,58,31,0.06);
  background-image: none;
  opacity: 1;
}
.calendar-cell.is-future.has-todos::after {
  content: "✎";
  position: absolute;
  top: 4px;
  right: 6px;
  color: var(--rust-400);
  font-size: 0.85rem;
  line-height: 1;
  pointer-events: none;
}
.calendar-cell.is-future:hover {
  opacity: 1;
}
.calendar-cell.is-positive {
  border-left: 3px solid var(--ink-green);
}
.calendar-cell.is-neutral {
  border-left: 3px solid var(--paper-edge);
}
.calendar-cell.is-negative {
  border-left: 3px solid var(--rust-400);
}

.calendar-cell.is-today {
  min-height: 130px;
  background: var(--ink);
  border: none;
  box-shadow: 1px 1px 0 var(--paper-light), 4px 4px 0 rgba(10,10,10,.35);
  z-index: 2;
  color: var(--paper-light);
}
.calendar-cell.is-today:hover {
  background: var(--rust-400);
}
.calendar-cell.is-today .calendar-day {
  color: var(--paper-light);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1;
}
.calendar-cell.is-today::before {
  content: 'TODAY · CLICK TO WRITE';
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  background: var(--rust-400);
  color: var(--paper-light);
  font-family: var(--ui);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  padding: 3px 9px;
  border-radius: 0;
  border: 1px solid var(--ink);
  white-space: nowrap;
  z-index: 3;
}

.calendar-day {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
}
.calendar-mood-label {
  display: inline-block;
  font-family: var(--ui);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-style: normal;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 0;
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-mood-label.ml-positive { background: var(--ink-green); color: var(--paper-light); }
.calendar-mood-label.ml-neutral  { background: var(--paper-edge); color: var(--ink); }
.calendar-mood-label.ml-negative { background: var(--rust-400); color: var(--paper-light); }
.calendar-mood-label.ml-mixed    { background: var(--ink); color: var(--paper-light); }
.calendar-cell.is-today .calendar-mood-label {
  background: var(--paper-light);
  color: var(--ink);
}

.calendar-preview {
  font-family: var(--serif);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--ink-mute);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.calendar-cell.is-today .calendar-preview { color: rgba(253,248,236,0.78); }
.calendar-preview.is-empty-preview {
  color: var(--rust-400);
  font-style: italic;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}
.calendar-cell:hover .calendar-preview.is-empty-preview { opacity: 1; }

.calendar-today-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 2px;
  text-align: center;
  margin-top: 2px;
}
.calendar-today-prompt-line {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  color: var(--paper-light);
  line-height: 1.15;
}
.calendar-today-prompt-sub {
  font-family: var(--ui);
  font-size: 9px;
  font-style: normal;
  color: rgba(253,248,236,0.7);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}

.calendar-mood-bar {
  display: flex;
  width: 100%;
  height: 4px;
  border-radius: 0;
  overflow: hidden;
  margin-top: auto;
  background: rgba(10,10,10,0.06);
}
.calendar-mood-seg { min-width: 0; }
.calendar-mood-seg.seg-pos { background: var(--ink-green); }
.calendar-mood-seg.seg-neu { background: var(--paper-edge); }
.calendar-mood-seg.seg-neg { background: var(--rust-400); }
.calendar-cell.is-today .calendar-mood-bar { background: rgba(253,248,236,0.18); }

/* =============================================================
   QUICK ENTRY (composer)
   ============================================================= */
.panel-composer { padding-bottom: 18px; }
.quick-entry-form {
  padding: 0 22px;
}
.field-label {
  display: block;
  margin: 0 0 6px;
  font-family: var(--ui);
  color: var(--ink-mute);
  font-size: 0.7rem;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
textarea, input[type="text"], input[type="number"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  background: var(--paper-light);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.55;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea {
  resize: vertical;
  min-height: 110px;
}
textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(10,10,10,.10);
}

.mood-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}
.mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--paper-edge);
  background: var(--paper-light);
  color: var(--ink);
  padding: 5px 12px;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: var(--ui);
  font-style: normal;
  font-weight: 500;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mood-chip:hover {
  border-color: var(--ink);
  background: var(--paper-mid);
}
.mood-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-light);
}
.mood-chip[data-mood="positive"].is-active {
  background: var(--ink-green);
  border-color: var(--ink-green);
}
.mood-chip[data-mood="negative"].is-active {
  background: var(--rust-400);
  border-color: var(--rust-400);
}
.mood-chip.is-active .mood-dot { border-color: var(--paper-light); }

.mood-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--ink-mute);
  display: inline-block;
}
.mood-dot-pos { background: var(--ink-green); border-color: var(--ink-green); }
.mood-dot-neu { background: var(--paper-edge); }
.mood-dot-neg { background: var(--rust-400); border-color: var(--rust-400); }

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

/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 1px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  box-shadow: 1px 1px 0 var(--paper-light), 2px 2px 0 rgba(10,10,10,.35);
}
.btn-primary:hover {
  background: var(--rust-400);
  border-color: var(--rust-400);
  transform: translate(1px,1px);
  box-shadow: 0 0 0 var(--paper-light), 1px 1px 0 rgba(10,10,10,.35);
}
.btn-primary:active {
  transform: translate(2px,2px);
  box-shadow: none;
}
.btn-secondary {
  background: var(--paper-light);
  color: var(--ink);
  border-color: var(--ink);
}
.btn-secondary:hover {
  background: var(--ink);
  color: var(--paper-light);
}
.btn-small {
  min-height: 30px;
  padding: 0 12px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
}

/* =============================================================
   MOOD GRAPH
   ============================================================= */
.mood-graph { padding-bottom: 14px; }
.mood-graph-canvas {
  display: flex;
  gap: 8px;
  padding: 0 22px;
  margin: 6px 0 6px;
  align-items: stretch;
}
.mood-graph-y-labels {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 60px;
  padding: 4px 4px 18px 0;
  text-align: right;
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-style: normal;
  font-weight: 600;
}
.mg-y-pos { color: var(--ink-green); }
.mg-y-neu { color: var(--ink-mute); }
.mg-y-neg { color: var(--rust-400); }

.mood-graph-y-labels-words {
  width: 88px;
  padding: 2px 8px 14px 0;
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.01em;
  text-transform: none;
  font-style: italic;
  font-weight: 400;
  color: var(--ink-mute);
  line-height: 1;
}
.mood-graph-y-labels-words span {
  line-height: 1;
  white-space: nowrap;
  display: block;
  text-align: right;
}
.mood-graph-plot {
  flex: 1;
  min-width: 0;
  background:
    linear-gradient(to bottom,
      rgba(58,90,42,0.04) 0%,
      rgba(58,90,42,0.04) 33%,
      rgba(106,106,106,0.03) 33%,
      rgba(106,106,106,0.03) 67%,
      rgba(154,58,31,0.04) 67%,
      rgba(154,58,31,0.04) 100%);
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  min-height: 180px;
  position: relative;
}
.mood-graph-plot svg {
  width: 100%;
  height: 180px;
  display: block;
}
.mood-graph-x-label {
  text-align: center;
  font-family: var(--ui);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-style: normal;
  font-weight: 600;
  color: var(--ink-mute);
  padding: 0 22px 14px;
}
.mg-line   { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.mg-area   { fill: rgba(10,10,10,0.06); stroke: none; }
.mg-grid   { stroke: var(--paper-edge); stroke-width: 0.5; stroke-dasharray: 2 3; opacity: 0.7; }
.mg-xaxis-label { fill: var(--ink-mute); font-size: 9px; font-style: normal; font-family: "Inter", sans-serif; }

.mg-band { opacity: 0.05; }
.mg-band-pos { fill: var(--ink-green); }
.mg-band-neu { fill: var(--ink-mute); }
.mg-band-neg { fill: var(--rust-400); }

.mg-dot-group { cursor: pointer; }
.mg-hit { fill: transparent; }
.mg-dot    { stroke: var(--paper-light); stroke-width: 1.5; cursor: pointer; transition: r 0.18s, stroke-width 0.18s; }
.mg-dot.pos { fill: var(--ink-green); }
.mg-dot.neu { fill: var(--ink-mute); }
.mg-dot.neg { fill: var(--rust-400); }
.mg-dot.today { stroke: var(--ink); stroke-width: 2.5; }
.mg-dot-group:hover .mg-dot { r: 8; }

.mg-dot-pulse {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  opacity: 0.4;
  animation: mgPulse 2.4s ease-in-out infinite;
}
.mg-dot-pulse.pos { stroke: var(--ink-green); }
.mg-dot-pulse.neg { stroke: var(--rust-400); }
@keyframes mgPulse {
  0%, 100% { opacity: 0.5; r: 8; }
  50%      { opacity: 0; r: 14; }
}

.mg-empty { cursor: pointer; }
.mg-empty-hit { fill: transparent; }
.mg-empty-ring {
  fill: var(--paper-light);
  stroke: var(--paper-edge);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  opacity: 0.7;
  transition: all 0.15s ease;
}
.mg-empty-plus-v, .mg-empty-plus-h {
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.mg-empty:hover .mg-empty-ring {
  fill: var(--paper-mid);
  stroke: var(--ink);
  stroke-dasharray: none;
  opacity: 1;
  r: 7;
}
.mg-empty:hover .mg-empty-plus-v,
.mg-empty:hover .mg-empty-plus-h { opacity: 1; }

.mg-future { fill: var(--paper-edge); opacity: 0.4; }

/* =============================================================
   PATTERNS
   ============================================================= */
.patterns-card { padding-bottom: 16px; }
.patterns-grid {
  padding: 0 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.pattern {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--ink);
  border-radius: 0;
  padding: 10px 12px;
  font-family: var(--serif);
  font-size: 0.86rem;
  line-height: 1.4;
}
.pattern-positive { border-left-color: var(--ink-green); }
.pattern-negative { border-left-color: var(--rust-400); }
.pattern-neutral  { border-left-color: var(--paper-edge); }
.pattern-headline {
  font-weight: 500;
  font-style: normal;
  color: var(--ink);
  margin-bottom: 2px;
}
.pattern-headline em {
  color: var(--rust-400);
  font-style: italic;
}
.pattern-positive .pattern-headline em { color: var(--ink-green); }
.pattern-detail {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-mute);
}
.patterns-empty {
  padding: 22px 16px;
  text-align: center;
  font-style: italic;
  color: var(--ink-mute);
  font-size: 0.9rem;
  grid-column: 1 / -1;
  font-family: var(--serif);
}

/* Pattern stat cards (used by widgets.js) */
.pattern-card {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pattern-num {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -.01em;
  line-height: 1;
}
.pattern-label {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
}

/* =============================================================
   SUMMARY
   ============================================================= */
.summary-card {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-left: 4px solid var(--rust-400);
  padding-bottom: 16px;
  position: relative;
}
.summary-card .panel-head { border-bottom: 3px double var(--ink); }
.summary-card::before {
  content: '✦';
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 18px;
  color: var(--rust-400);
  opacity: 0.6;
}
.summary-scope-toggle {
  display: inline-flex;
  gap: 0;
  background: var(--paper-light);
  padding: 0;
  border-radius: 0;
  border: 1px solid var(--ink);
  overflow: hidden;
}
.summary-scope-btn {
  background: transparent;
  border: none;
  padding: 4px 14px;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--paper-edge);
}
.summary-scope-btn:last-child { border-right: none; }
.summary-scope-btn:hover { color: var(--ink); background: var(--paper-mid); }
.summary-scope-btn.is-active {
  background: var(--ink);
  color: var(--paper-light);
}
.summary-body {
  padding: 6px 22px 0;
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--ink);
}
.summary-body p,
.summary-line {
  margin: 0 0 10px;
  font-family: var(--serif);
}
.summary-body p:last-child,
.summary-line:last-child { margin-bottom: 0; }
.summary-body em {
  color: var(--ink);
  font-style: italic;
  font-weight: 500;
  border-bottom: 1px solid var(--rust-400);
}
.summary-stat {
  display: inline-block;
  padding: 1px 8px;
  margin: 0 2px;
  background: var(--paper-mid);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  font-family: var(--ui);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.summary-stat.pos { background: var(--ink-green); color: var(--paper-light); border-color: var(--ink-green); }
.summary-stat.neu { background: var(--paper-mid); color: var(--ink); border-color: var(--paper-edge); }
.summary-stat-hz {
  background: var(--ink);
  color: var(--paper-light) !important;
  border-color: var(--ink) !important;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.summary-hz-chip {
  background: var(--paper-mid) !important;
  border: 1px solid var(--paper-edge) !important;
  color: var(--ink) !important;
  font-weight: 500;
}
.summary-hz-chip .summary-list-chip-count {
  color: var(--rust-400);
  font-weight: 600;
  font-style: normal;
}

.summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 10px;
}
.summary-list-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper-mid);
  border: 1px solid var(--paper-edge);
  padding: 2px 9px;
  border-radius: 0;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.summary-list-chip.pos { background: var(--ink-green); color: var(--paper-light); border-color: var(--ink-green); }
.summary-list-chip.neg { background: var(--rust-400); color: var(--paper-light); border-color: var(--rust-400); }
.summary-list-chip-count {
  font-size: 0.66rem;
  opacity: 0.75;
  font-weight: 400;
}
.summary-section-label {
  display: block;
  font-family: var(--ui);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--rust-400);
  font-weight: 600;
  font-style: normal;
  margin: 14px 0 6px;
}
.summary-section-label:first-child { margin-top: 0; }
.summary-empty {
  padding: 22px 16px;
  text-align: center;
  font-style: italic;
  color: var(--ink-mute);
  font-family: var(--serif);
}
.summary-reflection {
  margin-top: 12px !important;
  padding: 12px 16px !important;
  background: var(--paper-mid);
  border-left: 3px solid var(--rust-400);
  border-radius: 0;
  font-size: 0.92rem !important;
  line-height: 1.65;
  color: var(--ink-soft);
  font-family: var(--serif);
}
.summary-reflection em:first-child {
  color: var(--rust-400);
  font-weight: 500;
  letter-spacing: 0.02em;
  font-style: italic;
  border-bottom: none;
}

/* =============================================================
   HABIT GRAPH
   ============================================================= */
.habit-graph { padding-bottom: 16px; }
.habit-graph-canvas {
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.habit-graph-canvas:empty { display: none; }
.habit-graph-canvas:empty + .habit-graph-empty { display: flex; }
.habit-graph-empty {
  display: none;
  margin: 0 22px;
  padding: 22px 16px;
  background: var(--paper-mid);
  border: 1px dashed var(--paper-edge);
  border-radius: 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mute);
  font-size: 0.9rem;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.habit-row {
  display: grid;
  grid-template-columns: 140px 1fr 64px;
  gap: 10px;
  align-items: center;
  padding: 3px 0;
}
.habit-row-name {
  font-family: var(--serif);
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-row-days {
  display: grid;
  grid-template-columns: repeat(31, 1fr);
  gap: 1px;
}
.habit-day-sq {
  aspect-ratio: 1;
  max-height: 26px;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge-soft);
  border-radius: 0;
  transition: all 0.1s;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.habit-day-num {
  font-family: var(--serif);
  font-size: 0.62rem;
  font-weight: 500;
  font-style: normal;
  color: var(--ink-mute);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.habit-day-sq.filled .habit-day-num {
  color: var(--paper-light);
  opacity: 0.9;
}
.habit-day-sq.future .habit-day-num {
  color: var(--ink-mute);
  opacity: 0.4;
}
.habit-day-sq.filled {
  background: var(--ink);
  border-color: var(--ink);
}
.habit-day-sq.future {
  opacity: 0.3;
  cursor: default;
  background: transparent;
  border-style: dashed;
}
.habit-day-sq.today {
  border-color: var(--rust-400);
  border-width: 2px;
}
.habit-day-sq:not(.future):not(.filled):hover {
  background: var(--paper-mid);
  border-color: var(--ink);
}
.habit-row-count {
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  color: var(--ink-mute);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.habit-row-count .count-pct {
  color: var(--rust-400);
  font-weight: 600;
}

/* widgets.js habit table */
#habitGraphCanvas table {
  width: 100%;
  border-collapse: collapse;
}
#habitGraphCanvas th,
#habitGraphCanvas td {
  border: 1px solid var(--paper-edge-soft);
  padding: 0;
  text-align: center;
}
#habitGraphCanvas th {
  font-family: var(--ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  background: var(--paper-mid);
  padding: 4px 0;
}
#habitGraphCanvas th.habit-name-cell {
  text-align: left;
  padding: 4px 8px;
  background: var(--paper-mid);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-style: normal;
}
#habitGraphCanvas td.habit-name-cell {
  text-align: left;
  padding: 4px 8px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  position: relative;
}
.habit-name-text {
  cursor: pointer;
  font-style: italic;
}
.habit-name-text:hover { color: var(--rust-400); }
.habit-del-x {
  background: transparent;
  border: 0;
  color: var(--rust-400);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0.5;
  font-family: var(--serif);
  line-height: 1;
}
.habit-del-x:hover { opacity: 1; }
.habit-cell {
  width: 100%;
  height: 22px;
  background: var(--paper-light);
  cursor: pointer;
  transition: background 0.1s;
}
.habit-cell:hover { background: var(--paper-mid); }
.habit-cell.is-filled { background: var(--ink); }
.habit-cell.is-today { box-shadow: inset 0 0 0 1px var(--rust-400); }
.habit-cell.is-future { background: transparent; opacity: 0.3; cursor: default; }

#habitMonthLabel,
#moodGraphTitle {
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
}

/* Habit history */
#habitHistoryToggle {
  background: var(--paper-light);
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 5px 12px;
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border-radius: 1px;
}
#habitHistoryToggle:hover { background: var(--ink); color: var(--paper-light); }
#habitHistoryBody {
  margin: 10px 22px;
  padding: 12px;
  border: 1px solid var(--paper-edge);
  background: var(--paper-mid);
}
#habitHistoryYear {
  font-family: var(--serif);
  font-size: 0.95rem;
  padding: 4px 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  background: var(--paper-light);
  cursor: pointer;
}
#habitHistoryMonths {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}
#habitHistoryMonths button {
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 1px;
  color: var(--ink-mute);
}
#habitHistoryMonths button.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-light);
}
#habitHistoryShowBtn {
  margin-top: 8px;
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 6px 14px;
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border-radius: 1px;
}
#habitHistoryShowBtn:hover { background: var(--rust-400); border-color: var(--rust-400); }
.habit-history-empty {
  padding: 18px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mute);
}

/* Habit add (homepage) */
#homeHabitNewInput {
  padding: 8px 10px;
  font-family: var(--serif);
  font-size: 0.92rem;
  border: 1px solid var(--paper-edge);
  background: var(--paper-light);
  border-radius: 1px;
}
#homeHabitAddBtn {
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 8px 16px;
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border-radius: 1px;
}
#homeHabitAddBtn:hover { background: var(--rust-400); border-color: var(--rust-400); }

/* =============================================================
   RECENT ENTRIES
   ============================================================= */
.recent-panel { padding-bottom: 12px; }
.recent-list {
  padding: 0 22px;
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-edge) var(--paper-mid);
  transition: max-height 0.3s ease;
}
.recent-panel.is-expanded .recent-list { max-height: 640px; }
.recent-list::-webkit-scrollbar { width: 6px; }
.recent-list::-webkit-scrollbar-track { background: var(--paper-mid); }
.recent-list::-webkit-scrollbar-thumb { background: var(--paper-edge); }

.recent-panel:not(.is-expanded) .recent-card-item {
  padding: 8px 12px;
  gap: 10px;
  grid-template-columns: 96px 1fr auto;
}
.recent-panel:not(.is-expanded) .recent-card-preview {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.82rem;
}
.recent-panel:not(.is-expanded) .recent-card-date { font-size: 0.74rem; }
.recent-panel:not(.is-expanded) .recent-card-chips { display: none; }

.recent-expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--ui);
  font-style: normal;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 1px;
  cursor: pointer;
  margin: 10px 22px 6px;
  transition: all 0.15s;
}
.recent-expand-toggle:hover {
  background: var(--ink);
  color: var(--paper-light);
}
.rex-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  line-height: 1;
  font-size: 0.95rem;
}
.recent-panel.is-expanded .rex-chevron { transform: rotate(90deg); }

.recent-card-item {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  background: var(--paper-light);
  border-left: 3px solid var(--ink);
}
.recent-card-item.is-positive { border-left-color: var(--ink-green); }
.recent-card-item.is-neutral  { border-left-color: var(--paper-edge); }
.recent-card-item.is-negative { border-left-color: var(--rust-400); }
.recent-card-date {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 0.88rem;
}
.recent-card-body { min-width: 0; }
.recent-card-text {
  line-height: 1.55;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.92rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.recent-card-dreams {
  margin-top: 6px;
  color: var(--ink-mute);
  font-style: italic;
  font-size: 0.85rem;
  font-family: var(--serif);
}
.recent-card-tone {
  display: inline-block;
  padding: 1px 8px;
  font-family: var(--ui);
  font-size: 9.5px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 0;
  margin-left: 6px;
}
.recent-card-tone.pos { background: var(--ink-green); color: var(--paper-light); }
.recent-card-tone.neu { background: var(--paper-edge); color: var(--ink); }
.recent-card-tone.neg { background: var(--rust-400); color: var(--paper-light); }

/* widgets.js .recent-item compact card */
.recent-item {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recent-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.recent-date {
  font-family: var(--serif);
  font-size: 0.94rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}
.recent-mood {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rust-400);
  font-weight: 600;
}
.recent-text {
  font-family: var(--serif);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  position: relative;
  max-height: 60px;
  overflow: hidden;
  white-space: pre-wrap;
}
.recent-text.is-expanded { max-height: none; }
.recent-text-fade {
  position: absolute;
  inset: auto 0 0 0;
  height: 24px;
  background: linear-gradient(transparent, var(--paper-light));
  pointer-events: none;
}
.recent-text.is-expanded .recent-text-fade { display: none; }
.recent-actions {
  display: flex;
  gap: 6px;
}
.recent-actions button {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  color: var(--ink);
  padding: 4px 10px;
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border-radius: 1px;
}
.recent-actions button:hover { background: var(--ink); color: var(--paper-light); border-color: var(--ink); }

.text-link {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  font-weight: 500;
  font-style: italic;
  font-family: var(--serif);
  font-size: 0.88rem;
  border-bottom: 1px solid var(--rust-400);
  padding: 2px 0;
  transition: all 0.15s;
}
.text-link:hover { color: var(--rust-400); }

.empty-state {
  padding: 24px 18px;
  border: 1px dashed var(--paper-edge);
  border-radius: 0;
  color: var(--ink-mute);
  text-align: center;
  background: var(--paper-light);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
}

/* =============================================================
   EXPORT / COMPARE
   ============================================================= */
.export-card {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-left: 4px solid var(--ink);
  padding-bottom: 18px;
}
.export-controls {
  padding: 4px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-range {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.export-ctl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-style: normal;
  font-weight: 600;
  flex: 1 1 140px;
}
.export-ctl input[type="date"] {
  font-family: var(--serif);
  font-size: 0.9rem;
  font-style: normal;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  padding: 6px 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  cursor: pointer;
}
.export-ctl input[type="date"]:focus {
  outline: 2px solid var(--rust-400);
  border-color: var(--ink);
}
.export-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.export-quick-btn {
  background: var(--paper-light);
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 4px 12px;
  border-radius: 1px;
  font-family: var(--ui);
  font-style: normal;
  font-weight: 600;
  font-size: 0.7rem;
  cursor: pointer;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.export-quick-btn:hover {
  background: var(--ink);
  color: var(--paper-light);
}
.export-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 0 4px;
}
.export-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--serif);
  font-size: 0.86rem;
  font-style: italic;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  font-weight: 400;
}
.export-checkbox input[type="checkbox"] {
  accent-color: var(--ink);
  cursor: pointer;
  width: 14px;
  height: 14px;
  margin: 0;
}
.export-go-btn {
  align-self: flex-start;
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 9px 22px;
  border-radius: 1px;
  font-family: var(--ui);
  font-style: normal;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: all 0.15s;
  box-shadow: 1px 1px 0 var(--paper-light), 2px 2px 0 rgba(10,10,10,.35);
}
.export-go-btn:hover {
  background: var(--rust-400);
  border-color: var(--rust-400);
  transform: translate(1px,1px);
  box-shadow: 0 0 0 var(--paper-light), 1px 1px 0 rgba(10,10,10,.35);
}
.export-go-btn:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}
.export-status {
  font-family: var(--ui);
  font-size: 0.74rem;
  font-style: normal;
  color: var(--rust-400);
  min-height: 18px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.compare-card {
  padding-bottom: 18px;
}
.compare-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 6px 22px 14px;
  border-bottom: 1px solid var(--paper-edge);
  margin-bottom: 14px;
}
.compare-period {
  flex: 1 1 220px;
  min-width: 0;
}
.compare-period-label {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-style: normal;
  font-weight: 600;
  margin-bottom: 4px;
}
.compare-period-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.compare-kind,
.compare-month,
.compare-year {
  font-family: var(--serif);
  font-size: 0.86rem;
  font-style: normal;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  padding: 4px 8px;
  cursor: pointer;
  min-width: 80px;
  flex: 1;
}
.compare-kind:focus,
.compare-month:focus,
.compare-year:focus {
  outline: 2px solid var(--rust-400);
  border-color: var(--ink);
}
.compare-vs {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.2rem;
  color: var(--ink);
  padding: 0 6px;
  align-self: center;
  flex-shrink: 0;
}
.compare-run-btn {
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 7px 16px;
  border-radius: 1px;
  font-family: var(--ui);
  font-style: normal;
  font-weight: 600;
  font-size: 0.74rem;
  cursor: pointer;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: all 0.15s;
  white-space: nowrap;
}
.compare-run-btn:hover {
  background: var(--rust-400);
  border-color: var(--rust-400);
}

.compare-body {
  padding: 0 22px;
}
.compare-empty {
  text-align: center;
  font-style: italic;
  font-family: var(--serif);
  color: var(--ink-mute);
  padding: 22px 16px;
  font-size: 0.92rem;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}
.compare-col {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  padding: 12px 14px;
}
.compare-col-label {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rust-400);
  font-style: normal;
  font-weight: 600;
  border-bottom: 1px solid var(--paper-edge);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.compare-col h4,
.compare-col h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: -.005em;
  color: var(--ink);
  margin: 0 0 8px;
}
.compare-stat-row,
.compare-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dotted var(--paper-edge);
  font-family: var(--serif);
  font-size: 0.86rem;
  gap: 10px;
}
.compare-stat-row:last-of-type,
.compare-stat:last-of-type { border-bottom: none; }
.compare-stat-label {
  color: var(--ink-soft);
  font-style: italic;
}
.compare-stat-value,
.compare-stat-num {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  font-family: var(--serif);
}
.compare-stat-value.pos,
.compare-stat-num.pos { color: var(--ink-green); }
.compare-stat-value.neg,
.compare-stat-num.neg { color: var(--rust-400); }
.compare-section {
  margin-top: 10px;
}
.compare-section-label {
  font-family: var(--ui);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-style: normal;
  font-weight: 600;
  display: block;
  margin: 10px 0 4px;
}
.compare-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--paper-mid);
  border: 1px solid var(--paper-edge);
  padding: 2px 8px;
  border-radius: 0;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.compare-chip-count {
  font-size: 0.62rem;
  font-weight: 400;
  opacity: 0.7;
}
.compare-chip.pos { background: var(--ink-green); color: var(--paper-light); border-color: var(--ink-green); }
.compare-chip.neg { background: var(--rust-400); color: var(--paper-light); border-color: var(--rust-400); }

.compare-deltas {
  background: var(--paper-mid);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  padding: 12px 14px;
  margin-top: 10px;
}
.compare-deltas h3 {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 6px;
}
.compare-delta-line {
  font-family: var(--serif);
  font-size: 0.88rem;
  color: var(--ink-soft);
  padding: 2px 0;
}

@media (max-width: 640px) {
  .compare-grid { grid-template-columns: 1fr; }
  .compare-vs { text-align: center; width: 100%; padding: 4px 0; }
}

/* =============================================================
   DAY POPUP MODAL
   ============================================================= */
.day-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  padding: 20px;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
}
.day-popup.is-open { display: flex; }
.day-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.75);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.day-popup-dialog {
  position: relative;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 1px;
  max-width: 1020px;
  width: 100%;
  margin: 20px auto;
  box-shadow: 1px 1px 0 var(--ink), 12px 12px 0 rgba(10,10,10,.18);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dp-head {
  background: var(--paper-light);
  color: var(--ink);
  padding: 14px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-shrink: 0;
  border-top: 4px double var(--ink);
  border-bottom: 1px solid var(--ink);
}
.dp-head-left { flex: 1; min-width: 0; }
.dp-eyebrow {
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.75;
  font-weight: 600;
  font-style: normal;
  margin-bottom: 4px;
  display: block;
  color: var(--ink-mute);
}
.dp-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: -.005em;
  margin: 0 0 2px;
  color: var(--ink);
  line-height: 1.1;
}
.dp-sub {
  font-family: var(--serif);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-mute);
  margin: 0;
}
.dp-close {
  background: var(--paper-light);
  border: 1px solid var(--ink);
  color: var(--ink);
  width: 30px; height: 30px;
  border-radius: 1px;
  cursor: pointer;
  font-size: 1.1rem;
  font-family: var(--serif);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
}
.dp-close:hover { background: var(--ink); color: var(--paper-light); }

.dp-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-edge) var(--paper-mid);
  background: var(--paper);
}
.dp-body::-webkit-scrollbar { width: 8px; }
.dp-body::-webkit-scrollbar-thumb { background: var(--paper-edge); }

.dp-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.dp-col.dp-col-full { grid-column: 1 / -1; }

.dp-block {
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 1px;
  padding: 10px 14px;
}
.dp-block-label {
  display: block;
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-style: normal;
  font-weight: 600;
  color: var(--rust-400);
  margin-bottom: 6px;
}
.dp-block textarea,
.dp-block input[type="text"] {
  background: var(--paper);
  font-family: var(--serif);
  font-size: 0.92rem;
  padding: 8px 10px;
  border-radius: 1px;
  border: 1px solid var(--paper-edge);
  min-height: auto;
}
.dp-block textarea { min-height: 76px; }
.dp-block textarea:focus,
.dp-block input[type="text"]:focus {
  border-color: var(--ink);
  background: var(--paper-light);
}

.dp-dreams-block {
  background: var(--paper-mid);
  border: 1px dashed var(--ink);
  position: relative;
}
.dp-dreams-block::before {
  content: '☾';
  position: absolute;
  top: 8px; right: 14px;
  font-size: 18px;
  color: var(--rust-400);
  opacity: 0.6;
  line-height: 1;
}

/* Tone chips inside popup */
.dp-tone-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.dp-tone-row-fine {
  gap: 3px;
  justify-content: flex-start;
  padding: 2px 0 4px;
}
.dp-tone-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 5px 11px;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  line-height: 1;
  position: relative;
}
.dp-tone-chip:hover {
  border-color: var(--ink);
  background: var(--paper-mid);
}
.dp-tone-chip.is-active { box-shadow: 1px 1px 0 var(--ink); }

.dp-tone-shame.is-active,
.dp-tone-guilt.is-active,
.dp-tone-apathy.is-active,
.dp-tone-grief.is-active,
.dp-tone-fear.is-active,
.dp-tone-desire.is-active,
.dp-tone-anger.is-active,
.dp-tone-pride.is-active {
  background: var(--rust-400);
  color: var(--paper-light);
  border-color: var(--rust-400);
}
.dp-tone-courage.is-active,
.dp-tone-neutrality.is-active {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}
.dp-tone-willingness.is-active,
.dp-tone-acceptance.is-active,
.dp-tone-reason.is-active,
.dp-tone-love.is-active,
.dp-tone-joy.is-active,
.dp-tone-peace.is-active,
.dp-tone-assured.is-active {
  background: var(--ink-green);
  color: var(--paper-light);
  border-color: var(--ink-green);
}

/* Mini picker */
.dp-mini-picker { margin-top: 4px; }
.dp-mini-search {
  width: 100%;
  margin-bottom: 6px;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 5px 9px;
  font-family: var(--serif);
  font-size: 0.82rem;
  font-style: italic;
  border-radius: 1px;
  outline: none;
}
.dp-mini-search:focus { border-color: var(--ink); }

.dp-mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-height: 76px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-edge) var(--paper-mid);
}
.dp-mini-list::-webkit-scrollbar { width: 5px; }
.dp-mini-list::-webkit-scrollbar-thumb { background: var(--paper-edge); }

.dp-mini-item {
  padding: 2px 8px;
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  background: var(--paper-light);
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.12s;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.dp-mini-item.pol-positive { color: var(--ink-green); border-color: var(--ink-green); }
.dp-mini-item.pol-negative { color: var(--rust-400); border-color: var(--rust-400); }
.dp-mini-item:hover { background: var(--paper-mid); }
.dp-mini-item.is-selected {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}
.dp-mini-item.pol-positive.is-selected {
  background: var(--ink-green);
  color: var(--paper-light);
  border-color: var(--ink-green);
}
.dp-mini-item.pol-negative.is-selected {
  background: var(--rust-400);
  color: var(--paper-light);
  border-color: var(--rust-400);
}

.dp-mini-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--paper-edge);
}
.dp-mini-selected:empty { display: none; }
.dp-mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 3px 1px 8px;
  background: var(--ink);
  color: var(--paper-light);
  border-radius: 0;
  font-family: var(--ui);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.dp-mini-chip.pol-positive { background: var(--ink-green); }
.dp-mini-chip.pol-negative { background: var(--rust-400); }
.dp-mini-chip .chip-x {
  width: 14px; height: 14px;
  background: rgba(253,248,236,0.22);
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-style: normal;
  font-family: var(--serif);
}

/* Popup media */
.dp-media-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--paper-edge);
}
.dp-media-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 4px 12px;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  color: var(--ink);
  cursor: pointer;
  border-radius: 1px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.dp-media-btn:hover {
  background: var(--ink);
  color: var(--paper-light);
}
.dp-media-btn.is-recording {
  background: var(--rust-400);
  color: var(--paper-light);
  border-color: var(--rust-400);
  animation: recPulse 1.6s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(154,58,31,0.25); }
  50%      { box-shadow: 0 0 0 6px rgba(154,58,31,0.05); }
}
.dp-media-btn .media-icon {
  font-size: 9px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rust-400);
  color: var(--paper-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-family: var(--serif);
}
.dp-media-btn:hover .media-icon,
.dp-media-btn.is-recording .media-icon {
  background: var(--paper-light);
  color: var(--ink);
}

.dp-media-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.dp-media-preview:empty { display: none; }
.media-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  font-family: var(--serif);
  font-size: 0.74rem;
  font-style: italic;
  color: var(--ink-mute);
}
.media-chip img,
.media-chip video {
  width: 38px; height: 38px;
  object-fit: cover;
  border-radius: 0;
  border: 1px solid var(--paper-edge);
}
.media-chip audio { height: 22px; max-width: 160px; }
.media-chip-x {
  background: var(--ink);
  color: var(--paper-light);
  border: 1px solid var(--ink);
  width: 18px; height: 18px;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 0.78rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.media-chip-x:hover { background: var(--rust-400); border-color: var(--rust-400); }

/* Habit list in popup */
.habit-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.habit-list:empty { display: none; }
.habit-row-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  transition: all 0.12s;
}
.habit-row-item.is-checked {
  background: var(--paper-mid);
  border-color: var(--ink);
}
.habit-row-item label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.habit-row-item input[type="checkbox"] { display: none; }
.habit-box {
  width: 16px; height: 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper-light);
  flex-shrink: 0;
  position: relative;
  transition: all 0.12s;
}
.habit-row-item input:checked + .habit-box {
  background: var(--ink);
}
.habit-row-item input:checked + .habit-box::after {
  content: '✓';
  position: absolute;
  top: -3px; left: 2px;
  color: var(--paper-light);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  font-style: normal;
}
.habit-name-text {
  font-family: var(--serif);
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-row-item.is-checked .habit-name-text {
  text-decoration: line-through;
  color: var(--ink-mute);
}
.habit-row-item.is-editing .habit-name-text { display: none; }
.habit-row-item input[type="text"].habit-edit-input {
  flex: 1;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  padding: 3px 8px;
  font-family: var(--serif);
  font-size: 0.82rem;
  border-radius: 1px;
  outline: none;
}
.habit-tool {
  background: transparent;
  border: none;
  padding: 2px 6px;
  font-family: var(--ui);
  font-size: 0.62rem;
  font-style: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-mute);
  cursor: pointer;
  border-radius: 1px;
  transition: all 0.12s;
  flex-shrink: 0;
}
.habit-tool:hover { background: var(--ink); color: var(--paper-light); }
.habit-tool.delete:hover { background: var(--rust-400); }

.habit-add-row {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--paper-edge);
}
.habit-add-row input {
  flex: 1;
  min-width: 0;
  background: var(--paper-light);
  border: 1px solid var(--paper-edge);
  padding: 5px 10px;
  font-family: var(--serif);
  font-size: 0.84rem;
  font-style: italic;
  border-radius: 1px;
  outline: none;
}
.habit-hint {
  font-family: var(--serif);
  font-size: 0.7rem;
  font-style: italic;
  color: var(--ink-mute);
  margin: 6px 0 0;
}

.dp-foot {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--ink);
  background: var(--paper-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dp-foot-info {
  font-family: var(--serif);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--ink-mute);
}
.dp-foot-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =============================================================
   INFO MODAL
   ============================================================= */
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  padding: 20px;
  align-items: center;
  justify-content: center;
}
.info-modal.is-open { display: flex; }
.info-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.7);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.info-modal-dialog {
  position: relative;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 1px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 22px 26px;
  box-shadow: 1px 1px 0 var(--ink), 12px 12px 0 rgba(10,10,10,.18);
}
.info-modal-dialog h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: -.005em;
  margin: 0 0 12px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 3px double var(--ink);
}
.info-modal-dialog p {
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.6;
  margin-bottom: 10px;
  color: var(--ink-soft);
}
.info-modal-close {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  width: 30px; height: 30px;
  border-radius: 1px;
  font-family: var(--serif);
  transition: all 0.15s;
}
.info-modal-close:hover {
  background: var(--ink);
  color: var(--paper-light);
}

/* =============================================================
   SITE FOOTER
   ============================================================= */
.site-footer {
  border-top: 1px solid var(--ink);
  background: var(--paper-light);
  margin-top: auto;
  position: relative;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: -5px; left: 0; right: 0;
  height: 3px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: transparent;
}
.site-footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.site-footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.site-footer-nav > a {
  position: relative;
  font-family: var(--ui);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 4px 2px;
  text-decoration: none;
  transition: color 0.18s ease;
}
.site-footer-nav > a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--rust-400);
  transition: right 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.site-footer-nav > a:hover { color: var(--rust-400); }
.site-footer-nav > a:hover::after { right: 0; }

.site-footer-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 18px;
  border-left: 1px solid var(--paper-edge);
}
.site-footer-lang-label {
  font-family: var(--ui);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  font-style: normal;
}
.site-footer-lang-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--paper-light);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1 L5 5 L9 1' stroke='%230a0a0a' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  border: 1px solid var(--ink);
  border-radius: 1px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 500;
  padding: 5px 28px 5px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  max-height: 32px;
}
.site-footer-lang-select:hover {
  background-color: var(--paper-mid);
}
.site-footer-lang-select:focus {
  outline: 2px solid var(--rust-400);
  outline-offset: 1px;
}

.site-footer-copy {
  color: var(--ink-mute);
  font-family: var(--serif);
  font-size: 0.78rem;
  font-style: italic;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1080px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .site-header-inner {
    padding: 12px 20px 8px;
    gap: 8px;
  }
  .site-nav { gap: 0 18px; }
  .site-nav-link { font-size: 0.7rem; }
}

@media (max-width: 820px) {
  .site-header-top {
    grid-template-columns: minmax(0, 1fr) auto minmax(58px, 1fr);
    gap: 12px;
  }
  .site-brand-group {
    grid-column: 1;
    min-width: 0;
    gap: 8px;
  }
  .site-brand-mark {
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    line-height: 1.25;
  }
  .site-auth-link {
    min-height: 26px;
    padding: 0 9px;
    font-size: 0.6rem;
    letter-spacing: 0.13em;
  }
  .site-tagline { grid-column: 2; }
  .site-meta { display: none; }
  .site-nav { display: none; }
  .site-menu-toggle {
    display: inline-flex;
    grid-column: 3;
    justify-self: end;
  }
  .site-nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: var(--paper-light);
    border: 1px solid var(--ink);
    border-radius: 0;
    box-shadow: var(--shadow);
    margin-top: 6px;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .site-nav.is-open .site-nav-link {
    padding: 12px 18px;
    color: var(--ink);
    white-space: normal;
    border-bottom: 1px solid var(--paper-edge);
  }
  .site-nav.is-open .site-nav-link:last-child { border-bottom: none; }
  .site-nav.is-open .site-nav-link::after {
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    width: 3px;
    height: auto;
    background: transparent;
    transition: background 0.2s ease;
  }
  .site-nav.is-open .site-nav-link:hover {
    background: var(--paper-mid);
    color: var(--ink);
  }
  .site-nav.is-open .site-nav-link:hover::after { background: var(--rust-400); }
  .site-nav.is-open .site-nav-link.is-active {
    background: var(--ink);
    color: var(--paper-light);
  }
  .site-nav.is-open .site-nav-link.is-active::after { background: var(--rust-400); }
}

@media (max-width: 760px) {
  .site-header-inner {
    padding: 10px 16px;
    gap: 8px;
  }
  .site-meta { gap: 8px; }
  .site-meta-date { font-size: 0.62rem; }
  .site-meta-time { font-size: 0.95rem; }

  .page-main { padding: 22px 16px 56px; gap: 14px; }

  .panel-head { padding: 12px 16px 8px; }
  .quick-entry-form,
  .calendar-weekdays,
  .calendar-grid,
  .calendar-legend,
  .recent-list,
  .patterns-grid,
  .summary-body,
  .mood-graph-canvas,
  .mood-graph-x-label,
  .habit-graph-canvas { padding-left: 16px; padding-right: 16px; }

  .dp-body { grid-template-columns: 1fr; gap: 10px; padding: 12px 14px; }
  .dp-head { padding: 12px 14px; }
  .dp-foot { padding: 10px 14px; }

  .calendar-cell { min-height: 60px; padding: 5px 6px; }
  .calendar-cell.is-today { min-height: 84px; }
  .calendar-day { font-size: 0.86rem; }
  .calendar-mood-label { font-size: 7.5px; padding: 1px 4px; }

  .recent-card-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .recent-card-date {
    padding-bottom: 4px;
    border-bottom: 1px dotted var(--paper-edge);
  }

  .habit-row { grid-template-columns: 100px 1fr 50px; gap: 6px; }
  .habit-row-name { font-size: 0.74rem; }

  .life-line-actions { flex-direction: column; align-items: stretch; }
  .life-line-today-date { font-size: 10px; }

  .site-tagline { font-size: 1.3rem; letter-spacing: -.005em; }
  .site-footer-nav { gap: 12px 16px; }
  .site-footer-lang {
    width: 100%;
    justify-content: center;
    margin-left: 0;
    padding-left: 0;
    padding-top: 12px;
    border-left: none;
    border-top: 1px solid var(--paper-edge);
  }
}

@media (max-width: 480px) {
  .site-header-top {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }
  .site-tagline { display: none; }
  .site-menu-toggle { grid-column: 2; }
  .site-brand-group { gap: 7px; }
  .site-brand-mark {
    font-size: 0.62rem;
    letter-spacing: 0.13em;
  }
  .site-auth-link {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.58rem;
    letter-spacing: 0.11em;
  }
  .hero-title { font-size: 1.9rem; }
  .calendar-weekdays span { font-size: 0.58rem; letter-spacing: 0.12em; }
}

/* =============================================================
   PRINT
   ============================================================= */
@media print {
  body::before { display: none; }
  .site-header,
  .site-footer,
  .site-menu-toggle,
  .day-popup,
  .info-modal { display: none !important; }
  .panel { box-shadow: none; border: 1px solid #000; page-break-inside: avoid; }
  .panel-head { border-bottom: 1px solid #000; }
}


/* =============================================================
   AUTH PAGES — login, forgot password, reset password
   ============================================================= */
.auth-panel {
  max-width: 520px;
  margin: 40px auto;
  padding: 28px;
}
.auth-panel-head {
  padding-left: 0;
  padding-right: 0;
}
.auth-form {
  margin-top: 4px;
}
.auth-form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.auth-helper-line {
  margin: 8px 0 18px;
  font-family: var(--serif);
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink-mute);
}
.auth-helper-link,
.auth-inline-link {
  color: var(--ink);
  border-bottom: 1px solid var(--rust-400);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.auth-helper-link:hover,
.auth-inline-link:hover {
  color: var(--rust-400);
  border-bottom-color: var(--ink);
}
.auth-alert {
  margin: 0 0 18px;
  padding: 11px 13px;
  border: 1px solid var(--paper-edge);
  border-left: 4px solid var(--ink);
  background: var(--paper-mid);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.5;
}
.auth-alert-error {
  border-left-color: var(--rust-400);
}
.auth-alert-success {
  border-left-color: var(--ink-green);
}
.auth-note {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.6;
  font-style: italic;
}
.auth-small {
  margin: 5px 0 0;
  color: var(--ink-mute);
  font-family: var(--serif);
  font-size: 0.78rem;
  font-style: italic;
}

@media (max-width: 760px) {
  .auth-panel {
    margin: 24px auto;
    padding: 22px 18px;
  }
}

/* =============================================================
   MOBILE + DESKTOP COMPATIBILITY PATCH
   -------------------------------------------------------------
   This section is intentionally appended at the end so it can
   improve every page that uses header.php + style.css without
   touching individual PHP pages.
   ============================================================= */

html {
  width: 100%;
  -webkit-text-size-adjust: 100%;
          text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

body {
  width: 100%;
  overflow-x: clip;
}

@supports not (overflow: clip) {
  body { overflow-x: hidden; }
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

iframe { border: 0; }

.site-shell,
.site-header,
.site-header-inner,
.page-main,
.hero,
.panel,
.panel-head,
.dashboard-grid,
.dashboard-grid > *,
.compare-grid,
.compare-grid > *,
.patterns-grid,
.patterns-grid > *,
.summary-body,
.recent-card-body,
.dp-dialog,
.dp-body,
.dp-col,
.auth-panel {
  min-width: 0;
}

.panel,
.card,
.content-card,
.entry-card,
.tool-card,
.summary-card,
.export-card,
.compare-card,
.auth-panel,
.dp-block,
.recent-card-item,
.recent-item,
.empty-state {
  overflow-wrap: anywhere;
}

button,
.btn,
a,
input,
textarea,
select,
.site-menu-toggle,
.site-nav-link {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input,
textarea,
select {
  max-width: 100%;
}

/* Header: desktop stays full nav; phones use a clean dropdown menu. */
@media (min-width: 821px) {
  .site-header .site-nav {
    display: flex;
  }
  .site-header .site-menu-toggle {
    display: none;
  }
}

@media (max-width: 820px) {
  html { scroll-padding-top: 128px; }

  .site-header-inner {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .site-header-top {
    align-items: center;
  }

  .site-header .site-menu-toggle {
    display: inline-flex !important;
    min-height: 40px;
    min-width: 64px;
  }

  .site-header .site-nav {
    display: none !important;
    width: 100%;
  }

  .site-header .site-nav.is-open {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start !important;
    gap: 0;
    width: 100%;
    padding: 0;
    margin-top: 6px;
    background: var(--paper-light);
    border: 1px solid var(--ink);
    box-shadow: var(--shadow);
    max-height: min(72vh, 560px);
                max-height: min(72svh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .site-header .site-nav.is-open .site-nav-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 12px 16px;
    text-align: left;
    white-space: normal;
    line-height: 1.25;
  }

  .site-header-lang-select,
  .site-footer-lang-select {
    font-size: 16px;
  }
}

/* General responsive layout polish. */
@media (max-width: 760px) {
  body {
    font-size: 16px;
    line-height: 1.55;
  }

  body::before {
    background-size: 34px 34px;
    opacity: .09;
  }

  .page-main {
    max-width: 100%;
    padding: 18px max(12px, env(safe-area-inset-left)) 54px max(12px, env(safe-area-inset-right));
    gap: 14px;
  }

  .hero {
    width: 100%;
    padding: 12px 0 10px;
  }

  .hero-eyebrow,
  .panel-eyebrow,
  .life-line-eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.18em;
  }

  .hero-title {
    font-size: clamp(1.9rem, 10vw, 2.8rem);
    line-height: 0.98;
    margin-top: 8px;
  }

  .hero-copy {
    font-size: 1rem;
    line-height: 1.55;
  }

  .panel,
  .summary-card,
  .export-card,
  .compare-card,
  .auth-panel {
    width: 100%;
    max-width: 100%;
    box-shadow: 1px 1px 0 var(--ink), 2px 2px 0 rgba(10,10,10,.08);
  }

  .panel-head {
    align-items: stretch;
    gap: 10px;
  }

  .panel-title {
    font-size: clamp(1.15rem, 5.8vw, 1.45rem);
    line-height: 1.12;
  }

  .panel-sub {
    font-size: 0.72rem;
    line-height: 1.45;
  }

  .quick-entry-form,
  .calendar-weekdays,
  .calendar-grid,
  .calendar-legend,
  .recent-list,
  .patterns-grid,
  .summary-body,
  .mood-graph-canvas,
  .mood-graph-x-label,
  .habit-graph-canvas,
  .compare-controls,
  .compare-body,
  .export-controls,
  #habitHistoryBody {
    padding-left: 14px;
    padding-right: 14px;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  textarea {
    min-height: 140px;
  }

  .btn,
  .export-go-btn,
  .compare-run-btn,
  .export-quick-btn,
  .summary-scope-btn,
  .recent-expand-toggle,
  .dp-media-btn,
  .habit-tool,
  .site-auth-link {
    min-height: 42px;
  }
}

/* Generic one-column safety for pages that use their own grid names. */
@media (max-width: 760px) {
  .grid,
  .cards-grid,
  .card-grid,
  .tool-grid,
  .feature-grid,
  .journal-grid,
  .timeline-grid,
  .trackit-grid,
  .letters-grid,
  .meditation-grid,
  .selfanalyze-grid,
  .visionboard-grid,
  .vision-grid,
  .notes-grid {
    grid-template-columns: 1fr !important;
  }

  .card,
  .content-card,
  .entry-card,
  .tool-card,
  .feature-card,
  .journal-card,
  .timeline-card,
  .trackit-card,
  .letter-card,
  .meditation-card,
  .vision-card,
  .note-card,
  .content-box,
  .section,
  .section-card {
    width: 100%;
    max-width: 100%;
  }
}

/* Calendar: keep the seven-day grid readable instead of forcing side-scroll. */
@media (max-width: 640px) {
  .calendar-weekdays,
  .calendar-grid {
    padding-left: 12px;
    padding-right: 12px;
  }

  .calendar-weekdays span {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }

  .calendar-cell {
    min-width: 0;
    min-height: 52px;
    padding: 5px 4px;
  }

  .calendar-cell.is-today {
    min-height: 74px;
  }

  .calendar-cell.is-today::before {
    content: 'TODAY';
    top: -8px;
    font-size: 7.5px;
    letter-spacing: 0.18em;
    padding: 2px 6px;
  }

  .calendar-day {
    font-size: 0.82rem;
  }

  .calendar-preview,
  .calendar-today-prompt-sub {
    display: none;
  }

  .calendar-today-prompt-line {
    font-size: 11px;
  }

  .calendar-mood-label {
    max-width: 100%;
    font-size: 6.8px;
    letter-spacing: 0.08em;
    padding: 1px 3px;
  }

  .calendar-mood-bar {
    height: 3px;
  }
}

@media (max-width: 420px) {
  .calendar-weekdays,
  .calendar-grid {
    padding-left: 8px;
    padding-right: 8px;
  }

  .calendar-cell {
    min-height: 46px;
    padding: 4px 3px;
  }

  .calendar-cell.is-today {
    min-height: 66px;
  }

  .calendar-mood-label {
    display: none;
  }
}

/* Graphs and tables: prevent mobile overflow while preserving data. */
@media (max-width: 760px) {
  .mood-graph-canvas {
    gap: 5px;
    align-items: stretch;
  }

  .mood-graph-y-labels {
    width: 42px;
    font-size: 8px;
    letter-spacing: 0.08em;
  }

  .mood-graph-y-labels-words {
    display: none;
  }

  .mood-graph-plot,
  .mood-graph-plot svg {
    min-height: 156px;
  }

  .mood-graph-plot svg {
    height: 156px;
  }

  .habit-graph-canvas,
  #habitGraphCanvas,
  .table-wrap,
  .data-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #habitGraphCanvas table {
    min-width: 560px;
  }

  .habit-row-days {
    grid-template-columns: repeat(31, minmax(13px, 1fr));
  }
}

@media (max-width: 620px) {
  .habit-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px dotted var(--paper-edge);
  }

  .habit-row-name,
  .habit-row-count {
    text-align: left;
    font-size: 0.86rem;
  }

  .habit-day-sq {
    min-height: 20px;
  }
}

/* Forms/buttons: stack controls neatly on narrow screens. */
@media (max-width: 560px) {
  .quick-entry-actions,
  .auth-form-actions,
  .dp-foot-actions,
  .export-quick-row,
  .compare-period-row,
  .habit-add-row,
  .age-prompt-row {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-entry-actions .btn,
  .auth-form-actions .btn,
  .dp-foot-actions .btn,
  .export-go-btn,
  .compare-run-btn,
  .habit-add-row button,
  .age-prompt-row button,
  .recent-expand-toggle {
    width: 100%;
  }

  .summary-scope-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .summary-scope-btn {
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }

  .export-range,
  .compare-controls {
    gap: 10px;
  }

  .compare-kind,
  .compare-month,
  .compare-year {
    width: 100%;
    min-width: 0;
  }
}

/* Recent entries and summaries. */
@media (max-width: 560px) {
  .recent-panel:not(.is-expanded) .recent-card-item,
  .recent-card-item {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 12px;
  }

  .recent-item-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .summary-body {
    font-size: 0.95rem;
    line-height: 1.62;
  }

  .summary-list-chip,
  .compare-chip {
    max-width: 100%;
  }
}

/* Life-line/timeline: better spacing on phones. */
@media (max-width: 640px) {
  .life-line {
    padding: 14px 14px 12px;
  }

  .life-line-head {
    gap: 8px;
    margin-bottom: 18px;
  }

  .life-line-track {
    height: 96px;
    margin-left: 2px;
    margin-right: 2px;
  }

  .life-decade-label:not(.major) {
    display: none;
  }

  .life-line-today-label {
    max-width: 120px;
    white-space: normal;
    text-align: center;
  }
}

/* Popups/modals: fit real phone heights and keep actions reachable. */
@media (max-width: 640px) {
  .day-popup,
  .info-modal {
    padding: 8px;
    align-items: flex-start;
  }

  .day-popup-dialog,
  .info-modal-dialog {
    width: 100%;
    max-width: 100%;
    margin: 6px auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100svh - 16px);
    box-shadow: 1px 1px 0 var(--ink), 4px 4px 0 rgba(10,10,10,.16);
  }

  .dp-head {
    align-items: center;
  }

  .dp-title {
    font-size: clamp(1.1rem, 6vw, 1.35rem);
  }

  .dp-body {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .dp-block {
    padding: 10px;
  }

  .dp-tone-chip,
  .dp-mini-item,
  .dp-media-btn {
    min-height: 36px;
  }

  .dp-foot {
    position: sticky;
    bottom: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .dp-foot-actions {
    width: 100%;
  }
}

/* Footer and auth pages. */
@media (max-width: 560px) {
  .site-footer-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-footer-nav {
    flex-direction: column;
    gap: 8px;
  }

  .site-footer-lang {
    flex-direction: column;
    gap: 6px;
  }

  .site-footer-lang-select {
    width: min(100%, 260px);
  }

  .auth-panel {
    margin: 18px auto;
    padding: 18px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

