/*
 * Sand Clock: the tool's own components, styled in the site's design language (16 Nov 2026, on the UltraCompress Pro
 * template). The first part is the shared block of the Digital Ring Light's file, unchanged (tokens, page, hero,
 * buttons, toolbar, fields, windows, toasts, information sections). Base: /libs/site-pages.css (tokens, Inter and
 * Space Grotesk, theme toggle, focus rings) and /libs/shared-nav.css (the site's header and footer). The second part
 * is the tool: the stage the hourglass stands on (its colours follow the chosen scene, not the page theme: an
 * hourglass is judged against its room), the time and the buttons laid over the foot of the picture, the settings card
 * with its five tabs, and the focus view. Light is the default; dark applies when <html> has no data-theme. Written
 * by hand: this file is the source.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --radius-lg: 16px;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.24);
    --ok: #166534;
    --ok-soft: rgba(22, 101, 52, 0.09);
    --bad: #b91c1c;
    --bad-soft: rgba(185, 28, 28, 0.08);
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, 0.1);
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.26);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.1);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.1);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.1);
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container { max-width: calc(var(--app-max) + 2 * var(--content-gutter)); margin-top: 16px; }
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- The site header is the first thing on the page and stays at the top ----- */
body { padding-top: 0; }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: 90px; }
@media (max-width: 639.98px) { .theme-toggle { top: 75px; } } /* the header is 81 px tall from 640 px, 65 px below */

/* ----- Hero ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); }
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Small helpers ----- */
main [hidden], .dialog [hidden] { display: none !important; } /* the script hides fields that carry their own display */
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-2); }
.small { font-size: 0.9rem; }
.block { display: block; }
.hint { color: var(--text-3); font-size: 0.8rem; font-weight: 400; line-height: 1.45; }
.err { color: var(--bad); font-size: 0.85rem; font-weight: 600; }
.err:empty { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link:hover { color: var(--link-hover); }
code { font-size: 0.85em; padding: 1px 6px; border-radius: 6px; background: var(--code-bg); color: var(--code-text); }
kbd { font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); }

/* ----- Buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9999px; font-family: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; padding: 12px 24px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid rgba(185, 28, 28, 0.35); padding: 11px 23px; }
.btn-danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; transform: translateY(-2px); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-secondary.btn-sm, .btn-danger.btn-sm { padding: 8px 15px; }
.btn-stack { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; padding: 0; font-family: inherit; transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.icon-btn:hover { border-color: var(--brand); color: var(--link); background: var(--surface); }
.icon-btn.del:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn:focus-visible, .link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Toolbar ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 1.25rem; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.shell-hint { margin-top: 14px; }

/* ----- Fields ----- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.label { font-weight: 600; font-size: 0.85rem; color: var(--text-strong); }
.input, .select { width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: inherit; font-size: 0.95rem; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--placeholder); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.select { width: auto; max-width: 100%; appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; cursor: pointer; }
.select option { color: #0a0a14; background: #fff; }
.check-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 0.925rem; color: var(--text); padding: 4px 0; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.seg button:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.seg button[aria-pressed="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--chip); font-family: inherit; font-size: 0.8rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.chip .ico { width: 15px; height: 15px; color: var(--link); }
.chip:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Windows ----- */
.dialog { margin: auto; border: 1px solid var(--surface-border); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 16px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); }
.dialog--narrow { width: min(420px, calc(100vw - 16px)); }
.dialog--wide { width: min(680px, calc(100vw - 16px)); }
.dialog::backdrop { background: rgba(10, 10, 20, 0.6); backdrop-filter: blur(6px); }
.dialog[open] { animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
.dialog-head { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-title { margin: 0; font-size: 1.15rem; }
.dialog-close { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: border-color 0.2s ease, color 0.2s ease; }
.dialog-close:hover { border-color: var(--brand); color: var(--link); }
.dialog-body { padding: 20px; overflow-y: auto; max-height: calc(100vh - 210px); display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { padding: 14px 20px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-message { margin: 0; color: var(--text); }

/* ----- Toasts ----- */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { pointer-events: auto; background: #0a0a14; color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); min-width: 260px; max-width: 420px; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; animation: slideIn 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease; }
.toast button { background: none; border: 0; padding: 0; color: #c4b5fd; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; }
.toast.leaving { opacity: 0; transform: translateX(40px); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast.good { border-left-color: #4ade80; }
.toast.bad { border-left-color: #f87171; }

/* ----- Information sections ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 16px; box-shadow: var(--surface-shadow); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.step-card { position: relative; padding-top: 24px; }
.step-num { position: absolute; top: -16px; left: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: var(--text-strong); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ===== Sand Clock components ===== */

/* ----- The site's text rules (p, ul, li, headings) must not reach the tool: same weight as the site's, loaded later ----- */
:where(.app-shell) p, :where(.app-shell) ul, :where(.app-shell) li, :where(.dialog) p { margin: 0; line-height: 1.5; }
:where(.app-shell) h2, :where(.app-shell) h3, :where(.app-shell) h4 { margin: 0; line-height: 1.25; }
:root { --head: 81px; }
@media (max-width: 639.98px) { :root { --head: 65px; } }
.app-shell { scroll-margin-top: calc(var(--head) + 16px); }

/* ----- Cards: the site's white cards, one layer ----- */
.card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--surface-shadow); padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card-title { font-size: 1.3rem; color: var(--text-strong); }
.sub-title { font-size: 1rem; color: var(--text-strong); }

/* ----- Layout: the hourglass beside its settings; one above the other on narrow screens ----- */
.sc-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; --stage-h: clamp(540px, calc(100vh - var(--head) - 32px), 700px); }
@supports (height: 100svh) { .sc-layout { --stage-h: clamp(540px, calc(100svh - var(--head) - 32px), 700px); } }
@media (min-width: 1000px) { .sc-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); --stage-h: clamp(600px, calc(100vh - var(--head) - 48px), 780px); } }
.sc-slot { position: relative; min-width: 0; height: var(--stage-h); border-radius: 16px; background: #0a0c16; }
.sc-slot-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; color: #d1d5db; font-weight: 600; }

/* ----- The stage. Its own colours follow the scene, not the page theme: a hourglass is judged against its room. ----- */
.sc-stage {
    position: absolute; inset: 0; overflow: hidden; border-radius: 16px; isolation: isolate;
    --ink: #f6eee1; --ink-2: rgba(246, 238, 225, 0.82); --ink-3: rgba(246, 238, 225, 0.68); --hair: rgba(246, 238, 225, 0.2); --hair-strong: rgba(246, 238, 225, 0.5);
    --glass: rgba(14, 15, 24, 0.62); --glass-on: rgba(246, 238, 225, 0.17); --sheet: rgba(15, 16, 26, 0.92); --scrim: rgba(5, 6, 12, 0.82); --scrim-0: rgba(5, 6, 12, 0); --shade: rgba(0, 0, 0, 0.55);
    --sand: #d9a648; --focus: #c4b5fd;
    color: var(--ink); background: radial-gradient(120% 80% at 50% 45%, #1b1a3a 0%, #0b0e1f 45%, #04050b 100%);
}
.sc-stage[data-scene="luxury"] { background: radial-gradient(120% 80% at 50% 45%, #2a1d09 0%, #070605 50%, #010101 100%); }
.sc-stage[data-scene="natural"], .sc-stage[data-scene="minimal"] {
    --ink: #17181d; --ink-2: rgba(23, 24, 29, 0.84); --ink-3: rgba(23, 24, 29, 0.74); --hair: rgba(23, 24, 29, 0.22); --hair-strong: rgba(23, 24, 29, 0.55);
    --glass: rgba(255, 255, 255, 0.66); --glass-on: rgba(23, 24, 29, 0.12); --sheet: rgba(255, 255, 255, 0.94); --shade: rgba(255, 255, 255, 0.6); --focus: #5b21b6;
}
.sc-stage[data-scene="natural"] { --scrim: rgba(193, 174, 139, 0.88); --scrim-0: rgba(193, 174, 139, 0); background: linear-gradient(#a8926f, #cdbb9b 55%, #bba783); }
.sc-stage[data-scene="minimal"] { --scrim: rgba(211, 215, 221, 0.9); --scrim-0: rgba(211, 215, 221, 0); background: linear-gradient(#c3c8d1, #dfe2e8 55%, #cfd3da); }
.sc-view { position: absolute; inset: 0; }
.sc-canvas, .sc-flat { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; }
.sc-canvas.is-dragging { cursor: grabbing; }
.sc-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -5px; border-radius: 16px; }
.sc-flat { cursor: default; }
.sc-stage.is-focus .sc-canvas { touch-action: none; }
.sc-loading { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 30%; color: var(--ink-2); font-size: 0.95rem; font-weight: 500; pointer-events: none; transition: opacity 0.4s ease; }
.sc-stage[data-ready="true"] .sc-loading { opacity: 0; }

/* the bar at the top of the stage */
.sc-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; transition: opacity 0.35s ease; }
.sc-top > * { pointer-events: auto; }
.sc-modes { display: inline-flex; gap: 2px; padding: 4px; border-radius: 9999px; background: var(--glass); border: 1px solid var(--hair); }
.sc-modes button { min-height: 36px; padding: 6px 14px; border: 0; border-radius: 9999px; background: transparent; color: var(--ink-2); font-family: inherit; font-size: 0.875rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.sc-modes button:hover { color: var(--ink); }
.sc-modes button[aria-pressed="true"] { background: var(--glass-on); color: var(--ink); }
.sc-tools { display: flex; gap: 8px; }
.sc-tool { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; border: 1px solid var(--hair); background: var(--glass); color: var(--ink); cursor: pointer; transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease; }
.sc-tool:hover { border-color: var(--hair-strong); transform: translateY(-1px); }
.sc-tool[aria-pressed="false"] { color: var(--ink-3); }
.sc-tool[aria-pressed="true"] .snd-off, .sc-tool[aria-pressed="false"] .snd-on { display: none; }
.sc-tool[aria-expanded="true"] { background: var(--glass-on); border-color: var(--hair-strong); }
.sc-modes button:focus-visible, .sc-tool:focus-visible, .sc-btn:focus-visible, .sc-pop button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sc-pop-wrap { position: relative; }
.sc-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 6; width: 212px; display: grid; gap: 4px; padding: 6px; border-radius: 14px; background: var(--sheet); border: 1px solid var(--hair); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4); }
.sc-pop button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-family: inherit; font-size: 0.9rem; font-weight: 600; text-align: left; cursor: pointer; }
.sc-pop button:hover, .sc-pop button[aria-pressed="true"] { background: var(--glass-on); }
.swatch { width: 26px; height: 26px; flex: none; border-radius: 8px; border: 1px solid rgba(128, 128, 128, 0.5); }
.swatch[data-scene="midnight"] { background: radial-gradient(circle at 50% 60%, #3a2f63, #0b0e1f 70%); }
.swatch[data-scene="natural"] { background: linear-gradient(#cdbb9b 55%, #b98a52 55%); }
.swatch[data-scene="luxury"] { background: radial-gradient(circle at 50% 60%, #6b4a12, #050403 72%); }
.swatch[data-scene="minimal"] { background: linear-gradient(#dfe2e8 55%, #f4f5f7 55%); }

/* zoom and view, at the right edge */
.sc-zoom { position: absolute; right: 12px; top: 50%; transform: translateY(-78%); display: flex; flex-direction: column; gap: 8px; transition: opacity 0.35s ease; }

/* time, progress and the buttons, over the foot of the picture */
.sc-dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 64px 16px 16px; text-align: center; background: linear-gradient(to top, var(--scrim) 0%, var(--scrim) 38%, var(--scrim-0) 100%); pointer-events: none; }
.sc-dock > * { pointer-events: auto; }
.sc-status { min-height: 1.5em; color: var(--ink-2); font-size: 0.925rem; font-weight: 500; }
.sc-time { margin: 2px 0 12px; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: clamp(3.25rem, 2.2rem + 3.6vw, 4.5rem); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 2px 22px var(--shade); }
.sc-progress { position: relative; width: min(420px, 100%); height: 4px; margin: 0 auto; border-radius: 2px; background: var(--hair); }
.sc-progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); min-width: 0; border-radius: 2px; background: var(--sand); }
.sc-progress-fill::after { content: ""; position: absolute; right: -5px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--sand); box-shadow: 0 0 0 3px var(--scrim), 0 0 14px var(--sand); }
.sc-ends { width: min(420px, 100%); margin: 8px auto 14px; display: flex; justify-content: space-between; gap: 12px; color: var(--ink-3); font-size: 0.8rem; font-variant-numeric: tabular-nums; transition: opacity 0.35s ease; }
.sc-controls { display: flex; align-items: center; justify-content: center; gap: 8px; transition: opacity 0.35s ease; }
.sc-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 9999px; border: 1px solid var(--hair); background: var(--glass); color: var(--ink); font-family: inherit; font-size: 0.875rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease; }
.sc-btn:hover:not(:disabled) { border-color: var(--hair-strong); transform: translateY(-1px); }
.sc-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.sc-btn .ico { width: 17px; height: 17px; }
.sc-main { min-width: 132px; min-height: 52px; font-size: 1.05rem; }
.sc-stage[data-display="minimal"] .sc-time { font-size: 1.2rem; font-weight: 600; letter-spacing: 0; margin: 4px 0 12px; }
.sc-stage[data-display="minimal"] .sc-ends { display: none; }
.sc-stage[data-display="minimal"] .sc-progress { margin-bottom: 14px; }
.sc-stage[data-display="none"] .sc-time, .sc-stage[data-display="none"] .sc-progress, .sc-stage[data-display="none"] .sc-ends { display: none; }
.sc-stage[data-display="none"] .sc-status { margin-bottom: 12px; }
.sc-stage[data-mode="stopwatch"] #flipBtn, .sc-stage[data-mode="stopwatch"] #restartBtn { display: none; }

/* the message when the sand has run out, and small notes */
.sc-banner { position: absolute; left: 50%; top: 74px; transform: translateX(-50%); z-index: 5; width: min(340px, calc(100% - 32px)); padding: 16px 18px; border-radius: 16px; background: var(--sheet); border: 1px solid var(--hair); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42); text-align: center; animation: sc-rise 0.4s ease-out; }
@keyframes sc-rise { from { opacity: 0; transform: translate(-50%, 12px); } }
.sc-banner-title { font-size: 1.2rem; color: var(--ink); }
.sc-banner-text { margin-top: 4px; color: var(--ink-2); font-size: 0.925rem; }
.sc-banner-actions { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sc-note { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); z-index: 4; max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 12px; background: var(--sheet); border: 1px solid var(--hair); color: var(--ink); font-size: 0.85rem; font-weight: 500; text-align: center; }

/* ----- Focus view: the hourglass alone, over the whole page ----- */
.sc-focus { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #04050b; color: #ffffff; overflow: hidden; }
.sc-focus::backdrop { background: #04050b; }
.sc-focus-slot { position: absolute; inset: 0; }
.sc-stage.is-focus, .sc-stage:fullscreen { border-radius: 0; }
.sc-stage.is-focus .sc-canvas:focus-visible, .sc-stage:fullscreen .sc-canvas:focus-visible { border-radius: 0; }
.sc-stage.is-focus .sc-time { font-size: clamp(3.5rem, 2rem + 6.5vw, 6.5rem); }
.sc-stage.is-focus .sc-modes, .sc-stage.is-focus #settingsBtn, .sc-stage.is-focus #focusBtn { display: none; }
.sc-stage.is-focus .sc-top { justify-content: flex-end; }
.sc-stage.is-focus.is-idle { cursor: none; }
.sc-stage.is-focus.is-idle .sc-top, .sc-stage.is-focus.is-idle .sc-zoom, .sc-stage.is-focus.is-idle .sc-controls, .sc-stage.is-focus.is-idle .sc-ends { opacity: 0; pointer-events: none; }
.sc-stage.is-focus .sc-top:has(:focus-visible), .sc-stage.is-focus .sc-zoom:has(:focus-visible), .sc-stage.is-focus .sc-controls:has(:focus-visible) { opacity: 1; pointer-events: auto; }

/* ----- The settings card: five tabs ----- */
.sc-panel { padding: 0; gap: 0; overflow: hidden; }
@media (min-width: 1000px) { .sc-panel { height: var(--stage-h); } }
.sc-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 6px; border-bottom: 1px solid var(--surface-border); flex: none; }
.sc-tabs button { min-height: 44px; padding: 4px 2px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.sc-tabs button:hover { color: var(--link); }
.sc-tabs button[aria-selected="true"] { background: var(--tint-brand); color: var(--link); box-shadow: inset 0 0 0 1px var(--tint-brand-border); }
.sc-tabs button:focus-visible, .sc-pane:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sc-pane { flex: 1; min-height: 0; padding: 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; overscroll-behavior: contain; }
.sc-pane > div[id^="time"] { display: flex; flex-direction: column; gap: 16px; }
.pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pane-foot { margin-top: auto; padding-top: 4px; }
.pane-head .link { font-size: 0.875rem; font-weight: 600; }

/* presets */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.preset { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; min-height: 56px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; text-align: left; color: var(--text-strong); cursor: pointer; min-width: 0; transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; }
.preset:hover { border-color: var(--brand); transform: translateY(-1px); }
.preset:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.preset[aria-pressed="true"] { border-color: var(--brand); background: var(--tint-brand); box-shadow: 0 0 0 1px var(--brand); }
.preset-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; font-weight: 500; color: var(--text-3); }
.preset-time { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.preset-star { position: absolute; top: 6px; right: 8px; font-size: 0.75rem; line-height: 1; color: #b45309; }
:root:not([data-theme="light"]) .preset-star { color: #fbbf24; }
.presets.is-edit { grid-template-columns: minmax(0, 1fr); }
.preset-own { border-style: dashed; color: var(--link); }
.preset-own .preset-time { font-size: 0.95rem; }
.preset-row { display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 4px 6px 4px 12px; border-radius: 12px; border: 1px solid var(--chip-border); background: var(--surface); }
.preset-row .preset-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.preset-row .preset-name { color: var(--text-strong); font-weight: 600; font-size: 0.9rem; }
.preset-row .preset-time { font-size: 0.85rem; font-weight: 600; color: var(--text-3); font-family: inherit; }
.icon-btn { width: 40px; height: 40px; }
.icon-btn[aria-pressed="true"] { color: #b45309; }
:root:not([data-theme="light"]) .icon-btn[aria-pressed="true"] { color: #fbbf24; }
.icon-btn[aria-pressed="true"] .ico { fill: currentColor; }
.hms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.save-row { display: flex; gap: 8px; align-items: center; }
.save-row .input, .save-row .select { flex: 1; min-width: 0; width: auto; }
.card .select { width: 100%; }
.pomo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.round-line { align-self: flex-start; padding: 6px 12px; border-radius: 9999px; background: var(--tint-brand); border: 1px solid var(--tint-brand-border); color: var(--link); font-size: 0.875rem; font-weight: 600; }

/* glass and scene tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px 10px; border-radius: 12px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; font-size: 0.8rem; font-weight: 600; line-height: 1.25; color: var(--text-strong); text-align: center; cursor: pointer; min-width: 0; transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; }
.tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tile[aria-pressed="true"] { border-color: var(--brand); background: var(--tint-brand); box-shadow: 0 0 0 1px var(--brand); }
.tile-art { width: 100%; height: 84px; border-radius: 8px; background: #0e1020; display: block; }
.tiles-scene { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles-scene .tile { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 10px; text-align: left; font-size: 0.875rem; }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-note { font-size: 0.8rem; font-weight: 400; color: var(--text-3); }
.tiles-scene .swatch { width: 34px; height: 34px; }

/* sand */
.chip { color: var(--text-strong); min-height: 36px; }
.chip[aria-pressed="true"] { border-color: var(--brand); color: var(--text-strong); background: var(--tint-brand); box-shadow: 0 0 0 1px var(--brand); }
.dot { width: 16px; height: 16px; border-radius: 50%; flex: none; background: var(--dot, var(--surface-2)); border: 1px solid var(--line-strong); }
.dot-glow { box-shadow: 0 0 8px var(--dot); }
.dot-any { background: conic-gradient(#ef4444, #f59e0b, #84cc16, #06b6d4, #6366f1, #ec4899, #ef4444); }
.colour { width: 100%; height: 44px; padding: 4px; border-radius: 12px; border: 1px solid var(--field-border); background: var(--field); cursor: pointer; }

/* sliders and switches */
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.value { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1rem; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 32px; margin: 0; padding: 0; background: transparent; cursor: pointer; --fill: 50%; }
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track { height: 12px; border-radius: 9999px; border: 1px solid var(--line); background: linear-gradient(90deg, var(--brand) 0, var(--brand-2) var(--fill), var(--surface-2) var(--fill), var(--surface-2) 100%); }
.range::-moz-range-track { height: 12px; border-radius: 9999px; border: 1px solid var(--line); background: linear-gradient(90deg, var(--brand) 0, var(--brand-2) var(--fill), var(--surface-2) var(--fill), var(--surface-2) 100%); }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -8px; border-radius: 50%; background: #ffffff; border: 2px solid var(--brand); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #ffffff; border: 2px solid var(--brand); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
.range:focus-visible::-moz-range-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
.range:disabled { opacity: 0.45; cursor: not-allowed; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 0.925rem; color: var(--text-strong); }
.switch-row .hint { font-weight: 400; display: block; margin-top: 2px; }
.switch { position: relative; width: 52px; height: 44px; flex: none; padding: 0; border: 0; background: transparent; cursor: pointer; }
.switch::before { content: ""; position: absolute; left: 3px; top: 8px; width: 46px; height: 28px; border-radius: 14px; background: var(--line-strong); transition: background 0.2s ease; }
.switch::after { content: ""; position: absolute; top: 12px; left: 7px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
.switch[aria-checked="true"]::before { background: var(--gradient-brand); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 16px; }
.switch:disabled { opacity: 0.45; cursor: not-allowed; }
.reset { align-self: flex-start; padding: 6px 0; font-weight: 600; }

/* keys, sessions */
.keys { list-style: none; display: grid; gap: 8px; }
.keys li { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--text); }
.keys kbd { min-width: 3.6em; text-align: center; padding: 3px 8px; font-size: 0.78rem; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); }
.stat-num { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.35rem; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.8rem; color: var(--text-3); }
.history { list-style: none; display: grid; gap: 6px; }
.history li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.875rem; color: var(--text); }
.history .h-main { font-weight: 600; color: var(--text-strong); }
.history .h-sub { color: var(--text-3); text-align: right; }

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .card { padding: 16px; }
    .sc-panel { padding: 0; }
    .sc-pane { padding: 16px; }
    .sc-top { top: 8px; left: 8px; right: 8px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .sc-tools { order: -1; gap: 6px; max-width: calc(100% - 52px); } /* the first row keeps its right end free for the site's round theme button */
    .sc-modes { max-width: 100%; }
    .sc-tool { width: 44px; height: 44px; }
    .sc-modes button { min-height: 44px; padding: 6px 10px; }
    .sc-zoom { right: 8px; }
    .sc-dock { padding: 56px 12px 12px; }
    .sc-btn { width: 44px; padding: 0; }
    .sc-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .sc-banner .sc-btn { width: auto; padding: 0 16px; }
    .sc-btn .ico { width: 20px; height: 20px; }
    .sc-main { min-width: 112px; }
    .sc-banner { top: 112px; }
    .sc-note { top: 112px; }
    .toasts { bottom: 16px; right: 16px; left: 16px; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}
@media (max-width: 399px) { .sc-controls { gap: 6px; } .sc-main { min-width: 96px; padding-left: 12px; padding-right: 12px; } .tiles:not(.tiles-scene) { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tiles-scene { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: reduce) {
    .btn, .info-card, .toast, .seg button, .chip, .preset, .tile, .switch::before, .switch::after, .sc-tool, .sc-btn, .sc-modes button, .sc-tabs button,
    .sc-top, .sc-zoom, .sc-controls, .sc-ends, .sc-loading, .sc-banner, .dialog[open] { transition: none; animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026). The hourglass is a picture. */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"],
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]) { min-height: 44px; }
    main input[type="range"] { height: 44px; }
    main .seg button, main .chip { min-height: 44px; }
    main .seg button { min-width: 44px; }
    main .icon-btn { width: 44px; height: 44px; }
    main :is(p, li, .hint, .label, .select, .input, .seg button, .chip, .muted, .switch-row, .link, .tile, .tile-note, .preset-name, .preset-time, .stat-label, .sc-status, .sc-ends, .sc-modes button, .sc-tabs button, .sc-btn, .sc-pop button, .round-line, .history li, .keys kbd, .sc-note, .sc-banner-text, .pane-head .link) { font-size: 1rem; }
    .sc-stage[data-display="minimal"] .sc-time { font-size: 1.25rem; }
    main .btn-sm, .sc-banner .btn { font-size: 1rem; }
    .dialog :is(p, .label, .input, .btn) { font-size: 1rem; }
    .dialog .btn { min-height: 44px; }
}
