:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --border-color: #334155;
  --work-color: #e11d48;
  --rest-color: #0284c7;
  --warmup-color: #ea580c;
  --cooldown-color: #7c3aed;
  --current-theme-bg: #0f172a;
  --current-theme-accent: #38bdf8;
  --font-sans: 'Geist', -apple-system, "Helvetica Neue", Arial, sans-serif;
  --canvas: #fafaf8;
  --dot-color: rgba(0, 0, 0, 0.08);
  --dot-size: 2px;
  --dot-space: 24px;
  --ink: #171717;
  --paper: #ffffff;
  --hard-shadow: 4px 4px 0 #171717;
  --font-mono: var(--font-sans); /* one font family everywhere */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* Form controls don't inherit the page font by default */
button, input, select, textarea, dialog {
  font-family: var(--font-sans);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* FigJam / devonsa.work Dot Grid Background */
.canvas-dot-grid {
  position: absolute;
  inset: 0;
  background-color: var(--canvas);
  background-image: radial-gradient(
    var(--dot-color) calc(var(--dot-size) - 0.5px),
    transparent calc(var(--dot-size) + 0.5px)
  );
  background-size: var(--dot-space) var(--dot-space);
  background-position: center top;
  z-index: 0;
  pointer-events: none;
}

/* Viewport Fill Layer: Drains towards the bottom in snappy mechanical steps */
.viewport-fill-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 56px); /* Keeps the topper UI completely clean and outside the dropper */
  background: var(--active-interval-color, #e11d48);
  transition: height 0.12s cubic-bezier(0.2, 0, 0, 1), background-color 0.4s ease;
  z-index: 1;
  pointer-events: none;
}

/* Waterline Laser Edge (Where the liquid meets the dot grid) */
.waterline-edge {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 32px;
  z-index: 5;
  pointer-events: none;
}

.waterline-beam {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.75) 20%,
    rgba(255, 255, 255, 1) 50%,
    rgba(255, 255, 255, 0.75) 80%,
    rgba(255, 255, 255, 0.15) 100%
  );
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 0 20px rgba(255, 255, 255, 0.4);
}

/* Header */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 84px;
  padding: 14px 32px;
  background: var(--canvas);
  border-bottom: 2px solid var(--ink);
  z-index: 50;
  gap: 16px;
  position: relative;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.045em;
  color: var(--ink);
}

.brand-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.active-workout-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-caret { opacity: 0.6; font-size: 0.8rem; }

.active-workout-pill:hover,
.btn-icon-nav:hover {
  background: #fff3d1;
}

.btn-icon-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-icon-nav.btn-square {
  width: 46px;
  height: 46px;
  padding: 0;
}

/* Overflow menu */
.menu-wrap { position: relative; }

.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--hard-shadow);
  overflow: hidden;
  z-index: 100;
}

.nav-menu[hidden] { display: none; }

.menu-item {
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(23, 23, 23, 0.12);
  color: var(--ink);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: #fff3d1; }

/* Workout Stage */
.workout-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px 28px;
  position: relative;
  overflow: hidden;
  z-index: 10;
}

/* Status Stats Row */
.stats-header {
  width: 100%;
  max-width: 800px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--paper);
  padding: 12px 16px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  box-shadow: var(--hard-shadow);
  position: relative;
  z-index: 30;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #525252;
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
  font-variant-numeric: tabular-nums slashed-zero;
  color: var(--ink);
}

/* Central Countdown Display */
.countdown-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  max-width: 900px;
  flex: 1;
  margin: 12px 0;
  z-index: 10;
}

.interval-title {
  font-family: var(--font-sans);
  font-size: clamp(2.4rem, 6.5vw, 4.8rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.05;
  margin-bottom: 8px;
  color: var(--ink);
  max-width: 95%;
  word-wrap: break-word;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.timer-digits {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(6.5rem, 18vw, 14rem);
  font-weight: 800;
  font-family: var(--font-mono);
  font-feature-settings: "zero" 1, "tnum" 1;
  font-variant-numeric: tabular-nums slashed-zero;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.05em;
  margin: 8px 0;
  z-index: 10;
}

/* Up Next Card */
.up-next-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 8px 18px;
  border-radius: 6px;
  margin-bottom: 24px;
  color: var(--ink);
  font-size: 0.9rem;
  box-shadow: var(--hard-shadow);
  z-index: 20;
}

.up-next-label {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
  padding: 3px 8px;
  border-radius: 6px;
}

.up-next-name {
  font-weight: 700;
  color: var(--ink);
}

.up-next-dur {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-weight: 600;
}

/* Control Bar */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  max-width: 500px;
  margin-top: 4px;
  z-index: 10;
}

.btn-ctrl {
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--hard-shadow);
}

.btn-ctrl:hover {
  background: #fff3d1;
  transform: scale(1.04);
}

.btn-ctrl:active {
  transform: scale(0.95);
}

.btn-ctrl.btn-secondary {
  width: 52px;
  height: 52px;
  font-size: 1.2rem;
}

.btn-ctrl.btn-main {
  width: 78px;
  height: 78px;
  font-size: 2rem;
  background: #faac26;
  color: var(--ink);
  border: 2px solid var(--ink);
}

.btn-ctrl.btn-main:hover {
  background: #ffbe4d;
  transform: scale(1.04);
}

/* Total Workout Progress Bar at the very bottom */
.workout-progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 12px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
}

.workout-progress-bar {
  height: 100%;
  width: 0%;
  background: #faac26;
  border-right: 2px solid var(--ink);
  transition: width 0.1s linear;
}

/* Modals with Native Dialog */
dialog.custom-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #f5f5f5;
  color: var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  width: 90vw;
  max-width: 620px;
  max-height: 85vh;
  overflow: hidden;
  padding: 0;
  z-index: 1000;
}

/* Hide closed dialogs strictly */
dialog.custom-modal:not([open]) {
  display: none !important;
}

/* Only display flex when explicitly open */
dialog.custom-modal[open] {
  display: flex !important;
  flex-direction: column;
}

dialog.custom-modal::backdrop {
  background: rgba(23, 23, 23, 0.55);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.btn-close-modal {
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-close-modal:hover {
  background: #fff3d1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Timer cards (Home) */
.workout-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px 14px;
  min-height: 132px;
  padding: 16px 16px 48px 18px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}

.workout-card:hover { background: #fffaec; }

.workout-card.active {
  border-color: #faac26;
  background: #fff5dc;
}

.workout-card-left { min-width: 0; }

.workout-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.25;
}

.workout-card-desc {
  font-size: 0.9rem;
  color: #525252;
  line-height: 1.4;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.workout-card-badges {
  position: absolute;
  left: 18px;
  bottom: 14px;
  display: flex;
  gap: 6px;
}

.btn-play {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faac26;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  padding-left: 2px;
}
.workout-card:hover .btn-play { background: #ffbe4d; }

/* Edit tools appear on hover, always visible on touch */
.wc-tools {
  position: absolute;
  right: 14px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.workout-card:hover .wc-tools,
.workout-card:focus-within .wc-tools { opacity: 1; }
@media (hover: none) { .wc-tools { opacity: 1; } }

.badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
}

.badge-circ { background: #bfdbfe; }
.badge-tab, .badge-tabata { background: #fecdd3; }
.badge-rnd { background: #fde6b0; }
.badge-hiit { background: #bbf7d0; }
.badge-cust { background: #ddd6fe; }

.badge-duration {
  background: var(--paper);
  font-family: var(--font-mono);
}

/* Form inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #525252;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 4px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #faac26;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  background: #faac26;
  color: var(--ink);
  border: 2px solid var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: #ffbe4d;
}

.btn-primary:active {
  background: #e09a14;
}

.tab-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 10px;
}

.tab-btn {
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--ink);
  border-radius: 6px;
  padding: 28px 16px;
  text-align: center;
  background: var(--paper);
  cursor: pointer;
  margin-bottom: 16px;
}

.drop-zone:hover, .drop-zone.dragover {
  background: #fff3d1;
  border-color: #faac26;
}

.drop-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 4px;
}

.drop-subtext {
  font-size: 0.75rem;
  color: #525252;
}

/* Hotkey Hints Tooltip */
.hotkeys-bar {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 10px;
}

.hotkey-item kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: #fff;
}


/* Account modal */
.account-note {
  font-size: 0.9rem;
  line-height: 1.45;
  color: #525252;
  margin-bottom: 16px;
}

#account-status:empty { display: none; }
#account-status { margin: 14px 0 0; color: var(--ink); font-weight: 600; }

/* Library card actions */
.card-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-link {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 3px 9px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.btn-link:hover { background: #fff3d1; }
.btn-link.danger { background: #e11d48; border-color: var(--ink); color: #fff; }

.rename-input {
  padding: 4px 8px;
  font-size: 1.05rem;
  font-weight: 800;
}

/* ==========================================================================
   Views: Home (timer list) vs Timer stage
   ========================================================================== */
.view-home .workout-stage,
.view-home .viewport-fill-layer,
.view-home .crumb { display: none; }

.view-timer .home-view { display: none; }

.pill-back { font-weight: 800; }

.home-view {
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 10;
  padding: 28px 24px 64px;
}

.home-inner {
  max-width: 860px;
  margin: 0 auto;
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.home-title {
  font-size: clamp(2.6rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--ink);
}

.home-sub {
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #525252;
}

.home-actions { display: flex; gap: 8px; }

.btn-accent {
  background: #faac26;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-accent:hover { background: #ffbe4d; }

/* Now playing strip */
.now-playing {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 16px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--hard-shadow);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.now-playing[hidden] { display: none; }
.np-dot { width: 10px; height: 10px; border-radius: 50%; background: #faac26; flex-shrink: 0; }
.np-name { font-weight: 800; flex: 1; }
.np-time { font-variant-numeric: tabular-nums; color: #525252; }
.np-resume { font-weight: 700; }

/* Folders */
.folder {
  position: relative;
  margin-bottom: 56px;
}

.folder.drop-target .folder-body,
.folder.drop-target .folder-head {
  outline: 2px dashed #faac26;
  outline-offset: 6px;
}

.folder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  position: relative;
}

.folder-toggle {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.folder.collapsed .folder-body { display: none; }
.folder.collapsed .folder-head { border-bottom-color: rgba(23, 23, 23, 0.25); margin-bottom: 0; }

.folder-count {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #525252;
  font-variant-numeric: tabular-nums;
}

.folder-head .card-tools { opacity: 0; transition: opacity 0.12s ease; }
.folder-head:hover .card-tools,
.folder-head:focus-within .card-tools { opacity: 1; }
@media (hover: none) { .folder-head .card-tools { opacity: 1; } }

.folder-empty {
  padding: 14px 18px;
  border: 2px dashed rgba(23, 23, 23, 0.35);
  border-radius: 6px;
  color: #525252;
  font-size: 0.85rem;
  grid-column: 1 / -1;
}

.folder-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.workout-card[draggable="true"] { cursor: grab; }
.workout-card.dragging { opacity: 0.4; }
.workout-card:focus-visible { outline: 3px solid #faac26; outline-offset: 2px; }

.folder-name-input {
  font-size: 1.2rem;
  font-weight: 800;
  padding: 3px 8px;
  width: 220px;
  text-transform: none;
}

.new-folder-row { margin-bottom: 18px; display: flex; gap: 8px; }

/* Breadcrumb in the header (timer view) */
.crumb {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 6px;
  padding-left: 18px;
  border-left: 2px solid var(--ink);
  min-width: 0;
}

.crumb-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
}

/* Folder grip (drag to reorder) */
.folder-grip {
  position: absolute;
  left: -30px;
  top: calc((100% - 10px) / 2);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  padding: 4px 6px;
  color: #525252;
  cursor: grab;
  border-radius: 4px;
}
.folder-grip:hover { color: var(--ink); background: #fff3d1; }
.folder.reordering { opacity: 0.5; }

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  margin-bottom: 30px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #525252;
  margin-right: 2px;
}


.chip {
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { background: #fff3d1; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip-clear { border-style: dashed; }

/* ==========================================================================
   Tooltips
   ========================================================================== */
[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, -4px);
  background: var(--ink);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 300;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
[data-tip][aria-expanded="true"]::after { display: none; }

/* Keep tooltips on the right edge inside the window */
.nav-right [data-tip]::after { left: auto; right: 0; transform: translate(0, -4px); }
.nav-right [data-tip]:hover::after,
.nav-right [data-tip]:focus-visible::after { transform: translate(0, 0); }

@media (hover: none) { [data-tip]::after { display: none; } }

.icon-wrap { display: flex; align-items: center; justify-content: center; }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Timer editor dialog (import preview + custom timer)
   ========================================================================== */
dialog.editor-modal {
  max-width: 760px;
  max-height: 92vh;
  background: var(--canvas);
}

.editor-kicker { margin: 0 0 4px; }

.editor-title {
  font-size: 1.6rem;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.editor-body { padding: 24px; }

.editor-queue {
  display: inline-block;
  margin-bottom: 18px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fff3d1;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.editor-queue[hidden] { display: none; }

.editor-section { margin-bottom: 18px; }
.editor-section .form-label { margin-top: 12px; }
.editor-section .form-label:first-child { margin-top: 0; }

.editor-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  padding: 12px 14px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.editor-grid .form-label { margin-bottom: 6px; }

.editor-rows-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.editor-h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.editor-rows { display: flex; flex-direction: column; gap: 10px; }

.ed-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 84px auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.ed-index {
  font-size: 0.8rem;
  font-weight: 800;
  color: #525252;
  font-variant-numeric: tabular-nums;
}

.ed-row .form-input { padding: 8px 10px; font-size: 0.95rem; }
.ed-row-name { font-weight: 700; }
.ed-row-time { text-align: center; font-variant-numeric: tabular-nums; }

.ed-kind, .ed-row-tools { display: flex; gap: 6px; }
.ed-kind .chip { padding: 5px 10px; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: #fff3d1; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.editor-errors {
  min-height: 1.2em;
  margin-top: 14px;
  color: #e11d48;
  font-size: 0.9rem;
  font-weight: 700;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
}

.editor-total .home-sub { margin: 0 0 2px; }
.editor-total-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.editor-actions [hidden] { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
.app-container { height: 100vh; height: 100dvh; }

@media (max-width: 900px) {
  .top-nav { min-height: 72px; padding: 10px 20px; }
  .brand { font-size: 1.45rem; }
  .brand-logo { width: 42px; height: 42px; }
}

@media (max-width: 720px) {
  /* Header */
  .top-nav { min-height: 64px; padding: 8px 16px; gap: 10px; }
  .brand { font-size: 1.2rem; gap: 8px; }
  .brand-logo { width: 38px; height: 38px; }
  .btn-icon-nav.btn-square { width: 42px; height: 42px; }
  .nav-right { gap: 8px; }
  .crumb { margin-left: 0; padding-left: 10px; gap: 8px; }
  .crumb-name { max-width: 30vw; font-size: 1rem; }
  .active-workout-pill { padding: 8px 12px; font-size: 0.9rem; }

  /* Home */
  .home-view { padding: 22px 16px 56px; }
  .home-head { flex-direction: column; align-items: stretch; gap: 16px; }
  .home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .home-actions .btn-accent { grid-column: 1 / -1; order: -1; padding: 12px; font-size: 1rem; }
  .home-actions .btn-icon-nav { justify-content: center; }
  .filter-bar { gap: 12px 14px; margin-bottom: 24px; }
  .folder { margin-bottom: 40px; }
  .folder-body { grid-template-columns: 1fr; }
  .folder-grip { display: none; }
  .folder-toggle { font-size: 1.25rem; }
  .workout-card { min-height: 120px; }

  /* Timer screen: no keyboard hints on a phone */
  .hotkeys-bar { display: none; }
  .workout-stage { padding: 14px 16px 24px; }
  .stats-header { padding: 10px 12px; gap: 8px; }
  .stat-value { font-size: 0.95rem; }
  .stat-label { font-size: 0.6rem; }
  .control-bar { gap: 12px; }
  .up-next-card { max-width: 100%; flex-wrap: wrap; justify-content: center; text-align: center; }

  /* Dialogs */
  dialog.custom-modal { width: 94vw; max-height: 92dvh; }
  .modal-body { padding: 16px; }
  .editor-body { padding: 16px; }
  .editor-footer { padding: 12px 16px; }
  .editor-actions { width: 100%; }
  .editor-actions .btn-icon-nav { flex: 1; justify-content: center; }
  .ed-row { grid-template-columns: 24px minmax(0, 1fr) 76px; row-gap: 8px; }
  .ed-kind { grid-column: 2 / 3; }
  .ed-row-tools { grid-column: 3 / 4; justify-content: flex-end; }
}

@media (hover: none) {
  .hotkeys-bar { display: none; }
  .folder-grip { display: none; }
}

@media (max-width: 420px) {
}

/* Right-align the Import tooltip so it stays on screen */
.home-actions [data-tip]::after { left: auto; right: 0; transform: translate(0, -4px); }
.home-actions [data-tip]:hover::after,
.home-actions [data-tip]:focus-visible::after { transform: translate(0, 0); }

/* Toast action (Undo) */
.toast { display: flex; align-items: center; gap: 14px; }
.toast.show { pointer-events: auto; }
.toast-action {
  flex-shrink: 0;
  padding: 4px 12px;
  background: #faac26;
  color: var(--ink);
  border: 2px solid #fff;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}
.toast-action:hover { background: #ffbe4d; }
.toast-action[hidden] { display: none; }

/* Editor notice */
.editor-notice {
  margin-bottom: 18px;
  padding: 10px 14px;
  background: #fff3d1;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}
.editor-notice[hidden] { display: none; }

@media (max-width: 720px) {
  /* Cards: badges and tools get their own rows so nothing collides */
  .workout-card { padding-bottom: 16px; min-height: 0; }
  .workout-card-badges { position: static; grid-column: 1 / -1; }
  .wc-tools { position: static; grid-column: 1 / -1; justify-content: flex-start; opacity: 1; }
}

/* ==========================================================================
   Per-card menu, reordering
   ========================================================================== */
.card-menu {
  position: fixed;
  right: auto;
  min-width: 210px;
  z-index: 1500;
}
.card-menu[hidden] { display: none; }

.menu-item:disabled { opacity: 0.35; cursor: default; }
.menu-item:disabled:hover { background: transparent; }
.menu-item.danger { color: #e11d48; border-top: 2px solid rgba(23, 23, 23, 0.12); }
.menu-item:focus-visible { outline: none; background: #fff3d1; }

.card-menu-btn { font-size: 1.1rem; line-height: 1; padding-bottom: 4px; }
.workout-card.menu-open .wc-tools { opacity: 1; }
.workout-card.menu-open { border-color: var(--ink); background: #fffaec; }

@media (max-width: 720px) {
  .wc-tools { justify-content: flex-end; }
}

/* ==========================================================================
   ZINE THEME
   Neo-brutalist "zine" skin. Kept as one block at the end of the file so it
   overrides the base rules above; the base rules own layout and behaviour.
   ========================================================================== */

:root {
  /* palette */
  --canvas: #F5EFE6;
  --card: #FAF7F2;
  --paper: #FAF7F2;
  --ink: #121212;
  --yellow: #FFC700;
  --yellow-soft: #FFE9A6; /* desaturated yellow: section headers, hover highlights */
  --orange: #FF7A00;
  --purple: #A855F7;
  --dot: #D4CEC5;
  --muted: #5b554d;

  /* borders */
  --b-sm: 2.5px solid var(--ink);
  --b-md: 3.5px solid var(--ink);
  --b-lg: 4.5px solid var(--ink);

  /* hard shadows (no blur) */
  --sh-sm: 3px 3px 0 var(--ink);
  --sh-md: 5px 5px 0 var(--ink);
  --sh-lg: 8px 8px 0 var(--ink);
  --hard-shadow: var(--sh-md);

  /* radii */
  --r-pill: 9999px;
  --r-card: 20px;
  --r-btn: 14px;
  --r-cloud: 30px 40px 25px 35px;

  /* patterns */
  --zebra: repeating-linear-gradient(45deg, var(--ink) 0 6px, #fff 6px 12px);

  /* type: system only. ui-rounded = SF Pro Rounded on Apple */
  --font-sans: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: var(--font-display);

  --zine-fill: var(--orange);
}

input, textarea { user-select: text; }
html, body { background: var(--canvas); color: var(--ink); }

/* ---------- Background: dot grid + faint blueprint lines ---------- */
.canvas-dot-grid {
  background-color: var(--canvas);
  background-image:
    radial-gradient(circle, var(--dot) 1.6px, transparent 1.8px),
    linear-gradient(rgba(70, 110, 200, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 110, 200, 0.07) 1px, transparent 1px);
  background-size: 22px 22px, 110px 110px, 110px 110px;
  background-position: 0 0;
}

/* ---------- Stickers ---------- */
.stickers { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.sticker { position: absolute; filter: drop-shadow(3px 3px 0 var(--ink)); }
.s-burst-orange { width: 74px; top: 74px; left: -18px; transform: rotate(-12deg); }
.s-burst-yellow { width: 56px; bottom: 120px; right: 4%; transform: rotate(18deg); }
.s-smiley { width: 64px; top: 92px; right: 3%; transform: rotate(12deg); }
.s-smiley-purple { width: 70px; bottom: -14px; right: -12px; transform: rotate(-8deg); }
.s-star { width: 34px; bottom: 34%; left: 4%; transform: rotate(-20deg); }
/* On home the list scrolls over everything; keep stickers to the margins */
.view-home .s-smiley { top: auto; bottom: 18%; right: 1.5%; }
.view-home .s-burst-yellow { bottom: auto; top: 26%; right: 2%; }

/* ---------- Draining fill (time left in the interval) ---------- */
.viewport-fill-layer {
  max-height: calc(100vh - 70px);
  background-color: var(--zine-fill);
  background-image: radial-gradient(circle, rgba(18, 18, 18, 0.12) 1.6px, transparent 1.9px);
  background-size: 14px 14px;
  transition: height 0.12s cubic-bezier(0.2, 0, 0, 1), background-color 0.35s ease;
}
.waterline-edge { transform: none; padding: 0; }
.waterline-beam {
  top: -2px;
  height: 4.5px;
  transform: none;
  background: var(--ink);
  box-shadow: none;
}

/* ---------- Header ---------- */
.top-nav {
  padding: 12px 22px;
  background: var(--card);
  border-bottom: var(--b-lg);
}
.top-nav::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -12px;
  height: 8px;
  background: var(--zebra);
  border-bottom: var(--b-sm);
  pointer-events: none;
  z-index: -1; /* keep the tape under header tooltips */
}
.nav-left, .nav-right { gap: 12px; }

/* Brand as a cloud bubble with eyes */
.brand {
  position: relative;
  gap: 8px;
  padding: 6px 18px 6px 12px;
  background: var(--card);
  border: var(--b-md);
  border-radius: var(--r-cloud);
  box-shadow: var(--sh-sm);
  transform: rotate(-2deg);
}
.brand-eyes { width: 30px; height: 18px; flex-shrink: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.brand-star { position: absolute; width: 20px; height: 20px; top: -12px; right: -10px; transform: rotate(14deg); }

/* Breadcrumb: "← Timers" pill + current timer name */
.crumb { border-left: none; padding-left: 4px; }
.active-workout-pill {
  gap: 8px;
  padding: 8px 16px;
  background: var(--yellow);
  border: var(--b-md);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  transform: rotate(1deg);
  transition: transform 0.12s, box-shadow 0.12s;
}
.crumb-name { font-family: var(--font-display); font-weight: 900; }

/* ---------- Shared tactile press behaviour ---------- */
.active-workout-pill:hover,
.btn-icon-nav:hover,
.btn-ctrl:hover,
.btn-primary:hover,
.btn-play:hover,
.chip:hover,
.icon-btn:hover:not(:disabled),
.now-playing:hover,
.btn-close-modal:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--sh-md);
}
.active-workout-pill:active,
.btn-icon-nav:active,
.btn-ctrl:active,
.btn-primary:active,
.btn-play:active,
.chip:active,
.icon-btn:active:not(:disabled),
.now-playing:active,
.btn-close-modal:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-icon-nav {
  background: var(--card);
  border: var(--b-sm);
  border-radius: var(--r-btn);
  box-shadow: var(--sh-sm);
  padding: 7px 14px;
  font-weight: 800;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-icon-nav:hover { background: var(--card); }
.btn-icon-nav.btn-square { width: 42px; height: 42px; }

/* Orange stamp buttons */
.btn-accent,
.btn-accent:hover {
  background: var(--orange);
  color: var(--ink);
  border: var(--b-md);
  font-family: var(--font-display);
  font-weight: 900;
}

/* Tooltips */
[data-tip]::after {
  font-family: var(--font-display);
  font-weight: 800;
  border-radius: 10px;
}

/* Overflow menu */
.nav-menu {
  top: calc(100% + 14px);
  min-width: 210px;
  background: var(--card);
  border: var(--b-md);
  border-radius: 6px 16px 16px 16px;
  box-shadow: var(--sh-lg);
}
.menu-item {
  border-bottom: var(--b-sm);
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
}
.menu-item:hover { background: var(--yellow); }

/* =========================================================
   Home: timers in folders
   ========================================================= */
.home-view { padding-top: 40px; }

.home-head { align-items: flex-end; }

/* Bubble-letter title: yellow, ink outline, hard shadow, slanted */
.home-title.bubble-title {
  display: block;
  width: clamp(150px, 17vw, 196px);
  margin: 6px 0 4px;
  line-height: 0;
  font-size: 0;
  transform: rotate(-3deg);
  transform-origin: left center;
}
.bubble-title svg { width: 100%; height: auto; overflow: visible; }

.home-sub {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.1em;
}
.home-actions { gap: 12px; align-items: center; }

/* Filter bar */
.filter-bar { gap: 12px; }
.chip-label {
  font-family: var(--font-display);
  font-weight: 900;
  color: var(--ink);
}


.chip {
  padding: 6px 14px;
  border: var(--b-sm);
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-weight: 800;
  transition: transform 0.12s, box-shadow 0.12s;
}
.chip:hover { background: var(--card); }
.chip[aria-pressed="true"],
.chip[aria-pressed="true"]:hover { background: var(--yellow); color: var(--ink); }
.chip-clear { border-style: dashed; box-shadow: none; }

/* Now playing strip */
.now-playing {
  padding: 12px 18px;
  background: var(--yellow);
  border: var(--b-md);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-md);
  font-family: var(--font-display);
  transition: transform 0.12s, box-shadow 0.12s;
}
.np-dot {
  width: 14px; height: 14px;
  background: var(--orange);
  border: 2.5px solid var(--ink);
  animation: np-pulse 1s steps(2) infinite;
}
.np-name { font-weight: 900; }
.np-time { color: var(--ink); font-weight: 800; }
.np-resume { font-weight: 900; }
@keyframes np-pulse { 50% { background: var(--card); } }

/* Folder headers: handwritten stamp labels */
.folder { margin-bottom: 60px; }
.folder-head {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 18px;
}
.folder-toggle {
  position: relative;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 12px;
  background: var(--card);
  border: var(--b-md);
  border-radius: 12px 22px 12px 18px;
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  transform: rotate(-1.5deg);
}
.folder:nth-child(3n+2) .folder-toggle { background: var(--yellow-soft); transform: rotate(1deg); }
.folder:nth-child(3n+3) .folder-toggle { background: #FFE1C4; transform: rotate(-0.5deg); }
.folder.collapsed .folder-toggle { opacity: 0.75; box-shadow: none; }
.folder.collapsed .folder-head { margin-bottom: 0; }
.folder-count {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.78rem;
  color: var(--card);
  background: var(--ink);
  border-radius: var(--r-pill);
  padding: 2px 8px;
}
.folder-grip { color: var(--ink); }
.folder-grip:hover { background: var(--yellow); }
.folder.drop-target .folder-body,
.folder.drop-target .folder-head { outline: 3.5px dashed var(--orange); }
.folder-empty {
  border: 3px dashed rgba(18, 18, 18, 0.4);
  border-radius: 16px;
  font-weight: 700;
  background: rgba(250, 247, 242, 0.7);
}
.folder-body { gap: 18px; }
.folder-name-input { font-family: var(--font-display); font-weight: 900; }

/* Timer cards */
.workout-card {
  background: var(--card);
  border: var(--b-md);
  border-radius: 18px;
  box-shadow: var(--sh-md);
  transition: transform 0.12s, box-shadow 0.12s;
}
.workout-card:nth-child(3n+1) { transform: rotate(-0.4deg); }
.workout-card:nth-child(3n+2) { transform: rotate(0.5deg); }
.workout-card:hover {
  background: var(--yellow-soft);
  transform: translate(-2px, -2px);
  box-shadow: var(--sh-lg);
}
.workout-card.active { border-color: var(--ink); } /* the loaded timer is marked by its orange play stamp, not a tint */
.workout-card.dragging { opacity: 0.4; }
.workout-card:focus-visible { outline: 3.5px solid var(--orange); outline-offset: 3px; }

.workout-card-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.workout-card-desc { color: var(--muted); font-weight: 500; }

/* Chunky square play stamp */
.btn-play {
  width: 50px;
  height: 50px;
  font-size: 1.1rem;
  background: var(--yellow);
  border: var(--b-md);
  border-radius: 12px;
  box-shadow: var(--sh-sm);
  padding-left: 3px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.workout-card:hover .btn-play { background: var(--yellow); }
.workout-card.active .btn-play { background: var(--orange); }

/* Badges: heavy pills */
.badge {
  font-family: var(--font-display);
  font-size: 0.72rem;
  padding: 3px 10px;
  border: var(--b-sm);
  border-radius: var(--r-pill);
  font-weight: 900;
  background: var(--card);
}
.badge-circ { background: var(--yellow); }
.badge-tab, .badge-tabata { background: var(--orange); }
.badge-rnd { background: var(--card); box-shadow: inset 0 -5px 0 var(--orange); }
.badge-hiit { background: var(--purple); color: var(--card); }
.badge-cust { background: #E9D5FF; }
.badge-duration { background: var(--card); font-variant-numeric: tabular-nums; }

.btn-link {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: underline 2px;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--ink); }
.btn-link.danger { color: var(--card); background: var(--ink); padding: 2px 6px; border-radius: 6px; text-decoration: none; }

/* =========================================================
   Timer stage
   ========================================================= */
.workout-stage { padding-top: 30px; }

/* Stats = three chunky taped tags */
.stats-header {
  max-width: 820px;
  gap: 16px;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}
.stat-item {
  position: relative;
  background: var(--card);
  border: var(--b-md);
  border-radius: 16px;
  box-shadow: var(--sh-md);
  padding: 12px 10px 10px;
}
.stat-item:nth-child(1) { transform: rotate(-1.2deg); }
.stat-item:nth-child(2) { transform: rotate(0.8deg); }
.stat-item:nth-child(3) { transform: rotate(-0.6deg); }
.stat-item::before {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  width: 54px; height: 16px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 199, 0, 0.75);
  border: 1.5px solid rgba(18, 18, 18, 0.5);
}
.stat-item:nth-child(2)::before { background: rgba(168, 85, 247, 0.55); transform: translateX(-50%) rotate(4deg); }
.stat-item:nth-child(3)::before { background: rgba(255, 122, 0, 0.7); }
.stat-label { letter-spacing: 0.12em; color: var(--muted); font-weight: 800; }
.stat-value { font-family: var(--font-display); font-weight: 900; }

/* Interval name in a skewed label slab */
.interval-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.5vw, 4.2rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  background: var(--card);
  border: var(--b-lg);
  border-radius: var(--r-cloud);
  box-shadow: var(--sh-lg);
  padding: 10px 28px 12px;
  transform: rotate(-2deg);
  margin-bottom: 18px;
}

/* Giant digits with a hard offset "print" shadow */
.timer-digits {
  font-family: var(--font-display);
  font-size: clamp(7rem, 20vw, 16rem);
  font-weight: 900;
  line-height: 0.95;
  color: var(--card);
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  text-shadow: 8px 8px 0 var(--ink);
  letter-spacing: -0.03em;
}

/* Up Next with starburst label */
.up-next-card {
  gap: 12px;
  background: var(--card);
  border: var(--b-md);
  padding: 12px 22px 12px 14px;
  border-radius: var(--r-pill);
  margin-bottom: 22px;
  font-size: 1rem;
  box-shadow: var(--sh-md);
  transform: rotate(1deg);
}
.up-next-label {
  position: relative;
  display: grid;
  place-items: center;
  width: 100px;
  height: 100px;
  margin: -36px 4px -36px -46px;
  padding: 0;
  background: none;
  transform: rotate(-12deg);
  flex-shrink: 0;
  color: var(--ink);
}
.up-next-label svg { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(2px 2px 0 var(--ink)); }
.up-next-label span {
  position: relative;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.12rem;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.up-next-name { font-family: var(--font-display); font-weight: 900; font-size: 1.05rem; }
.up-next-dur {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink);
  padding: 2px 10px;
  border: var(--b-sm);
  border-radius: var(--r-pill);
  background: var(--yellow);
}
.up-next-dur:empty { display: none; }

/* Controls */
.btn-ctrl {
  background: var(--card);
  border: var(--b-md);
  border-radius: var(--r-btn);
  box-shadow: var(--sh-md);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-ctrl:hover { background: var(--card); }
.btn-ctrl.btn-secondary { width: 58px; height: 58px; font-size: 1.3rem; }
.btn-ctrl.btn-main,
.btn-ctrl.btn-main:hover {
  width: 96px;
  height: 96px;
  font-size: 2.4rem;
  background: var(--yellow);
  color: var(--ink);
  border: var(--b-lg);
  border-radius: 50%;
}
.btn-ctrl.btn-main { box-shadow: var(--sh-lg); }
.btn-ctrl.btn-main:hover { box-shadow: 10px 10px 0 var(--ink); }

/* Hotkeys */
.hotkeys-bar {
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 18px;
}
.hotkey-item {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: 3px 10px 3px 4px;
}
.hotkey-item kbd {
  background: var(--ink);
  color: var(--card);
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-weight: 800;
  margin-right: 4px;
}

/* Total progress: zebra track */
.workout-progress-bar-container { height: 16px; background: var(--zebra); border-top: var(--b-md); }
.workout-progress-bar { background: var(--orange); border-right: var(--b-md); }

/* =========================================================
   Modals
   ========================================================= */
dialog.custom-modal {
  border: var(--b-lg);
  border-radius: var(--r-card);
  background: var(--canvas);
  background-image: radial-gradient(circle, var(--dot) 1.4px, transparent 1.6px);
  background-size: 20px 20px;
  box-shadow: 10px 10px 0 var(--ink);
}
dialog.custom-modal::backdrop { background: rgba(18, 18, 18, 0.5); }

.modal-header { padding: 16px 20px; border-bottom: var(--b-md); background: var(--yellow); }
.modal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 900;
  text-transform: uppercase;
}
.btn-close-modal {
  background: var(--card);
  border: var(--b-sm);
  box-shadow: var(--sh-sm);
  font-weight: 900;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-close-modal:hover { background: var(--card); }

/* Forms */
.form-label { font-weight: 900; color: var(--ink); letter-spacing: 0.08em; }
.form-input, .form-select, .form-textarea {
  padding: 11px 13px;
  border-radius: 12px;
  border: var(--b-md);
  background: var(--card);
  font-weight: 600;
  box-shadow: var(--sh-sm);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--ink);
  background: #fff;
  box-shadow: 5px 5px 0 var(--orange);
}
input[type="range"] { accent-color: var(--orange); }
input[type="checkbox"] { accent-color: var(--ink); }

.btn-primary {
  border-radius: var(--r-pill);
  background: var(--orange);
  color: var(--ink);
  border: var(--b-md);
  box-shadow: var(--sh-md);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.05rem;
  text-transform: uppercase;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-primary:hover, .btn-primary:active { background: var(--orange); }

/* Drop zone */
.drop-zone { border: 3.5px dashed var(--ink); border-radius: var(--r-card); background: var(--card); }
.drop-zone:hover, .drop-zone.dragover { background: var(--yellow); border-color: var(--ink); }
.drop-text { font-family: var(--font-display); font-weight: 900; }
.modal-body > div[style*="border-top"] { border-top: var(--b-md) !important; }

/* Timer editor */
dialog.editor-modal { background-color: var(--canvas); }
.editor-modal .modal-header .home-sub { color: var(--ink); opacity: 0.7; margin: 0 0 4px; }
.editor-title { font-size: 1.7rem; }
.editor-queue {
  border: var(--b-sm);
  border-radius: var(--r-pill);
  background: var(--yellow);
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-weight: 900;
  padding: 4px 12px;
}
.editor-name { font-family: var(--font-display); font-weight: 900; font-size: 1.6rem; }
.editor-rows-head { border-bottom: var(--b-md); }
.editor-h3 { font-family: var(--font-display); font-weight: 900; text-transform: uppercase; }
.editor-rows { gap: 12px; }
.ed-row {
  background: var(--card);
  border: var(--b-md);
  border-radius: 16px;
  box-shadow: none; /* flat blocks: the shadows added too much noise inside the dialog */
}
.ed-row .icon-btn { box-shadow: none; }
.ed-index {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.75rem;
}
.ed-row .form-input { box-shadow: none; border-width: 2.5px; border-radius: 10px; }
.ed-row .form-input:focus { box-shadow: 3px 3px 0 var(--orange); }
.ed-row-name { font-family: var(--font-display); font-weight: 800; }
.ed-kind .chip { box-shadow: none; }
.ed-kind .chip[data-kind="work"][aria-pressed="true"] { background: var(--orange); }
.ed-kind .chip[data-kind="rest"][aria-pressed="true"] { background: var(--yellow); }
.icon-btn {
  border: var(--b-sm);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.icon-btn:hover:not(:disabled) { background: var(--card); }
.editor-errors { color: #D62E00; font-weight: 800; }
.editor-footer { background: var(--card); border-top: var(--b-md); }
.editor-total-value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
}

/* Account */
#account-status { font-weight: 800; }

/* Toast: sticker */
.toast {
  background: var(--yellow);
  color: var(--ink);
  border: var(--b-md);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-md);
  font-family: var(--font-display);
  font-weight: 900;
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .s-star, .s-burst-yellow, .s-smiley { display: none; }
  .stats-header { gap: 10px; }
  .brand-name { font-size: 1rem; }
  .brand-eyes { width: 26px; }
  .timer-digits { -webkit-text-stroke-width: 4px; text-shadow: 5px 5px 0 var(--ink); }
  .interval-title { padding: 8px 18px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .np-dot { animation: none; }
}

/* =========================================================
   Home header hierarchy (zine only)
   1. title   2. one primary action   3. secondary   4. tertiary
   Then a quiet toolbar: search + collapsible Filters.
   ========================================================= */
.home-head { margin-bottom: 26px; }

/* Primary: big orange stamp */
.btn-icon-nav.btn-hero {
  padding: 13px 22px;
  font-size: 1.05rem;
  border-width: 4px;
  box-shadow: var(--sh-md);
  transform: rotate(-1.5deg);
}
.btn-icon-nav.btn-hero:hover { transform: rotate(-1.5deg) translate(-2px, -2px); box-shadow: var(--sh-lg); }
.btn-icon-nav.btn-hero:active { transform: rotate(-1.5deg) translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* Tertiary: plain text action */
.btn-icon-nav.btn-tertiary,
.btn-icon-nav.btn-tertiary:hover,
.btn-icon-nav.btn-tertiary:active {
  background: none;
  border-color: transparent;
  box-shadow: none;
  transform: none;
  padding: 7px 6px;
  text-decoration: underline 2.5px;
  text-underline-offset: 4px;
}
.btn-icon-nav.btn-tertiary:hover { text-decoration-color: var(--orange); }

/* Toolbar sits on a ruled line so it reads as one unit */
.filter-bar {
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 34px;
  border-bottom: var(--b-md);
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 16px;
  background: var(--card);
  color: var(--ink);
  border: var(--b-md);
  border-radius: var(--r-btn);
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.filter-toggle:hover { transform: translate(-2px, -2px); box-shadow: var(--sh-md); }
.filter-toggle:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.filter-toggle[aria-expanded="true"] { background: var(--yellow); }
.filter-caret { transition: transform 0.15s; }
.filter-toggle[aria-expanded="true"] .filter-caret { transform: rotate(180deg); }
.filter-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--orange);
  border: 2px solid var(--ink);
  font-size: 0.75rem;
  text-align: center;
}
.filter-count[hidden] { display: none; }

.filter-panel {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  padding: 16px 18px;
  background: var(--card);
  border: var(--b-md);
  border-radius: 16px;
  box-shadow: var(--sh-sm);
}
.filter-panel[hidden] { display: none; }

@media (max-width: 720px) {
  .btn-icon-nav.btn-hero { transform: none; }
  .home-actions .btn-tertiary { justify-content: center; }
  .filter-panel { padding: 14px; }
}

/* Actions share the toolbar row with search + Filters */
.filter-bar .home-actions { margin-left: auto; }
.home-head { margin-bottom: 22px; }
@media (max-width: 720px) {
  .filter-bar .home-actions { margin-left: 0; width: 100%; }
  .home-head { align-items: flex-start; }
  .view-home .s-burst-orange { display: none; }
}

/* Undo button in the toast */
.toast-action,
.toast-action:hover {
  padding: 4px 12px;
  background: var(--card);
  color: var(--ink);
  border: var(--b-sm);
  border-radius: var(--r-pill);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--font-display);
  font-weight: 900;
}
.toast-action:active { transform: translate(2px, 2px); box-shadow: none; }

/* Editor notice */
.editor-notice {
  background: #FFF2C2;
  border: var(--b-sm);
  border-radius: 14px;
  box-shadow: var(--sh-sm);
  font-weight: 700;
}

/* Per-card "⋯" button and menu */
.card-menu-btn {
  width: 34px;
  height: 34px;
  font-size: 1.15rem;
  border-radius: 10px;
}
.card-menu {
  border-radius: 16px;
  box-shadow: var(--sh-lg);
}
.menu-item:focus-visible { background: var(--yellow); }
.menu-item.danger {
  color: #D62E00;
  border-top: var(--b-sm);
}
.menu-item.danger:hover { background: #FFE1C4; }
.menu-item:disabled:hover { background: transparent; }
.workout-card.menu-open {
  background: var(--card);
  border-color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: var(--sh-lg);
}

/* =========================================================
   Quick switcher (Cmd/Ctrl+K)
   ========================================================= */
dialog.switcher-modal {
  padding: 0;
  width: min(660px, 94vw);
  max-width: none;
  max-height: 78vh;
  margin: 10vh auto auto;
  overflow: hidden;
}

.switcher-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--yellow);
  border-bottom: var(--b-md);
  color: var(--ink);
}
.switcher-search svg { flex-shrink: 0; }
.switcher-search input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  background: var(--card);
  border: var(--b-sm);
  border-radius: var(--r-btn);
  outline: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  user-select: text;
}
.switcher-search input::placeholder { color: var(--muted); font-weight: 700; }
.switcher-search input:focus { box-shadow: var(--sh-sm); }

.switcher-search kbd,
.switcher-foot kbd {
  padding: 1px 8px;
  background: var(--ink);
  color: var(--card);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
}

.switcher-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--card);
}

.sw-heading {
  padding: 8px 18px;
  background: var(--canvas);
  border-bottom: var(--b-sm);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: var(--b-sm);
  cursor: pointer;
}
.sw-item[aria-selected="true"] { background: var(--yellow); }

.sw-main { flex: 1; min-width: 0; }
.sw-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sw-name mark {
  padding: 0 2px;
  background: var(--orange);
  color: var(--ink);
  border-radius: 4px;
}
.sw-meta {
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sw-item[aria-selected="true"] .sw-meta { color: var(--ink); }

.sw-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  background: var(--card);
  border: var(--b-sm);
  border-radius: var(--r-pill);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sw-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--orange);
  border-radius: 50%;
}

.sw-enter { flex-shrink: 0; font-weight: 900; opacity: 0; }
.sw-item[aria-selected="true"] .sw-enter { opacity: 1; }

.sw-empty {
  padding: 30px 22px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 900;
}
.sw-empty span { display: block; margin-top: 6px; font-family: var(--font-sans); font-weight: 700; color: var(--muted); }

.switcher-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 42px;
  padding: 10px 18px;
  background: var(--canvas);
  border-top: var(--b-md);
  font-size: 0.78rem;
  font-weight: 800;
}
.sw-warn { color: #D62E00; font-weight: 900; }
.sw-warn[hidden] { display: none; }

@media (hover: none) { .switcher-foot .sw-hints, .switcher-search kbd { display: none; } }
@media (max-width: 720px) { dialog.switcher-modal { margin-top: 6vh; } .sw-badge { display: none; } }

/* =========================================================
   Workout history
   ========================================================= */
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--yellow);
  color: var(--ink);
  border: var(--b-md);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.streak-chip:hover { transform: translate(-1px, -1px); box-shadow: var(--sh-md); }
.streak-chip:active { transform: translate(2px, 2px); box-shadow: none; }
.streak-chip[hidden] { display: none; }
.streak-chip.idle { background: var(--card); }
.streak-chip.at-risk { border-style: dashed; }
.streak-chip small { font-size: 0.75rem; font-weight: 800; opacity: 0.75; }

dialog.history-modal { max-width: 760px; }
.history-body { padding: 22px; }

.history-undo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--card);
  border-radius: var(--r-btn);
  font-weight: 800;
  font-size: 0.9rem;
}
.history-undo[hidden] { display: none; }
.history-undo .btn-icon-nav { color: var(--ink); background: var(--yellow); }

.hist-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.hist-tile {
  padding: 14px 16px;
  background: var(--card);
  border: var(--b-md);
  border-radius: var(--r-card);
  box-shadow: var(--sh-sm);
}
.hist-tile.hot { background: var(--yellow); }
.hist-tile .home-sub { margin: 0 0 6px; }
.hist-num {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.hist-num small { font-size: 0.95rem; font-weight: 800; letter-spacing: 0; margin-left: 4px; }
.hist-note { margin-top: 6px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.hist-tile.hot .hist-note { color: var(--ink); }

.hist-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: var(--b-md);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.hist-h small { font-family: var(--font-sans); font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.hist-section { margin-bottom: 28px; }

/* Calendar */
.hm-wrap { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; }
.hm-days {
  display: grid;
  grid-template-rows: repeat(7, var(--hm-cell));
  gap: var(--hm-gap);
  margin-top: 22px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  align-items: center;
}
.hm-main { --hm-cell: 20px; --hm-gap: 5px; }
.history-body { --hm-cell: 20px; --hm-gap: 5px; }
.hm-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--hm-cell);
  gap: var(--hm-gap);
  height: 18px;
  margin-bottom: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
}
.hm-months span { white-space: nowrap; overflow: visible; }
.hm-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--hm-cell));
  grid-auto-columns: var(--hm-cell);
  gap: var(--hm-gap);
}
.hm-cell {
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--card);
}
.hm-cell.l1 { background: #FFE9A6; }
.hm-cell.l2 { background: var(--yellow); }
.hm-cell.l3 { background: var(--orange); }
.hm-cell.l4 { background: var(--purple); }
.hm-cell.future { border-style: dashed; opacity: 0.3; background: transparent; }
.hm-cell.today { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.hm-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.hm-legend .hm-cell { width: 16px; height: 16px; }

/* Lists */
.hist-list { display: flex; flex-direction: column; gap: 10px; list-style: none; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: var(--b-sm);
  border-radius: var(--r-btn);
}
.hist-main { flex: 1; min-width: 0; }
.hist-name { font-family: var(--font-display); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-when { margin-top: 2px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.hist-dur { flex-shrink: 0; font-weight: 900; font-variant-numeric: tabular-nums; }
.hist-badge {
  flex-shrink: 0;
  padding: 2px 9px;
  border: var(--b-sm);
  border-radius: var(--r-pill);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--yellow);
}
.hist-badge.stopped { background: var(--card); }
.hist-rank {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--card);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 900;
}
.hist-empty { padding: 26px 20px; text-align: center; font-weight: 800; background: var(--card); border: var(--b-sm); border-style: dashed; border-radius: var(--r-card); }
.hist-empty span { display: block; margin-top: 6px; font-weight: 700; color: var(--muted); }
.hist-more { margin-top: 12px; }

@media (max-width: 720px) {
  .home-head .streak-chip { align-self: flex-start; }
  .history-body { padding: 16px; --hm-cell: 17px; --hm-gap: 4px; }
  .hist-row { flex-wrap: wrap; }
  .hist-badge { order: 3; }
}

/* =========================================================
   Phones: a short brand name, and room in the header
   ========================================================= */
.brand-short { display: none; }

@media (max-width: 720px) {
  /* "2ndSecs" on screen; the full name stays available to screen readers */
  .brand-full {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .brand-short { display: inline; }

  /* The starburst NEXT badge: still roomy, just a bit smaller */
  .up-next-label { width: 84px; height: 84px; margin: -30px 2px -30px -38px; }
  .up-next-label span { font-size: 1rem; }
}

@media (max-width: 520px) {
  /* Timer screen: the breadcrumb needs the room, so the brand shrinks to its logo */
  .view-timer .brand-short { display: none; }
  .view-timer .active-workout-pill span:not(.pill-back) { display: none; }
  .view-timer .active-workout-pill { padding: 8px 12px; }
}

/* =========================================================
   Sequence panel (timer screen)
   ========================================================= */
.sequence-panel {
  position: fixed;
  top: 92px;
  right: 14px;
  bottom: 30px;
  width: min(380px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: var(--b-md);
  border-radius: var(--r-card);
  box-shadow: var(--sh-lg);
  z-index: 60;
  overflow: hidden;
}
.sequence-panel[hidden] { display: none; }
.view-home .sequence-panel { display: none; }

.seq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--yellow-soft);
  border-bottom: var(--b-md);
}
.seq-kicker { margin: 0 0 2px; }
.seq-summary { font-family: var(--font-display); font-size: 1.15rem; font-weight: 900; }

.seq-list { list-style: none; overflow-y: auto; flex: 1; min-height: 0; }

.seq-heading {
  padding: 7px 16px;
  background: var(--canvas);
  border-bottom: var(--b-sm);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.seq-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: transparent;
  border: none;
  border-bottom: var(--b-sm);
  color: var(--ink);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.seq-row:hover { background: var(--yellow-soft); }
.seq-row:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }

.seq-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
}
.seq-row.rest .seq-dot { border-radius: 4px; }
.seq-row.done .seq-dot { background: var(--ink); }
.seq-row.current .seq-dot { background: var(--orange); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }

.seq-main { flex: 1; min-width: 0; }
.seq-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seq-row.rest .seq-name { font-weight: 700; color: var(--muted); }
.seq-row.done .seq-name { text-decoration: line-through; opacity: 0.55; }
.seq-at { margin-top: 1px; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.seq-dur { flex-shrink: 0; font-weight: 900; font-variant-numeric: tabular-nums; }
.seq-row.done .seq-dur { opacity: 0.55; }

.seq-row.current { background: var(--yellow); }
.seq-row.current .seq-at { color: var(--ink); }
.seq-now {
  flex-shrink: 0;
  padding: 1px 8px;
  background: var(--ink);
  color: var(--card);
  border-radius: var(--r-pill);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  /* Bottom sheet on phones */
  .sequence-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 26px;
    width: auto;
    max-height: 62vh;
  }
}

/* =========================================================
   Editor templates
   ========================================================= */
.editor-templates { margin-bottom: 24px; }
.editor-templates[hidden] { display: none; }
.editor-templates .form-label { margin-bottom: 8px; }
.tpl-panel {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--yellow-soft);
  border: var(--b-sm);
  border-radius: var(--r-btn);
}
.tpl-panel[hidden] { display: none; }
.tpl-panel .account-note { margin: 0 0 12px; color: var(--ink); }
.tpl-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tpl-field .form-label { margin-bottom: 4px; }
.tpl-field.wide { grid-column: 1 / -1; }
.tpl-field textarea { width: 100%; resize: vertical; min-height: 92px; font-family: var(--font-sans); }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* =========================================================
   Pinned timers
   ========================================================= */
.folder.pinned .folder-toggle { background: var(--yellow-soft); transform: rotate(-1.5deg); }
.pin-star { flex-shrink: 0; }

.card-pin-btn { color: var(--ink); }
.card-pin-btn[aria-pressed="true"] { background: var(--yellow-soft); }
.card-pin-btn svg { display: block; }

.badge-folder {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--card);
}

/* A little more air between the editor's fields, so each hard shadow has room */
.editor-grid { gap: 20px 24px; }

/* Sequence: view toggle and set stepper */
.seq-toggle {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--canvas);
  border-bottom: var(--b-sm);
}
.seq-toggle[hidden] { display: none; }
.seq-toggle .chip { box-shadow: none; padding: 5px 12px; }

.seq-heading.seq-sets {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--yellow-soft);
}
.seq-step {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--ink);
  border: var(--b-sm);
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.seq-step:hover:not(:disabled) { background: var(--yellow); }
.seq-step:disabled { opacity: 0.3; cursor: default; }
.seq-set-label { flex: 1; font-size: 0.78rem; letter-spacing: 0.1em; }
.seq-repeat {
  padding: 1px 9px;
  background: var(--ink);
  color: var(--card);
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

/* =========================================================
   Custom dropdown
   ========================================================= */
.cs { position: relative; }
.cs-native {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.cs-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px 11px 14px;
  background: var(--card);
  color: var(--ink);
  border: var(--b-md);
  border-radius: 12px;
  box-shadow: var(--sh-sm);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.cs-button:hover { transform: translate(-1px, -1px); box-shadow: var(--sh-md); }
.cs-button:focus-visible,
.cs-button[aria-expanded="true"] {
  outline: none;
  background: #fff;
  transform: none;
  box-shadow: 5px 5px 0 var(--orange);
}
.cs-button[hidden] { display: none; }
.cs-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-chevron { flex-shrink: 0; transition: transform 0.12s ease; }
.cs-button[aria-expanded="true"] .cs-chevron { transform: rotate(180deg); }

.cs-list {
  position: fixed;
  z-index: 3000;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  overflow-y: auto;
  padding: 6px;
  background: var(--card);
  border: var(--b-md);
  border-radius: 16px;
  box-shadow: var(--sh-lg);
}
.cs-list[hidden] { display: none; }

.cs-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.cs-option.active { background: var(--yellow-soft); }
.cs-option[aria-selected="true"] { font-weight: 900; }
.cs-option[aria-selected="true"]::after {
  content: "";
  flex-shrink: 0;
  margin-left: auto;
  width: 12px;
  height: 12px;
  background: var(--orange);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
}
.cs-create {
  /* Always visible at the bottom, however many folders there are */
  position: sticky;
  bottom: -6px;
  margin-top: 6px;
  padding-top: 12px;
  background: var(--card);
  border-top: var(--b-sm);
  border-radius: 0 0 10px 10px;
  font-family: var(--font-display);
  font-weight: 900;
}
.cs-create.active { background: var(--yellow); }

.cs-create-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cs-create-row[hidden] { display: none; }
.cs-create-input { flex: 1; min-width: 120px; }
.cs-create-error { flex-basis: 100%; color: #D62E00; font-size: 0.8rem; font-weight: 800; }
.cs-create-error:empty { display: none; }

/* Search opens a row below the toolbar, like Filters */
.search-panel { padding: 4px 8px; }
.search-panel input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
}
