/* ===== Theme tokens (v3: calm neutrals, one indigo accent) ===== */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0C;
  --surface-1: #141416;
  --surface-2: #1C1C1F;
  --surface-3: #26262A;
  --sheet-bg: var(--surface-2);
  --hairline: rgba(255, 255, 255, .08);
  --hairline-strong: rgba(255, 255, 255, .14);
  --border-input: #74747C;
  --text: #F2F2F3;
  --text-2: #A1A1A8;
  --accent: #8B93FF;
  --on-accent: #0B0B0C;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --danger: #FF6B6B;
  --die-bg: #F2F2F3; --die-fg: #0B0B0C;
  --group-shadow: none;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .30), 0 6px 20px rgba(0, 0, 0, .28);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, .30), 0 18px 48px rgba(0, 0, 0, .45);
  --seg-on: var(--surface-3);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #FAFAF9;
  --surface-1: #FFFFFF;
  --surface-2: #F4F4F3;
  --surface-3: #EBEBEA;
  --sheet-bg: var(--surface-1);
  --hairline: rgba(10, 10, 12, .08);
  --hairline-strong: rgba(10, 10, 12, .14);
  --border-input: #808087;
  --text: #0B0B0C;
  --text-2: #5F5F66;
  --accent: #4F46E5;
  --on-accent: #FFFFFF;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --danger: #D93036;
  --die-bg: #111113; --die-fg: #FAFAF9;
  --group-shadow: var(--shadow-1);
  --shadow-1: 0 1px 2px rgba(16, 16, 20, .06);
  --shadow-2: 0 1px 2px rgba(16, 16, 20, .06), 0 6px 20px rgba(16, 16, 20, .08);
  --shadow-3: 0 2px 6px rgba(16, 16, 20, .08), 0 18px 48px rgba(16, 16, 20, .16);
  --seg-on: var(--surface-1);
}
:root {
  /* aliases for names used by older code */
  --surface: var(--surface-1);
  --muted: var(--text-2);
  --divider: var(--hairline);
  --primary: var(--accent);
  --on-primary: var(--on-accent);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter Display", "Inter", "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  --fs-caption: 12px;  --lh-caption: 16px;
  --fs-footnote: 13px; --lh-footnote: 18px;
  --fs-sub: 14px;      --lh-sub: 20px;
  --fs-body: 16px;     --lh-body: 24px;
  --fs-title: 17px;    --lh-title: 22px;
  --fs-h2: 20px;       --lh-h2: 26px;
  --fs-large: 30px;    --lh-large: 36px;
  --fs-display: clamp(56px, 17vw, 104px);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 28px; --r-full: 999px;
  --hair: 1px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
  --dur-press: 120ms; --dur-1: 180ms; --dur-2: 240ms; --dur-3: 320ms;
}
@media (min-resolution: 2dppx) { :root { --hair: .5px; } }

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body) / var(--lh-body) var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, [role="switch"] { touch-action: manipulation; }
button, .card, .icon-btn, .pill, .fab, .switch, .step-btn, .tool-row { user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.num, .big-input, .step-value, .nr-counter, .die, .ball, .result-card, .stat-num { font-variant-numeric: tabular-nums; }
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon.sm { width: 18px; height: 18px; }
.icon svg { width: 100%; height: 100%; }

.section-label, .field-caption, .field-label, .stat-cap, .result-caption {
  font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-2);
}

/* ===== Layout: every screen is a full-height flex column; nothing scrolls except bounded regions ===== */
html, body { height: 100%; }
body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
#app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  position: relative; flex: none; z-index: 10;
  display: flex; align-items: center; gap: var(--sp-1);
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background: var(--bg);
}
.topbar h1 {
  flex: 1; min-width: 0; margin-left: var(--sp-2);
  font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  outline: none;
}
.topbar.home h1 { margin-left: var(--sp-3); font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -.025em; }
.topbar-back + h1 { margin-left: 0; }
.topbar-actions { display: flex; align-items: center; flex: none; }
.topbar .icon { width: 22px; height: 22px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2);
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-1);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { background: var(--surface-3); transform: scale(.97); }
.icon-btn[aria-pressed="true"] { color: var(--text); }
.topbar .icon-btn[aria-pressed="false"] { color: var(--text-2); }

.content {
  flex: 1 1 0; min-height: 0; width: 100%; max-width: 600px; margin: 0 auto;
  padding: var(--sp-2) var(--sp-5) calc(env(safe-area-inset-bottom) + var(--sp-4));
  display: flex; flex-direction: column;
  overflow-x: clip; overflow-y: auto; /* safety net only (landscape phones) */
}
.content:has(~ .fab) { padding-bottom: var(--sp-2); }
.scroll-region { flex: 1 1 0; min-height: 88px; overflow-y: auto; overscroll-behavior: contain; }
.fit-box {
  flex: 1 1 0; min-height: 0; container-type: size; display: grid; place-items: center; overflow: clip; padding: 8px;
}
.fit-box.scroll-region { overflow-y: auto; place-items: start center; min-height: 0; }
@media (max-width: 359px) {
  .content { padding-inline: var(--sp-4); }
}
.center-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); min-height: 0; padding: var(--sp-2) 0;
}
.section-label { margin: var(--sp-4) var(--sp-1) var(--sp-1); }
.section-label.first { margin-top: var(--sp-1); }
.idle { visibility: hidden; }
.region-empty { width: 100%; display: grid; place-items: center; height: 100%; min-height: 88px; text-align: center; font-size: var(--fs-sub); padding: var(--sp-4); }
.region-empty.left { display: block; height: auto; min-height: 0; text-align: left; padding: var(--sp-2) var(--sp-1); }
.foot-row { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 44px; }
.foot-row > * { min-width: 0; }
.foot-row .pill { margin: 0; flex: 0 1 auto; max-width: 100%; }
.foot-row .pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 419px) {
  .inline-actions .btn span { display: none; }
  .inline-actions .btn.sm { width: 44px; padding: 0; }
}
.foot-row .inline-actions { justify-content: flex-start; }

/* ===== Cards and grouped lists ===== */
.card, .group {
  background: var(--surface-1); border-radius: var(--r-lg);
  box-shadow: 0 0 0 var(--hair) var(--hairline) inset, var(--group-shadow);
}
.group { overflow: hidden; }

/* ===== Home ===== */
.home-stack { padding-top: var(--sp-1); }
.home-sections { flex: none; }
.tool-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: var(--sp-3); }
.tool-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-height: 76px; padding: 10px 2px 6px; border-radius: var(--r-md);
  background: var(--surface-1); box-shadow: 0 0 0 var(--hair) var(--hairline) inset, var(--group-shadow);
  text-align: center; transition: transform var(--dur-press) var(--ease-out), background var(--dur-1);
}
.tool-tile:hover { background: var(--surface-2); }
.tool-tile:active { transform: scale(.97); background: var(--surface-3); }
.tool-tile-label { max-width: 100%; font-size: 12px; line-height: 16px; font-weight: 500; overflow-wrap: anywhere; }
.saved-region { padding-bottom: var(--sp-2); }
.saved-head {
  display: flex; align-items: center; gap: var(--sp-2); height: 32px; margin-top: var(--sp-2);
  color: var(--text-2); font-size: var(--fs-footnote); font-weight: 600;
}
.saved-head .tile { width: 24px; height: 24px; border-radius: 7px; }
.saved-head .tile .icon { width: 14px; height: 14px; }
.saved-group:first-child .saved-head { margin-top: 0; }
.search {
  position: relative; display: flex; align-items: center; height: 44px;
  border-radius: var(--r-md); background: var(--surface-2); border: var(--hair) solid var(--hairline);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { position: absolute; left: 12px; color: var(--text-2); pointer-events: none; }
.search input {
  flex: 1; min-width: 0; height: 100%; padding: 0 0 0 40px; border: 0; background: transparent;
  font-size: var(--fs-body); outline: none; border-radius: var(--r-md); -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--text-2); opacity: 1; }
.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-clear { width: 40px; height: 40px; margin-right: 2px; }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }

.tool-row {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px;
  padding: 0 var(--sp-3) 0 var(--sp-4); background: transparent; color: var(--text);
  transition: background var(--dur-1);
}
a.tool-row:active { background: var(--surface-3); }
.tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text);
}
.tile .icon { width: 18px; height: 18px; }
.tool-row .row-label { flex: 1; min-width: 0; font-size: var(--fs-body); font-weight: 500; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-body .row-label { flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: var(--text-2); }
.plus-btn { color: var(--text); margin-right: -4px; }

.child-row { position: relative; display: flex; align-items: center; min-height: 48px; padding: 0 var(--sp-1) 0 32px; }
.child-row::before { content: ""; position: absolute; top: 0; left: 32px; right: 0; border-top: var(--hair) solid var(--hairline); }
.saved-head + .child-row::before, .child-list .child-row:first-child::before { display: none; }
.child-list .child-row { padding-left: var(--sp-1); }
.child-list .child-row::before { left: var(--sp-1); }
.child-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); min-height: 48px; }
.child-link:active .child-name { color: var(--accent); }
.child-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.child-sub { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-footnote); color: var(--text-2); }
.child-row .icon-btn .icon { width: 18px; height: 18px; }
.child-slot { flex: none; width: 44px; height: 44px; }

.search-results { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.search-results li + li { border-top: var(--hair) solid var(--hairline); }
.search-results .tool-row { min-height: 60px; }
.search-panel { margin-top: var(--sp-1); }
.search-empty { padding: var(--sp-8) 0; text-align: center; }
.search-empty-title { font-weight: 600; overflow-wrap: anywhere; margin-bottom: var(--sp-1); }

/* No repeat card */
.nr-card { display: flex; align-items: center; min-height: 56px; padding: 0 var(--sp-2) 0 var(--sp-4); margin-top: var(--sp-2); flex: none; }
.nr-main { flex: 1; display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; cursor: pointer; }
.nr-label { font-size: var(--fs-body); font-weight: 500; }
.nr-counter { font-size: var(--fs-sub); font-weight: 600; margin-right: var(--sp-1); }
.nr-counter.muted { font-weight: 500; }

/* ===== Buttons ===== */
.btn, .pill, .chip, .icon-btn, .step-btn {
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-1), color var(--dur-1);
}
.btn:active, .pill:active, .chip:active { transform: scale(.97); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 44px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--accent); font-size: var(--fs-body); font-weight: 600;
}
.btn:hover { background: var(--accent-soft); }
.btn.filled { background: var(--accent); color: var(--on-accent); }
.btn.filled:hover { background: var(--accent); filter: brightness(1.06); }
.btn.filled.danger { background: var(--danger); color: #1a0505; }
html[data-theme="light"] .btn.filled.danger { color: #fff; }
.btn.tonal { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 var(--hair) var(--hairline) inset; }
.btn.tonal:hover { background: var(--surface-3); }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: var(--fs-sub); border-radius: var(--r-md); }
.btn.danger-text { color: var(--danger); }
.btn:disabled { opacity: .4; cursor: default; }
.pill {
  align-self: center; display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 40px; padding: 0 var(--sp-4); margin: var(--sp-2) 0 var(--sp-1); flex: none;
  border: 0; border-radius: var(--r-full); background: var(--surface-2);
  box-shadow: 0 0 0 var(--hair) var(--hairline) inset;
  color: var(--text); font-size: var(--fs-sub); font-weight: 600; position: relative;
}
.pill::after { content: ""; position: absolute; inset: -2px 0; }
.pill .icon { color: var(--text-2); width: 18px; height: 18px; }
.pill:hover { background: var(--surface-3); }

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.chip {
  position: relative; height: 36px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-full);
  background: var(--surface-2); box-shadow: 0 0 0 var(--hair) var(--hairline) inset;
  color: var(--text); font-size: var(--fs-sub); font-weight: 600;
}
.chip::after { content: ""; position: absolute; inset: -4px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.fab {
  position: relative; z-index: 60; flex: none; align-self: center;
  margin: var(--sp-2) 0 calc(env(safe-area-inset-bottom) + 16px);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 52px; min-width: 148px; padding: 0 var(--sp-6); border: 0; border-radius: var(--r-full);
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-body); font-weight: 600;
  box-shadow: var(--shadow-3);
  transition: transform var(--dur-press) var(--ease-out), opacity var(--dur-1);
}
.fab:active { transform: scale(.97); }
.fab.disabled { opacity: .4; box-shadow: none; }

/* ===== Switch / stepper / rows ===== */
.switch {
  position: relative; flex: none; width: 51px; height: 31px; padding: 0;
  border: var(--hair) solid var(--border-input); border-radius: var(--r-full); background: var(--surface-3);
  transition: background var(--dur-1), border-color var(--dur-1);
}
.switch .thumb {
  position: absolute; top: 1px; left: 1px; width: 27px; height: 27px; border-radius: 50%;
  background: #FFFFFF; box-shadow: var(--shadow-1);
  transition: transform var(--dur-1) var(--ease-spring);
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .thumb { transform: translateX(20px); }
.switch:disabled { opacity: .4; }

.row { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: 6px 0; }
.switch-row { cursor: pointer; }
.switch-row.disabled { cursor: default; opacity: .7; }
.row-text { flex: 1; min-width: 0; }
.row-label { font-size: var(--fs-body); }
.row-hint { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-2); margin-top: 2px; }

.stepper { display: inline-flex; align-items: center; gap: var(--sp-1); }
.step-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); box-shadow: 0 0 0 var(--hair) var(--hairline) inset; color: var(--text);
}
.step-btn .icon { width: 18px; height: 18px; }
.step-btn:active { transform: scale(.97); }
.step-btn:disabled { opacity: .35; cursor: default; }
.step-value { min-width: 72px; text-align: center; font-size: var(--fs-body); font-weight: 600; }
.stepper-wrap { display: flex; justify-content: center; margin-top: var(--sp-3); }

/* Segmented control */
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 var(--hair) var(--hairline) inset; }
.seg {
  flex: 1; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2);
  font-size: var(--fs-sub); font-weight: 600; transition: background var(--dur-1), color var(--dur-1);
}
.seg[aria-checked="true"] { background: var(--seg-on); color: var(--text); box-shadow: var(--shadow-1); }
.seg.disabled { opacity: .45; cursor: default; }

/* ===== Number ===== */
.field-group { width: 100%; display: flex; flex-direction: column; align-items: center; }
.field-label { margin-top: var(--sp-2); }
.big-input {
  width: 100%; min-width: 0; padding: 0 0 4px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; text-align: center; color: var(--text);
  font-family: var(--font-display); font-size: clamp(48px, 16vw, 88px); font-weight: 300; letter-spacing: -.03em; line-height: 1.15;
  border-radius: var(--r-sm);
  -moz-appearance: textfield; appearance: textfield;
}
.big-input.long { font-size: clamp(30px, 10vw, 52px); }
.big-input::-webkit-inner-spin-button, .big-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.big-input:focus { outline: none; border-bottom-color: var(--accent); }

/* Preset bar: one 44px row */
.preset-bar {
  flex: none; display: flex; align-items: center; gap: var(--sp-1); height: 44px; margin-bottom: var(--sp-2);
  padding: 0 var(--sp-1) 0 var(--sp-3);
  background: var(--surface-2); border-radius: var(--r-lg); box-shadow: 0 0 0 var(--hair) var(--hairline) inset;
}
.preset-bar-text { flex: 1; min-width: 0; font-size: var(--fs-sub); line-height: var(--lh-sub); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-bar-actions { display: flex; flex: none; gap: 0; }
.preset-bar .btn { min-height: 36px; height: 36px; padding: 0 var(--sp-3); }

/* ===== List tool ===== */
.items { margin-top: var(--sp-1); }
.items .empty-list { padding: var(--sp-8) 0; }
.item {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2); text-align: center;
  min-height: 48px; padding: var(--sp-2) var(--sp-3); font-size: 18px;
  border-bottom: var(--hair) solid var(--hairline);
  overflow-wrap: anywhere; user-select: text; -webkit-user-select: text;
  transition: opacity var(--dur-1);
}
.item.drawn { opacity: .4; text-decoration: line-through; }
.item.picked { color: var(--accent); font-weight: 600; }
.weight-badge {
  flex: none; padding: 1px 7px; border-radius: var(--r-full); background: var(--surface-3);
  color: var(--text-2); font-size: var(--fs-footnote); font-weight: 600; text-decoration: none;
}
.empty-list { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding: var(--sp-12) 0; }

/* ===== Fields and list editor ===== */
.editor { gap: var(--sp-3); }
.editor > * { flex: none; }
.editor .editor-text { flex: 1 1 0; min-height: 96px; resize: none; }
.field-caption { display: flex; flex-direction: column; gap: 6px; }
.caption-row { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-1); }
.field {
  width: 100%; padding: 12px 14px; border: var(--hair) solid var(--border-input); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); font-size: var(--fs-body); line-height: var(--lh-body);
  letter-spacing: 0; text-transform: none; font-weight: 400;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 200px; line-height: 1.5; }
select.field { appearance: none; -webkit-appearance: none; }
.field-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.hint { font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
.field-count { font-size: var(--fs-footnote); text-align: right; flex: none; }
.editor-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ===== Dice ===== */
.dice-area { display: grid; grid-template-columns: repeat(var(--cols, 4), var(--die, 64px)); justify-content: center; align-content: center; gap: 16px; cursor: pointer; }
.dice-page .dice-info { flex: none; display: flex; flex-direction: column; align-items: center; }
.dice-page .stepper-wrap { flex: none; margin-top: var(--sp-2); }
.die {
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  width: var(--die); height: var(--die); padding: calc(var(--die) * .14); border-radius: 24%;
  background: var(--die-bg); color: var(--die-fg);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.die.numeric { display: flex; align-items: center; justify-content: center; padding: 0; }
.die-num { font-family: var(--font-display); font-size: calc(var(--die) * .42); font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.pip { width: 72%; height: 72%; place-self: center; border-radius: 50%; background: var(--die-fg); }
.die.rolling { animation: wobble .25s ease-in-out infinite; }
.die.settle { animation: reveal var(--dur-2) var(--ease-spring) both; }
@keyframes wobble {
  0% { transform: rotate(-8deg) scale(1.02); }
  50% { transform: rotate(8deg) scale(.98); }
  100% { transform: rotate(-8deg) scale(1.02); }
}
.notation-chip {
  height: 36px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-full); background: var(--surface-2);
  box-shadow: 0 0 0 var(--hair) var(--hairline) inset; color: var(--text); font-size: var(--fs-sub); font-weight: 600;
  font-variant-numeric: tabular-nums; margin-top: var(--sp-2); position: relative;
}
.notation-chip::after { content: ""; position: absolute; inset: -4px; }
.dice-total { text-align: center; margin-top: var(--sp-2); }
.total-main { font-size: 20px; line-height: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.total-sub { font-size: var(--fs-sub); line-height: var(--lh-sub); color: var(--text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ===== Coin ===== */
.coin-stage { width: min(100cqw, 100cqh, 240px); aspect-ratio: 1; perspective: 900px; cursor: pointer; }
.coin-stage.arc { animation: arc 900ms cubic-bezier(.3, .6, .4, 1); }
@keyframes arc { 0% { transform: translateY(0); } 40% { transform: translateY(-40px); } 100% { transform: translateY(0); } }
.coin-page > .fit-box { overflow: visible; padding: 48px 8px 28px; }
.coin { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .10), var(--shadow-3);
}
.face.front { background: radial-gradient(circle at 30% 25%, #FFFFFF 0%, #E4E4E7 45%, #A1A1AA 100%); color: #0B0B0C; }
.face.back { background: radial-gradient(circle at 30% 25%, #5A5A63 0%, #2A2A2F 55%, #18181B 100%); color: #F2F2F3; transform: rotateY(180deg); }
.face-letter { font-family: var(--font-display); font-size: min(22vw, 96px); font-weight: 600; line-height: 1; }
.face-label { font-size: var(--fs-caption); font-weight: 600; letter-spacing: .2em; }
.coin-result { font-family: var(--font-display); font-size: 28px; line-height: 36px; font-weight: 600; min-height: 36px; letter-spacing: -.02em; }
.coin-stats { display: flex; width: 100%; max-width: 320px; margin-top: var(--sp-2); }
.stat { flex: 1; text-align: center; padding: var(--sp-1) 0; }
.stat + .stat { border-left: var(--hair) solid var(--hairline-strong); }
.stat-num { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; }
.coin-streak { flex: none; min-height: var(--lh-sub); font-size: var(--fs-sub); line-height: var(--lh-sub); color: var(--text-2); }
.coin-page { align-items: center; text-align: center; }
.coin-page > * { flex: none; }
.coin-page > .fit-box { flex: 1 1 0; align-self: stretch; }
.coin-page .coin-stats { margin-top: var(--sp-1); }
.coin-reset { margin-top: 0; }

/* ===== Lots ===== */
.lots-status { flex: none; text-align: center; color: var(--text-2); font-size: var(--fs-sub); line-height: var(--lh-sub); padding: var(--sp-1) 0; min-height: 40px; }
.lots-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), var(--tile, 72px)); justify-content: center; align-content: center; gap: 8px; }
.lot { position: relative; width: var(--tile, 72px); height: calc(var(--tile, 72px) * 4 / 3); padding: 0; border: 0; border-radius: var(--r-md); background: transparent; perspective: 600px; color: inherit; }
.lot:disabled { opacity: 1; cursor: default; }
.lot-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 400ms var(--ease-out); border-radius: var(--r-md); }
.lot.revealed .lot-inner { transform: rotateY(180deg); }
.lot-face {
  position: absolute; inset: 0; border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.lot-front { background: var(--surface-2); box-shadow: 0 0 0 var(--hair) var(--hairline) inset; }
.lot-q { font-size: calc(var(--tile, 72px) * .36); font-weight: 500; color: var(--text-2); line-height: 1; }
.lot-num { font-size: var(--fs-caption); font-weight: 600; letter-spacing: .06em; color: var(--text-2); }
.lot-back { transform: rotateY(180deg); background: transparent; }
.lot.win .lot-back { background: var(--accent); color: var(--on-accent); }
.lot.blank .lot-back { border: 1px dashed var(--hairline-strong); color: var(--text-2); }
.lot-win { font-weight: 700; letter-spacing: .1em; font-size: var(--fs-footnote); }
.lot-blank { font-size: 24px; }
.lot.win .icon { width: 26px; height: 26px; }

/* ===== Settings ===== */
/* Settings */
.settings { gap: var(--sp-3); padding-top: var(--sp-2); }
.settings > * { flex: none; }
.settings-card { padding: var(--sp-2) var(--sp-4); }
.settings-card .row + .row { border-top: var(--hair) solid var(--hairline); }
.settings-card .segmented { margin: var(--sp-2) 0 var(--sp-1); }
.settings-foot { display: flex; align-items: center; justify-content: space-between; }
.settings-foot .btn { padding: 0 var(--sp-3); }
.settings-foot .privacy-link { color: var(--text-2); font-weight: 500; }
.version { text-align: center; font-size: var(--fs-footnote); line-height: 20px; }

/* ===== Result overlay ===== */
.result-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4);
  background: rgba(0, 0, 0, .5);
  padding: env(safe-area-inset-top) var(--sp-4) calc(env(safe-area-inset-bottom) + 96px);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .result-overlay { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}
.result-overlay.enter { animation: fade var(--dur-1) var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.result-card {
  position: relative; width: min(84vw, 380px); aspect-ratio: 1; border-radius: var(--r-2xl);
  background: var(--surface-1); box-shadow: var(--shadow-3), 0 0 0 var(--hair) var(--hairline) inset;
  color: var(--text); font-family: var(--font-display); font-weight: 600; letter-spacing: -.035em; line-height: 1.12;
  overflow-wrap: anywhere; cursor: pointer; user-select: none; -webkit-user-select: none;
  outline-offset: 4px;
}
.result-caption {
  position: absolute; top: var(--sp-6); left: var(--sp-6); right: var(--sp-6); z-index: 1;
  display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font); letter-spacing: .06em;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; pointer-events: none;
}
.result-caption::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.result-body { position: absolute; inset: 0; display: flex; padding: 52px var(--sp-6) var(--sp-6); overflow: auto; text-align: center; }
.result-inner { margin: auto; max-width: 100%; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .5em; }
.result-card.lines .result-inner { flex-direction: column; flex-wrap: nowrap; gap: .3em; }
.result-inner.reveal { animation: reveal var(--dur-2) var(--ease-spring); }
@keyframes reveal {
  from { opacity: 0; transform: translateY(8px) scale(.98); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}
.result-val { max-width: 100%; }
.result-actions { display: flex; gap: var(--sp-2); }

/* ===== Sheet / dialog / menu / toast ===== */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  dialog::backdrop { -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
}
.sheet {
  width: min(100%, 600px); max-width: 100%; max-height: 85dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--sheet-bg); box-shadow: var(--shadow-3); overflow: auto;
}
.sheet[open] { animation: slide-up var(--dur-3) var(--ease-out); }
@keyframes slide-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-body { padding: var(--sp-2) var(--sp-5) calc(env(safe-area-inset-bottom) + var(--sp-4)); }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--hairline-strong); margin: var(--sp-1) auto var(--sp-3); }
.sheet-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: var(--sp-2); }
.sheet-head h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; letter-spacing: -.01em; }
.sheet-sub { color: var(--text-2); font-size: var(--fs-sub); }
.sheet-rows .switch-row, .sheet-rows .row, .sheet-rows .sheet-field, .sheet-rows .sheet-block { border-top: var(--hair) solid var(--hairline); }
.sheet-rows > :first-child { border-top: 0; }
.sheet-field { padding: var(--sp-3) 0; }
.sheet-block { padding: var(--sp-3) 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-3); }
.history-list { max-height: 50dvh; overflow: auto; }
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); width: 100%;
  min-height: 48px; padding: var(--sp-2) 0; border: 0; border-bottom: var(--hair) solid var(--hairline);
  background: transparent; text-align: left; user-select: text; -webkit-user-select: text;
}
.history-text { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.history-time { color: var(--text-2); font-size: var(--fs-footnote); flex: none; font-variant-numeric: tabular-nums; }
.empty { padding: var(--sp-6) 0; text-align: center; }

.confirm {
  width: min(88vw, 360px); padding: var(--sp-6) var(--sp-6) var(--sp-3); border: 0; border-radius: var(--r-xl);
  background: var(--sheet-bg); box-shadow: var(--shadow-3);
}
.confirm[open] { animation: pop-in var(--dur-2) var(--ease-spring); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.confirm p { font-size: var(--fs-title); line-height: var(--lh-title); overflow-wrap: anywhere; }
.confirm h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; letter-spacing: -.01em; margin-bottom: var(--sp-4); }
.confirm-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

.menu {
  position: absolute; z-index: 70; min-width: 200px; padding: var(--sp-1);
  border-radius: var(--r-md); background: var(--sheet-bg); box-shadow: var(--shadow-3), 0 0 0 var(--hair) var(--hairline) inset;
  animation: menu-in var(--dur-1) var(--ease-out); transform-origin: top right;
}
@keyframes menu-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 var(--sp-3);
  border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-size: var(--fs-body);
}
.menu-item:hover:not(:disabled), .menu-item:active:not(:disabled) { background: var(--surface-3); }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--danger); }

.toast {
  position: fixed; inset: auto; left: 50%; margin: 0; z-index: 80;
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  transform: translateX(-50%) translateY(6px);
  max-width: min(90vw, 420px); padding: 10px var(--sp-4); border: 0; border-radius: var(--r-full);
  background: var(--text); color: var(--bg); font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: 500;
  text-align: center; overflow: visible; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ===== v3 tools: source card, teams, shuffle, wheel, lottery, cards ===== */
.tool-stack { gap: var(--sp-2); }
.tool-stack > * { flex: none; }
.tool-stack > .fit-box, .tool-stack > .scroll-region { flex: 1 1 0; }
.tool-stack > .scroll-region { min-height: 88px; }
.inline-actions { display: flex; justify-content: center; gap: var(--sp-2); }
.inline-actions .btn.sm { min-height: 40px; height: 40px; }
.disabled.row { opacity: .5; }

/* Source summary row (opens the Items sheet) */
.source-row {
  flex: none; display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: 56px; padding: 0 var(--sp-2) 0 var(--sp-4);
  border: 0; color: var(--text); text-align: left; cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-1);
}
.source-row:active { transform: scale(.99); background: var(--surface-2); }
.source-text-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.source-title { font-size: var(--fs-body); line-height: 22px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-sub { font-size: var(--fs-footnote); line-height: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-row.need .source-title { color: var(--accent); }
.source-edit { flex: none; padding: 0 var(--sp-3); font-size: var(--fs-sub); font-weight: 600; color: var(--accent); }
.source-sheet { display: flex; flex-direction: column; gap: var(--sp-3); }
.source-panel { display: flex; flex-direction: column; gap: var(--sp-2); }
.source-text { min-height: 144px; }
.source-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.source-btns { display: flex; gap: var(--sp-2); }
.source-list-row { display: flex; align-items: center; gap: var(--sp-2); }
.source-list-row select { flex: 1; min-width: 0; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.source-list-row .btn { flex: none; }
.settings-card { display: flex; flex-direction: column; gap: var(--sp-1); }

.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-2); }
.team-card { padding: var(--sp-4); min-width: 0; }
.team-head { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: 600; margin-bottom: var(--sp-2); }
.team-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.team-count { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li { font-size: var(--fs-body); line-height: 28px; overflow-wrap: anywhere; }
.team-card.reveal, .shuffle-out li.reveal, .playing-card.reveal { animation: reveal var(--dur-2) var(--ease-spring) both; }

.shuffle-out { list-style: none; margin: 0; padding: var(--sp-1) 0; background: var(--surface-1); border-radius: var(--r-lg); box-shadow: 0 0 0 var(--hair) var(--hairline) inset, var(--group-shadow); }
.shuffle-out li { display: flex; align-items: baseline; gap: var(--sp-3); padding: 10px var(--sp-4); }
.shuffle-out li + li { border-top: var(--hair) solid var(--hairline); }
.shuffle-idx { min-width: 28px; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: var(--fs-sub); }
.shuffle-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.wheel-stage { position: relative; width: min(100cqw, 100cqh, 360px); aspect-ratio: 1; }
.wheel { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 50% 50%; will-change: transform; }
.wheel-seg { stroke: var(--surface-1); stroke-width: .6; }
.wheel-rim { fill: none; stroke: var(--hairline-strong); stroke-width: 1.5; }
.wheel-empty { fill: var(--surface-2); stroke: var(--hairline-strong); stroke-width: 1; }
.wheel-empty-text { fill: var(--text-2); font-family: var(--font); }
.wheel text { font-family: var(--font-display); pointer-events: none; }
.wheel-pointer {
  position: absolute; left: 50%; top: -4px; width: 16px; height: 20px; transform: translateX(-50%);
  background: var(--text); clip-path: polygon(0 0, 100% 0, 50% 100%); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3));
}
.wheel-hub {
  position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--surface-1); box-shadow: var(--shadow-2), 0 0 0 var(--hair) var(--hairline-strong);
}
.wheel-result {
  flex: none; height: 36px; max-width: 100%; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-family: var(--font-display); font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.02em;
}

.lottery-lines { display: flex; flex-direction: column; gap: var(--sp-4); align-items: center; padding: var(--sp-2) 0; }
.chips.nowrap { flex: none; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; margin-top: 0; padding: 4px 0; scrollbar-width: none; }
.chips.nowrap::-webkit-scrollbar { display: none; }
.chips.nowrap .chip { flex: none; }
.lottery-lines.reveal .ball { animation: reveal var(--dur-2) var(--ease-spring) both; }
.lottery-line { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); max-width: 100%; }
.line-label { font-size: 13px; line-height: 18px; color: var(--text-2); }
.balls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--sp-2); }
.ball {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--text); color: var(--bg); font-family: var(--font-display); font-size: 16px; font-weight: 600; box-shadow: var(--shadow-1);
}
.ball.bonus { background: var(--accent); color: var(--on-accent); }
.plus { color: var(--text-2); font-weight: 300; font-size: 20px; }
.lottery-foot { text-align: center; padding-bottom: var(--sp-2); }

.hand { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: var(--sp-3); padding: var(--sp-2) 0; }
.playing-card {
  position: relative; width: 76px; height: 108px; flex: none; border-radius: 10px; background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .10), var(--shadow-2); color: #111113; font-family: var(--font-display);
  user-select: none; -webkit-user-select: none;
}
.playing-card.red { color: #C8102E; }
.pc-corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; font-size: 15px; font-weight: 600; }
.pc-corner.tl { top: 6px; left: 6px; }
.pc-corner.br { bottom: 6px; right: 6px; transform: rotate(180deg); }
.pc-suit { margin-top: 1px; }
.pc-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.playing-card.joker { display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 8px 0; }
.pc-star { font-size: 16px; line-height: 1; }
.pc-joker-text { writing-mode: vertical-rl; text-orientation: upright; font-size: 12px; font-weight: 700; letter-spacing: .05em; }
@media (max-width: 359px) {
  .playing-card { width: 64px; height: 90px; }
  .pc-corner { font-size: 13px; }
  .pc-center { font-size: 28px; }
}

/* ===== Motion: off and reduced kill decorative CSS motion (essential motion uses WAAPI) ===== */
[data-motion="off"] *, [data-motion="off"] *::before, [data-motion="off"] *::after,
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after {
  animation: none !important;
  transition: none !important;
}
[data-motion="off"] :is(.btn, .pill, .fab, .icon-btn, .step-btn, .chip, .tool-tile, .source-row, .seg, .notation-chip):active,
[data-motion="reduced"] :is(.btn, .pill, .fab, .icon-btn, .step-btn, .chip, .tool-tile, .source-row, .seg, .notation-chip):active { transform: none !important; }

/* ===== Help sheet (static #help and in-app sheets) ===== */
.help-doc { overflow-wrap: anywhere; }
.help-doc h1 { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -.015em; margin: var(--sp-1) 0 var(--sp-2); }
.help-doc h2 { font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600; margin-top: var(--sp-5); }
.help-doc h3 { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 600; margin-top: var(--sp-3); }
.help-doc p { margin-top: var(--sp-1); font-size: var(--fs-sub); line-height: 1.55; color: var(--text-2); }
.help-steps { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); font-size: var(--fs-sub); line-height: 1.55; color: var(--text-2); }
.help-steps li + li { margin-top: var(--sp-1); }
.help-links ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.help-links a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 var(--sp-3); border-radius: var(--r-full);
  background: var(--surface-3); font-size: var(--fs-footnote); color: var(--text); white-space: nowrap;
}
.help-foot { text-align: center; font-size: var(--fs-footnote); color: var(--text-2); margin-top: var(--sp-3); }
.help-foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--sp-2); color: var(--text-2); }
.help-foot a:hover { text-decoration: underline; }
.help-sheet .sheet-actions { margin-top: 0; }

/* ===== Static pages, ad dock ===== */
.noscript { padding: var(--sp-6); text-align: center; }
.link-row { color: inherit; text-decoration: none; cursor: pointer; }
.link-icon { display: inline-flex; color: var(--accent); }
.version { cursor: default; }
.doc-page { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; }
.doc { padding: var(--sp-2) var(--sp-5) calc(env(safe-area-inset-bottom) + var(--sp-4)); }
.doc p { margin-top: var(--sp-3); font-size: var(--fs-body); line-height: 1.6; color: var(--text-2); overflow-wrap: anywhere; }
.doc p:first-child { margin-top: var(--sp-1); }
.doc a { color: var(--accent); }

.ad-dock { display: none; }
html[data-home]:not([data-noads]) .ad-dock {
  flex: none; height: calc(58px + env(safe-area-inset-bottom)); padding: 4px 0 env(safe-area-inset-bottom);
  display: flex; justify-content: center; border-top: var(--hair) solid var(--hairline); background: var(--bg);
}
html .ad-dock:has(ins[data-ad-status="unfilled"]) { display: none !important; }

/* ===== Compact (short phones, e.g. 320x568): tighter spacing, never scrolling ===== */
@media (max-height: 600px) {
  :root { --fs-display: 64px; }
  .topbar { min-height: calc(48px + env(safe-area-inset-top)); }
  .content { --sp-2: 6px; --sp-3: 8px; --sp-4: 12px; --sp-5: 16px; }
  .fab { height: 48px; margin-top: 4px; margin-bottom: calc(env(safe-area-inset-bottom) + 10px); }
  .big-input { font-size: clamp(40px, 13vw, 60px); }
  .big-input.long { font-size: clamp(26px, 8vw, 40px); }
  .nr-card, .nr-main { min-height: 48px; }
  .settings-card .row, .row { min-height: 48px; }
  .seg { height: 34px; }
  .tool-tile { min-height: 72px; }
  .dice-area { gap: 10px; }
  .lots-status { min-height: 0; padding: 0; }
  .lots-box { padding: 4px; }
  .lots-grid { gap: 6px; }
}

.home-stack > * { flex: none; }
.home-stack > .scroll-region { flex: 1 1 0; }
.lists-page > .scroll-region { padding-bottom: var(--sp-2); }
