/* Rhythm Roulette — "Paper & Ink": light, warm, paper-score look. */

/* ---------------- Fonts (self-hosted, latin subset, variable) ---------------- */

@font-face {
  font-family: "Bodoni Moda";
  src: url("../fonts/bodoni-moda-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ---------------- Design tokens ---------------- */

:root {
  --paper: #F3ECDC;            /* page background */
  --card: #FBF8EF;             /* cards, sheets */
  --field: #FFFDF7;            /* selects / inputs */
  --seg: #EAE2CF;              /* segmented control track */
  --ink: #2B211C;              /* text, notation, selected states */
  --muted: #6E625A;            /* secondary text */
  --accent: #B8432B;           /* brick red: primary actions, highlights */
  --accent-shadow: #8A2F1D;
  --danger: #A2432F;           /* destructive text: muted brick */
  --ok: #2F6B3A;               /* "ready to save" */
  --hairline: rgba(43, 33, 28, 0.12);
  --hairline-strong: rgba(43, 33, 28, 0.2);
  --track: rgba(43, 33, 28, 0.14);

  --font-title: "Bodoni Moda", "Bodoni 72", Didot, Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-card: 16px;
  --r-ctl: 12px;
  --tap: 44px;                 /* minimum touch target */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior: none; }

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------------- Shared components ---------------- */

/* Card */
.card, .control {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}

/* Small section label */
.label, .control-head > span:first-child, .control-head > label, .ed-meter-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* Title */
.title {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* Segmented control */
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-ctl);
  background: var(--seg);
}
.segmented button {
  min-height: 46px;
  padding: 2px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.segmented-2 { grid-template-columns: repeat(2, 1fr); }
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.segmented-5 { grid-template-columns: repeat(5, 1fr); }
/* beats per bar: 8 numbers on one row (two rows on very narrow phones) */
.segmented-meter { grid-template-columns: repeat(8, 1fr); }
.segmented-meter button { padding: 0; font-size: 18px; }
@media (max-width: 330px) { .segmented-meter { grid-template-columns: repeat(4, 1fr); } }
/* phrase count under each option */
.segmented button small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] small { color: var(--paper); opacity: .8; }
.segmented button small:empty { display: none; }
.segmented button.empty:not([aria-pressed="true"]) { opacity: .45; }

/* Select */
.select {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-ctl);
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%232B211C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 20px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis;
}
.select option, .select optgroup { background: var(--field); color: var(--ink); }

/* Secondary button */
.btn-secondary, .btn-editor, .btn-small, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-ctl);
  background: var(--field);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}
.btn-secondary:active, .btn-editor:active, .btn-small:active, .btn-ghost:active { background: var(--seg); }
.btn-small:disabled { opacity: .4; cursor: default; }
.btn-small.danger { color: var(--danger); }
.btn-editor svg { width: 20px; height: 20px; flex: none; }

/* Primary button: brick red with a solid "paper print" shadow */
.btn-primary, .btn-start, .btn-small.accent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--paper);
  font-weight: 700;
  box-shadow: 0 4px 0 var(--accent-shadow);
  margin-bottom: 4px; /* room for the shadow */
}
.btn-primary:active, .btn-start:active, .btn-small.accent:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--accent-shadow);
}
.btn-start:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 0 4px 0 var(--accent-shadow); }

/* Square icon button (practice top bar, editor back) */
.btn-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}
.btn-bar:active { background: var(--seg); }
.btn-bar svg { width: 22px; height: 22px; flex: none; }
.btn-bar span { display: none; } /* icon only; the aria-label names it */

/* Sliders */
input[type="range"] {
  flex: 1;
  min-width: 0;
  height: var(--tap);
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--ink) var(--fill, 50%), var(--track) var(--fill, 50%));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px; margin-top: -10px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--accent);
}

.muted { color: var(--muted); text-align: center; margin: 0; font-size: 15px; }
.muted.error { color: var(--accent); }
.keys { font-size: 13px; }
kbd {
  font: inherit; font-size: 12px;
  padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--hairline-strong);
  background: var(--field); color: var(--ink);
}
@media (hover: none) { .keys { display: none; } }

/* ---------------- Setup ---------------- */

.setup {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) calc(20px + var(--safe-r)) calc(24px + var(--safe-b)) calc(20px + var(--safe-l));
}

.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 4px; }
.wheel { position: relative; width: 210px; height: 210px; }
.wheel svg { display: block; width: 100%; height: 100%; }
.wheel h1 {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}
.wheel h1 .accent { color: var(--accent); }
.strap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
}
.strap::before, .strap::after { content: ""; width: 34px; height: 1px; background: var(--accent); }

.control { padding: 16px 16px 14px; }
.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  margin-bottom: 12px;
}
.control-head output {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
}
.control-head output small { font-size: 17px; margin-left: 4px; }

.grouping-options { margin-top: 8px; }
.grouping-info { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

.set-row { display: flex; gap: 10px; }
.btn-editor { flex: none; }

.pool-note { margin: 10px 0 0; font-size: 14px; color: var(--accent); }

.stepper { display: flex; align-items: center; gap: 14px; }
.step {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-ctl);
  background: var(--card);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}
.step:active { background: var(--seg); }

.btn-start {
  min-height: 64px;
  margin-top: 4px;
  border-radius: 18px;
  font-size: 24px;
  letter-spacing: 0.02em;
}
.btn-start svg { width: 18px; height: 18px; }

.btn-ghost { align-self: center; }

/* Discreet link back to the main site */
.site-link { text-align: center; margin-top: 2px; }
.site-link a {
  display: inline-block;
  padding: 12px 10px; /* comfortable touch target */
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.site-link a:hover, .site-link a:focus-visible { color: var(--ink); text-decoration: underline; }

/* "Update available, tap to reload" */
.update-banner {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(43, 33, 28, 0.25);
}

/* ---------------- Practice ---------------- */

.practice {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--paper);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 20px 0;
}
.topbar-right { display: flex; gap: 10px; }

/* One dot per phrase in rotation; the current one is bigger and red. */
.pool-dots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pool-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(43, 33, 28, 0.22);
}
.pool-dots i.on {
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2px solid var(--ink);
}
.pool-dots.many { gap: 4px; max-width: 46vw; }
.pool-dots.many i { width: 6px; height: 6px; }
.pool-dots.many i.on { width: 11px; height: 11px; }

.stage {
  position: relative;
  min-height: 0;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.sheet {
  max-width: 100%;
  padding: 24px 14px 18px;
  border: 1px solid var(--hairline);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(43, 33, 28, 0.08);
}
.phrase { color: var(--ink); }
.phrase svg { display: block; width: 100%; height: 100%; }

.phrase-caption { text-align: center; max-width: 100%; }
.phrase-name {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}
.phrase-meta {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.countdown {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 20px 10px;
}
.countdown output {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
.countdown output small { font-size: 18px; margin-left: 4px; }

/* Progress bar: shrinks from full to empty = time left. */
.progress {
  height: 12px;
  margin: 0 20px calc(18px + var(--safe-b));
  border-radius: 6px;
  background: rgba(43, 33, 28, 0.12);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}

/* Last 3 seconds: the bar pulses once per second, and the screen edges glow
   faintly so the change can be anticipated. */
.practice::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.practice.warn .progress-bar { animation: bar-pulse 1s ease-out infinite; }
.practice.warn .countdown output { color: var(--accent); }
.practice.warn::after {
  box-shadow: inset 0 0 6vmin 0 rgba(184, 67, 43, 0.22);
  animation: edge-pulse 1s ease-out infinite;
}
.practice.paused .progress-bar,
.practice.paused::after { animation-play-state: paused; }

@keyframes bar-pulse {
  0%   { opacity: 1; }
  60%  { opacity: .5; }
  100% { opacity: 1; }
}
@keyframes edge-pulse {
  0%   { opacity: 1; }
  100% { opacity: .15; }
}

/* New phrase fade-in */
.phrase.enter { animation: phrase-in .22s ease-out; }
@keyframes phrase-in {
  from { opacity: 0; transform: translateY(1.5vmin); }
  to   { opacity: 1; transform: none; }
}

.pause-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(243, 236, 220, 0.86);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.pause-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: clamp(34px, 9vmin, 60px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pause-sub { color: var(--muted); margin-top: 6px; font-size: 16px; }

/* Short landscape phones: tighter */
@media (max-height: 520px) {
  .topbar { padding-top: 10px; }
  .stage { padding: 8px 20px; gap: 10px; }
  .sheet { padding: 12px 16px; }
  .phrase-name { font-size: 20px; }
  .phrase-meta { margin-top: 4px; }
  .countdown output { font-size: 26px; }
  .progress { margin-bottom: calc(10px + var(--safe-b)); }
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(48px + var(--safe-b));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
  animation: toast 1.6s ease forwards;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes toast {
  0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; }
}

/* ---------------- Editor ---------------- */

.editor {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) calc(20px + var(--safe-r)) calc(28px + var(--safe-b)) calc(20px + var(--safe-l));
}
.ed-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.ed-top h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.ed-top-spacer { width: 48px; flex: none; }

.ed-list, .ed-form { display: flex; flex-direction: column; gap: 14px; }
.ed-note { text-align: left; font-size: 14px; line-height: 1.45; }
.ed-meter-card { padding: 14px 16px 16px; }
.ed-meter-head { margin: 0 0 10px; }

.ed-grouping-row { display: flex; align-items: center; gap: 12px; }
.ed-grouping-row > span { flex: 0 0 64px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.ed-grouping-row > .segmented { flex: 1; }
.ed-grouping-row button { min-height: 44px; }

.ed-set-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ed-set-actions > button { flex: 1 1 auto; }
.btn-small { min-height: 48px; padding: 0 14px; font-size: 15px; }
.btn-small.accent { font-size: 16px; }

.ed-phrases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ed-item { display: flex; gap: 10px; }
.ed-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 12px 16px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--ink);
  text-align: left;
}
.ed-item-main:active, .ed-more:active { background: var(--seg); }
.ed-item-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ed-item-name { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item-meta { flex: none; color: var(--muted); font-size: 13px; }
/* the notation's box keeps room for counting marks under the staff: trim it */
.ed-mini { height: 68px; margin-bottom: -12px; color: var(--ink); display: flex; align-items: center; }
.ed-mini svg { width: 100%; height: 100%; }
.ed-more {
  flex: none;
  width: 56px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.ed-io { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* phrase form */
.ed-field { display: flex; flex-direction: column; gap: 6px; }
.ed-field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.ed-input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-ctl);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.ed-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ed-input.mono { font-family: ui-monospace, Consolas, monospace; font-size: 15px; width: 100%; }

.ed-preview {
  height: clamp(150px, 30vh, 300px);
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(43, 33, 28, 0.06);
}
.ed-preview svg { display: block; width: 100%; height: 100%; }
.ed-pos { color: var(--muted); font-size: 14px; margin-top: -4px; }

.ed-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.chip i { font-style: normal; font-size: 12px; color: var(--muted); margin-right: 1px; }
.chip.rest { border-style: dashed; color: var(--muted); }
.chip.sel { border: 2px solid var(--accent); box-shadow: 4px 0 0 -1px var(--accent); }
.chip-start { min-width: 30px; padding: 0; color: var(--muted); }
.chip-bar { width: 2px; height: 32px; background: var(--ink); opacity: .45; margin: 0 3px; border-radius: 1px; }

.ed-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.pal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 84px;
  padding: 6px 2px 8px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}
.pal:not(:disabled):active { background: var(--seg); border-color: var(--accent); }
.pal:disabled { opacity: .3; cursor: default; }
.pal-icon { width: 40px; height: 54px; color: var(--ink); }
.pal-icon svg { width: 100%; height: 100%; display: block; }
.pal-label { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.1; text-align: center; }
@media (max-width: 380px) { .pal-label { font-size: 11px; } }

.ed-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-status { margin: 0; font-size: 15px; font-weight: 600; color: var(--accent); min-height: 1.4em; }
.ed-status.ok { color: var(--ok); }

.ed-advanced summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; }
.ed-advanced[open] summary { margin-bottom: 8px; }

.ed-form-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; align-items: start; }
.ed-form-actions .btn-ghost { min-height: 64px; border-radius: 18px; }
.ed-form-actions .btn-start { margin-top: 0; }

/* ---------------- Dialogs ---------------- */

.dialog {
  width: min(92vw, 420px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(43, 33, 28, 0.25);
}
.dialog::backdrop { background: rgba(43, 33, 28, 0.35); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.dlg h3 { margin: 0; font-size: 19px; font-weight: 700; }
.dlg-msg { margin: 0; line-height: 1.45; white-space: pre-line; }
.dlg-input {
  height: 48px; padding: 0 14px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-ctl);
  background: var(--field); color: var(--ink); font: inherit; font-size: 17px;
}
.dlg-options { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.dlg-options button {
  min-height: 48px; padding: 8px 14px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-ctl);
  background: var(--field); color: var(--ink);
  font-size: 16px; font-weight: 600; text-align: left;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.dlg-options button:active { background: var(--seg); }
.dlg-options button small { color: var(--muted); font-weight: 500; }
.dlg-options button.danger, .dlg-actions .danger { color: var(--danger); }
.dlg-actions { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 10px; }
.dlg-actions button {
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-ctl);
  background: var(--field); color: var(--ink);
  font-size: 16px; font-weight: 600;
}
.dlg-actions .primary {
  border: 0; background: var(--accent); color: var(--paper); font-weight: 700;
  box-shadow: 0 3px 0 var(--accent-shadow);
}
.dlg-actions .danger { border-color: rgba(162, 67, 47, 0.4); background: #F8EAE3; }

@media (prefers-reduced-motion: reduce) {
  .phrase.enter, .practice.warn .progress-bar, .practice.warn::after { animation: none; }
  .practice.warn::after { opacity: 1; }
}
