/* ==========================================================================
   Handwriting Repeater – stylesheet
   Layout: full-height writing app (pen panel | page | page panel, control bar),
   then the homepage content. Light theme on :root, dark theme below it.

   1. Fonts          5. Side panels & tiles   9.  Dialogs        13. Footer
   2. Design tokens  6. Tile pop-outs         10. Toast & print  14. Responsive
   3. Base           7. Writing area          11. Home content   15. Motion
   4. Header         8. Bottom bar            12. Article pages
   ========================================================================== */

/* 1. Fonts (self-hosted, SIL Open Font License) ---------------------------- */
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url(../fonts/fredoka-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url(../fonts/fredoka-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url(../fonts/fredoka-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url(../fonts/nunito-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url(../fonts/nunito-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url(../fonts/nunito-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url(../fonts/nunito-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "Lilita One"; font-weight: 400; font-display: swap; src: url(../fonts/lilita-one-latin-400-normal.woff2) format("woff2"); }

/* 2. Design tokens ---------------------------------------------------------- */
:root {
  /* type */
  --f-title: "Lilita One", "Fredoka", "Arial Black", sans-serif;
  --f-fun: "Fredoka", "Nunito", system-ui, sans-serif;
  --f-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* app colours */
  --text: #1e2230;
  --royal: #b493ee;     /* bars and dialog headers */
  --royal-2: #9b78e3;
  --navy: #5b2a86;      /* outlines */
  --tile: #cbb5f7;
  --tile-hi: #e2d5ff;
  --tile-b: #9c7ae0;    /* tile borders */
  --drawer-ico: #5b2a86; /* icon on the phone Tools/Page buttons */
  --side-bg: #f4ecff;
  --board: #fbf6fd;
  --sel-1: #ffe0f0;     /* selected / open (pink) */
  --sel-2: #ff9fd0;
  --sel-b: #e0579f;
  --on-1: #d3f8e4;      /* switched on (mint) */
  --on-2: #6fd8a2;
  --on-b: #2fa66a;
  --pink: #ff7ab8;
  --pop-bg: #f8f2ff;    /* panels and dialogs */
  --pop-card: #ffffff;
  --pop-text: #4a2370;
  --ink: #7c4fd6;
  --ink-2: #6a3cc7;
  --on-ink: #ffffff;
  --banner-bg: linear-gradient(100deg, #c3a4f6 0%, #d9b3f2 45%, #f7b6d9 100%);
  --banner-link: #5b2a86;
  --date-bg: #fff;
  --date-text: #5b2a86;
  --tile-sub: #5b2a86;

  /* homepage content colours */
  --c-bg: #faf7fc;
  --c-tint: #f3ecfb;
  --c-card: #ffffff;
  --c-text: #2b2238;
  --c-muted: #5f5670;
  --c-head: #4a2370;
  --c-accent: #8a5ce6;
  --c-accent-2: #ff6fb5;
  --c-line: #e4d9f3;
  --c-num1: #a98bf0;
  --c-num2: #7b52d9;
  --cta-bg: var(--banner-bg);
  --cta-text: #3d1a5e;

  --side-w: 256px;
  --shadow-card: 0 1px 2px rgba(60, 20, 100, .06), 0 10px 30px rgba(60, 20, 100, .08);
  --outline-text: 2px 2px 0 var(--navy), -1px -1px 0 var(--navy), 1px -1px 0 var(--navy), -1px 1px 0 var(--navy);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --text: #eceef3;
    --royal: #4a2f78; --royal-2: #3a2362; --navy: #170a28;
    --tile: #4b3278; --tile-hi: #5b3f8f; --tile-b: #2f1c52; --drawer-ico: #fff;
    --side-bg: #1d1330; --board: #130d1c;
    --sel-1: #ffb6dc; --sel-2: #ff7ab8; --sel-b: #b03c78;
    --on-1: #9be8bf; --on-2: #3fbf7f; --on-b: #1f7a4c;
    --pop-bg: #241739; --pop-card: #2f2049; --pop-text: #efe3ff;
    --ink: #c3a6ff; --ink-2: #d6c2ff; --on-ink: #1a0f2b;
    --banner-bg: linear-gradient(100deg, #3b2462 0%, #4a2a6e 50%, #6a2c5e 100%);
    --banner-link: #fff; --date-bg: #2f2049; --date-text: #efe3ff; --tile-sub: #dfe6ff;
    --c-bg: #130d1c; --c-tint: #1a1227; --c-card: #221836; --c-text: #ece4f8; --c-muted: #b9add0;
    --c-head: #e2d2ff; --c-accent: #c3a6ff; --c-accent-2: #ff8cc6; --c-line: #3a2c55; --c-num1: #8a68d8; --c-num2: #6a45c4;
    --cta-bg: linear-gradient(100deg, #3b2462, #6a2c5e); --cta-text: #efe3ff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #eceef3;
  --royal: #4a2f78; --royal-2: #3a2362; --navy: #170a28;
  --tile: #4b3278; --tile-hi: #5b3f8f; --tile-b: #2f1c52; --drawer-ico: #fff;
  --side-bg: #1d1330; --board: #130d1c;
  --sel-1: #ffb6dc; --sel-2: #ff7ab8; --sel-b: #b03c78;
  --on-1: #9be8bf; --on-2: #3fbf7f; --on-b: #1f7a4c;
  --pop-bg: #241739; --pop-card: #2f2049; --pop-text: #efe3ff;
  --ink: #c3a6ff; --ink-2: #d6c2ff; --on-ink: #1a0f2b;
  --banner-bg: linear-gradient(100deg, #3b2462 0%, #4a2a6e 50%, #6a2c5e 100%);
  --banner-link: #fff; --date-bg: #2f2049; --date-text: #efe3ff; --tile-sub: #dfe6ff;
  --c-bg: #130d1c; --c-tint: #1a1227; --c-card: #221836; --c-text: #ece4f8; --c-muted: #b9add0;
  --c-head: #e2d2ff; --c-accent: #c3a6ff; --c-accent-2: #ff8cc6; --c-line: #3a2c55; --c-num1: #8a68d8; --c-num2: #6a45c4;
  --cta-bg: linear-gradient(100deg, #3b2462, #6a2c5e); --cta-text: #efe3ff;
}

/* 3. Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--c-bg); color: var(--text); font: 16px/1.6 var(--f-body); }
a { color: var(--ink); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; padding: 8px 12px; border-radius: 8px; background: var(--pop-card); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border: 1px solid var(--tile-b); border-radius: 10px;
  background: var(--pop-card); color: var(--text); font: 500 14px/1.2 var(--f-body);
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid transparent; border-radius: 10px; background: transparent; cursor: pointer;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* 4. Header ----------------------------------------------------------------- */
.banner {
  background:
    radial-gradient(circle at 12% 30%, rgba(255, 255, 255, .35) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 70%, rgba(255, 255, 255, .35) 0 2px, transparent 3px),
    radial-gradient(circle at 92% 20%, rgba(255, 255, 255, .3) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 35% 80%, rgba(255, 255, 255, .3) 0 1.5px, transparent 2.5px),
    var(--banner-bg);
  border-bottom: 4px solid var(--navy);
}
.banner-in {
  position: relative; display: flex; align-items: center; justify-content: center;
  max-width: 1500px; height: 102px; margin: 0 auto; padding-inline: 24px;
}
.logo { position: absolute; left: 24px; top: 50%; width: 68px; height: 68px; transform: translateY(-50%); transition: transform .2s; }
.logo:hover { transform: translateY(-50%) rotate(-8deg); }
.logo svg { display: block; width: 100%; height: 100%; }
.banner-mid { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.banner-title {
  margin: 0; color: #fff; font: 400 clamp(26px, 3.7vw, 46px)/1 var(--f-title); letter-spacing: .04em;
  text-align: center; text-decoration: none;
  text-shadow: 3px 3px 0 var(--navy), -1.5px -1.5px 0 var(--navy), 1.5px -1.5px 0 var(--navy), -1.5px 1.5px 0 var(--navy), 0 6px 14px rgba(91, 42, 134, .3);
}
.banner-date {
  display: flex; align-items: center; margin: 0; padding: 5px 16px;
  border: 2.5px solid var(--navy); border-radius: 99px; box-shadow: 0 3px 0 var(--navy);
  background: var(--date-bg); color: var(--date-text); font: 600 clamp(13px, 1.6vw, 19px)/1.2 var(--f-fun); letter-spacing: .02em;
}
.banner-date time:empty::before { content: "\00a0"; }
.banner-nav { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; }
.banner-nav a { padding: 8px 11px; border-radius: 9px; color: var(--banner-link); font: 600 15px/1 var(--f-fun); text-decoration: none; }
.banner-nav a:hover { background: rgba(255, 255, 255, .4); }
.banner-nav .heart {
  display: grid; place-items: center; width: 42px; height: 42px; padding: 0;
  border: 2.5px solid var(--navy); border-radius: 50%; background: #fff; cursor: pointer;
}
.banner-nav .heart svg { width: 22px; height: 22px; }
.banner-nav .heart:hover svg { animation: beat .6s; }
@keyframes beat { 50% { transform: scale(1.2); } }

/* 5. Side panels & tiles ------------------------------------------------- */
.app {
  position: relative; display: grid; height: calc(100svh - 106px); min-height: 430px;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "left board right" "bar bar bar";
  background: var(--board); transition: grid-template-columns .25s ease;
}
.app:fullscreen { height: 100vh; }
.app.no-left { grid-template-columns: 0 minmax(0, 1fr) var(--side-w); }
.app.no-right { grid-template-columns: var(--side-w) minmax(0, 1fr) 0; }
.app.no-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }

.side { position: relative; z-index: 8; display: flex; min-height: 0; background: var(--side-bg); }
.side-left { grid-area: left; border-right: 4px solid var(--tile-b); }
.side-right { grid-area: right; border-left: 4px solid var(--tile-b); }
.side-scroll { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; height: 100%; padding: 8px; }
.no-left .side-left .side-scroll, .no-right .side-right .side-scroll { visibility: hidden; }
.side-scroll > .tile, .side-scroll > .tg { flex: 1 1 0; min-height: 0; max-height: 84px; }
.tg { position: relative; display: flex; flex-direction: column; }
.tg > .tile { flex: 1 1 auto; }

.tile {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 0; padding: 4px 12px;
  border: 2.5px solid var(--tile-b); border-radius: 10px; box-shadow: 0 3px 0 var(--tile-b);
  background: linear-gradient(180deg, var(--tile-hi), var(--tile));
  color: #fff; font: 600 clamp(16px, 2.75vh, 22px)/1.1 var(--f-fun); text-align: left; text-decoration: none;
  text-shadow: var(--outline-text); cursor: pointer; user-select: none;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.tile:hover { filter: brightness(1.06); }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-b); }
.tile > span { flex: 1; text-align: center; }
.side-left .tile { flex-direction: row-reverse; }
.tile .ti { flex: none; width: clamp(26px, 5.2vh, 46px); height: clamp(26px, 5.2vh, 46px); filter: drop-shadow(1px 2px 0 rgba(27, 42, 143, .45)); }
.tile small { display: block; margin-top: 3px; color: var(--tile-sub); font: 500 clamp(11px, 1.75vh, 13px)/1.2 var(--f-body); text-shadow: none; opacity: .9; }
.tile[aria-expanded="true"] { background: linear-gradient(180deg, var(--sel-1), var(--sel-2)); border-color: var(--sel-b); box-shadow: 0 3px 0 var(--sel-b); }

/* on/off tiles (Loop Mode, Trace Mode) */
.tile-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tile-toggle:focus-within { outline: 2.5px solid var(--navy); outline-offset: 2px; }
.onoff {
  position: absolute; top: 4px; right: 8px; padding: 3px 6px; border-radius: 99px;
  background: var(--navy); color: #fff; font: 700 10px/1 var(--f-body); font-style: normal; letter-spacing: .06em; text-shadow: none;
}
.onoff::after { content: "OFF"; }
.tile-toggle:has(input:checked) { background: linear-gradient(180deg, var(--on-1), var(--on-2)); border-color: var(--on-b); box-shadow: 0 3px 0 var(--on-b); }
.tile-toggle:has(input:checked) .onoff { background: var(--on-b); }
.tile-toggle:has(input:checked) .onoff::after { content: "ON"; }

/* progress ring on the My Progress tile */
.goal-ring { --f: 0; position: relative; flex: none; aspect-ratio: 1; border-radius: 50%; }
.tile > .goal-ring { flex: none; width: clamp(26px, 5.2vh, 46px); height: clamp(26px, 5.2vh, 46px); border: 2px solid var(--navy); background: conic-gradient(var(--pink) calc(var(--f) * 360deg), rgba(255, 255, 255, .6) 0); }
.goal-ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--tile); }

/* hide/show handles */
.collapse {
  position: absolute; top: 50%; z-index: 6; display: grid; place-items: center;
  width: 52px; height: 140px; margin-top: -70px; padding: 0;
  border: 3px solid var(--tile-b); border-radius: 12px; box-shadow: 0 3px 0 var(--tile-b);
  background: color-mix(in srgb, var(--tile) 75%, #fff); color: var(--navy); cursor: pointer;
}
.collapse:hover { background: var(--tile-hi); }
.collapse svg { width: 30px; height: 30px; filter: drop-shadow(1px 1px 0 #fff); transition: transform .25s; }
.c-left { right: -56px; }
.c-right { left: -56px; }
.no-left .c-left svg, .no-right .c-right svg { transform: rotate(180deg); }

/* 6. Tile pop-outs ------------------------------------------------------ */
.tile-body {
  position: absolute; top: 0; left: calc(100% + 12px); z-index: 40;
  display: flex; flex-direction: column; gap: 10px; width: 290px; padding: 10px;
  border: 3px solid var(--tile-b); border-radius: 16px;
  box-shadow: 0 4px 0 var(--tile-b), 0 18px 40px rgba(60, 20, 100, .25);
  background: var(--pop-bg); color: var(--pop-text); animation: drop .18s ease;
}
.side-right .tile-body { left: auto; right: calc(100% + 12px); }
.tile-body::before { content: ""; position: absolute; top: 22px; width: 14px; height: 14px; border: 3px solid var(--tile-b); background: inherit; transform: rotate(45deg); }
.side-left .tile-body::before { left: -9px; border-top: 0; border-right: 0; }
.side-right .tile-body::before { right: -9px; border-bottom: 0; border-left: 0; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

/* shared look for buttons inside pop-outs */
.tool-switch button, .seg3 button, .pen-types button, .paper-opt, .act {
  border: 2.5px solid var(--tile-b); border-radius: 10px; box-shadow: 0 2px 0 var(--tile-b);
  background: var(--pop-card); color: var(--pop-text); font-family: var(--f-fun); font-weight: 600; cursor: pointer;
}
.tool-switch button[aria-pressed="true"], .seg3 button[aria-pressed="true"],
.pen-types button[aria-pressed="true"], .paper-opt[aria-pressed="true"] {
  border-color: var(--sel-b); box-shadow: 0 2px 0 var(--sel-b);
  background: linear-gradient(180deg, var(--sel-1), var(--sel-2)); color: var(--navy); text-shadow: none;
}
.act:hover, .paper-opt:hover { filter: brightness(1.05); }

.tool-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--tile); }
.tool-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 0; box-shadow: none; background: transparent; color: #fff; font-size: 15px; font-weight: 500; text-shadow: 1px 1px 0 var(--navy); }
.tool-switch button[aria-pressed="true"] { border: 0; }
.seg3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg3 button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 4px 7px; font-size: 12px; }
.seg3 .dot { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.pen-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.pen-types button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; font-size: 10.5px; line-height: 1.1; }
.pen-types svg { width: 22px; height: 22px; }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  flex: none; width: 30px; height: 30px; padding: 0; border: 2.5px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--tile-b); background: var(--c); cursor: pointer;
}
.swatch.sq { border-radius: 7px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--sel-2), 0 0 0 5px var(--navy); }
.swatch.custom { position: relative; overflow: hidden; background: conic-gradient(#e33, #ec3, #3c5, #39e, #a3e, #e33); }
.swatch.custom::after { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--c, #fff); pointer-events: none; }
.swatch.custom input { position: absolute; inset: -8px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }

.paper-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#tbLines { width: 400px; }
.paper-opt { display: flex; flex-direction: column; gap: 3px; padding: 4px 4px 5px; font-size: 10.5px; }
.paper-opt canvas { display: block; width: 100%; height: auto; border: 1px solid var(--tile-b); border-radius: 6px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.act { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 10px 4px; font-size: 13px; text-align: center; text-decoration: none; }
.act:disabled { opacity: .55; }

/* 7. Writing area -------------------------------------------------------- */
.board { grid-area: board; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.viewport { flex: 1; display: flex; padding: 10px 60px; overflow: hidden; overscroll-behavior: contain; scrollbar-width: none; }
.viewport::-webkit-scrollbar { display: none; }
.viewport.zoomed { overflow: auto; }
.pages { --page-w: 800px; margin: auto; }
.page { position: relative; display: none; width: var(--page-w); border-radius: 2px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 12px 32px rgba(40, 30, 10, .16); }
.page.active { display: block; }
.page canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.pages.erasing .page canvas { cursor: cell; }
.pen-cursor { position: absolute; z-index: 2; width: 34px; height: 34px; margin: -31px 0 0 -2px; pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .25)); }
.pen-cursor svg { display: block; width: 100%; height: 100%; }

/* pills floating over the page: rewrite progress and page switcher */
.progress, .page-nav {
  position: absolute; left: 50%; z-index: 3; display: flex; align-items: center; white-space: nowrap;
  border: 3px solid var(--navy); border-radius: 99px; box-shadow: 0 3px 0 var(--navy);
  background: var(--pop-bg); color: var(--pop-text); font: 600 14px/1 var(--f-fun); font-variant-numeric: tabular-nums;
}
.progress { top: 12px; gap: 10px; padding: 7px 14px; font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, -8px); transition: .25s; }
.progress.on { opacity: 1; transform: translate(-50%, 0); }
.prog-bar { width: 150px; height: 12px; overflow: hidden; border: 2px solid var(--tile-b); border-radius: 99px; background: var(--pop-card); }
.prog-bar span { display: block; width: 0; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--royal-2), var(--pink)); transition: width .1s linear; }
.page-nav { bottom: 16px; gap: 6px; padding: 4px; transform: translateX(-50%); }
.page-nav span { padding: 0 6px; }
.page-nav button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: linear-gradient(180deg, var(--sel-1), var(--sel-2)); color: var(--navy); cursor: pointer; }
.page-nav button svg { width: 16px; height: 16px; }
.page-nav button:disabled { opacity: .35; cursor: default; }

/* 8. Bottom bar ---------------------------------------------------------- */
.bottombar {
  grid-area: bar; z-index: 5; display: grid; align-items: center; gap: 18px;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  grid-template-areas: "ml zoom main speed mr";
  padding: 5px 18px calc(5px + env(safe-area-inset-bottom, 0px));
  border-top: 4px solid var(--navy); background: linear-gradient(180deg, var(--royal), var(--royal-2)); color: #fff;
}
.slider { display: flex; flex-direction: column; gap: 2px; width: min(220px, 100%); color: #fff; font: 600 14px/1.2 var(--f-fun); text-shadow: 1px 1px 0 var(--navy); }
.slider > span { display: flex; justify-content: space-between; gap: 8px; }
.slider label { cursor: pointer; }
.slider output { color: #fff; font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--pink); }
.s-zoom { grid-area: zoom; }
.s-speed { grid-area: speed; justify-self: end; }
#mLeft { grid-area: ml; }
#mRight { grid-area: mr; }
.bb-main { grid-area: main; display: flex; align-items: center; gap: 6px; }
.bottombar .icon-btn { color: #fff; }
.icon-btn.round { width: 42px; height: 42px; border: 2px solid rgba(255, 255, 255, .35); border-radius: 50%; background: rgba(255, 255, 255, .16); }
.icon-btn.round:hover { background: rgba(255, 255, 255, .28); }
.icon-btn.round:disabled { opacity: .4; background: rgba(255, 255, 255, .08); }
.icon-btn.round[aria-pressed="true"] { border-color: var(--navy); background: var(--sel-2); color: var(--navy); }
.rewrite {
  display: inline-flex; align-items: center; gap: 10px; min-height: 50px; margin: 0 8px; padding: 0 30px 0 24px;
  border: 3px solid var(--navy); border-radius: 16px; box-shadow: 0 5px 0 var(--navy), 0 10px 20px rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, #ffc2e1, var(--pink)); color: #fff;
  font: 400 24px/1 var(--f-title); letter-spacing: .04em; text-shadow: var(--outline-text);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.rewrite:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--navy); }
.rewrite.playing { background: linear-gradient(180deg, var(--on-1), var(--on-2)); }
.rewrite svg { width: 22px; height: 22px; }
.rewrite .i-pause, .rewrite.playing .i-play { display: none; }
.rewrite.playing .i-pause { display: block; }
.m-only, .scrim { display: none; }
.m-drawer {
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 56px; height: 50px; padding: 4px 2px 3px;
  border: 2.5px solid var(--tile-b); border-radius: 12px; box-shadow: 0 3px 0 var(--tile-b);
  background: linear-gradient(180deg, var(--tile-hi), var(--tile)); color: #fff;
  font: 600 12px/1 var(--f-fun); letter-spacing: .02em; text-shadow: var(--outline-text);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.m-drawer svg { width: 22px; height: 22px; color: var(--drawer-ico); }
.m-drawer:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-b); }
.left-open #mLeft, .right-open #mRight { background: linear-gradient(180deg, var(--sel-1, #ffd6ea), var(--sel-2, #ff9fcd)); }

/* 9. Dialogs ------------------------------------------------------------- */
.dlg {
  width: min(460px, 94vw); max-height: 90vh; padding: 0; overflow: auto;
  border: 4px solid var(--navy); border-radius: 20px; box-shadow: 0 8px 0 var(--navy), 0 30px 80px rgba(0, 0, 0, .4);
  background: var(--pop-bg); color: var(--pop-text);
}
.dlg-wide { width: min(640px, 96vw); }
.dlg::backdrop { background: rgba(15, 25, 80, .55); backdrop-filter: blur(3px); }
.dlg form, .dlg-body { display: flex; flex-direction: column; gap: 14px; padding: 0 0 20px; }
.dlg form > *:not(.dlg-head), .dlg-body > *:not(.dlg-head) { margin-inline: 20px; }
.dlg-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 12px 12px 20px; border-bottom: 4px solid var(--navy); background: linear-gradient(180deg, var(--royal), var(--royal-2));
}
.dlg-title { margin: 0; color: #fff; font: 400 clamp(20px, 3vw, 27px)/1.1 var(--f-title); letter-spacing: .03em; text-shadow: var(--outline-text); text-wrap: balance; }
.dlg-head .icon-btn { width: 40px; height: 40px; border: 3px solid var(--navy); border-radius: 50%; box-shadow: 0 2px 0 var(--navy); background: #fff; color: var(--navy); }
.dlg-head .icon-btn:hover { background: var(--sel-2); }
.dlg-p { margin: 0; color: var(--pop-text); font: 500 16px/1.45 var(--f-fun); }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.dlg-actions.center { justify-content: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.dlg .lbl { color: var(--pop-text); font: 600 15px/1.2 var(--f-fun); }
.dlg textarea, .dlg input[type="text"], .dlg input[type="number"], .dlg input[type="email"], .dlg select {
  width: 100%; padding: 10px 12px; border: 2.5px solid var(--tile-b); border-radius: 12px;
  background: var(--pop-card); color: var(--text); font: 500 16px/1.4 var(--f-fun);
}
.dlg textarea { min-height: 62px; resize: vertical; }
.dlg textarea:focus, .dlg input:focus, .dlg select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sel-2) 60%, transparent); }
.dlg input[type="range"] { width: 100%; accent-color: var(--royal); }
.dlg .hint { margin: 0; color: var(--pop-text); font: 13px/1.6 var(--f-fun); opacity: .8; }
.dlg .btn {
  min-height: 46px; padding: 8px 20px; border: 3px solid var(--navy); border-radius: 14px; box-shadow: 0 4px 0 var(--navy);
  font: 600 17px/1 var(--f-fun); transition: transform .08s, box-shadow .08s;
}
.dlg .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }
.dlg .btn.primary { background: linear-gradient(180deg, #ffc2e1, var(--pink)); color: #fff; text-shadow: 1px 1px 0 var(--navy), -1px -1px 0 var(--navy), 1px -1px 0 var(--navy), -1px 1px 0 var(--navy); }
.dlg .btn.primary:hover { background: linear-gradient(180deg, #ffd0e8, #ff8ac2); }
.dlg .btn.ghost { background: linear-gradient(180deg, var(--tile-hi), var(--tile)); color: #fff; text-shadow: 1px 1px 0 var(--navy), -1px -1px 0 var(--navy), 1px -1px 0 var(--navy), -1px 1px 0 var(--navy); }
.dlg .btn.sm { min-height: 34px; padding: 4px 12px; box-shadow: 0 2px 0 var(--navy); font-size: 14px; }

/* selectable rows: Type Text tabs, "Place as" options, preset chips */
.tt-tabs, .seg { padding: 5px; border: 2.5px solid var(--tile-b); border-radius: 14px; background: var(--tile); }
.tt-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.tt-tab { padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: #fff; font: 600 14px/1 var(--f-fun); text-shadow: 1px 1px 0 var(--navy), -1px -1px 0 var(--navy), 1px -1px 0 var(--navy), -1px 1px 0 var(--navy); cursor: pointer; }
.tt-tab:hover { background: rgba(255, 255, 255, .18); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; }
.seg span { display: block; padding: 7px 4px; border-radius: 8px; color: #fff; font: 600 14px/1.2 var(--f-fun); text-align: center; text-shadow: 1px 1px 0 var(--navy); cursor: pointer; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
#ttPresets:empty { display: none; }
.chip { padding: 5px 12px; border: 2px solid var(--tile-b); border-radius: 99px; box-shadow: 0 2px 0 var(--tile-b); background: var(--pop-card); color: var(--pop-text); font: 600 14px/1.3 var(--f-fun); cursor: pointer; }
.tt-tab[aria-selected="true"], .seg input:checked + span, .chip.sel, .chip[aria-pressed="true"] {
  border-color: var(--sel-b); box-shadow: 0 2px 0 var(--sel-b); background: linear-gradient(180deg, var(--sel-1), var(--sel-2)); color: var(--navy); text-shadow: none;
}
.tt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tt-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: flex; align-items: center; gap: 7px; font: 500 15px/1.3 var(--f-fun); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--royal); }

/* tracing score */
.dlg-score { width: min(400px, 92vw); text-align: center; }
.score-stars { display: flex; justify-content: center; gap: 6px; margin-top: 4px; font-size: 42px; line-height: 1; }
.score-stars span { color: var(--pop-card); -webkit-text-stroke: 1px var(--tile-b); }
.score-stars span.on { color: #ff9fd0; -webkit-text-stroke: 0; animation: pop .4s backwards; }
.score-stars span.on:nth-child(2) { animation-delay: .12s; }
.score-stars span.on:nth-child(3) { animation-delay: .24s; }
@keyframes pop { from { opacity: 0; transform: scale(.3); } }
.score-num { margin: 0; color: var(--ink-2); font: 400 64px/1 var(--f-title); font-variant-numeric: tabular-nums; text-shadow: 3px 3px 0 var(--sel-2); }
.score-msg { margin: 0; font: 600 17px/1.35 var(--f-fun); }
.score-detail { margin: 0; color: var(--pop-text); font: 13px/1.6 var(--f-fun); opacity: .85; }

/* my progress */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; text-align: center;
  border: 2.5px solid var(--tile-b); border-radius: 12px; box-shadow: 0 3px 0 var(--tile-b); background: linear-gradient(180deg, var(--tile-hi), var(--tile));
}
.stat b { color: #fff; font: 400 28px/1 var(--f-title); font-variant-numeric: tabular-nums; text-shadow: var(--outline-text); }
.stat span { color: var(--tile-sub); font: 600 12.5px/1.2 var(--f-fun); }
.hero-stat { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; border-color: var(--sel-b); box-shadow: 0 3px 0 var(--sel-b); background: linear-gradient(180deg, var(--sel-1), var(--sel-2)); }
.hero-stat::before { content: "🔥"; font-size: 28px; }
.hero-stat b { font-size: 40px; text-shadow: 2px 2px 0 var(--sel-b), -1px -1px 0 var(--sel-b), 1px -1px 0 var(--sel-b), -1px 1px 0 var(--sel-b); }
.hero-stat span { color: var(--navy); font-size: 17px; }
.mini-h { margin: 4px 0 0; font: 600 16px/1.2 var(--f-fun); }
.mini-h small { font-weight: 400; opacity: .8; }
.bars { --goal: 50%; position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 150px; padding-top: 4px; }
.bar { display: grid; grid-template-rows: 18px 1fr 18px; align-items: end; min-width: 0; height: 100%; color: var(--pop-text); font: 11px/1.6 var(--f-fun); text-align: center; }
.bar-v { font-variant-numeric: tabular-nums; }
.bar-track { position: relative; display: flex; align-items: flex-end; height: 100%; overflow: hidden; border: 2px solid var(--tile-b); border-radius: 6px; background: var(--pop-card); }
.bar-track::after { content: ""; position: absolute; left: 0; right: 0; bottom: var(--goal); border-top: 1.5px dashed color-mix(in srgb, var(--on-b) 70%, transparent); }
.bar-fill { display: block; width: 100%; border-radius: 6px 6px 0 0; background: var(--royal-2); }
.bar.hit .bar-fill { background: var(--pink); }
.bar.today .bar-l { font-weight: 600; }
.goal-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--pop-text); font: 600 15px/1 var(--f-fun); }
.goal-pick span { margin-right: 4px; }

/* contact & support */
.mail-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 10px 12px;
  border: 2.5px dashed var(--tile-b); border-radius: 12px; background: var(--pop-card); font: 600 16px/1.2 var(--f-fun); word-break: break-all;
}

/* The email can wrap, but the Copy button must stay whole */
.mail-line .btn { flex: none; white-space: nowrap; word-break: normal; }

/* 10. Toast & print ------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 100; max-width: min(92vw, 520px); padding: 11px 18px;
  border: 3px solid var(--sel-2); border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
  background: var(--navy); color: #fff; font: 600 15px/1.35 var(--f-fun); text-align: center;
  opacity: 0; pointer-events: none; transform: translate(-50%, 30px); transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.print-area { display: none; }
@media print {
  @page { size: A4 landscape; margin: 0; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .print-area img { display: block; width: 100%; height: auto; break-after: page; }
}

/* 11. Homepage content -------------------------------------------------- */
.hw-content { background: var(--c-bg); color: var(--c-text); font: 400 17.5px/1.75 var(--f-body); }
.hw-content h2, .hw-content h3 { color: var(--c-head); font-family: var(--f-fun); letter-spacing: -.005em; text-wrap: balance; }
.hw-content h2 { margin: 0 0 10px; font-size: clamp(26px, 3.3vw, 36px); font-weight: 700; line-height: 1.2; text-align: center; }
.hw-content h3 { margin: 0 0 8px; font-size: 21px; font-weight: 600; line-height: 1.3; }
.hw-content p { margin: 0 0 14px; }
.hw-content a { color: var(--c-accent); font-weight: 600; text-underline-offset: 3px; }
.hw-content b, .hw-content strong { font-weight: 700; }
.hc-wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px; }
.hc-narrow { max-width: 860px; }
.hc-sec { padding-block: 64px; }
.hc-tint { background: var(--c-tint); }
.hw-content .hc-sub { max-width: 60ch; margin: 0 auto 38px; color: var(--c-muted); text-align: center; }
.hc-sec > .hc-wrap > h2 + p:not(.hc-sub) { margin-top: 16px; }

/* intro */
.hc-intro { padding-block: 56px 40px; background: linear-gradient(180deg, var(--c-tint), var(--c-bg)); text-align: center; }
.hw-content .hc-title { max-width: 22ch; margin: 0 auto 18px; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.12; }
.hw-content .hc-lede { max-width: 68ch; margin: 0 auto 22px; color: var(--c-muted); font-size: 18.5px; }
.hc-lede strong { color: var(--c-text); }
.hc-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 26px; padding: 0; list-style: none; }
.hc-facts li { position: relative; padding: 6px 14px 6px 32px; border: 2px solid var(--c-line); border-radius: 99px; background: var(--c-card); color: var(--c-head); font: 600 15px/1.3 var(--f-fun); }
.hc-facts li::before { content: ""; position: absolute; left: 13px; top: 50%; width: 11px; height: 6px; border-left: 2.5px solid #2fa66a; border-bottom: 2.5px solid #2fa66a; transform: translateY(-70%) rotate(-45deg); }
.hc-toc { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; color: var(--c-muted); font-size: 15px; }
.hc-toc span { font-weight: 700; }
.hc-toc a { border-bottom: 2px solid var(--c-line); text-decoration: none; }
.hc-toc a:hover { border-color: var(--c-accent); }

/* cards and notes */
.hc-card { margin-top: 26px; padding: 28px 30px; border-radius: 20px; box-shadow: var(--shadow-card); background: var(--c-card); }
.hc-card p:last-child { margin-bottom: 0; }
.hw-content .hc-note { max-width: 860px; margin: 26px auto 0; padding: 18px 22px; border: 2px dashed var(--c-line); border-radius: 16px; background: var(--c-card); color: var(--c-muted); font-size: 16px; }
.hc-note h3 { font-size: 19px; }
.hc-note p:last-child { margin: 0; }
.hc-quote { margin-top: 22px; padding: 20px 24px; border-left: 5px solid var(--c-accent); border-radius: 16px; background: var(--c-tint); }
.hc-quote p { margin: 0; }
.hc-small { color: var(--c-muted); font-size: 14.5px; }

/* step timeline */
.hc-steps { position: relative; display: flex; flex-direction: column; gap: 34px; margin: 0; padding: 0; list-style: none; }
.hc-steps::before { content: ""; position: absolute; top: 10px; bottom: 10px; left: 50%; border-left: 3px dashed color-mix(in srgb, var(--c-accent) 45%, transparent); transform: translateX(-50%); }
.hc-step { position: relative; display: flex; }
.hc-step:nth-child(even) { justify-content: flex-end; }
.hc-num {
  position: absolute; left: 50%; top: 6px; z-index: 1; display: grid; place-items: center; width: 58px; height: 58px;
  border: 3px solid #fff; border-radius: 18px; box-shadow: 0 4px 0 #4a2370, 0 10px 20px rgba(74, 35, 112, .25);
  background: linear-gradient(180deg, var(--c-num1), var(--c-num2)); color: #fff; font: 700 28px/1 var(--f-fun); transform: translateX(-50%);
}
.hc-step-card { width: calc(50% - 56px); padding: 24px 24px 18px; border-radius: 22px; box-shadow: 0 1px 2px rgba(60, 20, 100, .06), 0 12px 34px rgba(60, 20, 100, .1); background: var(--c-card); }
.hc-step-card h3 { margin-bottom: 10px; font-size: 23px; }
.hc-step-card figure { margin: 14px 0 4px; overflow: hidden; border: 2px solid var(--c-line); border-radius: 14px; line-height: 0; }
.hc-step-card img { display: block; width: 100%; height: auto; }
.hc-tip { padding: 10px 14px; border-left: 4px solid var(--c-accent-2); border-radius: 12px; background: color-mix(in srgb, var(--c-accent-2) 10%, var(--c-card)); font-size: 16px; }

/* feature and audience cards */
.hc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.hc-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hc-feat, .hc-who { padding: 22px 20px; border-radius: 18px; box-shadow: 0 1px 2px rgba(60, 20, 100, .05), 0 8px 24px rgba(60, 20, 100, .07); background: var(--c-card); }
.hc-feat h3 { font-size: 18.5px; }
.hc-feat p, .hc-who p { margin-bottom: 8px; color: var(--c-muted); font-size: 16px; }
.hc-who p b { color: var(--c-head); }
.hc-ico { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 14px; background: var(--c-tint); font-size: 24px; line-height: 1; }
.hc-wide-fig { max-width: 900px; margin: 34px auto 0; text-align: center; }
.hc-wide-fig img { display: block; width: 100%; height: auto; border: 2px solid var(--c-line); border-radius: 18px; box-shadow: 0 12px 34px rgba(60, 20, 100, .12); }
.hc-wide-fig figcaption { margin-top: 10px; color: var(--c-muted); font-size: 15px; }

/* tables */
.hc-table-wrap { margin: 22px 0 12px; overflow-x: auto; border-radius: 16px; box-shadow: 0 1px 2px rgba(60, 20, 100, .05), 0 8px 24px rgba(60, 20, 100, .07); }
.hc-table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--c-card); font-size: 16px; line-height: 1.55; }
.hc-table th, .hc-table td { padding: 13px 16px; border-bottom: 1px solid var(--c-line); text-align: left; vertical-align: top; }
.hc-table thead th { background: linear-gradient(180deg, var(--c-num1), var(--c-num2)); color: #fff; font: 600 16px/1.3 var(--f-fun); }
.hc-table tbody th { color: var(--c-head); font: 600 16px/1.4 var(--f-fun); white-space: nowrap; }
.hc-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--c-tint) 55%, var(--c-card)); }
.hc-table tbody tr:last-child > * { border-bottom: 0; }

/* lists */
.hc-numbered { display: grid; gap: 10px; margin: 20px 0; padding: 0; list-style: none; counter-reset: n; }
.hc-numbered li { position: relative; padding: 12px 16px 12px 58px; border-radius: 14px; box-shadow: 0 1px 2px rgba(60, 20, 100, .05), 0 6px 18px rgba(60, 20, 100, .06); background: var(--c-card); counter-increment: n; }
.hc-numbered li::before { content: counter(n); position: absolute; left: 14px; top: 12px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(180deg, var(--c-num1), var(--c-num2)); color: #fff; font: 700 16px/1 var(--f-fun); }
.hc-routine { display: grid; gap: 12px; margin: 26px 0 0; padding: 0; list-style: none; }
.hc-routine li { display: flex; align-items: flex-start; gap: 16px; padding: 16px 18px; border-radius: 16px; box-shadow: 0 1px 2px rgba(60, 20, 100, .05), 0 6px 18px rgba(60, 20, 100, .06); background: var(--c-card); }
.hc-time { flex: none; min-width: 74px; padding: 6px 8px; border-radius: 12px; background: linear-gradient(180deg, #ffd6eb, #ff9fd0); color: #4a2370; font: 700 15px/1.2 var(--f-fun); text-align: center; }
.hc-routine h3 { margin: 2px 0; font-size: 18.5px; }
.hc-routine p { margin: 0; color: var(--c-muted); font-size: 16px; }
.hc-ticks { margin: 20px 0; padding: 0; list-style: none; }
.hc-ticks li { position: relative; margin-bottom: 12px; padding-left: 32px; }
.hc-ticks li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 14px; height: 8px; border-left: 3px solid var(--c-accent-2); border-bottom: 3px solid var(--c-accent-2); transform: rotate(-45deg); }
.hc-safe .hc-ticks { margin-top: 0; }

/* FAQ */
.hc-faq { display: grid; gap: 10px; margin-top: 26px; }
.hc-faq details { padding: 0 20px; border-radius: 14px; box-shadow: 0 1px 2px rgba(60, 20, 100, .05), 0 6px 18px rgba(60, 20, 100, .06); background: var(--c-card); }
.hc-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; color: var(--c-head); font: 600 18px/1.35 var(--f-fun); list-style: none; cursor: pointer; }
.hc-faq summary::-webkit-details-marker { display: none; }
.hc-faq summary::after { content: "+"; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--c-tint); color: var(--c-accent); font-size: 20px; line-height: 1; }
.hc-faq details[open] summary::after { content: "\2212"; }
.hc-faq details p { margin: 0 0 18px; color: var(--c-muted); font-size: 16.5px; }

/* call to action */
.hc-cta { padding-block: 60px; background: var(--cta-bg); text-align: center; }
.hw-content .hc-cta-title { margin: 0 0 10px; color: #fff; font: 700 clamp(26px, 3.3vw, 36px)/1.2 var(--f-fun); text-shadow: var(--outline-text); }
.hc-cta p { color: var(--cta-text); font-weight: 600; }
.hw-content .hc-btn {
  display: inline-flex; align-items: center; min-height: 54px; padding: 0 28px;
  border: 3px solid #5b2a86; border-radius: 16px; box-shadow: 0 5px 0 #5b2a86;
  background: linear-gradient(180deg, #ffc2e1, #ff7ab8); color: #fff; font: 700 19px/1 var(--f-fun); text-decoration: none; text-shadow: 1px 1px 0 #5b2a86;
}
.hc-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #5b2a86; }

/* 12. Article pages (guides, About, Privacy…) --------------------------- */
.article { max-width: 760px; padding-block: 40px 50px; color: var(--c-text); font: 400 17.5px/1.75 var(--f-body); }
.article h1, .article h2, .article h3 { color: var(--c-head); font-family: var(--f-fun); text-wrap: balance; }
.article h1 { margin: 10px 0 14px; font-size: clamp(30px, 4.5vw, 46px); font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.article h2 { margin: 38px 0 12px; font-size: 26px; font-weight: 700; line-height: 1.2; }
.article h3 { margin: 26px 0 8px; font-size: 19px; font-weight: 600; line-height: 1.3; }
.article .meta { margin-bottom: 28px; color: var(--c-muted); font-size: 14px; }
.article .lead { font-size: 19px; font-weight: 600; }
.article li { margin-bottom: 6px; }
.crumbs { color: var(--c-muted); font-size: 13px; }
.crumbs a { color: var(--c-muted); }
.cta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 34px 0; padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--ink) 25%, var(--c-line)); border-radius: 14px; background: color-mix(in srgb, var(--ink) 9%, var(--c-card));
}
.cta p { margin: 0; font-weight: 600; }
.post-list { display: grid; gap: 14px; padding: 0; list-style: none; }
.post-list a { display: block; padding: 18px 20px; border: 1px solid var(--c-line); border-radius: 14px; background: var(--c-card); color: var(--c-text); text-decoration: none; }
.post-list a:hover { border-color: var(--ink); }
.post-list strong { display: block; margin-bottom: 4px; font: 600 19px/1.3 var(--f-fun); }
.post-list span { color: var(--c-muted); font-size: 15px; }

/* 13. Footer -------------------------------------------------------------- */
.site-footer { margin-top: 20px; padding-block: 28px 36px; border-top: 1px solid var(--c-line); background: var(--c-bg); color: var(--c-muted); }
.footer-in { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.footer-brand { margin: 0; font-size: 15px; }
.footer-brand strong { color: var(--c-head); font-family: var(--f-fun); font-weight: 600; }
.footer-in nav { display: flex; flex-wrap: wrap; gap: 16px; margin-left: auto; }
.footer-in nav a { color: var(--c-muted); font-size: 14px; text-decoration: none; }
.footer-in nav a:hover { color: var(--c-head); }

/* 14. Responsive --------------------------------------------------------- */
@media (max-width: 1180px) {
  .app { --side-w: 232px; }
}

/* tablets & phones: side panels become slide-in drawers */
@media (max-width: 980px) {
  .banner-in { height: 84px; }
  .logo { left: 14px; width: 52px; height: 52px; }
  .banner-nav { right: 12px; }
  .banner-nav a:not(.heart) { display: none; }
  .app { height: calc(100svh - 88px); }
  .app, .app.no-left, .app.no-right { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "bar"; }
  .side { position: fixed; top: 0; bottom: 0; z-index: 40; width: min(300px, 86vw); padding-top: env(safe-area-inset-top, 0px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: transform .25s ease; }
  .side-left { left: 0; transform: translateX(-105%); }
  .side-right { right: 0; transform: translateX(105%); }
  .left-open .side-left, .right-open .side-right { transform: none; }
  .side-scroll { overflow-y: auto; }
  .no-left .side-left .side-scroll, .no-right .side-right .side-scroll { visibility: visible; }
  .side-scroll > .tile, .side-scroll > .tg { flex: 0 0 auto; max-height: none; }
  .tile { min-height: 56px; font-size: 18px; }
  .tile .ti, .tile > .goal-ring { width: 38px; height: 38px; }
  .tile-body, .side-right .tile-body { position: static; width: auto; margin: -4px 4px 4px; border-top: 0; border-radius: 0 0 12px 12px; box-shadow: none; }
  .tile-body::before { display: none; }
  #tbLines { width: auto; }
  #tbLines .paper-grid { grid-template-columns: repeat(2, 1fr); }
  .collapse { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; display: block; background: rgba(15, 17, 22, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .left-open .scrim, .right-open .scrim { opacity: 1; pointer-events: auto; }
  .m-only { display: inline-grid; }
  .m-drawer { display: inline-flex; }
  .viewport { padding: 10px; }
  .hc-grid, .hc-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .hc-steps::before { left: 28px; }
  .hc-num { left: 28px; width: 50px; height: 50px; border-radius: 15px; font-size: 24px; }
  .hc-step, .hc-step:nth-child(even) { justify-content: flex-start; }
  .hc-step-card { flex: 1; width: auto; min-width: 0; margin-left: 70px; }
}

@media (max-width: 760px) {
  .bottombar { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "ml zoom speed mr" "main main main main"; gap: 6px 10px; }
  .slider, .s-speed { width: 100%; justify-self: stretch; }
  .bb-main { justify-self: center; gap: 2px; }
  .progress { top: 8px; padding: 6px 12px; }
  .prog-bar { width: 90px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: 150px; }
}

@media (max-width: 600px) {
  /* Phones: logo, title and buttons sit side by side so they can never overlap */
  .banner-in { height: 72px; padding-inline: 8px; gap: 6px; justify-content: space-between; }
  .logo { position: static; flex: none; width: 42px; height: 42px; transform: none; }
  .logo:hover { transform: rotate(-8deg); }
  .banner-mid { flex: 1; min-width: 0; gap: 6px; }
  .banner-title { font-size: clamp(16px, 5.4vw, 26px); white-space: nowrap; }
  .banner-date { padding: 3px 10px; font-size: clamp(10.5px, 3.2vw, 12px); white-space: nowrap; }
  .banner-nav { position: static; flex: none; transform: none; gap: 4px; }
  .banner-nav .heart { width: 32px; height: 32px; }
  .banner-nav .heart svg { width: 19px; height: 19px; }
  .app { height: calc(100svh - 76px); }
  .bottombar { padding-inline: 10px; column-gap: 8px; }
  .bb-main .icon-btn.round { width: 38px; height: 38px; }
  .rewrite { min-height: 46px; margin: 0 4px; padding: 0 16px 0 12px; font-size: 20px; }
  .slider { font-size: 13px; }
  .slider > span { white-space: nowrap; }
  .s-zoom, .s-speed { align-self: center; }
  .dlg form > *:not(.dlg-head), .dlg-body > *:not(.dlg-head) { margin-inline: 14px; }
  .dlg-title { font-size: 20px; }
  .footer-in nav { gap: 4px 6px; margin-left: 0; }
  .footer-in nav a { display: inline-block; padding: 10px 8px; }
}

/* Phones turned sideways (short screens): slimmer header and a one-row bottom bar so everything fits */
@media (max-height: 500px) and (orientation: landscape) {
  .banner-in { height: 52px; }
  .logo { width: 38px; height: 38px; }
  .banner-title { font-size: 24px; }
  .banner-date { display: none; }
  .banner-nav .heart { width: 34px; height: 34px; }
  .app { height: calc(100svh - 56px); min-height: 0; }
  .bottombar { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto; grid-template-areas: "ml zoom main speed mr"; gap: 10px; padding-block: 4px; }
  .m-drawer { height: 44px; }
  .rewrite { min-height: 42px; font-size: 19px; padding: 0 14px 0 12px; }
  .bb-main .icon-btn.round { width: 36px; height: 36px; }
  .slider { font-size: 12px; }
  .viewport { padding: 6px; }
  /* progress bubble and page arrows move into the empty space beside the page, so they never cover writing */
  .progress { left: 8px; top: 8px; flex-direction: column; align-items: stretch; gap: 6px; width: 132px; padding: 7px 10px; border-radius: 14px; white-space: normal; text-align: center; font-size: 12px; line-height: 1.25; transform: translateY(-8px); }
  .progress.on { transform: none; }
  .prog-bar { width: 100%; }
  .page-nav { left: 8px; bottom: 8px; transform: none; font-size: 12px; }
  .page-nav span { padding: 0 2px; }
  .page-nav button { width: 28px; height: 28px; }
  .dlg { max-height: 94vh; }
  .toast { bottom: 70px; }
}

@media (max-width: 440px) {
  .slider .sl-long { display: none; }
}

@media (max-width: 560px) {
  .hw-content { font-size: 16.5px; }
  .hc-sec { padding-block: 46px; }
  .hc-grid, .hc-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hc-steps::before { left: 20px; }
  .hc-num { left: 20px; width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }
  .hc-step-card { margin-left: 52px; padding: 18px 16px 12px; }
  .hc-step-card h3 { font-size: 20px; }
  .hc-card { padding: 22px 18px; }
  .hc-routine li { flex-direction: column; gap: 8px; }
}

@media (max-width: 420px) {
  .tt-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .bb-main .icon-btn.round { width: 36px; height: 36px; }
  .bb-main .icon-btn svg { width: 19px; height: 19px; }
}

/* 15. Motion -------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
