:root {
  --bg: rgba(14,16,20,.5);
  --bg-elev: rgba(26,29,36,.9);
  --bg-elev-2: #252932;
  --line: #2c313b;
  --line-strong: #3a4150;
  --fg: #f5efe5;
  --fg-dim: #c5c8cc;
  --muted: #8d96a4;
  --muted-2: #6c7585;
  --accent: #ff6b1a;
  --accent-hi: #ff7f3a;
  --accent-dim: rgba(255, 107, 26, 0.16);
  --accent-ring: rgba(255, 107, 26, 0.32);
  --danger: #ef4444;
  --ok: var(--accent);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.55);

  --col: min(100% - 1.5rem, 480px);
  --gutter: 0.75rem;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "liga", "ss01";
  touch-action: manipulation;
}

/* ---------- Background: duotone Arnold ---------- */

#bg-photo, #bg-tint, #bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#bg-photo {
  z-index: 0;
  /* Multiply blends grayscale image onto amber base => duotone */
  background-color: var(--accent);
  background-image: url("./assets/arnold.jpg");
  background-position: center top;
  background-size: cover;
  background-repeat: no-repeat;
  background-blend-mode: multiply;
  /* Darken the overall plate so the duotone reads moody, not bright */
  filter: brightness(0.55) contrast(1.05);
}

#bg-tint {
  z-index: 1;
  background:
    /* horizontal vignette */
    radial-gradient(120% 80% at 50% 12%, transparent 0%, rgba(14,16,20,0.55) 70%, rgba(14,16,20,0.92) 100%),
    /* vertical fade so content lower on the page sits on near-black */
    linear-gradient(180deg, rgba(14,16,20,0) 0%, rgba(14,16,20,0.35) 35%, rgba(14,16,20,0.85) 80%, rgba(14,16,20,0.96) 100%);
}

#bg-grain {
  z-index: 2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.08 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

main {
  position: relative;
  z-index: 3;
  width: var(--col);
  margin-inline: auto;
  min-height: 100dvh;
  padding-top: max(var(--gutter), env(safe-area-inset-top));
  /* leave room for the fixed bottom bar */
  padding-bottom: calc(72px + max(0.5rem, env(safe-area-inset-bottom)));
}

body {
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* ---------- Typography ---------- */

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; }
.label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

::selection { background: var(--accent); color: #0e1014; }
a { color: var(--accent-hi); text-decoration-thickness: 1px; }

/* ---------- Form primitives ---------- */

button {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.32; cursor: default; }
button.primary {
  background: var(--accent);
  color: #1a0d04;
  border-color: var(--accent);
  box-shadow: 0 4px 16px -6px rgba(255, 107, 26, 0.6);
}
button.primary:active { background: var(--accent-hi); }
button.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--fg-dim);
}
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

input[type="text"], input[type="number"], select, textarea {
  font-family: var(--body);
  font-size: 1rem;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.875rem;
  min-height: 48px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
::placeholder { color: var(--muted-2); }

/* ---------- App header ---------- */

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.25rem;
  margin-bottom: 0.5rem;
}
.app-bar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.app-logo {
  width: 32px;
  height: 32px;
  display: block;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
}
.app-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  /* Without this, iOS standalone treats double/triple taps on the text
     as selection gestures and swallows the corresponding `click` events,
     which breaks the triple-tap easter egg. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.icon-btn {
  min-height: 40px;
  min-width: 40px;
  padding: 0 0.625rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--fg);
}
.icon-btn.primary {
  font-size: 0.85rem;
  padding-inline: 0.875rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 0.25s ease;
}
.progress-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

/* ---------- Section labels ---------- */

.section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 1.25rem 0.25rem 0.625rem;
}
.section .label { color: var(--muted); }
.section .count { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

/* ---------- Routine cards ---------- */

.routine-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.routine-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  min-height: auto;
  font-family: var(--body);
  font-weight: 400;
  letter-spacing: 0;
}
.routine-card:active { transform: scale(0.98); }
.rc-row1 {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}
.rc-badge {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.routine-card.active .rc-badge {
  background: var(--accent);
  color: #1a0d04;
  border-color: var(--accent);
}
.rc-title {
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--fg);
}
.rc-eyebrow {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.125rem;
}
.rc-chev { color: var(--muted); font-size: 1.1rem; flex-shrink: 0; }
.rc-row2 {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding-left: calc(38px + 0.625rem);
}
.routine-card.rest .rc-title { color: var(--muted); }
.routine-card.rest .rc-badge { background: transparent; color: var(--muted); border-style: dashed; }

/* ---------- Workout view: sticky bar ---------- */

.workout-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: max(var(--gutter), env(safe-area-inset-top)) 0 0.625rem;
  margin: calc(-1 * max(var(--gutter), env(safe-area-inset-top))) 0 0.75rem;
  background: linear-gradient(180deg, var(--bg) 30%, rgba(14,16,20,0.85) 90%, rgba(14,16,20,0) 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 0 0 1rem 1rem;
}
/* Icon-only back button — translucent, no chrome, melts into the
   sticky top toolbar. Big chevron, generous tap target. */
.back-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  margin-inline-start: -0.4rem; /* hugs the left edge */
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.12s ease, transform 0.06s ease;
}
.back-btn:hover { opacity: 0.85; }
.back-btn:active { transform: scale(0.9); opacity: 0.75; }
.back-btn svg { display: block; }
.workout-bar .title-block { min-width: 0; overflow: hidden; }
.workout-bar .title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workout-bar .sub {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.workout-progress {
  height: 4px;
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.workout-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 0.25s ease;
}

/* ---------- Exercise cards ---------- */

.exercise {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.875rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.exercise.complete { border-color: var(--accent); }
.ex-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.ex-head h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.ex-edit-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}
.ex-edit {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius-sm);
  min-height: 36px;
  min-width: 36px;
  padding: 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.ex-edit:active { background: var(--bg-elev-2); }
.ex-edit.danger-edit { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }
.ex-edit.danger-edit:active { background: rgba(239, 68, 68, 0.12); }

.ex-notes {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.625rem;
  font-style: italic;
}
.ex-stats {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 0.875rem;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0.3rem 0.55rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--fg);
}
.stat-chip .k {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  font-family: var(--body);
}
.stat-chip.weight {
  background: var(--accent-dim);
  border-color: var(--accent-ring);
  color: var(--accent-hi);
}
.stat-chip.weight .k { color: var(--accent); }

/* Set checkboxes — big tactile pills */
.sets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.5rem;
}
.set-btn {
  position: relative;
  min-height: 56px;
  min-width: 0;
  padding: 0.4rem 0.5rem 0.5rem;
  background: var(--bg-elev-2);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--display);
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.set-btn .lbl {
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.set-btn .n {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.set-btn.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d04;
}
.set-btn.done .lbl { color: rgba(26, 13, 4, 0.6); }
.set-btn.done::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.75rem;
  color: #1a0d04;
  opacity: 0.85;
  font-weight: 700;
}
.set-btn:active { transform: scale(0.95); }

.video-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  background: var(--bg-elev-2);
  color: var(--fg);
  text-decoration: none;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  min-height: 40px;
  cursor: pointer;
}
.video-link::before {
  content: "▶";
  color: var(--accent);
  font-size: 0.7rem;
}
button.video-link { font: inherit; font-weight: 600; font-size: 0.85rem; }

/* ---------- Collapsible media panel (<details>-style) ---------- */

/* Break out of .exercise's horizontal padding so the embed itself can
   use the full card width. Top + bottom borders only — left/right are
   the card edges. */
.media-panel {
  margin: 0.875rem -1rem -0.875rem;
  background: var(--bg-elev-2);
  border-top: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.media-toggle {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.875rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  letter-spacing: 0;
}
.media-toggle:hover { background: var(--bg-elev); }
.media-toggle:active { background: var(--bg-elev); transform: none; }
.media-toggle-title { flex: 1; text-align: left; }
.media-toggle-chev {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  transition: transform 0.2s cubic-bezier(.22, .8, .25, 1), color 0.15s ease;
}
.media-panel.open .media-toggle-chev {
  transform: rotate(90deg);
  color: var(--accent);
}
.media-content {
  padding: 0;
  border-top: 1px solid var(--line);
  animation: media-panel-in 0.22s cubic-bezier(.22, .8, .25, 1);
}
/* Inside the panel the wrap is full-bleed: no margin, no border (panel
   already has one), and the bottom of the iframe meets the card edge. */
.media-content .media-wrap {
  margin-top: 0;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
@keyframes media-panel-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.media-wrap {
  margin-top: 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}
.media-wrap.short {
  aspect-ratio: 9 / 16;
  max-height: 70dvh;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}
.media-wrap iframe, .media-wrap img {
  display: block; width: 100%; height: 100%; border: 0; object-fit: contain;
}

.rest-card {
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state {
  background: rgba(26, 29, 36, 0.7);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2rem 1.25rem 1.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px dashed var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 1.9rem;
  line-height: 1;
  font-weight: 300;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.empty-state p {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.95rem;
  max-width: 28ch;
  line-height: 1.4;
}
.empty-state button.primary {
  margin-top: 0.5rem;
  min-width: 70%;
}

/* ---------- Edit views ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}
.field label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { margin-left: auto; }


.bottom-action { margin-top: 1rem; }
.bottom-action button { width: 100%; }

.row { display: flex; gap: 0.625rem; align-items: center; flex-wrap: wrap; }
.weight-row { display: flex; gap: 0.5rem; align-items: stretch; }
.weight-row input[type="number"] { flex: 1; min-width: 0; }
.weight-row select { width: 5.5rem; flex: 0 0 auto; }

/* ---------- Drawer ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  animation: drawer-fade 0.18s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  margin-inline: auto;
  width: min(100% - 0.5rem, 540px);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  z-index: 60;
  padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom)) 1rem;
  max-height: 90dvh;
  overflow-y: auto;
  animation: drawer-slide 0.22s cubic-bezier(.22, .8, .25, 1);
  box-shadow: 0 -18px 50px -10px rgba(0, 0, 0, 0.6);
}
.drawer-handle {
  width: 40px; height: 4px;
  background: var(--line-strong);
  border-radius: 999px;
  margin: 0.375rem auto 0.625rem;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  padding-block: 0.25rem 0.5rem;
}
.drawer-header h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.015em;
}
.drawer-body { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.drawer-body .bottom-action { margin-top: 0.75rem; }

@keyframes drawer-slide {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes drawer-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.drawer.no-anim, .drawer-backdrop.no-anim { animation: none; }

body[data-drawer-open] { overflow: hidden; }

/* ---------- Log view ---------- */

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.log-item {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.875rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.log-desc {
  color: var(--fg);
  font-size: 0.92rem;
  line-height: 1.3;
}
.log-time {
  color: var(--muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Motivation (easter-egg screen) ---------- */

.motivation {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
  cursor: pointer;
  animation: motivation-bg 0.6s ease-out both;
}
@keyframes motivation-bg {
  from { background: rgba(14, 16, 20, 0); -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px); }
  to   { background: rgba(14, 16, 20, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
}

.motivation .quote {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.45rem, 5.5vw, 2.05rem);
  line-height: 1.28;
  letter-spacing: -0.015em;
  text-align: center;
  text-wrap: balance;
  color: var(--fg);
  max-width: 22ch;
  margin: 0 auto;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}
.motivation .quote .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(10px);
  animation: word-in 0.55s cubic-bezier(.22, .8, .25, 1) both;
  filter: blur(2px);
}
@keyframes word-in {
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.motivation-hint {
  position: absolute;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--body);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  animation: hint-in 0.5s ease-out 1.6s forwards;
}
@keyframes hint-in {
  to { opacity: 0.7; }
}

/* ---------- Edit list (rename/delete routines) ---------- */

.edit-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.25rem 0 0.875rem 0.125rem;
  line-height: 1.4;
}
.edit-hint em {
  color: var(--fg-dim);
  font-style: normal;
  font-weight: 600;
}
.edit-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem 0.4rem 0.625rem;
}
.edit-row .rc-badge { flex-shrink: 0; width: 34px; height: 34px; font-size: 0.9rem; }

/* ---------- Drag-to-reorder ---------- */

.drag-handle {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  padding: 0;
  width: 28px;
  min-height: 40px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  /* Prevent the browser from interpreting touch on the handle as scroll. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; color: var(--fg); }

.edit-row {
  transition: transform 0.18s cubic-bezier(.2, .7, .3, 1), box-shadow 0.18s ease;
  will-change: transform;
}
.edit-list.reordering .edit-row .edit-row-name,
.edit-list.reordering .edit-row .ex-edit { pointer-events: none; }
.edit-row.dragging {
  z-index: 10;
  position: relative;
  transition: none;
  box-shadow: 0 14px 32px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--accent-ring);
  border-color: var(--accent);
}

/* ---------- Floating action button (round +) ---------- */

.fab-row {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}
.fab {
  width: 60px;
  height: 60px;
  min-height: 60px;
  border-radius: 50%;
  padding: 0;
  background: var(--accent);
  color: #1a0d04;
  border: 1px solid var(--accent);
  box-shadow: 0 8px 24px -6px rgba(255, 107, 26, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.fab:active { transform: scale(0.92); background: var(--accent-hi); }
.fab svg { display: block; }
.edit-row-name {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  padding: 0.45rem 0.45rem;
  min-height: 40px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.edit-row-name:focus {
  outline: 0;
  background: var(--bg-elev-2);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- Menu sheet (bottom kebab drawer) ---------- */

.drawer-menu .drawer-header { border-bottom: 1px solid var(--line); }
.menu-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  text-align: left;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  min-height: 64px;
  cursor: pointer;
  color: var(--fg);
  justify-content: flex-start;
}
.menu-item:active { background: var(--bg-elev); transform: scale(0.99); }
.menu-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.menu-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  letter-spacing: normal;
  text-transform: none;
}
.menu-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.menu-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- Modal (confirm dialog) ---------- */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: modal-fade 0.15s ease;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal-dialog {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  width: min(100%, 380px);
  box-shadow: 0 20px 60px -16px rgba(0, 0, 0, 0.75);
  animation: modal-pop 0.2s cubic-bezier(.22, .8, .25, 1);
}
.modal-dialog h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}
.modal-dialog p {
  margin: 0 0 1.1rem;
  color: var(--fg-dim);
  font-size: 0.92rem;
  line-height: 1.42;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
}
.modal-actions button { flex: 1; }

button.danger-primary {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 16px -6px rgba(239, 68, 68, 0.55);
}
button.danger-primary:active { background: #d33b3b; }

@keyframes modal-pop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom) + 0.5rem);
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100% - 1.5rem);
  background: rgba(37, 41, 50, 0.96);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-family: var(--body);
  font-size: 0.88rem;
  line-height: 1.3;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.7);
  animation: toast-in 0.18s cubic-bezier(.2,.8,.25,1), toast-out 0.3s ease-out 2.4s forwards;
  pointer-events: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translate(-50%, 8px); }
}

/* ---------- Bottom action bar (fixed) ---------- */

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
  background: rgba(14, 16, 20, 0.78);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
}
.bottom-bar-inner {
  width: var(--col);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.bottom-bar .group { display: flex; gap: 0.375rem; align-items: center; }
.bottom-bar .icon-btn.primary {
  background: var(--accent);
  color: #1a0d04;
  border-color: var(--accent);
  padding-inline: 1.1rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
/* Toolbar buttons (undo / redo) — borderless, icon-first. */
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.5rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.06s ease;
}
.tool-btn:hover { color: var(--fg); }
.tool-btn:active {
  background: var(--bg-elev-2);
  transform: scale(0.92);
}
.tool-btn:disabled {
  color: var(--muted-2);
  cursor: default;
  opacity: 0.55;
}
.tool-btn svg { display: block; }
