/* Open routine layout: only the tablature has a panel surface. */

.routine-screen {
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: max(12px,var(--sa-bottom));
  scroll-padding-block: 12px;
}

.routine-screen>.topbar,
.routine-content,
#routineDrawer { flex-shrink: 0; }

.routine-content {
  box-sizing: border-box;
  width: min(1040px,100%);
  margin: 12px auto 0;
  padding: 0 24px;
}

.routine-exercise {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  text-align: center;
}

.routine-steps {
  display: flex;
  list-style: none;
  gap: 8px;
  width: 100%;
  padding: 0;
  margin: 0 0 18px;
}

.routine-steps li {
  position: relative;
  flex: 1;
  min-width: 0;
  text-align: center;
  color: #adb9cf;
}

.routine-steps li+li::before {
  content: "";
  position: absolute;
  right: calc(50% + 28px);
  top: 22px;
  width: calc(100% - 48px);
  height: 2px;
  background: #526781;
}

.routine-steps li.is-complete::before,
.routine-steps li.is-current::before { background: #70f7ff; }

body #app .routine-steps button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 64px;
  padding: 0 2px;
  border: 0;
  border-radius: var(--ui-radius);
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: 700 16px/1.15 var(--ui-font);
  cursor: pointer;
}

.routine-steps button::before {
  content: attr(data-step);
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  border: 2px solid #647c9d;
  border-radius: 50%;
  background: #0a1527;
  font-size: 22px;
  color: #adb9cf;
}

.routine-steps .is-current button::before { color: #70f7ff; border-color: #70f7ff; box-shadow: 0 0 16px #70f7ff55; }

.routine-steps .is-complete button::before {
  content: "✓";
  background: #00ae82;
  color: white;
  border-color: #41ffcb;
  font-size: 28px;
  box-shadow: 0 0 12px #00dca744;
}

body #app .routine-steps .is-current button { color: #fff; }

.routine-steps button:focus-visible { outline: 2px solid #70f7ff; outline-offset: 3px; }

.routine-exercise h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(26px,3vw,42px);
  line-height: 1.2;
}

.routine-exercise h2:focus-visible { outline: 2px solid #ffd84b; outline-offset: 4px; }

#routineContext { margin: 0 0 8px; color: #ffe38a; font-size: 18px; }

#routineInstruction {
  margin: 0 0 16px;
  color: var(--ui-muted);
  font-size: 18px;
  line-height: 1.35;
}

.routine-tab-scroll {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 12px 8px;
  border-radius: 16px;
  overflow: hidden;
}

.routine-tab-scroll svg { display: block; width: 100%; height: auto; }

.routine-legend {
  text-align: left;
  font-size: 14px;
  color: #70f7ff;
  margin: 8px 8px 0;
}

.routine-actions { display: flex; justify-content: center; margin: 16px 0 0; }

.routine-actions button {
  width: 220px;
  min-height: 48px;
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 22px;
}

.routine-actions [hidden],
.routine-content [hidden] { display: none !important; }

#routineTuner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  font-size: 16px;
  white-space: nowrap;
}

@media (min-width:768px) {
  #routineDrawer .control-group { min-width: 0; }

  #routineDrawer .control-options { display: none; }

  #routineDrawer .control-select { display: block; width: 100%; min-width: 0; max-width: none; }

  #routineDrawer .select-trigger { height: 48px; max-width: none; }

  body #app #routineDrawer>.control-panel { display: grid; grid-template-columns: minmax(110px,1fr) minmax(160px,1fr) auto minmax(200px,1.1fr); max-width: 1000px; margin-inline: auto; gap: 16px; padding-block: 0; align-items: start; }
}

@media (min-width:1001px) and (max-height:700px) {
  .routine-screen { --sa-top: env(safe-area-inset-top,0px); --screen-nav-h: calc(56px + var(--sa-top)); }

  .routine-content { margin-top: 4px; }

  .routine-steps { margin-bottom: 8px; }

  body #app .routine-steps button { min-height: 52px; font-size: 14px; gap: 3px; }

  .routine-steps button::before { width: 34px; height: 34px; font-size: 18px; }

  .routine-steps li+li::before { top: 17px; }

  .routine-exercise h2 { font-size: 28px; margin-bottom: 4px; }

  #routineInstruction { font-size: 16px; margin-bottom: 8px; }

  .routine-tab-scroll { padding-block: 4px; }

  .routine-actions { margin-top: 8px; }

  .routine-actions button { min-height: 44px; font-size: 20px; }
}

@media (max-width:767px),(orientation:landscape) and (max-width:1000px) and (max-height:599px) {
  .routine-content { padding: 0 10px; margin-top: 0; }

  .routine-steps { gap: 2px; margin-bottom: 14px; }

  body #app .routine-steps button {
    font-size: 12px;
    min-height: 56px;
    gap: 5px;
    overflow-wrap: anywhere;
  }

  .routine-steps button::before { width: 32px; height: 32px; font-size: 18px; }

  .routine-steps .is-complete button::before { font-size: 22px; }

  .routine-steps li+li::before { top: 16px; right: calc(50% + 20px); width: calc(100% - 38px); }

  .routine-exercise h2 { font-size: 26px; }

  #routineInstruction { font-size: 15px; margin-bottom: 12px; }

  .routine-tab-scroll { padding: 8px 0; border-radius: 12px; }

  .routine-legend { font-size: 12px; }

  .routine-actions button { min-height: 44px; font-size: 20px; }

  #routineDrawer .control-options { display: grid; }

  #routineDrawer .control-select { display: none; }
}

.routine-exercise.is-complete {
  position: relative;
  isolation: isolate;
  text-align: center;
  padding-block: 24px;
}

.routine-exercise.is-complete h2 { font-size: clamp(34px,5vw,52px); color: #fff; text-shadow: 0 0 22px #ffd84b60; }

.routine-exercise.is-complete #routineInstruction { max-width: 580px; margin: 12px auto 0; }

.routine-celebration { margin: 0 auto 18px; }

.routine-medal {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: auto;
  border: 1px solid #ffe38a;
  border-radius: 50%;
  color: #ffe38a;
  background: radial-gradient(circle,#73551a88,#171020);
  box-shadow: 0 0 32px #ffd84b44,inset 0 0 20px #ffd84b22;
  animation: routine-medal-pop .65s ease-out both;
}

.routine-medal svg { width: 64px; height: 64px; }

.routine-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
  z-index: -1;
}

.routine-confetti i {
  position: absolute;
  top: -16px;
  left: var(--x);
  width: 7px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  animation: routine-confetti-fall 2.8s var(--delay) ease-out both;
}

.routine-confetti i:nth-child(3n) { border-radius: 50%; width: 9px; height: 9px; }

.routine-finish {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  width: min(100%,600px);
}

.routine-finish button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

#routineReplay { grid-column: 1 / -1; }

.routine-finish img { flex: none; filter: drop-shadow(0 0 5px var(--ui-accent)); }

@keyframes routine-medal-pop{0%{opacity:0;transform:scale(.5) rotate(-12deg)}65%{opacity:1;transform:scale(1.12) rotate(5deg)}100%{transform:scale(1) rotate(0)}}

@keyframes routine-confetti-fall{0%{opacity:0;transform:translateY(0) rotate(0)}10%{opacity:1}80%{opacity:.9}100%{opacity:0;transform:translate(var(--drift),520px) rotate(var(--turn))}}

@media (prefers-reduced-motion:reduce) {
  .routine-confetti { display: none; }

  .routine-medal { animation: none; }
}

.routine-target {
  display: inline-block;
  margin: 0 .12em;
  padding: 0 .2em;
  border-radius: 8px;
  color: #70f7ff;
  background: #103940;
  border: 1px solid #70f7ff88;
  text-shadow: 0 0 14px #70f7ff77;
  box-shadow: 0 0 16px #70f7ff20;
  font-size: 1.25em;
  line-height: 1.15;
  white-space: nowrap;
}

@media (min-width:1001px) and (max-height:580px) {
  .routine-steps,
  #routineInstruction { margin-bottom: 4px; }
}

@media (min-width:1001px) and (min-height:741px) and (orientation:landscape) {
  .routine-content { margin-top: clamp(20px,calc((100dvh - 740px)*.25),140px); }

  .routine-steps { margin-bottom: clamp(24px,4dvh,56px); }

  .routine-exercise h2 { margin-bottom: 12px; }

  #routineInstruction { margin-bottom: clamp(20px,3dvh,36px); }

  .routine-actions { margin-top: clamp(24px,3dvh,40px); }
}

/* Live guidance is present only while the user has enabled the microphone. */
.routine-mic-control { flex: 0 1 260px; min-width: 0; }
#routineMic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  font-size: 16px;
}
#routineMic svg { width: 20px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#routineMicPrivacy { display: block; max-width: 280px; margin: 5px auto 0; color: var(--ui-muted); font: 12px/1.35 var(--ui-font); text-align: center; }
#routineMic:disabled { opacity: .6; cursor: default; }
#routineMenuBtn { position: relative; }
#routineMenuBtn.is-listening::after { content: ""; position: absolute; right: 3px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: #70f7ff; box-shadow: 0 0 9px #70f7ff; }
.routine-listening { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 8px 10px; color: #a4faff; font: 16px/1.3 var(--ui-font); text-align: left; }
#routineMicStatus { margin: 0; }
#routineNoteProgress { flex: none; padding: 5px 10px; border: 1px solid #70f7ff55; border-radius: 20px; color: #fff; font-variant-numeric: tabular-nums; }
.routine-chord-link { stroke: transparent; stroke-width: 3; }
.routine-tab-column.is-target .routine-chord-link { stroke: #70f7ff; filter: drop-shadow(0 0 4px #70f7ff); }
.routine-tab-column.is-target .routine-note-face { fill: #125263; stroke: #a4faff; stroke-width: 1.5; filter: drop-shadow(0 0 4px #70f7ff70); }
.routine-tab-column.is-target .routine-note-number { fill: #fff; }
.routine-tab-column.is-played .routine-note-face { fill: #073c33; stroke: #4de7b6; stroke-width: 1; }
.routine-tab-column.is-played .routine-note-number { fill: #88ffda; }
.routine-tab-column.is-played .routine-chord-link { stroke: #4de7b680; }
.routine-path { fill: none; stroke: #4de7b6; stroke-width: 2.5; opacity: .8; filter: drop-shadow(0 0 3px #4de7b680); }
.routine-path.is-arriving { stroke: #70f7ff; stroke-dasharray: 1; stroke-dashoffset: 0; animation: routine-trace .42s ease-out both; }
.routine-transition { position: fixed; z-index: 25; left: 50%; top: 50%; transform: translate(-50%,-50%); display: flex; align-items: center; gap: 14px; padding: 22px 30px; width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box; border: 1px solid #4de7b6; border-radius: 22px; color: #b4ffe5; background: #07281ff5; box-shadow: 0 0 55px #4de7b644,0 12px 60px #000b; pointer-events: none; animation: routine-well-played .2s ease-out both; }
.routine-transition span { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%; background: #4de7b6; color: #08261f; font-size: 30px; }
.routine-transition strong { font: 800 28px/1.1 var(--ui-font); }
.is-transitioning #routineTabScroll { opacity: .55; transition: opacity .2s; }
@keyframes routine-trace { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes routine-well-played { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@media (max-width:767px),(orientation:landscape) and (max-width:1000px) and (max-height:599px) {
  body #app #routineDrawer>.control-panel { display: flex; flex-direction: column; align-items: stretch; }
  .routine-mic-control { flex: 1 1 100%; }
  .routine-listening { font-size: 14px; gap: 8px; }
}
@media (prefers-reduced-motion:reduce) {
  .routine-path.is-arriving,.routine-transition { animation: none; }
  .is-transitioning #routineTabScroll { transition: none; }
}
