/* The same snow caps frame the twilight tools and the light editing dialogs. */
:is(#climbTimer, #climbPicker, #climbNoise, #climbGroups, #lessonBoardEditor) {
  --modal-navy: #0c2042;
  --modal-gold: #f9b80d;
  --modal-ice: #f2f9ff;
  --modal-mountains: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 190' preserveAspectRatio='none'%3E%3Cdefs%3E%3Cg id='peaks'%3E%3Cpath fill='%23284467' d='M0 112 41 87Q52 80 63 88L122 135Q131 142 142 134L172 108Q184 99 197 111L279 190H0Z'/%3E%3Cpath fill='%2329517a' d='M36 190 173 109Q184 101 197 111L279 190Z'/%3E%3Cpath fill='%23335e89' d='M0 92 49 33Q64 16 81 36L197 190H0Z'/%3E%3Cpath fill='%2323476e' d='M65 24 60 63 81 116 69 134 107 152 122 190H0V92L49 33Q57 24 65 24Z'/%3E%3Cpath fill='%236a92b9' d='M0 92 49 33Q64 16 81 36L119 87Q115 96 86 78L76 98Q72 105 66 98L52 80 35 92Q28 98 26 87L24 79Q10 88 0 92Z'/%3E%3Cpath fill='%234a739b' d='M0 92 49 33Q57 24 65 24L60 63 69 101 52 80 35 92Q28 98 26 87L24 79Q10 88 0 92Z'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23peaks'/%3E%3Cuse href='%23peaks' transform='translate(800 -4) scale(-1 1.022)'/%3E%3C/svg%3E");
  --modal-glass: linear-gradient(155deg, #b0cde444, #709cc92e 48%, #8eb3db38);
  --modal-glass-line: #a6c6e377;
  --modal-glass-shadow: inset 0 1px 3px #eaf5ff2b, 0 5px 12px #050f292f;
  --modal-gold-fill: linear-gradient(165deg, #ffe58b, #ffd44d 45%, var(--modal-gold));
  --modal-blue-fill: linear-gradient(170deg, #3077df, #174ea8);
  --modal-card-line: #bed1e6;
  --modal-card-shadow: 0 4px 10px #153e6817;
}

:is(#climbTimer, #climbPicker, #climbNoise) {
  background: var(--modal-mountains) center bottom / 100% clamp(94px, 29%, 184px) no-repeat,
    radial-gradient(ellipse at 55% 70%, #173d72, var(--modal-navy) 86%);
  border-color: #426890;
  box-shadow: inset 0 0 0 1px #8db9e126, 0 18px 48px #04102c66;
}

:is(#climbTimer, #climbPicker, #climbNoise) h2 {
  color: #f8fcff;
  text-shadow: 0 3px 8px #040f27a6;
}

:is(#climbTimer, #climbPicker, #climbNoise) button,
#climbGroups .climb-tool-close,
#lessonBoardEditor .lesson-editor-head button {
  background: var(--modal-glass);
  border-color: var(--modal-glass-line);
  color: #f8fcff;
  box-shadow: var(--modal-glass-shadow);
}

:is(#climbTimer, #climbPicker, #climbNoise) .climb-gold-button,
#climbNoise .climb-noise-modes button[aria-pressed="true"] {
  background: var(--modal-gold-fill);
  border-color: #ffe894;
  color: var(--modal-navy);
  box-shadow: inset 0 1px 2px #fff4bc, inset 0 -3px #a55b192f,
    0 3px 0 #996317, 0 5px 15px #f9b80d4d;
}

:is(#climbTimer, #climbPicker, #climbNoise) :is(button, input):focus-visible {
  outline: 2px solid #ffe18a;
  outline-offset: 2px;
}

:is(#climbTimer, #climbNoise) .journey-note {
  color: #c9dcef;
}

/* Timer. The live conic fill still follows --timer-remaining. */
#timerRing {
  background: conic-gradient(#ffd44d, var(--modal-gold) var(--timer-remaining, 100%),
    #355475 0%, #355475 100%);
  box-shadow: inset 0 0 0 2px #fff0ae73, 0 0 0 4px #f9b80d52, 0 0 30px #f9b80d60;
}

#timerRing::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke-linecap='round'%3E%3Ccircle cx='50' cy='50' r='45' pathLength='60' stroke='%23fbd360' stroke-opacity='.62' stroke-width='1' stroke-dasharray='.04 .96'/%3E%3Cdefs%3E%3Cpath id='ticks' d='M50 4v5m0 82v5M4 50h5m82 0h5' stroke='%23ffda6a' stroke-width='1.5'/%3E%3C/defs%3E%3Cuse href='%23ticks'/%3E%3Cuse href='%23ticks' transform='rotate(30 50 50)'/%3E%3Cuse href='%23ticks' transform='rotate(60 50 50)'/%3E%3C/svg%3E") center / 100% no-repeat,
    radial-gradient(circle, #132f59 52%, #0c2042);
  box-shadow: 0 0 0 1px #ffe69579, inset 0 0 14px #f9b80d46;
}

#climbTimer #timerFace {
  text-shadow: 0 3px 8px #050e25aa;
}

#climbTimer > .climb-tool-actions {
  width: min(100%, 30rem);
  box-sizing: border-box;
  margin-inline: auto;
  background: var(--modal-glass);
  border-block: 1px solid var(--modal-glass-line);
}

#climbTimer > #timerStatus + .climb-tool-actions {
  margin-block: 0;
  padding-block: 7px 3px;
  border-radius: 15px 15px 0 0;
  border-block-end: 0;
  background: linear-gradient(115deg, #a5c5e253, #709cc94d);
  box-shadow: inset 1px 0 var(--modal-glass-line), inset -1px 0 var(--modal-glass-line),
    inset 0 1px #eaf5ff25;
}

#climbTimer > .climb-tool-actions + .climb-tool-actions {
  margin-block-start: 0;
  padding-block: 3px 7px;
  border-radius: 0 0 15px 15px;
  border-block-start: 0;
  background: linear-gradient(115deg, #a5c5e253, #709cc94d);
  box-shadow: inset 1px 0 var(--modal-glass-line), inset -1px 0 var(--modal-glass-line),
    0 4px 12px #050f2930;
}

.mirror-student-tools #climbTimer > .timer-buttons {
  margin-block-start: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#climbTimer input[type="number"] {
  color-scheme: only light;
  color: #112643;
  background: #f9fcff;
  border-color: #9fbad9;
  box-shadow: inset 0 1px 3px #26436824;
}

/* Name picker. Keep both adjacent reel names and the live announcement. */
#climbPicker .climb-picker-reel {
  position: relative;
  isolation: isolate;
}

#climbPicker .climb-picker-reel::before {
  content: "";
  position: absolute;
  inset: -46% max(-16%, calc((100% - 100vw) / 2 + 32px));
  z-index: -1;
  pointer-events: none;
  background: repeating-conic-gradient(from 8deg, #ffdf732d 0 14deg, transparent 14deg 37deg);
  mask-image: radial-gradient(ellipse closest-side, #000 22%, #000b 52%, transparent);
}

#climbPicker #pickerName {
  --picker-sparkles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 38 40'%3E%3Cpath fill='%23fff2bb' d='M14 8Q15 19 26 21Q15 22 14 34Q12 23 2 21Q12 19 14 8ZM31 2Q32 8 37 9Q32 10 31 16Q30 10 24 9Q30 8 31 2ZM7 29Q8 33 12 34Q8 35 7 39Q6 35 2 34Q6 33 7 29Z'/%3E%3C/svg%3E");
  background: var(--picker-sparkles) left 5px top 4px / clamp(18px, 4vw, 34px) auto no-repeat,
    var(--picker-sparkles) right 5px bottom 4px / clamp(18px, 4vw, 34px) auto no-repeat,
    linear-gradient(124deg, #fff1ad6b, #fff1ad3d 55%, transparent 55.3%),
    var(--modal-gold-fill);
  color: var(--modal-navy);
  box-shadow: inset 0 0 0 2px #ffeaa1, inset 0 0 0 5px #bb7d205c,
    0 4px #b97a1b, 0 7px 20px #081b39aa, 0 0 28px #ffcd4d55;
  border-radius: 16px;
  text-shadow: 0 1px #ffedac80;
}

#climbPicker #pickerName.picked {
  box-shadow: inset 0 0 0 2px #fff2ae, inset 0 0 0 5px #bb7d2069,
    0 4px #b97a1b, 0 7px 20px #081b39aa, 0 0 34px #ffcd4d83;
}

#climbPicker :is(#pickerClass, #pickerAttendanceBtn) {
  background: linear-gradient(#edf7ff, #cde5f8);
  border-color: #b4d4ef;
  border-radius: 999px;
  color: #112f53;
}

#climbPicker #pickerReset {
  border-radius: 999px;
}

#climbPicker #pickerProgress:not(:empty) {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding-inline: 12px;
  border-radius: 999px;
  background: var(--modal-glass);
  color: #f2f8ff;
  box-shadow: inset 0 0 0 1px var(--modal-glass-line);
}

/* Noise meter. Paint the entire LED scale and reveal its illuminated portion
   using the same level and logical direction as the existing meter. */
#climbNoise .climb-noise-meter {
  isolation: isolate;
  margin-block-start: 24px;
  background: radial-gradient(ellipse, #52cde535, transparent 68%);
}

#climbNoise .climb-noise-meter::before {
  content: "";
  position: absolute;
  inset: -50% 0 -55%;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-radial-gradient(ellipse at -18% 58%, transparent 0 11%, #69d5f335 11.5% 12%, transparent 12.5% 17%) left / 26% 100% no-repeat,
    repeating-radial-gradient(ellipse at 118% 58%, transparent 0 11%, #69d5f335 11.5% 12%, transparent 12.5% 17%) right / 26% 100% no-repeat;
  mask-image: linear-gradient(transparent, #000 26% 74%, transparent);
}

#climbNoise :is(.climb-noise-modes, .climb-noise-controls) {
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  margin-inline: auto;
  padding: 7px 8px;
  background: var(--modal-glass);
  border: 1px solid var(--modal-glass-line);
  border-radius: 15px;
  box-shadow: var(--modal-glass-shadow);
}

#climbNoise .climb-noise-modes {
  margin-block-start: 7px;
}

#climbNoise #noiseHint {
  margin-block-end: 15px;
}

#climbNoise #noiseMic:not(.mic-live),
#noiseTargetLabel {
  background: #284f76;
  color: #f2faff;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px #99c3e67a;
}

#noiseTargetLabel {
  z-index: 1;
  inset-block-start: -11px;
  padding: 1px 8px;
  box-shadow: inset 0 0 0 1px #a4d5faaa, 0 0 12px #6ed2ff52;
}

#noiseMeterBar {
  --led-direction: to right;
  --leds: linear-gradient(var(--led-direction), #52eea3 0%, #54e4aa 21%, #59d6ff 32%,
    #50caff 47%, #ffdb68 54%, #ffc34e 70%, #ff9266 79%, #ff705f 100%);
  --led-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 540 32' preserveAspectRatio='none'%3E%3Cpattern id='led' width='10' height='32' patternUnits='userSpaceOnUse'%3E%3Crect x='2.5' width='5' height='32' rx='2.5' ry='4' fill='white'/%3E%3C/pattern%3E%3Cpath fill='url(%23led)' d='M0 0h540v32H0z'/%3E%3C/svg%3E");
  background: linear-gradient(#132b48, #234668 52%, #193656);
  border-color: #809fbacc;
  box-shadow: inset 0 2px 6px #b0dcff4d, 0 5px 15px #040f2e72;
}

[dir="rtl"] #noiseMeterBar,
#noiseMeterBar:dir(rtl) {
  --led-direction: to left;
}

#noiseMeterBar::before {
  inset: 5px 6px;
  width: auto;
  border-radius: 0;
  /* The translucent layer leaves the unlit colors legible at a level of zero. */
  background: linear-gradient(var(--led-direction), transparent var(--level, 0%), #10233a8c 0%),
    linear-gradient(180deg, #e7f9ff38, transparent 46%, #081b482c), var(--leds);
  mask: var(--led-shape) center / 100% 100% no-repeat;
}

#noiseMeterBar::after {
  inset-block: -6px;
  background: #f5fcff;
  box-shadow: 0 0 8px #a5e5ff, 0 0 15px #70c8ff9c;
}

#climbNoise #noiseStatus {
  color: #91f6c8;
  text-shadow: 0 0 16px #55efb066;
}

#climbNoise.noise-warned #noiseStatus {
  color: #ffd474;
  text-shadow: 0 0 16px #ffc66b64;
}

/* Light dialogs. A pale veil uses the same inline mountains as the dark tools. */
#climbGroups,
#lessonBoardEditor {
  background: linear-gradient(#f2f9ffdf, #f2f9ffdc) bottom / 100% 100% no-repeat,
    var(--modal-mountains) bottom / 100% clamp(86px, 32%, 175px) no-repeat, var(--modal-ice);
  border-color: var(--modal-card-line);
  color: var(--modal-navy);
}

#climbGroups > header,
#lessonBoardEditor .lesson-editor-head {
  background: linear-gradient(110deg, var(--modal-navy), #18385f);
  color: #fbfdff;
  box-shadow: inset 0 -3px var(--modal-gold);
}

#climbGroups > header {
  --group-dialog-padding: clamp(14px, 3vw, 26px);
  margin: calc(-1 * var(--group-dialog-padding)) calc(-1 * var(--group-dialog-padding)) 0;
  padding: var(--group-dialog-padding) var(--group-dialog-padding) 0;
  box-shadow: none;
  background: none;
  position: relative;
  isolation: isolate;
}

#climbGroups > header::before {
  content: "";
  position: absolute;
  inset: 0 0 -5px;
  z-index: -1;
  background: linear-gradient(110deg, var(--modal-navy), #18385f);
  box-shadow: inset 0 -3px var(--modal-gold);
  border-radius: 21px 21px 0 0;
  pointer-events: none;
}

#climbGroups #groupsClose {
  border-radius: 50%;
}

#climbGroupsTitle {
  --modal-heading-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='17' cy='7' r='3.4' fill='%23ffc44d'/%3E%3Cpath fill='%23ffc44d' d='M15 12q6-2 8 5v2h-6q0-4-2-7Z'/%3E%3Ccircle cx='8' cy='7' r='4' fill='%2379c5ef'/%3E%3Cpath fill='%2379c5ef' d='M1 20v-2a7 7 0 0 1 14 0v2Z'/%3E%3C/svg%3E");
}

#lessonBoardEditorTitle {
  --modal-heading-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke='%23ffcd5b' d='M12 2v2m-4 18 2-5m6 5-2-5m-7-4 3-3 2 2 5-5'/%3E%3Cpath stroke='white' d='M2 4h20M4 4h16v12H4z'/%3E%3C/svg%3E");
}

#climbGroupsTitle::before,
#lessonBoardEditorTitle::before {
  content: "";
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -.16em;
  margin-inline-end: .36em;
  background: var(--modal-heading-icon) center / contain no-repeat;
}

#climbGroups :is(#groupsClass, #groupsAttendanceBtn) {
  --badge-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2337608c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3 19v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2zm13-14a3 3 0 0 1 0 6m2 2a4 4 0 0 1 3 4v2h-3'/%3E%3C/svg%3E");
  border-radius: 999px;
  color: var(--modal-navy);
  background: #d8eafa;
  position: relative;
  padding-inline-start: 2.1em;
}

#climbGroups #groupsAttendanceBtn {
  --badge-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2337608c' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='7' r='3'/%3E%3Cpath d='M10 19H3v-2a5 5 0 0 1 5-5h2m7 2v3l2 1'/%3E%3Ccircle cx='17' cy='17' r='5'/%3E%3C/svg%3E");
  background: #f8fcff;
  border-color: #b7cbe3;
}

#climbGroups :is(#groupsClass, #groupsAttendanceBtn)::before {
  content: "";
  position: absolute;
  inset-inline-start: .7em;
  inset-block-start: 50%;
  translate: 0 -50%;
  width: 1.075em;
  height: 1.075em;
  background: var(--badge-icon) center / contain no-repeat;
}

#climbGroups .climb-group-field,
#climbGroups #groupsHint {
  background: #fff;
  border: 1px solid #cfdded;
  padding-inline: clamp(10px, 2vw, 18px);
}

#climbGroups .climb-group-field {
  border-radius: 15px 15px 0 0;
  border-block-end: 0;
  padding-block-start: 6px;
}

#climbGroups #groupsHint {
  border-radius: 0 0 15px 15px;
  border-block-start: 0;
  padding-block: 4px;
  margin-block-start: 0;
  color: #425c7c;
  box-shadow: 0 8px 12px -7px #153e6840;
}

#climbGroups #groupsCount {
  border-color: var(--modal-card-line);
  color: var(--modal-navy);
  box-shadow: var(--modal-card-shadow);
}

#climbGroups :is(#groupsDone, #groupsReset),
#lessonBoardEditor :is(#lessonBoardCancel, #lessonBoardQuickCheck, #lessonBoardSettings, .lesson-format .btn) {
  color: var(--modal-navy);
  background: #fff;
  border-color: var(--modal-card-line);
  box-shadow: var(--modal-card-shadow);
  text-shadow: none;
}

#climbGroups #groupsGenerate,
#lessonBoardEditor #lessonBoardSave {
  background: var(--modal-blue-fill);
  border-color: #2159b5;
  color: white;
  box-shadow: inset 0 1px #acd4ff83, inset 0 -3px #08266052, 0 4px 8px #123e7541;
}

/* Mirror uses the same dialogs on the display. The phone has separate controls. */
.mirror-student-tools #climbPicker .climb-picker-reel::before {
  inset-block: -28% 0;
}

.mirror-student-tools #climbNoise header[data-mirror-mode]:not([data-mirror-mode=""])::after {
  padding: .2em .65em;
  border-radius: 999px;
  color: #f2faff;
  background: var(--modal-glass);
  box-shadow: inset 0 0 0 1px var(--modal-glass-line);
}

.mirror-student-tools #climbGroups .climb-group-card {
  background-image: linear-gradient(#ffffffdf, #ffffff70);
  box-shadow: var(--modal-card-shadow);
}

/* The editor's existing mobile wrapping and sticky header still apply. */
#lessonBoardEditor h2 {
  color: #fff;
  text-shadow: none;
}

#lessonBoardEditor .lesson-editor-row :is(select, input[type="date"]),
#lessonBoardEditor .lesson-editable,
#lessonBoardEditor .lesson-format input[type="color"] {
  border-color: var(--modal-card-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--modal-card-shadow);
}

#lessonBoardEditor #lessonBoardEmpty {
  position: relative;
  padding-inline-start: 2.1em;
  border-radius: 9px;
  background: #deedfc;
  color: #183d67;
  box-shadow: inset 0 0 0 1px #b6d2ef;
}

#lessonBoardEditor #lessonBoardEmpty::before {
  content: "";
  position: absolute;
  inset-inline-start: .6em;
  inset-block-start: 50%;
  translate: 0 -50%;
  width: 1.1em;
  height: 1.1em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23285fb0' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7h.01M12 11v6'/%3E%3C/svg%3E") center / contain no-repeat;
}

#lessonBoardEditor .lesson-format {
  background: #fff;
  border-color: #d4e1ef;
  border-radius: 13px;
  box-shadow: var(--modal-card-shadow);
}

#lessonBoardEditor .lesson-format small {
  color: #425c7c;
}

#lessonBoardEditor .lesson-editor-footer {
  margin-inline: 0;
  padding-inline: clamp(11px, 2vw, 22px);
  background: #fff;
  border-color: #d5e3f1;
}

@media (max-width: 480px) {
  #climbGroups :is(#groupsClass, #groupsAttendanceBtn) {
    font-size: .875rem;
  }

  #climbGroups #groupsHint {
    padding-inline: 6px;
  }

  #lessonBoardEditor #lessonBoardDay {
    width: clamp(7rem, 33vw, 9rem);
  }

  #lessonBoardEditor > .lesson-editor-head + .lesson-editor-row > label:nth-child(2),
  #lessonBoardEditor #lessonBoardSlot {
    min-width: 3.2rem;
  }

  #lessonBoardEditor #lessonBoardSettings {
    padding-inline: 9px;
    font-size: .85rem;
  }

  #lessonBoardEditor .lesson-editor-footer {
    gap: 6px;
  }

  #lessonBoardEditor .lesson-editor-footer .btn {
    min-width: 0;
    padding: 5px 8px;
    font-size: clamp(.77rem, 3.2vw, .94rem);
    line-height: 1.2;
    white-space: normal;
  }
}

@media (max-width: 350px) {
  #climbGroups #groupsHint {
    padding-inline: 4px;
  }
}
