body { margin: 0; font-family: var(--font-sans); font-size: calc(15rem / 17); line-height: 1.5; background: var(--page); color: var(--ink); }
.af-demo { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-4) var(--space-5); }
.af-demo-col { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5); max-width: 380px; }

/* Button */
.af-btn { font: inherit; font-weight: 600; font-size: calc(16rem / 17); line-height: calc(20rem / 17); min-height: 50px; padding: 0 var(--space-5); border-radius: var(--radius-card); border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); cursor: pointer; }
.af-btn-block { width: 100%; }
.af-btn-primary { background: var(--ballpoint); color: var(--on-ballpoint); }
.af-btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.af-btn-small { min-height: 38px; font-size: calc(14rem / 17); padding: 0 var(--space-4); border-radius: var(--radius-pill); text-align: center; text-wrap: balance; }
.af-btn:disabled { opacity: .45; cursor: default; }
.af-btn:focus-visible, .af-link:focus-visible, .af-chip:focus-visible, .af-person:focus-visible, .af-tile:focus-visible, .af-sticker:focus-visible, .af-story:focus-visible { outline: 2px solid var(--ballpoint); outline-offset: 2px; }
.af-link { font: inherit; font-size: calc(14rem / 17); font-weight: 600; color: var(--ballpoint); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
/* Touch targets: a control drawn smaller than 44 by 44 takes taps on an invisible
   44px box centred on it (never smaller than the control), so it keeps its look.
   ::before, because .af-person's tick is its ::after. */
.af-link, .af-btn-small, .af-chip, .af-person, .af-cal-nav, .af-play, .af-sticker-pill { position: relative; }
.af-link::before, .af-btn-small::before, .af-chip::before, .af-person::before, .af-cal-nav::before, .af-play::before, .af-sticker-pill::before { content: ""; position: absolute; inset: min(0px, (100% - 44px) / 2); }

/* Chip, Person */
.af-chip { font: inherit; font-size: calc(13rem / 17); line-height: calc(18rem / 17); padding: 5px 12px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.af-chip[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
.af-person { font: inherit; font-size: calc(15rem / 17); display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px 14px 4px 4px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.af-person[aria-pressed="true"] { border-color: var(--ballpoint); background: var(--tray); }
.af-person[aria-pressed="true"]::after { content: "✓"; color: var(--ballpoint); font-weight: 700; }
.af-person-add { padding: 4px 14px; color: var(--ballpoint); border-style: dashed; border-color: var(--line-strong); background: transparent; }
.af-face { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; color: #FFFFFF; flex: none; }

/* Field */
.af-field { display: grid; gap: 6px; }
.af-field label { font-size: calc(13rem / 17); color: var(--pencil); }
.af-input { font: inherit; font-size: calc(17rem / 17); color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-field); padding: 12px 14px; min-height: 50px; box-shadow: var(--shadow-card); width: 100%; min-width: 0; }
/* iOS draws date and time fields at their own width, centred: this keeps them to the field's width, text at the start like the others. */
.af-input:is([type="date"], [type="time"], [type="datetime-local"]) { -webkit-appearance: none; appearance: none; display: block; text-align: start; }
.af-input::-webkit-date-and-time-value { text-align: start; }
.af-input:focus-visible { outline: 2px solid var(--ballpoint); outline-offset: 2px; }
.af-input-code { font-family: var(--font-mono); font-size: calc(22rem / 17); letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.af-field small { font-size: calc(12.5rem / 17); color: var(--pencil); }

/* Status */
.af-pill { display: inline-flex; width: fit-content; align-items: center; gap: 6px; border-radius: var(--radius-pill); padding: 3px 10px; font-size: calc(12rem / 17); font-weight: 600; color: var(--ballpoint); border: 1px dashed var(--ballpoint); }
.af-pill-live { border-style: solid; }
.af-pill-revealed { color: #0B2530; background: var(--highlighter); border: 1px solid transparent; }
.af-progress { display: grid; gap: 6px; }
.af-progress-track { height: 6px; border-radius: 3px; background: var(--tray); overflow: hidden; }
/* The fill slides in from the left (transform, so it animates off the main thread): set
   --progress from 0 to 1 on it. A width set inline still works, without the slide. */
.af-progress-fill { display: block; height: 100%; background: var(--ballpoint); border-radius: 3px; transform: translateX(calc(var(--progress) * 100% - 100%)); transition: transform .6s cubic-bezier(.16,1,.3,1); }
@media (prefers-reduced-motion: reduce) { .af-progress-fill { transition: none; } }
.af-progress-text { font-size: calc(13rem / 17); color: var(--pencil); }
.af-progress-warn { display: flex; gap: var(--space-2); align-items: center; font-size: calc(13.5rem / 17); color: var(--warn); }
/* Floating at the bottom of a story while photos go up: a panel pill, what's sent as a
   ring (the same --progress, from 0 to 1, set on .af-progress), the words beside it,
   the warn line under them. */
@property --progress { syntax: "<number>"; inherits: true; initial-value: 0; }
.af-progress-floating { position: fixed; z-index: 9; left: 0; right: 0; bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); width: min(440px, calc(100% - 2 * var(--space-5))); margin: 0 auto; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--space-3); padding: 8px 16px 8px 8px; border-radius: var(--radius-pill); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-card); transition: --progress .6s cubic-bezier(.16,1,.3,1); }
.af-progress-floating:has(.af-progress-warn:not([hidden])) { border-radius: var(--radius-card); }
.af-progress-floating .af-progress-track { width: 28px; height: 28px; border-radius: 50%; background: conic-gradient(var(--ballpoint) calc(var(--progress) * 360deg), var(--tray) 0); display: grid; place-items: center; }
.af-progress-floating .af-progress-track::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); }
.af-progress-floating .af-progress-fill { display: none; }
.af-progress-floating .af-progress-text { color: var(--ink); }
.af-progress-floating .af-progress-warn { grid-column: 1 / -1; padding: 2px 0 2px 6px; }
@media (prefers-reduced-motion: reduce) { .af-progress-floating { transition: none; } }

/* Photos */
.af-tile { position: relative; aspect-ratio: 1; border-radius: var(--radius-photo); overflow: hidden; border: 0; padding: 0; cursor: pointer; background: var(--tray); }
.af-tile-img { position: absolute; inset: 0; background-size: cover; background-position: center; }
.af-tile-check { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ballpoint); color: var(--on-ballpoint); display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 2px solid #FFFFFF; }
.af-tile[aria-pressed="false"] .af-tile-img { opacity: .35; }
.af-tile[aria-pressed="false"] .af-tile-check { background: var(--photo-scrim); color: transparent; }
.af-tile-len { position: absolute; right: 4px; bottom: 4px; font-size: 11px; font-weight: 600; color: #FFFFFF; background: var(--photo-scrim); padding: 1px 5px; border-radius: 4px; }
.af-dev { aspect-ratio: 1; border-radius: var(--radius-print); display: grid; place-content: center; text-align: center; gap: 2px; border: 1px dashed var(--line-strong); color: var(--ballpoint); background: repeating-linear-gradient(-45deg, var(--tray) 0 6px, var(--tray-stripe) 6px 12px); }
.af-dev b { font-family: var(--font-serif); font-weight: 400; font-size: calc(24rem / 17); line-height: 1; }
.af-dev span { font-size: calc(12rem / 17); }
.af-dev-empty { color: var(--pencil); }
@media (prefers-reduced-motion: no-preference) { .af-dev { animation: af-develop 3s ease-in-out infinite alternate; } @keyframes af-develop { from { filter: brightness(.95); } to { filter: brightness(1.06); } } }
.af-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
/* Prints: photos shown as tilted white-framed prints, optionally with a sticker */
.af-prints { position: relative; display: flex; align-items: flex-start; padding: var(--space-2) var(--space-1) var(--space-3); }
.af-print { position: relative; flex: none; width: 34%; margin-left: -6%; background: #FFFFFF; padding: 5px 5px 18px; border-radius: 3px; box-shadow: var(--shadow-print); transform: rotate(var(--tilt, 0deg)); }
.af-print:first-child { margin-left: 0; }
.af-print:nth-child(even) { margin-top: 10px; z-index: 1; }
.af-print-img { display: block; aspect-ratio: 4 / 5; border-radius: 1px; background-size: cover; background-position: center; }
.af-print-stamp { position: absolute; left: 6px; bottom: 4px; font: 500 11px/1 var(--font-mono); font-style: normal; letter-spacing: .06em; text-transform: uppercase; color: #35525D; }
/* odd prints after the first sit under their left neighbour: stamp on the right */
.af-print:nth-child(odd):not(:first-child) .af-print-stamp { left: auto; right: 6px; }
.af-prints-sticker { position: absolute; right: 2%; top: -4px; z-index: 2; transform: rotate(12deg); }
.af-prints-sticker svg { width: 40px; height: 40px; display: block; }

/* Reactions */
.af-sticker { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; border: 1px solid transparent; background: none; font: inherit; color: inherit; cursor: pointer; min-width: 56px; }
.af-sticker svg { width: 40px; height: 40px; }
.af-sticker small { font-size: calc(11.5rem / 17); color: var(--pencil); font-variant-numeric: tabular-nums; }
.af-sticker[aria-pressed="true"] { background: var(--tray); border-color: var(--ballpoint); }
.af-sticker[aria-pressed="true"] small { color: var(--ballpoint); font-weight: 600; }
.af-stickers { display: flex; gap: 6px; }
/* StickerBar: small pills under a photo, the count beside the sticker */
.af-stickers-pills { flex-wrap: wrap; }
.af-sticker-pill { display: inline-flex; align-items: center; gap: 4px; min-width: 0; min-height: 42px; padding: 0 12px 0 6px; border-radius: var(--radius-pill); border-color: var(--line); background: var(--panel); }
.af-sticker-pill:not(:has(small)) { padding: 0 6px; }
.af-sticker-pill svg, .af-sticker-pill img { width: 32px; height: 32px; }
.af-sticker-pill small { font-size: calc(13rem / 17); font-weight: 600; }
.af-note p { margin: 0; font-family: var(--font-hand); color: var(--ballpoint); font-size: calc(28rem / 17); line-height: calc(30rem / 17); }
.af-note small { font-size: calc(12.5rem / 17); color: var(--pencil); }
.af-voice { display: grid; grid-template-columns: 34px 1fr auto; gap: var(--space-3); align-items: center; }
.af-play { width: 34px; height: 34px; border-radius: 50%; background: var(--ballpoint); color: var(--on-ballpoint); display: grid; place-items: center; font-size: 12px; border: 0; cursor: pointer; }
.af-wave { height: 22px; background: repeating-linear-gradient(90deg, var(--pencil) 0 2px, transparent 2px 5px); opacity: .6; clip-path: polygon(0 40%,8% 20%,16% 55%,24% 10%,32% 45%,40% 25%,48% 60%,56% 15%,64% 50%,72% 30%,80% 55%,88% 20%,100% 45%,100% 100%,0 100%); }
.af-voice small { color: var(--pencil); font-size: calc(12.5rem / 17); font-variant-numeric: tabular-nums; }
.af-mic { display: grid; grid-template-columns: auto 1fr; gap: var(--space-4); align-items: center; padding: var(--space-4); border-radius: 20px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-card); }
.af-mic button { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--ballpoint); color: var(--on-ballpoint); font-size: 22px; cursor: pointer; touch-action: none; user-select: none; }
.af-mic button[data-rec="true"] { background: var(--warn); color: #FFFFFF; }
.af-mic b { display: block; font-weight: 600; font-size: calc(17rem / 17); }
.af-mic span { color: var(--pencil); font-size: calc(14rem / 17); }

/* Surfaces */
.af-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px; display: grid; gap: var(--space-2); box-shadow: var(--shadow-card); }
.af-sheet { background: var(--page); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 10px var(--space-5) var(--space-6); display: grid; gap: 14px; box-shadow: var(--shadow-sheet); }
.af-sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); justify-self: center; }
.af-sheet h3, .af-sheet .sheet-title { margin: 0; font-family: var(--font-serif); font-weight: 400; font-size: calc(24rem / 17); line-height: calc(28rem / 17); }
.af-sheet p { margin: 0; color: var(--pencil); font-size: calc(14rem / 17); }
.af-toast { background: var(--ink); color: var(--page); border-radius: 14px; padding: 12px 14px; font-size: calc(14rem / 17); }

/* Story */
.af-story { display: grid; gap: var(--space-2); text-align: left; width: 100%; padding: var(--space-4); border-radius: var(--radius-story); border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; box-shadow: var(--shadow-card); }
.af-story:hover { border-color: var(--ballpoint); }
.af-story-name { font-family: var(--font-serif); font-size: calc(24rem / 17); line-height: 1.1; }
.af-story-n { color: var(--ballpoint); }
.af-story-kind { font-family: var(--font-hand); color: var(--ballpoint); font-size: calc(28rem / 17); line-height: 1; }
.af-story-desc { color: var(--pencil); font-size: calc(14rem / 17); }
.af-story-art { display: grid; grid-template-columns: repeat(3, 56px) 1fr; gap: 6px; align-items: center; }
.af-story-art .af-pill { justify-self: start; margin-left: 6px; }
.af-story .af-prints { max-width: 170px; }
.af-story-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.af-story-tags span { font-size: calc(12rem / 17); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px 9px; color: var(--pencil); }
.af-credits { text-align: center; display: grid; gap: 4px; }
.af-credits-top { font-family: var(--font-mono); font-size: calc(11rem / 17); letter-spacing: .12em; text-transform: uppercase; color: var(--pencil); }
.af-credits-title { font-family: var(--font-serif); font-size: calc(32rem / 17); line-height: 1.05; margin: 6px 0 10px; }
.af-credits ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: calc(16rem / 17); font-variant-numeric: tabular-nums; }
.af-credits ol span { color: var(--pencil); }
.af-credits-sign { font-family: var(--font-hand); color: var(--ballpoint); font-size: calc(28rem / 17); margin-top: 6px; }
.af-label { font-family: var(--font-mono); font-size: calc(11rem / 17); line-height: calc(14rem / 17); font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--pencil); }
.af-hl { background: linear-gradient(transparent 55%, var(--highlighter) 55% 90%, transparent 90%); -webkit-box-decoration-break: clone; box-decoration-break: clone; } /* a title that wraps: each line keeps its padding and corners */
/* Swash: the highlighter sweeping in under a few words, for the moments a story has happened */
.af-swash { white-space: nowrap; background: linear-gradient(transparent 55%, var(--highlighter) 55% 90%, transparent 90%) no-repeat 0 0 / 100% 100%; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
@media (prefers-reduced-motion: no-preference) {
  .af-swash-draw { background-size: 0% 100%; animation: af-swash-draw 1.2s .4s cubic-bezier(.16,1,.3,1) forwards; }
  @keyframes af-swash-draw { to { background-size: 100% 100%; } }
}

/* Night. Two ways in, as in tokens.css: an explicit data-theme="dark" (the
   prototype's device frame, a theme toggle), or the device setting when no
   light theme is forced. */
/* The highlighter becomes a solid marker behind the words */
/* ---- DateRange: a story's dates, first day then the last ---- */
.af-cal { display: grid; gap: 10px; }
.af-cal-head { display: flex; align-items: center; justify-content: space-between; }
.af-cal-head b { font-weight: 600; }
.af-cal-nav { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; box-shadow: var(--shadow-card); }
.af-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; text-align: center; }
.af-cal-weekday { font-family: var(--font-mono); font-size: calc(11rem / 17); letter-spacing: .12em; color: var(--pencil); padding-bottom: 4px; }
.af-cal-day { font: inherit; font-size: calc(15rem / 17); min-height: 40px; border: 0; background: none; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; }
.af-cal-day:focus-visible, .af-cal-nav:focus-visible { outline: 2px solid var(--ballpoint); outline-offset: -2px; border-radius: 8px; }
.af-cal-today { text-decoration: underline; text-underline-offset: 4px; }
.af-cal-between { background: color-mix(in srgb, var(--ballpoint) 22%, transparent); }
.af-cal-start, .af-cal-end { background: var(--ballpoint); color: var(--on-ballpoint); font-weight: 600; }
.af-cal-start { border-radius: 20px 0 0 20px; }
.af-cal-end { border-radius: 0 20px 20px 0; }
.af-cal-start.af-cal-end { border-radius: 20px; }
.af-cal-hint { margin: 0; font-size: calc(12.5rem / 17); color: var(--pencil); }

[data-theme="dark"] .af-hl { background: linear-gradient(transparent 14%, var(--highlighter) 14% 86%, transparent 86%); color: var(--on-highlighter); padding: 0 4px; border-radius: 2px; }
/* The swash too: a solid marker, dark words. Both markers stop at 14% from the top and
   bottom of the glyphs' box, which is taller than the line: a full fill ran into the
   line above and below when a title wrapped. */
[data-theme="dark"] .af-swash { background-image: linear-gradient(transparent 14%, var(--highlighter) 14% 86%, transparent 86%); color: var(--on-highlighter); padding: 0 4px; border-radius: 2px; }
/* Prints are paper, a soft white at night */
[data-theme="dark"] .af-print { background: #F0F7F9; }
/* A thin light die-cut edge keeps the stickers' ink outline visible */
[data-theme="dark"] .af-sticker svg, [data-theme="dark"] .af-sticker-art { filter: drop-shadow(0 0 .6px var(--ink)) drop-shadow(0 0 .6px var(--ink)) drop-shadow(0 0 .6px var(--ink)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .af-hl { background: linear-gradient(transparent 14%, var(--highlighter) 14% 86%, transparent 86%); color: var(--on-highlighter); padding: 0 4px; border-radius: 2px; }
  :root:not([data-theme="light"]) .af-swash { background-image: linear-gradient(transparent 14%, var(--highlighter) 14% 86%, transparent 86%); color: var(--on-highlighter); padding: 0 4px; border-radius: 2px; }
  :root:not([data-theme="light"]) .af-print { background: #F0F7F9; }
  :root:not([data-theme="light"]) .af-sticker svg, :root:not([data-theme="light"]) .af-sticker-art { filter: drop-shadow(0 0 .6px var(--ink)) drop-shadow(0 0 .6px var(--ink)) drop-shadow(0 0 .6px var(--ink)); }
}

/* Icon: a line icon in the colour of the text around it */
.af-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* AddTile: the dashed tile that adds photos, first in a story's grid */
.af-add-tile { aspect-ratio: 1; min-width: 0; border-radius: var(--radius-photo); border: 2px dashed var(--ballpoint); background: var(--panel); color: var(--ballpoint); display: grid; place-content: center; justify-items: center; gap: 4px; padding: 6px; font: inherit; font-size: calc(13rem / 17); font-weight: 600; line-height: 1.25; text-align: center; cursor: pointer; }
.af-add-tile .af-icon { width: 26px; height: 26px; stroke-width: 2; }
.af-add-tile:disabled { opacity: .5; cursor: default; }
.af-add-tile:focus-visible { outline: 2px solid var(--ballpoint); outline-offset: 2px; }

/* Choice: cards to pick one from */
.af-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.af-choice-opt { position: relative; display: grid; gap: 2px; align-content: start; padding: 12px 14px; border-radius: var(--radius-field); border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; }
.af-choice-opt input { position: absolute; opacity: 0; pointer-events: none; }
.af-choice-opt span { font-size: calc(13rem / 17); color: var(--pencil); }
.af-choice-opt:has(input:checked) { border: 2px solid var(--ballpoint); padding: 11px 13px; background: var(--tray); }
.af-choice-opt:has(input:checked) b { color: var(--ballpoint); }
.af-choice-opt:has(input:focus-visible) { outline: 2px solid var(--ballpoint); outline-offset: 2px; }

/* StoryRow: a compact row on Home */
.af-story-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; color: var(--ink); text-decoration: none; }
.af-story-row + .af-story-row { border-top: 1px solid var(--line); }
.af-story-row-tile { width: 44px; height: 44px; justify-self: center; border-radius: var(--radius-print); }
.af-story-row-text { display: grid; gap: 1px; min-width: 0; }
.af-story-row-text b { font-family: var(--font-serif); font-weight: 400; font-size: calc(17rem / 17); line-height: calc(22rem / 17); }
.af-story-row-text small { color: var(--pencil); font-size: calc(12.5rem / 17); }
.af-story-row-chev { color: var(--pencil); font-size: calc(20rem / 17); }
