@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/cormorant-normal-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/cormorant-normal-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/cormorant-normal-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/cormorant-italic-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-600.woff2') format('woff2');
}

:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface2: #e9eee9;
  --accent: #2f6f67;
  --accent2: #c86f5d;
  --text: #263133;
  --text-mid: #667174;
  --text-dim: #9ba5a7;
  --slate: #dbe4ef;
  --rose: #f0cfc4;
  --teal: #cde8e3;
  --sage: #dce7c8;
  --amber: #efe1a8;
  --border: rgba(61,59,47,0.08);
  --border-bright: rgba(61,59,47,0.15);
  --radius: 8px;
  --radius-sm: 8px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-emoji: var(--font-sans);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ---- Buttons ---- */
.btn {
  padding: 8px 14px;
  background: transparent;
  border: 1.5px solid var(--border-bright);
  color: var(--text);
  border-radius: 24px;
  cursor: pointer;
  font: 500 13px/1.4 var(--font-sans);
  transition: all 0.2s;
  letter-spacing: 0;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.danger:hover { background: #c45b5b; border-color: #c45b5b; color: #fff; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.lg { padding: 10px 18px; font-weight: 600; }
.btn.block { width: 100%; text-align: center; }

/* ---- Header ---- */
.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  gap: 10px;
}
.header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.routine-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.routine-name {
  font: 500 30px/1.05 var(--font-serif);
  min-width: 0;
  word-break: break-word;
  letter-spacing: 0;
}
.routine-name input {
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border-bright);
  padding: 6px 10px; border-radius: var(--radius-sm); font: 500 26px var(--font-serif); width: 100%;
}
.header-actions {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.48);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.header-actions::-webkit-scrollbar { display: none; }
.header-plan {
  flex: 0 0 auto;
  min-height: 42px;
  padding-inline: 18px;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(68, 88, 82, 0.12);
}
.header-actions .btn {
  justify-content: center;
  min-height: 32px;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-mid);
  font-size: 12px;
  white-space: nowrap;
}
.header-actions .btn:hover,
.header-actions .btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(38,49,51,0.08);
}
.header-actions .help-button {
  flex: 0 0 32px;
  width: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-mid);
  font-weight: 700;
  border-radius: 50%;
}
.header-actions .help-button:hover {
  color: var(--text);
  border-color: var(--border-bright);
}
.discipline-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  background: transparent; border: 1.5px solid var(--border-bright); border-radius: 24px;
  font-size: 12px; font-weight: 500; font-family: inherit; color: inherit;
  cursor: pointer; transition: all 0.2s;
  text-transform: uppercase; letter-spacing: 0;
}
.discipline-badge:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.discipline-badge {
  justify-self: start;
  min-height: 32px;
  padding-inline: 12px;
  background: var(--surface2);
  border-color: transparent;
  font-size: 11px;
  color: var(--text-mid);
}
.editing-mode .header-actions { width: fit-content; }

/* ---- Progress ---- */
.progress-section { margin-bottom: 16px; }
.progress-bar {
  width: 100%; height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden; margin-bottom: 8px; border: 1px solid var(--border);
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.3s; border-radius: 3px; }
.progress-text { font-size: 12px; color: var(--text-mid); }
.progress-row { display: flex; justify-content: space-between; align-items: center; }

.class-summary { margin-bottom: 10px; }
.class-glance {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(38,49,51,0.04);
}
.class-glance span {
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.class-glance strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}
.class-glance small {
  flex: 0 0 auto;
  color: var(--text-mid);
  font-size: 11px;
  line-height: 1.2;
}
.class-glance-equipment {
  flex: 1 1 auto;
  justify-content: flex-end;
}

/* ---- Teacher Visual Cues ---- */
.teacher-visuals { margin-bottom: 10px; }
.class-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(38,49,51,0.04);
  overflow: hidden;
}
.class-map-summary {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}
.class-map-summary::-webkit-details-marker { display: none; }
.class-map-title {
  font-weight: 700;
  font-size: 13px;
}
.class-map-flow {
  min-width: 0;
  color: var(--text-mid);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.class-map-chevron {
  color: var(--text-mid);
  font-size: 12px;
  transition: transform 0.2s;
}
.class-map[open] .class-map-chevron { transform: rotate(180deg); }
.class-map-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}
.visual-panel { display: flex; flex-direction: column; gap: 10px; }
.routine-arc {
  display: flex;
  gap: 4px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  user-select: none;
}
.arc-segment {
  position: relative;
  flex: var(--arc-size) 0 58px;
  min-width: 58px;
  height: 38px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 6px;
  background: var(--surface2);
}
.arc-segment::before,
.arc-segment::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--arc-color);
}
.arc-segment::before { opacity: 0.35; }
.arc-segment::after { right: auto; width: var(--arc-fill); opacity: 0.9; transition: width 0.25s; }
.arc-segment span {
  position: relative;
  z-index: 1;
  max-width: 100%;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.equipment-timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  user-select: none;
}
.equipment-stop {
  flex: 0 0 136px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px;
}
.equipment-stop.transition-stop {
  background: var(--surface2);
  border-style: dashed;
}
.equipment-stop-meta,
.balance-label {
  display: block;
  color: var(--text-mid);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.equipment-stop-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.equipment-stop-chips,
.transition-equipment {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}
.timeline-chip,
.memory-chip,
.cue-badge,
.side-badge,
.energy-badge,
.balance-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-bright);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-mid);
  background: var(--surface2);
}
.timeline-chip,
.memory-chip,
.balance-chip { padding: 3px 7px; }
.class-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.class-balance .balance-label { margin: 0 2px 0 0; }
.balance-chip { background: var(--surface); color: var(--text); }
.side-badge {
  padding: 2px 8px;
  background: var(--teal);
  color: var(--text);
}
.energy-badge {
  padding: 2px 8px;
  background: var(--amber);
  color: var(--text);
}
.cue-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.cue-badge {
  padding: 2px 7px;
  text-transform: uppercase;
  background: var(--surface2);
}

/* ---- Equipment Filter ---- */
.eq-filter { margin-bottom: 12px; }
.filter-panel {
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 24px;
  overflow: hidden;
}
.filter-panel summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  cursor: pointer;
  list-style: none;
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
}
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary strong {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eq-filter-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 10px 10px;
}
.eq-chip {
  padding: 6px 14px; background: transparent; border: 1.5px solid var(--border-bright);
  border-radius: 24px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.eq-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Edit Top Bar ---- */
.edit-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.edit-bar .btn { flex: 1; min-width: 80px; }

/* ---- Block Cards ---- */
.blocks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.block-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(61,59,47,0.04);
}
.block-card:hover { border-color: var(--border-bright); box-shadow: 0 2px 8px rgba(61,59,47,0.08); }

.block-header {
  display: flex; align-items: center; gap: 12px; padding: 16px; cursor: pointer;
  background: var(--surface); border-bottom: 1.5px solid var(--border);
}
.block-emoji {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-bright);
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  font: 600 14px/1 var(--font-sans);
  text-align: center;
}
.block-info { flex: 1; min-width: 0; }
.block-title { font: 500 17px/1.3 var(--font-serif); letter-spacing: 0; }
.block-title input {
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border-bright);
  padding: 4px 8px; border-radius: var(--radius-sm); font: 500 17px var(--font-serif); width: 100%;
}
.eq-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.eq-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  background: var(--surface2); border: 1px solid var(--border-bright); border-radius: 12px;
  font-size: 11px; font-weight: 500; color: var(--text-mid);
}
.toggle-arrow { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
.toggle-arrow.collapsed { transform: rotate(-90deg); }
.block-actions { display: flex; gap: 4px; align-items: center; }

.block-content { display: flex; flex-direction: column; max-height: 2000px; overflow: hidden; transition: max-height 0.3s; }
.block-content.collapsed { max-height: 0; }

/* ---- Transition Card ---- */
.transition-card {
  padding: 12px 16px; background: var(--surface2); border: 1.5px dashed var(--border-bright);
  border-radius: var(--radius); display: flex; align-items: center; gap: 12px; font-size: 13px;
  font-style: italic; color: var(--text-mid);
}
.transition-label {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-mid);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}
.transition-title { flex: 1; min-width: 0; }
.transition-equipment { margin-top: 0; flex: 0 0 auto; }

/* ---- Step Rows ---- */
.step-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border);
}
.step-checkbox { width: 20px; height: 20px; min-width: 20px; margin-top: 2px; cursor: pointer; accent-color: var(--accent); }
.step-content { flex: 1; min-width: 0; }
.step-emoji {
  width: 26px;
  height: 26px;
  min-width: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-bright);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: 600 12px/1 var(--font-sans);
  margin-bottom: 4px;
}
.step-name { font-weight: 500; font-size: 14px; margin-bottom: 2px; }
.step-detail { font-size: 13px; color: var(--text-mid); }
.step-row.checked { opacity: 0.5; }
.step-row.checked .step-name { text-decoration: line-through; }

.pulse-badge {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  background: var(--rose); color: var(--text);
  border-radius: 12px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Quiz Mode ---- */
.quiz-card { cursor: pointer; user-select: none; }
.quiz-card .step-detail { display: none; }
.quiz-card.revealed .step-detail { display: block; }
.quiz-toggle {
  padding: 2px 8px; background: var(--surface2); border: 1px solid var(--border-bright);
  border-radius: 12px; font-size: 11px; cursor: pointer; color: var(--text-mid); transition: all 0.2s;
}
.quiz-toggle:hover, .quiz-toggle.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* ---- Teach Mode ---- */
.teach-mode {
  background: #fbfbf8;
}
.teach-mode .container {
  max-width: 820px;
}
.teach-mode .header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 100;
  background: rgba(251,251,248,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.teach-mode .class-summary,
.teach-mode .teacher-visuals,
.teach-mode .eq-filter {
  display: none;
}
.teach-mode .progress-section {
  position: sticky;
  top: calc(82px + env(safe-area-inset-top, 0px));
  z-index: 90;
  background: rgba(251,251,248,0.96);
  padding: 8px 0 12px;
}
.teach-mode .blocks {
  gap: 16px;
}
.teach-mode .block-header {
  padding: 18px 20px;
}
.teach-mode .block-title {
  font-size: 24px;
}
.teach-mode .step-row {
  padding: 18px 20px;
  gap: 16px;
}
.teach-mode .step-checkbox {
  width: 28px;
  height: 28px;
  min-width: 28px;
}
.teach-mode .step-emoji {
  width: 36px;
  height: 36px;
  min-width: 36px;
  font-size: 16px;
}
.teach-mode .step-name {
  font-size: 22px;
  line-height: 1.2;
}
.teach-mode .step-detail {
  font-size: 16px;
  line-height: 1.45;
  margin-top: 6px;
}

/* ---- Study Mode ---- */
.study-mode .class-summary,
.study-mode .eq-filter,
.study-mode .progress-section {
  display: none;
}
.study-mode .blocks { gap: 10px; }
.study-mode .block-header { padding: 14px 16px; }
.study-mode .toggle-arrow { display: none; }
.memory-card-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}
.memory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 12px;
}
.memory-steps {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-left: 20px;
}
.memory-steps li {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.memory-more {
  margin-top: 10px;
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
}

.add-step-btn {
  padding: 10px 16px; background: var(--surface2); border: 1px dashed var(--border-bright);
  color: var(--text-mid); border-radius: var(--radius-sm); cursor: pointer; font: 500 13px var(--font-sans);
  transition: all 0.2s; margin: 12px 16px;
}
.add-step-btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.block-edit-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  flex-wrap: wrap;
}
.block-edit-actions .add-step-btn {
  flex: 1 1 120px;
  margin: 0;
}
.block-edit-actions .quick-add { border-color: var(--accent); color: var(--accent); }
.block-edit-actions .suggest-add { border-color: var(--accent2); color: var(--accent2); }

.add-block-btn {
  padding: 12px 16px; background: var(--surface2); border: 2px dashed var(--border-bright);
  color: var(--text-mid); border-radius: var(--radius); cursor: pointer; font: 600 14px var(--font-sans);
  transition: all 0.2s; text-align: center; margin-bottom: 24px;
}
.add-block-btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ---- Edit Toolbar per block ---- */
.edit-toolbar {
  display: flex; gap: 6px; align-items: center; padding: 8px 16px;
  background: rgba(255,255,255,0.02); flex-wrap: wrap;
}

/* ---- Library Panel ---- */
.library-overlay {
  position: fixed; inset: 0; background: rgba(61,59,47,0.25); z-index: 8900;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.library-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 100%; max-width: 400px;
  background: var(--surface); border-left: 1.5px solid var(--border-bright); z-index: 9000;
  display: flex; flex-direction: column; transform: translate3d(0,0,0); box-shadow: -8px 0 24px rgba(61,59,47,0.1);
  padding-top: env(safe-area-inset-top, 0px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.library-header { padding: 16px; border-bottom: 1px solid var(--border-bright); display: flex; justify-content: space-between; align-items: center; }
.library-title { font: 500 20px/1.2 var(--font-serif); }
.library-content { flex: 1; overflow-y: auto; padding: 16px; }
.library-empty { text-align: center; color: var(--text-mid); padding: 32px 16px; font-size: 14px; }
.library-section-title { font: 600 11px/1 var(--font-sans); letter-spacing: 0; text-transform: uppercase; color: var(--text-mid); padding: 12px 4px 8px; }

.routine-card {
  background: var(--bg); border: 1.5px solid var(--border-bright); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; transition: all 0.2s;
}
.routine-card:hover { border-color: var(--accent); }
.routine-card-title { font: 500 16px/1.2 var(--font-serif); margin-bottom: 4px; }
.routine-card-meta { font-size: 12px; color: var(--text-mid); margin-bottom: 8px; }
.routine-card-description { font-size: 13px; line-height: 1.35; color: var(--text); margin: -2px 0 10px; }
.routine-card-btns { display: flex; gap: 8px; }
.routine-card-btns .btn { flex: 1; }
.schedule-intro {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.schedule-intro strong { font: 600 15px/1.2 var(--font-sans); }
.schedule-intro span { color: var(--text-mid); font-size: 13px; line-height: 1.35; }
.schedule-add { margin-bottom: 8px; }
.schedule-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.schedule-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-mid);
  font-size: 11px;
  font-weight: 700;
}
.status-ready { color: var(--accent); background: rgba(92,107,79,0.08); }
.status-taught { color: var(--text); background: var(--surface2); }
.status-needs-plan { color: #9a6a2f; background: rgba(212,196,160,0.22); }
.schedule-linked {
  margin: 8px 0 10px;
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
}
.schedule-actions { flex-wrap: wrap; }
.schedule-actions .btn { flex: 1 1 104px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(61,59,47,0.3);
  display: flex; align-items: center; justify-content: center; z-index: 10000; padding: 16px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border: 1.5px solid var(--border-bright); border-radius: var(--radius);
  padding: 24px; max-width: 500px; width: 100%; max-height: calc(100vh - 32px);
  overflow-y: auto; box-shadow: 0 20px 60px rgba(61,59,47,0.15);
  -webkit-overflow-scrolling: touch;
}
.modal h3 { font: 500 22px/1.2 var(--font-serif); margin-bottom: 16px; }
.modal p { color: var(--text-mid); font-size: 14px; margin-bottom: 16px; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-label {
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.form-input {
  background: var(--bg); border: 1.5px solid var(--border-bright); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); font: 14px var(--font-sans);
}
.form-input:focus { outline: none; border-color: var(--accent); }
.modal-btns { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.modal-btns-inline { margin-top: 0; }
.tour-intro { margin-bottom: 12px; }
.tour-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.tour-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tour-item strong {
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
}
.tour-item span {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-mid);
}

/* ---- Dropdown ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0; background: var(--surface);
  border: 1.5px solid var(--border-bright); border-radius: var(--radius-sm);
  min-width: 200px; z-index: 1000; margin-top: 4px; box-shadow: 0 8px 24px rgba(61,59,47,0.1);
}
.dropdown-menu button {
  width: 100%; text-align: left; padding: 10px 16px; background: none;
  border: none; border-bottom: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-size: 13px; transition: background 0.2s;
}
.dropdown-menu button:last-child { border-bottom: none; }
.dropdown-menu button:hover { background: var(--surface2); }

/* ---- Utility ---- */
.hidden { display: none !important; }
.success { color: var(--accent); font-size: 12px; margin-top: 8px; }
.error { color: #c45b5b; font-size: 12px; margin-top: 8px; }

@media (max-width: 540px) {
  .container { padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .header { padding: 10px 0 12px; gap: 8px; }
  .header-main { align-items: center; gap: 10px; }
  .routine-name { font-size: 28px; }
  .routine-name input { font-size: 24px; }
  .header-plan { min-height: 40px; padding-inline: 14px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .header-actions .btn { flex: 1 0 auto; }
  .header-actions .help-button { flex: 0 0 32px; }
  .editing-mode .header-actions { width: fit-content; }
  .class-glance { gap: 8px; padding: 9px 10px; }
  .class-glance-secondary { display: none !important; }
  .class-glance-equipment strong { max-width: 150px; }
  .modal-overlay {
    align-items: flex-end;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 0;
  }
  .modal {
    height: calc(100vh - 24px - env(safe-area-inset-top, 0px));
    max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px));
    padding: 18px;
    border-radius: 16px 16px 0 0;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  @supports (height: 100dvh) {
    .modal {
      height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
      max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
    }
  }
  .modal-btns {
    position: sticky;
    bottom: -16px;
    margin: 4px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(255,255,255,0), var(--surface) 24%);
  }
  .modal-btns .btn {
    flex: 1;
    min-height: 44px;
  }
  .modal-btns-inline {
    position: static;
    margin: 0;
    padding: 0;
    background: none;
  }
  .edit-bar { flex-direction: column; }
  .edit-bar .btn { min-width: auto; min-height: 44px; font-size: 14px; }
  .library-panel { max-width: 100%; }
}

/* ---- Bottom Sheet ---- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(61,59,47,0.25);
  z-index: 9500; opacity: 0;
  pointer-events: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--border-bright);
  border-radius: 16px 16px 0 0; z-index: 9600;
  transform: translate3d(0,100%,0);
  visibility: hidden; pointer-events: none;
  max-height: 85vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 16px);
  -webkit-overflow-scrolling: touch;
}
.sheet.open { transform: none !important; visibility: visible; pointer-events: auto; }
.sheet-handle {
  width: 36px; height: 4px; background: var(--text-dim); border-radius: 2px;
  margin: 10px auto 8px; opacity: 0.5;
}
.sheet-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px 12px; border-bottom: 1.5px solid var(--border);
}
.sheet-header h3 { font: 500 20px/1.2 var(--font-serif); }
.sheet-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.sheet-field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-mid);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0;
}
.sheet-field input[type="text"],
.sheet-field textarea,
.sheet-field select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border-bright); padding: 12px;
  border-radius: var(--radius-sm); font: 15px var(--font-sans);
  -webkit-appearance: none;
}
.sheet-field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.sheet-field input:focus,
.sheet-field textarea:focus,
.sheet-field select:focus { outline: none; border-color: var(--accent); }

.switch-row {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  background: var(--bg); border: 1.5px solid var(--border-bright);
  border-radius: var(--radius-sm); cursor: pointer;
}
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch-row span { font-size: 14px; font-weight: 500; }

.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: border-color 0.2s, transform 0.15s;
}
.color-swatch:active { transform: scale(0.9); }
.color-swatch.selected { border-color: var(--accent); }

.eq-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.eq-toggle {
  padding: 10px 16px; background: var(--surface2); border: 1px solid var(--border-bright);
  border-radius: 20px; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.eq-toggle.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-pick {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-pick:active { transform: scale(0.9); }
.emoji-pick.selected { border-color: var(--accent); background: rgba(92,107,79,0.1); }

.sheet-actions {
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; bottom: 0; z-index: 2;
  padding: 16px 20px; border-top: 1px solid var(--border); margin-top: 8px;
  background: var(--surface);
}
.sheet-actions .btn { min-height: 48px; font-size: 15px; }
.sheet-row-actions { display: flex; gap: 10px; }
.sheet-row-actions .btn { flex: 1; }
.quick-build-tools { flex-wrap: wrap; }
.quick-build-tools .btn { min-width: 130px; }

.pulse-toggle {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg); border: 1.5px solid var(--border-bright);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.pulse-toggle.active { border-color: var(--rose); background: rgba(212,181,168,0.2); }

.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg);
  border: 1.5px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 12px;
}
.suggestion-card:hover { border-color: var(--accent); }
.suggestion-emoji {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-bright);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: 600 13px/1 var(--font-sans);
  flex-shrink: 0;
}

.block-emoji,
.step-emoji,
.suggestion-emoji,
.emoji-pick,
.transition-card span:first-child {
  font-family: var(--font-emoji);
}
.suggestion-main { flex: 1; min-width: 0; }
.suggestion-title { font-weight: 600; font-size: 14px; line-height: 1.25; }
.suggestion-detail { color: var(--text-mid); font-size: 12px; line-height: 1.4; margin-top: 4px; }
.suggestion-meta {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-top: 8px;
}
.suggestion-card .btn { flex-shrink: 0; }

.step-edit-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-top: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s; min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}
.step-edit-row:active { background: var(--surface2); }
.step-edit-row .step-emoji { width: 28px; height: 28px; min-width: 28px; text-align: center; }
.step-edit-row .step-name { font-weight: 500; font-size: 14px; flex: 1; }
.step-edit-row .step-name.empty { color: var(--text-dim); font-style: italic; }
.step-edit-row .step-chevron { color: var(--text-dim); font-size: 16px; }

.add-step-btn {
  min-height: 48px; display: flex; align-items: center; justify-content: center;
}
.add-block-btn {
  min-height: 52px; display: flex; align-items: center; justify-content: center;
}

/* ---- Confirm Overlay ---- */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(61,59,47,0.3);
  z-index: 11000; display: flex; align-items: flex-end;
  animation: fadeIn 0.15s;
}
.confirm-sheet {
  width: 100%; background: var(--surface);
  border-radius: 16px 16px 0 0; padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1.5px solid var(--border-bright);
}
.confirm-msg {
  font-size: 15px; color: var(--text); margin-bottom: 20px;
  text-align: center; line-height: 1.5;
}
.confirm-btns { display: flex; flex-direction: column; gap: 10px; }
.confirm-btns .btn { min-height: 48px; font-size: 15px; }

/* ---- Undo Snackbar ---- */
.undo-snackbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 12px 12px 14px;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(38,49,51,0.24);
  pointer-events: none;
}
.undo-message {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}
.undo-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.undo-button,
.undo-close {
  border: 0;
  background: transparent;
  color: var(--surface);
  font: 700 13px/1 var(--font-sans);
  cursor: pointer;
  pointer-events: auto;
}
.undo-button {
  min-height: 36px;
  padding: 0 8px;
  color: #f3df9b;
}
.undo-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
}
.undo-close:active,
.undo-button:active { opacity: 0.7; }

@media (max-width: 380px) {
  .tour-item { grid-template-columns: 1fr; gap: 4px; }
  .undo-snackbar { align-items: flex-start; }
}
