  /* ---------------------------------------------------------------------------
     Palette drawn from a Byzantine silk textile — moss green ground, brick-red
     lozenges, indigo accents, pearl ivory, and ochre gold.
       moss   #3c3f20 / #565934 / #b7b78c
       brick  #451a26 / #9c4a44 / #b97068   (the "mulberry" ramp)
       indigo #26314a / #374d72
       ochre  #bd9236
       ivory  #f4ecd8 / #efe6cf
     --------------------------------------------------------------------------- */
  :root {
    --bg: #f4ecd8;
    --surface: #fdf8ea;
    --surface-2: #efe6cf;
    --ink: #2a1a1c;
    --ink-soft: #77584f;
    --border: #e2d6bc;
    --mulberry-900: #451a26;
    --mulberry-700: #9c4a44;
    --mulberry-500: #b97068;
    --mulberry-tint: #e7d5c8;
    --leaf-700: #3c3f20;
    --leaf-500: #565934;
    --leaf-300: #b7b78c;
    --indigo-700: #26314a;
    --indigo-500: #374d72;
    --indigo-tint: #d6dce6;
    --gold: #bd9236;
    --shadow: rgba(69, 26, 38, 0.16);
    --focus: #374d72;
    --hero-bg: #7a2930;
    --hero-plum: #5a2130;
    --hero-olive-mid: #565934;
    --hero-olive-edge: #232d3f;
    --hero-ink: #f5edd9;
    --hero-ink-soft: #e6d9b6;
    --hero-ink-softer: #ddcfa2;
    --hero-ink-faint: #cbbc8b;
    --hero-line: #8e4636;
    --hero-band: #5c2230;
    --hero-tint: rgba(52, 18, 16, 0.32);
    --hero-art-filter: none;
    --on-accent: #fff;
    --goal-title: var(--ink);
  }

  /* ---- alternate palettes (maroon is the default above) ----
     these come before the dark-mode blocks so that, when both a palette
     and dark mode are active, the dark blocks win on the neutral tokens
     (bg/surface/ink) and the dark-palette blocks win on the accents. ---- */
  :root[data-palette="gold"] {
    --bg: #f7f0da; --surface: #fefaee; --surface-2: #f0e7cc; --border: #e6dab7;
    --mulberry-900: #6f4a12; --mulberry-700: #a97f1f; --mulberry-500: #c6a052; --mulberry-tint: #ecdfbe;
    --shadow: rgba(90, 62, 12, 0.16); --focus: #86671a; --hero-bg: #7c5c1e;
    --hero-line: #9a7526; --hero-band: #5c3f12; --hero-tint: rgba(58, 40, 12, 0.34);
    --hero-art-filter: sepia(0.35) saturate(1.25) hue-rotate(-6deg);
  }
  :root[data-palette="olive"] {
    --bg: #f1f1e2; --surface: #fbfbef; --surface-2: #e8e9d2; --border: #dbdcbf;
    --mulberry-900: #2e3a1b; --mulberry-700: #556a2d; --mulberry-500: #7c8e4d; --mulberry-tint: #dee2c7;
    --shadow: rgba(50, 60, 30, 0.16); --focus: #4a5c28; --hero-bg: #3e4a25;
    --hero-line: #5c6a35; --hero-band: #384420; --hero-tint: rgba(38, 46, 22, 0.36);
    --hero-art-filter: sepia(0.45) saturate(0.85) hue-rotate(22deg);
  }
  :root[data-palette="blue"] {
    --bg: #eef1f0; --surface: #fbfcfc; --surface-2: #e3e8ea; --border: #d3dade;
    --mulberry-900: #1d2942; --mulberry-700: #33507d; --mulberry-500: #5b79a6; --mulberry-tint: #d2dbec;
    --shadow: rgba(29, 41, 66, 0.16); --focus: #33507d; --hero-bg: #26314c;
    --hero-line: #3f5a86; --hero-band: #22314c; --hero-tint: rgba(22, 32, 54, 0.42);
    --hero-art-filter: grayscale(0.35) sepia(0.55) hue-rotate(170deg) saturate(1.35) brightness(0.95);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #15150f;
      --surface: #221f16;
      --surface-2: #2d2a1d;
      --ink: #f2ebd6;
      --ink-soft: #c9b7a6;
      --border: #433f2d;
      --mulberry-900: #ecb0a6;
      --mulberry-700: #d98a7f;
      --mulberry-500: #c9756a;
      --mulberry-tint: #3a2622;
      --leaf-700: #c9c893;
      --leaf-500: #a9a96f;
      --leaf-300: #494c2b;
      --indigo-700: #9fb1d3;
      --indigo-500: #8093bb;
      --indigo-tint: #2a3348;
      --gold: #d9b459;
      --shadow: rgba(0, 0, 0, 0.42);
      --focus: #9fb1d3;
      --on-accent: #241611;
    }
  }
  :root[data-theme="dark"] {
    --bg: #15150f;
    --surface: #221f16;
    --surface-2: #2d2a1d;
    --ink: #f2ebd6;
    --ink-soft: #c9b7a6;
    --border: #433f2d;
    --mulberry-900: #ecb0a6;
    --mulberry-700: #d98a7f;
    --mulberry-500: #c9756a;
    --mulberry-tint: #3a2622;
    --leaf-700: #c9c893;
    --leaf-500: #a9a96f;
    --leaf-300: #494c2b;
    --indigo-700: #9fb1d3;
    --indigo-500: #8093bb;
    --indigo-tint: #2a3348;
    --gold: #d9b459;
    --shadow: rgba(0, 0, 0, 0.42);
    --focus: #9fb1d3;
    --on-accent: #241611;
  }

  @media (prefers-color-scheme: dark) {
    :root[data-palette="gold"]:not([data-theme="light"]) {
      --mulberry-900: #f0d79a; --mulberry-700: #dcb457; --mulberry-500: #c99f45; --mulberry-tint: #3a3220;
      --focus: #dcb457; --hero-bg: #4a3814; --goal-title: #e6c882;
    }
    :root[data-palette="olive"]:not([data-theme="light"]) {
      --mulberry-900: #c9d69f; --mulberry-700: #9bb060; --mulberry-500: #85994f; --mulberry-tint: #2c331d;
      --focus: #9bb060; --hero-bg: #2b331b; --goal-title: #aec277;
    }
    :root[data-palette="blue"]:not([data-theme="light"]) {
      --mulberry-900: #b9cdec; --mulberry-700: #7fa2d4; --mulberry-500: #6b8cbb; --mulberry-tint: #23304a;
      --focus: #7fa2d4; --hero-bg: #1c2439; --goal-title: #93b4de;
    }
  }
  :root[data-theme="dark"][data-palette="gold"] {
    --mulberry-900: #f0d79a; --mulberry-700: #dcb457; --mulberry-500: #c99f45; --mulberry-tint: #3a3220;
    --focus: #dcb457; --hero-bg: #4a3814; --goal-title: #e6c882;
  }
  :root[data-theme="dark"][data-palette="olive"] {
    --mulberry-900: #c9d69f; --mulberry-700: #9bb060; --mulberry-500: #85994f; --mulberry-tint: #2c331d;
    --focus: #9bb060; --hero-bg: #2b331b; --goal-title: #aec277;
  }
  :root[data-theme="dark"][data-palette="blue"] {
    --mulberry-900: #b9cdec; --mulberry-700: #7fa2d4; --mulberry-500: #6b8cbb; --mulberry-tint: #23304a;
    --focus: #7fa2d4; --hero-bg: #1c2439; --goal-title: #93b4de;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  h1, h2, h3, p, div, span, button, li { overflow-wrap: break-word; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Karla", ui-sans-serif, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
  }
  h1, h2, h3 { font-family: "Fraunces", Georgia, serif; text-wrap: balance; margin: 0; }
  .num { font-family: "Space Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
  a { color: inherit; }
  button {
    font-family: inherit;
    cursor: pointer;
  }
  :focus-visible {
    outline: 2.5px solid var(--focus);
    outline-offset: 2px;
  }

  .app {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px calc(64px + env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  /* ---------- Hero ---------- */
  .hero {
    position: relative;
    overflow: hidden;
    color: var(--hero-ink);
    border-radius: 22px;
    padding: calc(22px + env(safe-area-inset-top)) 20px 26px;
    margin-bottom: 0;
    background-color: var(--hero-bg);
  }
  /* carpet-edge line — fades out before the rounded corners */
  .hero::before,
  .hero::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent 0, var(--hero-line) 16%, var(--hero-line) 84%, transparent 100%);
    pointer-events: none;
  }
  .hero::before { top: 0; }
  .hero::after { bottom: 0; }
  .hero-fringe {
    position: relative;
    z-index: 3;
    pointer-events: none;
    background-repeat: repeat-x;
    background-position: top center;
    /* taper the threads in from the edges so they don't spill past the corners */
    -webkit-mask: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
    mask: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
  }
  .hero-fringe--bottom {
    height: 30px;
    margin: -10px 0 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='30' viewBox='0 0 96 30'%3E%3Cpath d='M1.3 3.6 Q2.0 13.5 3.4 24.6' stroke='%23d3bf94' stroke-width='0.80' stroke-opacity='0.88' stroke-linecap='round' fill='none'/%3E%3Cpath d='M2.2 3.6 Q2.9 13.6 4.0 24.8' stroke='%23b49c6d' stroke-width='1.37' stroke-opacity='0.41' stroke-linecap='round' fill='none'/%3E%3Cpath d='M3.0 3.6 Q2.6 12.7 1.9 23.1' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M4.1 3.6 Q4.3 12.9 4.7 23.5' stroke='%23d3bf94' stroke-width='1.19' stroke-opacity='0.59' stroke-linecap='round' fill='none'/%3E%3Cpath d='M5.0 3.6 Q5.0 14.7 5.0 26.7' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.80' stroke-linecap='round' fill='none'/%3E%3Cpath d='M5.6 3.6 Q6.1 12.2 7.1 22.2' stroke='%23b49c6d' stroke-width='1.30' stroke-opacity='0.53' stroke-linecap='round' fill='none'/%3E%3Cpath d='M11.0 3.6 Q11.1 13.6 11.5 24.8' stroke='%23b49c6d' stroke-width='1.13' stroke-opacity='0.32' stroke-linecap='round' fill='none'/%3E%3Cpath d='M12.2 3.6 Q12.4 14.2 12.7 25.8' stroke='%23d3bf94' stroke-width='0.90' stroke-opacity='0.66' stroke-linecap='round' fill='none'/%3E%3Cpath d='M13.2 3.6 Q13.4 15.9 13.8 28.9' stroke='%23b49c6d' stroke-width='1.24' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M14.4 3.6 Q15.0 13.9 16.2 25.2' stroke='%23d3bf94' stroke-width='1.36' stroke-opacity='0.73' stroke-linecap='round' fill='none'/%3E%3Cpath d='M15.6 3.6 Q15.1 15.4 14.3 28.1' stroke='%23d3bf94' stroke-width='1.18' stroke-opacity='0.87' stroke-linecap='round' fill='none'/%3E%3Cpath d='M20.4 3.6 Q20.5 12.2 20.7 22.2' stroke='%23b49c6d' stroke-width='1.38' stroke-opacity='0.45' stroke-linecap='round' fill='none'/%3E%3Cpath d='M21.6 3.6 Q22.3 13.0 23.7 23.6' stroke='%23b49c6d' stroke-width='1.02' stroke-opacity='0.31' stroke-linecap='round' fill='none'/%3E%3Cpath d='M22.7 3.6 Q22.1 10.7 20.9 19.4' stroke='%23d3bf94' stroke-width='1.15' stroke-opacity='0.76' stroke-linecap='round' fill='none'/%3E%3Cpath d='M24.0 3.6 Q23.5 12.0 22.5 21.9' stroke='%23d3bf94' stroke-width='0.81' stroke-opacity='0.87' stroke-linecap='round' fill='none'/%3E%3Cpath d='M25.2 3.6 Q24.6 12.6 23.4 22.8' stroke='%23b49c6d' stroke-width='1.05' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M30.4 3.6 Q30.2 10.3 29.9 18.8' stroke='%23d3bf94' stroke-width='1.08' stroke-opacity='0.82' stroke-linecap='round' fill='none'/%3E%3Cpath d='M31.3 3.6 Q31.6 11.0 31.9 19.9' stroke='%23d3bf94' stroke-width='1.11' stroke-opacity='0.64' stroke-linecap='round' fill='none'/%3E%3Cpath d='M32.1 3.6 Q32.0 9.9 31.8 17.9' stroke='%23d3bf94' stroke-width='0.78' stroke-opacity='0.71' stroke-linecap='round' fill='none'/%3E%3Cpath d='M32.9 3.6 Q33.6 10.7 34.7 19.5' stroke='%23d3bf94' stroke-width='1.27' stroke-opacity='0.90' stroke-linecap='round' fill='none'/%3E%3Cpath d='M34.1 3.6 Q34.4 11.1 35.0 20.1' stroke='%23b49c6d' stroke-width='1.24' stroke-opacity='0.49' stroke-linecap='round' fill='none'/%3E%3Cpath d='M34.9 3.6 Q35.2 11.3 35.7 20.5' stroke='%23b49c6d' stroke-width='1.37' stroke-opacity='0.48' stroke-linecap='round' fill='none'/%3E%3Cpath d='M40.2 3.6 Q40.0 10.2 39.6 18.6' stroke='%23d3bf94' stroke-width='1.34' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M41.0 3.6 Q41.0 11.4 40.9 20.7' stroke='%23b49c6d' stroke-width='1.13' stroke-opacity='0.48' stroke-linecap='round' fill='none'/%3E%3Cpath d='M41.7 3.6 Q41.1 12.3 40.0 22.3' stroke='%23d3bf94' stroke-width='1.28' stroke-opacity='0.61' stroke-linecap='round' fill='none'/%3E%3Cpath d='M43.0 3.6 Q43.6 10.3 44.9 18.8' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.79' stroke-linecap='round' fill='none'/%3E%3Cpath d='M43.7 3.6 Q43.5 12.0 43.0 21.8' stroke='%23d3bf94' stroke-width='0.88' stroke-opacity='0.71' stroke-linecap='round' fill='none'/%3E%3Cpath d='M44.7 3.6 Q44.0 10.5 42.6 19.0' stroke='%23b49c6d' stroke-width='0.99' stroke-opacity='0.42' stroke-linecap='round' fill='none'/%3E%3Cpath d='M50.0 3.6 Q50.7 11.7 52.0 21.3' stroke='%23b49c6d' stroke-width='1.04' stroke-opacity='0.47' stroke-linecap='round' fill='none'/%3E%3Cpath d='M51.0 3.6 Q50.7 11.0 50.1 20.0' stroke='%23d3bf94' stroke-width='1.15' stroke-opacity='0.55' stroke-linecap='round' fill='none'/%3E%3Cpath d='M52.3 3.6 Q51.9 12.0 51.2 21.8' stroke='%23d3bf94' stroke-width='0.94' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M53.8 3.6 Q54.0 12.4 54.2 22.6' stroke='%23d3bf94' stroke-width='1.13' stroke-opacity='0.58' stroke-linecap='round' fill='none'/%3E%3Cpath d='M59.7 3.6 Q60.2 11.9 61.1 21.7' stroke='%23b49c6d' stroke-width='0.74' stroke-opacity='0.36' stroke-linecap='round' fill='none'/%3E%3Cpath d='M61.2 3.6 Q61.0 12.3 60.6 22.3' stroke='%23d3bf94' stroke-width='0.95' stroke-opacity='0.56' stroke-linecap='round' fill='none'/%3E%3Cpath d='M62.2 3.6 Q62.0 11.6 61.7 21.2' stroke='%23d3bf94' stroke-width='0.80' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M63.5 3.6 Q62.9 13.6 61.9 24.7' stroke='%23d3bf94' stroke-width='1.11' stroke-opacity='0.69' stroke-linecap='round' fill='none'/%3E%3Cpath d='M69.3 3.6 Q69.7 13.4 70.4 24.3' stroke='%23b49c6d' stroke-width='0.78' stroke-opacity='0.36' stroke-linecap='round' fill='none'/%3E%3Cpath d='M70.4 3.6 Q71.0 14.5 72.0 26.4' stroke='%23b49c6d' stroke-width='0.72' stroke-opacity='0.49' stroke-linecap='round' fill='none'/%3E%3Cpath d='M71.2 3.6 Q72.0 14.6 73.4 26.5' stroke='%23d3bf94' stroke-width='0.99' stroke-opacity='0.68' stroke-linecap='round' fill='none'/%3E%3Cpath d='M72.5 3.6 Q73.3 13.0 74.8 23.6' stroke='%23b49c6d' stroke-width='0.86' stroke-opacity='0.50' stroke-linecap='round' fill='none'/%3E%3Cpath d='M73.8 3.6 Q73.8 12.8 73.9 23.3' stroke='%23d3bf94' stroke-width='1.09' stroke-opacity='0.62' stroke-linecap='round' fill='none'/%3E%3Cpath d='M79.2 3.6 Q79.1 12.0 78.8 21.8' stroke='%23b49c6d' stroke-width='1.03' stroke-opacity='0.44' stroke-linecap='round' fill='none'/%3E%3Cpath d='M80.5 3.6 Q80.1 11.9 79.3 21.7' stroke='%23d3bf94' stroke-width='1.22' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M81.6 3.6 Q81.0 11.5 79.8 21.0' stroke='%23d3bf94' stroke-width='0.81' stroke-opacity='0.63' stroke-linecap='round' fill='none'/%3E%3Cpath d='M83.3 3.6 Q84.0 10.6 85.3 19.2' stroke='%23b49c6d' stroke-width='1.08' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M88.7 3.6 Q88.0 11.5 86.7 20.9' stroke='%23b49c6d' stroke-width='1.28' stroke-opacity='0.52' stroke-linecap='round' fill='none'/%3E%3Cpath d='M89.4 3.6 Q88.9 9.6 87.8 17.5' stroke='%23d3bf94' stroke-width='0.88' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M90.4 3.6 Q89.8 10.1 88.6 18.3' stroke='%23d3bf94' stroke-width='1.13' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M91.4 3.6 Q90.6 10.5 89.2 19.1' stroke='%23b49c6d' stroke-width='1.39' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M92.3 3.6 Q91.6 10.1 90.2 18.4' stroke='%23d3bf94' stroke-width='1.24' stroke-opacity='0.65' stroke-linecap='round' fill='none'/%3E%3Cpath d='M93.1 3.6 Q92.4 9.9 91.1 18.0' stroke='%23b49c6d' stroke-width='0.78' stroke-opacity='0.58' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
    background-size: 96px 30px;
  }
  /* dark maroon band covering the top edge of the fringe, fading at the ends */
  .hero-fringe--bottom::before,
  .hero-fringe--top::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 6px;
    height: 8px;
    background: linear-gradient(to right, transparent 0, var(--hero-band) 15%, var(--hero-band) 85%, transparent 100%);
  }
  .hero-fringe--top {
    height: 30px;
    margin: 0 0 -10px;
    transform: scaleY(-1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='30' viewBox='0 0 96 30'%3E%3Cpath d='M1.3 3.6 Q2.0 13.5 3.4 24.6' stroke='%23d3bf94' stroke-width='0.80' stroke-opacity='0.88' stroke-linecap='round' fill='none'/%3E%3Cpath d='M2.2 3.6 Q2.9 13.6 4.0 24.8' stroke='%23b49c6d' stroke-width='1.37' stroke-opacity='0.41' stroke-linecap='round' fill='none'/%3E%3Cpath d='M3.0 3.6 Q2.6 12.7 1.9 23.1' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M4.1 3.6 Q4.3 12.9 4.7 23.5' stroke='%23d3bf94' stroke-width='1.19' stroke-opacity='0.59' stroke-linecap='round' fill='none'/%3E%3Cpath d='M5.0 3.6 Q5.0 14.7 5.0 26.7' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.80' stroke-linecap='round' fill='none'/%3E%3Cpath d='M5.6 3.6 Q6.1 12.2 7.1 22.2' stroke='%23b49c6d' stroke-width='1.30' stroke-opacity='0.53' stroke-linecap='round' fill='none'/%3E%3Cpath d='M11.0 3.6 Q11.1 13.6 11.5 24.8' stroke='%23b49c6d' stroke-width='1.13' stroke-opacity='0.32' stroke-linecap='round' fill='none'/%3E%3Cpath d='M12.2 3.6 Q12.4 14.2 12.7 25.8' stroke='%23d3bf94' stroke-width='0.90' stroke-opacity='0.66' stroke-linecap='round' fill='none'/%3E%3Cpath d='M13.2 3.6 Q13.4 15.9 13.8 28.9' stroke='%23b49c6d' stroke-width='1.24' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M14.4 3.6 Q15.0 13.9 16.2 25.2' stroke='%23d3bf94' stroke-width='1.36' stroke-opacity='0.73' stroke-linecap='round' fill='none'/%3E%3Cpath d='M15.6 3.6 Q15.1 15.4 14.3 28.1' stroke='%23d3bf94' stroke-width='1.18' stroke-opacity='0.87' stroke-linecap='round' fill='none'/%3E%3Cpath d='M20.4 3.6 Q20.5 12.2 20.7 22.2' stroke='%23b49c6d' stroke-width='1.38' stroke-opacity='0.45' stroke-linecap='round' fill='none'/%3E%3Cpath d='M21.6 3.6 Q22.3 13.0 23.7 23.6' stroke='%23b49c6d' stroke-width='1.02' stroke-opacity='0.31' stroke-linecap='round' fill='none'/%3E%3Cpath d='M22.7 3.6 Q22.1 10.7 20.9 19.4' stroke='%23d3bf94' stroke-width='1.15' stroke-opacity='0.76' stroke-linecap='round' fill='none'/%3E%3Cpath d='M24.0 3.6 Q23.5 12.0 22.5 21.9' stroke='%23d3bf94' stroke-width='0.81' stroke-opacity='0.87' stroke-linecap='round' fill='none'/%3E%3Cpath d='M25.2 3.6 Q24.6 12.6 23.4 22.8' stroke='%23b49c6d' stroke-width='1.05' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M30.4 3.6 Q30.2 10.3 29.9 18.8' stroke='%23d3bf94' stroke-width='1.08' stroke-opacity='0.82' stroke-linecap='round' fill='none'/%3E%3Cpath d='M31.3 3.6 Q31.6 11.0 31.9 19.9' stroke='%23d3bf94' stroke-width='1.11' stroke-opacity='0.64' stroke-linecap='round' fill='none'/%3E%3Cpath d='M32.1 3.6 Q32.0 9.9 31.8 17.9' stroke='%23d3bf94' stroke-width='0.78' stroke-opacity='0.71' stroke-linecap='round' fill='none'/%3E%3Cpath d='M32.9 3.6 Q33.6 10.7 34.7 19.5' stroke='%23d3bf94' stroke-width='1.27' stroke-opacity='0.90' stroke-linecap='round' fill='none'/%3E%3Cpath d='M34.1 3.6 Q34.4 11.1 35.0 20.1' stroke='%23b49c6d' stroke-width='1.24' stroke-opacity='0.49' stroke-linecap='round' fill='none'/%3E%3Cpath d='M34.9 3.6 Q35.2 11.3 35.7 20.5' stroke='%23b49c6d' stroke-width='1.37' stroke-opacity='0.48' stroke-linecap='round' fill='none'/%3E%3Cpath d='M40.2 3.6 Q40.0 10.2 39.6 18.6' stroke='%23d3bf94' stroke-width='1.34' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M41.0 3.6 Q41.0 11.4 40.9 20.7' stroke='%23b49c6d' stroke-width='1.13' stroke-opacity='0.48' stroke-linecap='round' fill='none'/%3E%3Cpath d='M41.7 3.6 Q41.1 12.3 40.0 22.3' stroke='%23d3bf94' stroke-width='1.28' stroke-opacity='0.61' stroke-linecap='round' fill='none'/%3E%3Cpath d='M43.0 3.6 Q43.6 10.3 44.9 18.8' stroke='%23d3bf94' stroke-width='1.35' stroke-opacity='0.79' stroke-linecap='round' fill='none'/%3E%3Cpath d='M43.7 3.6 Q43.5 12.0 43.0 21.8' stroke='%23d3bf94' stroke-width='0.88' stroke-opacity='0.71' stroke-linecap='round' fill='none'/%3E%3Cpath d='M44.7 3.6 Q44.0 10.5 42.6 19.0' stroke='%23b49c6d' stroke-width='0.99' stroke-opacity='0.42' stroke-linecap='round' fill='none'/%3E%3Cpath d='M50.0 3.6 Q50.7 11.7 52.0 21.3' stroke='%23b49c6d' stroke-width='1.04' stroke-opacity='0.47' stroke-linecap='round' fill='none'/%3E%3Cpath d='M51.0 3.6 Q50.7 11.0 50.1 20.0' stroke='%23d3bf94' stroke-width='1.15' stroke-opacity='0.55' stroke-linecap='round' fill='none'/%3E%3Cpath d='M52.3 3.6 Q51.9 12.0 51.2 21.8' stroke='%23d3bf94' stroke-width='0.94' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M53.8 3.6 Q54.0 12.4 54.2 22.6' stroke='%23d3bf94' stroke-width='1.13' stroke-opacity='0.58' stroke-linecap='round' fill='none'/%3E%3Cpath d='M59.7 3.6 Q60.2 11.9 61.1 21.7' stroke='%23b49c6d' stroke-width='0.74' stroke-opacity='0.36' stroke-linecap='round' fill='none'/%3E%3Cpath d='M61.2 3.6 Q61.0 12.3 60.6 22.3' stroke='%23d3bf94' stroke-width='0.95' stroke-opacity='0.56' stroke-linecap='round' fill='none'/%3E%3Cpath d='M62.2 3.6 Q62.0 11.6 61.7 21.2' stroke='%23d3bf94' stroke-width='0.80' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M63.5 3.6 Q62.9 13.6 61.9 24.7' stroke='%23d3bf94' stroke-width='1.11' stroke-opacity='0.69' stroke-linecap='round' fill='none'/%3E%3Cpath d='M69.3 3.6 Q69.7 13.4 70.4 24.3' stroke='%23b49c6d' stroke-width='0.78' stroke-opacity='0.36' stroke-linecap='round' fill='none'/%3E%3Cpath d='M70.4 3.6 Q71.0 14.5 72.0 26.4' stroke='%23b49c6d' stroke-width='0.72' stroke-opacity='0.49' stroke-linecap='round' fill='none'/%3E%3Cpath d='M71.2 3.6 Q72.0 14.6 73.4 26.5' stroke='%23d3bf94' stroke-width='0.99' stroke-opacity='0.68' stroke-linecap='round' fill='none'/%3E%3Cpath d='M72.5 3.6 Q73.3 13.0 74.8 23.6' stroke='%23b49c6d' stroke-width='0.86' stroke-opacity='0.50' stroke-linecap='round' fill='none'/%3E%3Cpath d='M73.8 3.6 Q73.8 12.8 73.9 23.3' stroke='%23d3bf94' stroke-width='1.09' stroke-opacity='0.62' stroke-linecap='round' fill='none'/%3E%3Cpath d='M79.2 3.6 Q79.1 12.0 78.8 21.8' stroke='%23b49c6d' stroke-width='1.03' stroke-opacity='0.44' stroke-linecap='round' fill='none'/%3E%3Cpath d='M80.5 3.6 Q80.1 11.9 79.3 21.7' stroke='%23d3bf94' stroke-width='1.22' stroke-opacity='0.67' stroke-linecap='round' fill='none'/%3E%3Cpath d='M81.6 3.6 Q81.0 11.5 79.8 21.0' stroke='%23d3bf94' stroke-width='0.81' stroke-opacity='0.63' stroke-linecap='round' fill='none'/%3E%3Cpath d='M83.3 3.6 Q84.0 10.6 85.3 19.2' stroke='%23b49c6d' stroke-width='1.08' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M88.7 3.6 Q88.0 11.5 86.7 20.9' stroke='%23b49c6d' stroke-width='1.28' stroke-opacity='0.52' stroke-linecap='round' fill='none'/%3E%3Cpath d='M89.4 3.6 Q88.9 9.6 87.8 17.5' stroke='%23d3bf94' stroke-width='0.88' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M90.4 3.6 Q89.8 10.1 88.6 18.3' stroke='%23d3bf94' stroke-width='1.13' stroke-opacity='0.89' stroke-linecap='round' fill='none'/%3E%3Cpath d='M91.4 3.6 Q90.6 10.5 89.2 19.1' stroke='%23b49c6d' stroke-width='1.39' stroke-opacity='0.57' stroke-linecap='round' fill='none'/%3E%3Cpath d='M92.3 3.6 Q91.6 10.1 90.2 18.4' stroke='%23d3bf94' stroke-width='1.24' stroke-opacity='0.65' stroke-linecap='round' fill='none'/%3E%3Cpath d='M93.1 3.6 Q92.4 9.9 91.1 18.0' stroke='%23b49c6d' stroke-width='0.78' stroke-opacity='0.58' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
    background-size: 96px 30px;
  }
  .hero-pattern, .hero-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  .hero-pattern {
    z-index: 0;
    opacity: 0.32;
    background:
      linear-gradient(var(--hero-tint), var(--hero-tint)),
      url("assets/silk-road-pattern.jpg") center / 250px auto repeat;
    filter: saturate(0.65) brightness(0.85) blur(3px);
  }
  /* "the Spinner" — the cocoon/thread/pen/page illustration behind the header */
  .hero-art { z-index: 1; opacity: 1; filter: var(--hero-art-filter); }
  .hero-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
  }
  .wordmark {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 600;
  }
  .mascot-icon { width: 48px; height: 48px; flex: 0 0 auto; display: block; }
  .tagline {
    font-size: 0.8rem;
    color: var(--hero-ink-soft);
    letter-spacing: 0.02em;
  }
  .theme-toggle {
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.3);
    color: inherit;
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 0.78rem;
    font-weight: 600;
  }
  .theme-opts { display: flex; gap: 8px; flex-wrap: wrap; }
  .theme-opts button {
    flex: 1 1 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
  }
  .theme-opts button.active {
    border-color: var(--mulberry-700);
    background: var(--mulberry-tint);
  }
  .theme-opts .sw {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.18);
    flex: 0 0 auto;
  }
  .sw-maroon { background: #9c4a44; }
  .sw-gold { background: #a97f1f; }
  .sw-olive { background: #556a2d; }
  .sw-blue { background: #33507d; }

  /* theme picker: a small dropdown anchored to the button, no backdrop */
  .theme-dropdown {
    position: fixed;
    z-index: 300;
    width: 240px;
    max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.4);
    padding: 12px;
  }
  .theme-dropdown[hidden] { display: none; }
  .theme-dd-label {
    margin: 0 0 7px;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
  .theme-dd-label + .theme-opts { margin-bottom: 12px; }
  .theme-opts--grid { display: grid; grid-template-columns: 1fr 1fr; }

  .streak-counters {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    margin-bottom: 20px;
  }
  .streak-share {
    margin-left: auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.3);
    color: inherit;
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 0.78rem;
    font-weight: 600;
  }
  .streak-share:hover { background: rgba(255,255,255,0.24); }
  .streak-share svg { display: block; }
  .counter .num {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
  }
  .counter .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hero-ink-softer);
    margin-top: 4px;
  }

  .strip {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 8px;
  }
  .day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px 5px;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.16);
    position: relative;
  }
  .day.is-today {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5) inset;
  }
  .day .wk { font-size: 0.66rem; letter-spacing: 0.06em; color: var(--hero-ink-softer); text-transform: uppercase; }
  .day .mark { font-size: 1rem; line-height: 1; opacity: 0.5; }
  .day.is-filled .mark { opacity: 1; }
  .day .dnum { font-size: 0.62rem; color: var(--hero-ink-faint); }

  /* ---------- Layout ---------- */
  .layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
  }
  @media (min-width: 960px) {
    .layout { grid-template-columns: 340px 1fr; align-items: stretch; }
    /* let the editor grow so the writing pane matches the sidebar's height */
    #writingPanel { flex: 1; display: flex; flex-direction: column; }
    #writingPanel .editor-wrap { flex: 1; min-height: 0; }
    #writingPanel textarea#editor { height: 100%; resize: none; }
  }

  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 8px 24px -18px var(--shadow);
  }
  .sidebar { display: flex; flex-direction: column; gap: 20px; }
  .main-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

  /* ---------- Goal strip (Deadline / Weekly Target / Challenge), above the editor ---------- */
  .goal-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
  }
  .mini-panel {
    flex: 1 1 200px;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px -18px var(--shadow);
    overflow: hidden;
  }
  .mini-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    font-family: "Fraunces", Georgia, serif;
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--goal-title);
    padding: 13px 15px;
  }
  .mp-emoji { flex: 0 0 auto; }
  .mp-label { flex: 1; }
  .mini-caret {
    color: var(--ink-soft);
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    flex: 0 0 auto;
  }
  .mini-panel:hover .mini-caret,
  .mini-panel:focus-within .mini-caret,
  .mini-panel.open .mini-caret { transform: rotate(90deg); }

  .mini-panel-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.24s ease;
  }
  .mini-panel:hover .mini-panel-body,
  .mini-panel:focus-within .mini-panel-body,
  .mini-panel.open .mini-panel-body { grid-template-rows: 1fr; }
  .mini-panel-clip { overflow: hidden; min-height: 0; }
  .mini-panel-pad { padding: 0 15px 15px; }
  @media (hover: none) and (min-width: 641px) {
    /* Touch tablet: no real hover — a tap toggles .open; ignore sticky :hover. */
    .mini-panel:hover:not(.open) .mini-panel-body { grid-template-rows: 0fr; }
    .mini-panel:hover:not(.open) .mini-caret { transform: none; }
  }

  /* When a panel's body is pulled into the goal modal (mobile), show it fully. */
  #goalModalSlot .mini-panel-body { display: block; }
  #goalModalSlot .mini-panel-clip { overflow: visible; }
  #goalModalSlot .mini-panel-pad { padding: 0; }

  .panel h2 {
    font-size: 1.05rem;
    margin-bottom: 12px;
  }

  /* Prompts */
  .tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 14px;
  }
  .tab {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink-soft);
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .tab.active {
    background: var(--mulberry-700);
    border-color: var(--mulberry-700);
    color: var(--on-accent);
  }
  .prompt-card {
    background: var(--mulberry-tint);
    border-radius: 14px;
    padding: 16px;
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.45;
    min-height: 92px;
    display: flex;
    align-items: center;
  }
  .prompt-create {
    display: block;
    width: 100%;
    min-height: 92px;
    resize: vertical;
    background: var(--mulberry-tint);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.45;
    color: var(--ink);
  }
  .prompt-create::placeholder { color: var(--ink-soft); font-style: italic; }

  /* ---------- Writing schedule (Create tab) ---------- */
  #scheduleWrap { margin-bottom: 12px; }
  .schedule-today {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--mulberry-tint);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.88rem;
  }
  .schedule-today .btn { margin-left: auto; }
  .schedule-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  .schedule-month { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 0.95rem; }
  .schedule-nav {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--ink);
  }
  .schedule-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }
  .sched-dow {
    text-align: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    padding-bottom: 2px;
  }
  .sched-cell {
    min-height: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    font-family: inherit;
    color: var(--ink);
    overflow: hidden;
  }
  .sched-cell.sched-empty { border: none; background: none; }
  .sched-num { font-size: 0.72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .sched-cell.is-today { border-color: var(--mulberry-500); }
  .sched-cell.is-today .sched-num { color: var(--mulberry-700); font-weight: 700; }
  .sched-cell.has-plan { background: var(--mulberry-tint); border-color: var(--mulberry-tint); }
  .sched-cell.is-selected { box-shadow: 0 0 0 2px var(--mulberry-500) inset; }
  .sched-plan {
    font-size: 0.56rem;
    line-height: 1.15;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .schedule-editor { margin-top: 12px; }
  .schedule-upcoming { margin-top: 12px; }
  .schedule-upcoming-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin-bottom: 6px;
  }
  .schedule-up-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
    width: 100%;
    text-align: left;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 6px;
    font-family: inherit;
    color: var(--ink);
    font-size: 0.85rem;
  }
  .schedule-up-row.is-selected { box-shadow: 0 0 0 2px var(--mulberry-500) inset; }
  .schedule-up-date {
    flex: 0 0 auto;
    min-width: 86px;
    font-weight: 700;
    color: var(--mulberry-700);
  }
  .schedule-up-subj {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
  }
  .btn {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .btn:hover { border-color: var(--mulberry-500); }
  .btn-primary {
    background: var(--mulberry-700);
    border-color: var(--mulberry-700);
    color: var(--on-accent);
  }
  .btn-primary:hover { background: var(--mulberry-900); border-color: var(--mulberry-900); }
  .btn-ghost { background: transparent; }

  /* Form fields (deadline modal, etc.) */
  .field {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    padding: 9px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    margin-bottom: 12px;
  }
  .field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .hint { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.4; margin: 4px 0 12px; }

  /* Badges */
  .badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 10px;
  }
  .badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
    padding: 10px 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    opacity: 0.45;
    filter: grayscale(0.6);
  }
  .badge.unlocked {
    opacity: 1;
    filter: none;
    background: linear-gradient(160deg, var(--mulberry-tint), var(--surface-2));
    border-color: var(--gold);
  }
  .badge .icon { font-size: 1.4rem; }
  .badge .name { font-size: 0.66rem; font-weight: 700; }
  .badge .desc { font-size: 0.6rem; color: var(--ink-soft); line-height: 1.2; }

  /* Writing pane */
  .writing-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
  }
  .level-block { min-width: 200px; flex: 1; }
  .level-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--ink-soft);
    margin-bottom: 6px;
  }
  .level-line strong { color: var(--ink); font-family: "Fraunces", serif; font-size: 0.92rem; }
  .level-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    border: 1px solid var(--border);
  }
  .level-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--indigo-500), var(--leaf-500), var(--mulberry-700));
    border-radius: 999px;
    transition: width 0.4s ease;
  }
  @media (prefers-reduced-motion: reduce) {
    .level-bar > span { transition: none; }
  }

  textarea#editor {
    width: 100%;
    min-height: 360px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.12rem;
    line-height: 1.65;
    padding: 18px;
  }
  .word-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--ink-soft);
  }
  .word-row .num { font-weight: 700; }
  .word-row.goal-met { color: var(--leaf-700); }
  .save-state { display: flex; align-items: center; gap: 6px; }
  .dot-saved { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf-500); }

  .session-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 6px;
  }
  .session-title {
    font-family: "Fraunces", serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
  }
  .link-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.78rem;
    color: var(--ink-soft);
    text-decoration: underline;
    cursor: pointer;
  }
  .link-btn:hover { color: var(--ink); }

  .writing-footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
  }

  /* Toast */
  #toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--mulberry-900);
    color: var(--on-accent);
    padding: 11px 14px 11px 18px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 12px 30px -12px var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 90;
    max-width: 90vw;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
  #toastUndoBtn {
    display: none;
    background: #ecd7db;
    color: #4d1229;
    border: none;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    flex: 0 0 auto;
  }
  #toastUndoBtn:hover { background: #ffffff; }

  /* Modal */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(23,14,9,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 60;
  }
  .modal-backdrop.open { display: flex; }
  #sprintSetupModal { align-items: flex-start; padding-top: calc(84px + env(safe-area-inset-top)); }
  #sprintSetupModal .modal { max-height: calc(100dvh - 104px - env(safe-area-inset-top)); overflow-y: auto; }
  .modal {
    background: var(--surface);
    border-radius: 20px;
    padding: 20px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
  }
  .modal h3 { margin-bottom: 4px; }
  .modal p.sub { font-size: 0.8rem; color: var(--ink-soft); margin: 4px 0 14px; }
  #shareCanvas {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 14px;
  }
  .modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .modal-close {
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 0.78rem;
    margin-top: 10px;
    text-decoration: underline;
  }

  /* ---------- Floating panel (draggable, non-blocking) ---------- */
  .floating-panel {
    position: fixed;
    top: calc(84px + env(safe-area-inset-top));
    right: 40px;
    width: 240px;
    max-height: calc(100dvh - 104px - env(safe-area-inset-top));
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 44px -18px rgba(0,0,0,0.45);
    padding: 12px 16px 16px;
    z-index: 55;
    display: none;
  }
  .floating-panel.open { display: block; }
  .floating-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    font-family: "Fraunces", serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ink);
  }
  .floating-panel-head:active { cursor: grabbing; }
  .floating-panel-close {
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 0.9rem;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
  }
  .floating-panel-close:hover { color: var(--ink); }
  .floating-panel .sub { font-size: 0.8rem; color: var(--ink-soft); margin: 6px 0 4px; }
  @media (max-width: 640px) {
    .app {
      padding: 0 14px calc(40px + env(safe-area-inset-bottom));
      padding-left: max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }

    /* Hero bleeds to the screen edges, content stays inset */
    /* the carpet fringe doesn't hold up at phone widths — drop it here */
    .hero-fringe { display: none; }
    .hero {
      margin-left: calc(-1 * max(14px, env(safe-area-inset-left)));
      margin-right: calc(-1 * max(14px, env(safe-area-inset-right)));
      padding: calc(2px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 14px;
      padding-right: max(16px, env(safe-area-inset-right));
      margin-bottom: 16px;
    }
    /* open a band below the wordmark so the Spinner art has room */
    .hero-top { flex-wrap: wrap; align-items: flex-start; margin-bottom: 40px; }
    /* drop the Spinner down so it clears the "Mulberry" wordmark */
    .hero-art { transform: translateY(32px); }
    .wordmark { font-size: 1.3rem; }
    .tagline { margin-top: 2px; }
    .mascot-icon { width: 38px; height: 38px; }
    .theme-toggle { padding: 6px 11px; font-size: 0.74rem; }
    .streak-counters { gap: 24px; margin-bottom: 0; }
    .counter .num { font-size: 1.9rem; }

    /* The week-at-a-glance day strip is desktop-only; the hero stays compact on phones */
    .strip { display: none; }

    .panel { padding: 15px; border-radius: 16px; }
    .layout { gap: 16px; }

    /* Single column: flatten sidebar + main-col and order it
       Prompts -> goals -> editor -> badges -> settings. */
    .sidebar, .main-col { display: contents; }
    #promptsPanel { order: 1; }
    #goalStrip    { order: 2; }
    #writingPanel { order: 3; }
    #badgesPanel  { order: 4; }
    #easeInRow    { order: 5; }
    #reminderRow  { order: 6; }

    /* Goals collapse to a row of emoji buttons; tapping one opens the goal modal. */
    #goalStrip { flex-wrap: nowrap; gap: 10px; }
    #goalStrip .mini-panel { flex: 1 1 0; }
    #goalStrip .mini-panel-title { justify-content: center; padding: 14px 6px; }
    #goalStrip .mp-label,
    #goalStrip .mini-caret { display: none; }
    #goalStrip .mp-emoji { font-size: 1.5rem; }
    #goalStrip .mini-panel-body { display: none; }

    /* Stack all button rows into full-width, tappable buttons */
    .prompt-actions,
    .writing-footer,
    .modal-actions {
      flex-direction: column;
      align-items: stretch;
    }
    .prompt-actions .btn,
    .writing-footer .btn,
    .modal-actions .btn {
      width: 100%;
      justify-content: center;
    }
    .btn { padding: 12px 14px; font-size: 0.9rem; }

    /* keep the prompt's two actions side by side */
    #promptsPanel > .prompt-actions { flex-direction: row; }
    #promptsPanel > .prompt-actions .btn { width: auto; }
    #promptsPanel > .prompt-actions #shuffleBtn { flex: 0 0 auto; }
    #promptsPanel > .prompt-actions #useBtn { flex: 1 1 auto; min-width: 0; }

    /* Sprint + Pomodoro become emoji tiles, matching the goal strip */
    .head-actions { flex: 1 1 100%; flex-direction: row; flex-wrap: nowrap; gap: 10px; }
    .head-actions .btn {
      flex: 1 1 0;
      flex-direction: column;
      padding: 14px 6px;
      background: var(--surface);
      border-radius: 14px;
    }
    .head-actions .btn .mp-emoji { font-size: 1.5rem; }
    .head-actions .btn .mp-label { display: none; }

    .writing-head { gap: 10px; }
    .level-block { min-width: 0; }
    .writing-footer { justify-content: stretch; }

    /* Inputs at >=16px so iOS doesn't auto-zoom the page on focus */
    .field,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"] {
      font-size: 16px;
    }

    textarea#editor { min-height: 240px; font-size: 1.05rem; padding: 14px; }

    /* Modals go near-full-width and scroll inside themselves */
    .modal-backdrop { padding: 12px; }
    .modal {
      max-width: none;
      border-radius: 16px;
      padding: 18px;
      max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
      overflow-y: auto;
    }
    #sprintSetupModal { padding-top: calc(16px + env(safe-area-inset-top)); }

    /* Pomodoro floating panel spans the width on small screens */
    .floating-panel {
      right: 12px;
      left: 12px;
      width: auto;
      top: calc(60px + env(safe-area-inset-top));
    }

    /* Full-screen sprint session */
    .sprint-head {
      padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
    }
    .sprint-body { padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
    textarea#sprintEditor { font-size: 1.1rem; padding: 16px; }
    .sprint-clock { font-size: 1.8rem; }

    #shareCanvas { width: 100%; }
    #celebrationMsg { font-size: 1.1rem; }
  }

  /* ---------- Sprint: setup controls ---------- */
  .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

  .duration-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 14px 0;
  }
  .dur-chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    padding: 10px 0;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: "Space Mono", monospace;
  }
  .dur-chip.selected {
    background: var(--mulberry-700);
    border-color: var(--mulberry-700);
    color: var(--on-accent);
  }

  .toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 4px;
  }
  .switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    margin-top: 2px;
    display: inline-block;
  }
  .switch input { opacity: 0; width: 0; height: 0; position: absolute; }
  .switch .track {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: background 0.2s ease;
  }
  .switch .thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
  .switch input:checked + .track { background: var(--mulberry-700); }
  .switch input:checked + .track + .thumb { transform: translateX(18px); }
  .toggle-text .t-name { font-weight: 700; font-size: 0.85rem; }
  .toggle-text .t-desc { font-size: 0.75rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.4; }

  /* ---------- Sprint: full-screen session ---------- */
  .sprint-backdrop {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 80;
    display: none;
    flex-direction: column;
    align-items: center;
  }
  .sprint-backdrop.open { display: flex; }
  .sprint-head {
    width: 100%;
    max-width: 760px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 22px 20px 10px;
  }
  .sprint-mode-tag {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    font-weight: 700;
    margin-bottom: 4px;
  }
  .sprint-clock {
    font-size: 2.1rem;
    font-weight: 700;
  }
  .sprint-clock.low { color: var(--mulberry-700); }

  .sprint-body {
    width: 100%;
    max-width: 760px;
    flex: 1;
    padding: 10px 20px 26px;
    display: flex;
    flex-direction: column;
  }
  .sprint-editor-wrap {
    position: relative;
    flex: 1;
    border-radius: 18px;
    transition: box-shadow 0.15s ease;
  }
  textarea#sprintEditor {
    width: 100%;
    height: 100%;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.2rem;
    line-height: 1.7;
    padding: 22px;
    resize: none;
  }
  .sprint-editor-wrap.locked textarea#sprintEditor {
    filter: blur(9px);
    user-select: none;
  }
  .lock-overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 20px;
    pointer-events: none;
  }
  .sprint-editor-wrap.locked .lock-overlay { display: flex; }
  .lock-overlay .lock-icon { font-size: 2.2rem; }
  .lock-overlay .lock-title {
    font-family: "Fraunces", serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ink);
  }
  .lock-overlay .lock-sub {
    font-size: 0.82rem;
    color: var(--ink-soft);
    background: var(--surface);
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
  }

  .sprint-footer {
    display: flex;
    justify-content: center;
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--ink-soft);
  }
  .sprint-quit {
    background: none;
    border: none;
    color: var(--ink-soft);
    text-decoration: underline;
    font-size: 0.8rem;
  }

  /* ---------- Voice-to-text ---------- */
  .editor-wrap { position: relative; }
  .mic-btn {
    position: absolute;
    right: 16px;
    bottom: 16px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--mulberry-700);
    color: var(--on-accent);
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px -8px var(--shadow);
    z-index: 5;
  }
  .mic-btn:hover { background: var(--mulberry-900); }
  .mic-btn.unsupported { display: none; }
  .mic-btn.listening {
    background: #c2294f;
    animation: micPulse 1.3s ease-in-out infinite;
  }
  @keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(194,41,79,0.5), 0 8px 18px -8px var(--shadow); }
    50% { box-shadow: 0 0 0 10px rgba(194,41,79,0), 0 8px 18px -8px var(--shadow); }
  }
  @media (prefers-reduced-motion: reduce) {
    .mic-btn.listening { animation: none; }
  }
  .dictation-pill {
    position: absolute;
    right: 16px;
    bottom: 70px;
    max-width: calc(100% - 32px);
    background: var(--mulberry-900);
    color: var(--on-accent);
    font-size: 0.78rem;
    font-style: italic;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 8px 18px -8px var(--shadow);
    display: none;
    z-index: 5;
  }
  .dictation-pill.show { display: block; }

  @keyframes wiltShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
  }
  .sprint-editor-wrap.wilting { animation: wiltShake 0.3s ease; }
  @media (prefers-reduced-motion: reduce) {
    .sprint-editor-wrap.wilting { animation: none; }
  }

  /* ---------- Celebration (reward) ---------- */
  #celebration {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(23,14,9,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 95;
  }
  #celebration.show { opacity: 1; }
  #discoBallSvg { width: 180px; height: 180px; }
  #ballSpin { transform-origin: 100px 100px; animation: discoSpin 3s linear infinite; }
  #beamsSpin { transform-origin: 100px 100px; animation: discoSpin 6s linear infinite reverse; }
  @keyframes discoSpin { to { transform: rotate(360deg); } }
  .sparkles circle { animation: sparklePulse 1.3s ease-in-out infinite; opacity: 0; }
  .sparkles circle:nth-child(1) { animation-delay: 0s; }
  .sparkles circle:nth-child(2) { animation-delay: 0.2s; }
  .sparkles circle:nth-child(3) { animation-delay: 0.4s; }
  .sparkles circle:nth-child(4) { animation-delay: 0.6s; }
  .sparkles circle:nth-child(5) { animation-delay: 0.8s; }
  .sparkles circle:nth-child(6) { animation-delay: 1s; }
  .sparkles circle:nth-child(7) { animation-delay: 0.3s; }
  .sparkles circle:nth-child(8) { animation-delay: 0.7s; }
  @keyframes sparklePulse { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
  #celebrationMsg {
    font-family: "Fraunces", serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--on-accent);
    background: var(--mulberry-700);
    padding: 10px 20px;
    border-radius: 999px;
    box-shadow: 0 12px 30px -12px rgba(0,0,0,0.5);
    text-align: center;
  }
  #celebrationActions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
  @media (prefers-reduced-motion: reduce) {
    #ballSpin, #beamsSpin, .sparkles circle { animation: none; }
    .sparkles circle { opacity: 0.8; }
  }
  #confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }
  .confetti-piece {
    position: absolute;
    top: -20px;
    width: 16px;
    height: 16px;
    animation-name: confettiFall;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
  }
  .confetti-piece svg { width: 100%; height: 100%; display: block; }
  @keyframes confettiFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--drift, 40px), 420px) rotate(var(--spin, 480deg)); opacity: 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .confetti-piece { display: none; }
  }

  /* ---- pomodoro hourglass ---- */
  .pomodoro-hourglass {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .pomo-glass {
    stroke: var(--hero-plum);
    stroke-width: 1.6;
    stroke-opacity: 0.55;
  }
  .pomo-sand {
    fill: var(--mulberry-700);
    transition: fill 0.6s ease;
  }
  .pomodoro-hourglass.phase-break .pomo-sand { fill: var(--leaf-500); }
  .pomo-stream {
    transition: opacity 0.4s ease;
  }
  .pomo-stream line {
    stroke: var(--mulberry-700);
    stroke-width: 1.4;
    transition: stroke 0.6s ease;
  }
  .pomodoro-hourglass.phase-break .pomo-stream line { stroke: var(--leaf-500); }
  .pomo-stream .grain {
    fill: var(--mulberry-700);
    transition: fill 0.6s ease;
    animation: grainFall 0.5s linear infinite;
  }
  .pomodoro-hourglass.phase-break .pomo-stream .grain { fill: var(--leaf-500); }
  .pomo-stream .grain.g2 { animation-delay: 0.25s; }
  @keyframes grainFall {
    0% { transform: translateY(-2px); opacity: 0; }
    30% { opacity: 1; }
    100% { transform: translateY(3px); opacity: 0; }
  }
  .pomo-label {
    font-family: "Fraunces", serif;
    display: flex;
    gap: 6px;
    align-items: baseline;
  }
  .pomo-phase {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--ink-soft);
  }
  .pomo-clock { font-size: 1rem; color: var(--ink); }
  @media (prefers-reduced-motion: reduce) {
    .pomo-stream .grain { animation: none; opacity: 0.8; }
  }

  /* ---------- Group challenge ---------- */
  .challenge-board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;
  }
  .cb-row {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.9rem;
  }
  .cb-row.me { border-color: var(--mulberry-500); background: var(--mulberry-tint); }
  .cb-row.win { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
  .cb-rank {
    font-family: "Space Mono", ui-monospace, monospace;
    font-weight: 700;
    color: var(--ink-soft);
    text-align: center;
  }
  .cb-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cb-total { font-weight: 700; font-variant-numeric: tabular-nums; }

  textarea.code-box {
    display: block;
    width: 100%;
    min-height: 76px;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: "Space Mono", ui-monospace, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    padding: 10px;
    margin-bottom: 12px;
    word-break: break-all;
  }
