/* Desktop-first studio, layered over the original clock and native picker styles. */
[hidden],
.hidden {
  display: none !important;
}
button,
input,
select {
  font: inherit;
}
button {
  transition:
    background 0.18s,
    border-color 0.18s,
    transform 0.18s;
}
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.studio-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1/-1;
}
.brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  height: 32px;
  width: 32px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 20px;
}
.studio-brand strong {
  font-size: 17px;
  letter-spacing: -0.5px;
}
.brand-caption {
  color: var(--muted);
  font-size: 12px;
  margin-left: 12px;
}
.studio-brand #focusClock {
  margin-left: auto;
  font-size: 12px;
}
html.clock-focus .studio-brand {
  max-width: 1100px;
  width: 100%;
  margin-inline: auto;
}
html.clock-focus .clock-card {
  max-width: 1100px;
}
html.clock-focus .clock-hm {
  font-size: clamp(100px, min(32cqi, 43dvh), 340px);
  letter-spacing: -0.075em;
}
html.clock-focus .clock-actions {
  margin-top: 36px;
}
.clock-picker-toggle {
  padding: 13px 24px;
}
.date {
  font-size: 17px;
}
.zone {
  font-size: 12px;
}
.editor-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}
.editor-heading .card-title {
  margin: 0 !important;
  font-size: 24px !important;
  font-weight: 600;
  letter-spacing: -0.7px;
}
.create-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.create-switch .chip {
  padding: 10px 22px;
}
.create-switch [aria-pressed="true"] {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--text);
}
.optional {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.6;
  margin-left: 6px;
}
.text-input {
  background: var(--field);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 13px 15px;
  border-radius: 12px;
  width: 100%;
  min-width: 0;
}
.text-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}
.repeat-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}
.repeat-caption .field-label {
  margin: 0 !important;
}
.weekday-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.day-choice {
  height: 35px;
  flex: 1;
  border-radius: 50%;
  max-width: 38px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.day-choice[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
  color: var(--accent-2);
}
.sound-select {
  width: 100%;
  text-align: left;
  padding: 14px;
  background: var(--field);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
}
.volume-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
}
.volume-caption .field-label {
  margin: 0 !important;
}
.volume-caption output {
  font-size: 12px;
  color: var(--muted);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent-2);
  margin: 18px 0;
}
.gradual-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}
input[type="checkbox"] {
  accent-color: var(--accent-2);
  width: 16px;
  height: 16px;
}
.section-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  margin: 10px 0 18px;
}
.test-tiles {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.test-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 86px;
  border: 1px solid var(--card-border);
  background: var(--field);
  color: var(--muted);
  border-radius: 13px;
  font-size: 10px;
  cursor: pointer;
}
.test-tile > span {
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  font-weight: 500;
}
.test-tile i {
  position: absolute;
  right: 7px;
  top: 3px;
  color: var(--accent-2);
  font-size: 13px;
  font-style: normal;
}
.test-tile[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 8%, var(--field));
}
.test-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.selected-tests {
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.7;
}
#setupCard .sound-tests {
  margin-top: 30px !important;
}
#setupCard .wake-settings > .field-label {
  margin: 0 !important;
}
#setupCard .sound-settings > .field-label {
  margin-top: 0 !important;
}
.setup-actions {
  padding-top: 14px;
}
#formMsg:empty {
  display: none;
}
.setup-actions .primary {
  min-height: 50px;
}
#studioStatus {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dialog-bg);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 22px;
  box-shadow: 0 8px 40px #0003;
  font-size: 12px;
  z-index: 100;
  pointer-events: none;
}
#studioStatus:empty {
  display: none;
}
#alarmsCard {
  background: color-mix(in srgb, var(--card) 75%, transparent);
}
.alarm-list {
  gap: 12px;
  display: flex;
  flex-direction: column;
}
.list-section {
  list-style: none;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 12px 0 0;
}
.routine-card {
  list-style: none;
  border: 1px solid var(--card-border);
  border-radius: 17px;
  padding: 18px;
  background: var(--card);
}
.routine-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.routine-edit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.routine-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  white-space: nowrap;
}
.routine-time {
  font-family: "Wake Clock", sans-serif;
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -1.5px;
}
.routine-toggle {
  width: 36px;
  height: 22px;
  border: 0;
  flex-shrink: 0;
  border-radius: 50px;
  background: var(--switch-off);
  position: relative;
  cursor: pointer;
}
.routine-toggle:after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
}
.routine-toggle[aria-checked="true"] {
  background: var(--accent-2);
}
.routine-toggle[aria-checked="true"]:after {
  left: 17px;
}
.routine-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.day-dot {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid transparent;
  border-radius: 50%;
  font-size: 10px;
}
.day-dot.chosen {
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.routine-menu {
  position: relative;
}
.routine-menu summary {
  cursor: pointer;
  list-style: none;
  padding: 6px;
}
.routine-menu summary::-webkit-details-marker {
  display: none;
}
.routine-menu > div {
  position: absolute;
  z-index: 3;
  right: 0;
  top: 28px;
  min-width: 120px;
  background: var(--dialog-bg);
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 8px 30px #0004;
}
.routine-menu button {
  background: none;
  color: var(--text);
  border: 0;
  display: block;
  padding: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}
.routine-menu button:hover {
  background: var(--hover);
}
.routine-tests {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 8px;
}
.routine-card.is-off .routine-time {
  color: var(--muted);
}
.empty {
  line-height: 1.8;
  padding: 45px 10px;
  font-size: 13px;
}
.dialog {
  border: 1px solid var(--card-border);
}
.studio-dialog {
  width: min(600px, calc(100% - 32px));
  padding: 30px;
  max-height: 85dvh;
  overflow: auto;
  border-radius: 24px;
}
.dialog-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}
.dialog-top h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.6px;
  margin: 0;
  flex: 1;
}
.icon-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.icon-close:hover {
  background: var(--hover);
}
.dialog-top .chip {
  min-width: 96px;
}
dialog::backdrop {
  background: #040611a8;
  backdrop-filter: blur(8px);
}
.setting-group {
  padding: 20px 0;
  border-top: 1px solid var(--card-border);
}
.setting-group h3 {
  font-size: 13px;
  font-weight: 500;
  margin: 0 0 14px;
}
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice {
  flex: 1;
  min-width: 38px;
  min-height: 44px;
  padding: 10px 7px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.choice[aria-pressed="true"] {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--on-accent);
}
.studio-dialog > .primary {
  margin-top: 20px;
}
.sound-option,
.sound-action {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--card-border);
  padding: 16px 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.sound-option[aria-pressed="true"] {
  color: var(--accent-2);
}
.sound-option:hover {
  background: var(--hover);
}
.sound-action {
  color: var(--accent);
}
.sound-check {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 10px;
}
.mission-dialog {
  width: min(600px, calc(100% - 32px));
  max-height: 92dvh;
  padding: 30px;
  border-radius: 24px;
  overflow: auto;
}
.mission-dialog .dialog-top {
  position: sticky;
  top: -30px;
  background: var(--dialog-bg);
  padding-top: 8px;
  padding-bottom: 8px;
  z-index: 5;
}
.mission-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 24px;
}
#missionBody {
  text-align: center;
}
#missionBody h3 {
  font-size: 20px;
  font-weight: 500;
}
#missionBody .text-input {
  text-align: center;
  min-height: 58px;
  margin: 20px 0;
  font-size: 24px;
}
#missionBody .problem {
  font-size: 64px;
  font-weight: 300;
}
.mission-complete {
  font-size: 35px;
  font-weight: 300;
  padding: 50px 0;
}
.stroop-stage {
  display: grid;
  place-items: center;
  min-height: 140px;
  padding: 24px 16px;
  border: 1px solid #ffffff24;
  border-radius: 16px;
  background: #10131b;
}
.stroop-word {
  font-size: clamp(36px, 9vw, 68px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
}
.stroop-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.stroop-choice {
  min-height: 60px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #ffffff30;
  border-radius: 14px;
  background: var(--stroop-fill);
  color: var(--stroop-text);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}
.stroop-choice:hover {
  filter: brightness(1.12);
}
#missionHint {
  color: var(--accent-2);
  font-size: 12px;
  text-align: center;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  gap: 4px;
  max-width: 420px;
  margin: 20px auto;
}
.mine-cell {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent-2) 12%, var(--field));
  color: var(--text);
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
}
.mine-cell.revealed {
  border-color: var(--card-border);
  background: var(--field);
}
.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.sudoku-board {
  gap: 0;
  background: var(--card);
  border: 1px solid var(--muted);
}
.sudoku-cell {
  aspect-ratio: 1;
  background: var(--field);
  border: 1px solid var(--card-border);
  color: var(--accent);
  font-size: 24px;
  cursor: pointer;
}
.sudoku-cell:disabled {
  opacity: 1;
  color: var(--text);
  font-weight: 600;
  cursor: default;
}
.sudoku-cell.selected {
  background: color-mix(in srgb, var(--accent-2) 25%, var(--field));
}
.sudoku-cell.conflict {
  color: var(--danger);
}
.puzzle-board,
.puzzle-tray {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  width: 100%;
  margin: 24px auto;
}
.puzzle-board {
  background: var(--field);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1.8;
}
.puzzle-slot,
.puzzle-piece {
  background: transparent;
  border: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  cursor: pointer;
}
.puzzle-tray {
  gap: 10px;
}
.puzzle-piece {
  aspect-ratio: 1.25;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
}
.puzzle-piece.picked {
  border-color: var(--accent);
}
.puzzle-slot:not(.placed):hover {
  background: var(--hover);
}
:root[data-theme="midnight-cherry"] .routine-card,
:root[data-theme="midnight-cherry"] .sudoku-board {
  --text: #341522;
  --muted: #765260;
  --accent: #305d86;
  --accent-2: #a9384b;
  --field: #00000008;
  --card-border: #34152220;
  background: #fff3f6;
}
:root[data-theme="cobalt-coral"] .day-dot.chosen {
  color: var(--accent-2);
  border-color: var(--accent-2);
}
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  html:not(.clock-focus),
  html:not(.clock-focus) body {
    height: 100%;
    overflow: hidden;
  }
  html:not(.clock-focus) .app {
    display: grid;
    max-width: 2100px;
    width: 100%;
    height: 100dvh;
    grid-template-columns: minmax(260px, 0.85fr) minmax(430px, 1.4fr) 64px;
    grid-template-rows: 40px minmax(0, 1fr) auto auto;
    gap: 24px;
    padding: 24px 32px;
    transition: grid-template-columns 0.3s;
  }
  html:not(.clock-focus) .app.alarms-open {
    grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.3fr) minmax(
        250px,
        0.8fr
      );
  }
  .app > .clock-card {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 14px 0;
  }
  .clock-face {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .clock-hm {
    font-size: clamp(75px, 10vw, 190px);
    letter-spacing: -0.075em;
  }
  .clock-top {
    margin: 0;
    gap: 8px;
    flex-wrap: wrap;
  }
  .clock-top .badge {
    font-size: 10px;
  }
  .clock-top .clock-buttons {
    gap: 5px;
  }
  .clock-buttons .chip {
    padding: 9px 12px;
    font-size: 11px;
  }
  html:not(.clock-focus) #setupCard {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 28px;
    border-radius: 24px;
    overflow: hidden;
  }
  .setup-fields {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
  }
  .sound-tests {
    display: grid !important;
    grid-template-columns: 1fr 1.1fr;
    gap: 24px;
  }
  .sound-settings,
  .wake-settings {
    display: block;
    min-width: 0;
  }
  .wake-settings {
    border-left: 1px solid var(--card-border);
    padding-left: 20px;
  }
  .app #setupCard .field-label {
    font-size: 10px;
    letter-spacing: 0.09em;
  }
  .app #setupCard #panelTime > .field-label,
  .app #setupCard #panelTimer > .field-label {
    margin-top: 26px;
  }
  .custom-time-picker:not([hidden]) {
    min-height: 124px;
  }
  .app #setupCard #panelTimer .timer-row {
    min-height: 124px;
  }
  .app #setupCard .time-number {
    font-size: 38px;
  }
  html:not(.clock-focus) #alarmsCard {
    grid-column: 3;
    grid-row: 2;
    min-height: 0;
    padding: 0;
    overflow: visible;
    border-radius: 24px;
  }
  .app.alarms-open #alarmsCard {
    padding: 24px 18px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .app.alarms-open .alarms-panel {
    overflow: visible;
    flex: initial;
  }
  .alarms-header {
    margin-bottom: 12px;
  }
  .app.alarms-open #alarmsHeading {
    font-size: 17px;
  }
  .sidebar-label {
    font-size: 11px;
  }
  .app .browser-tools {
    grid-column: 1/-1;
    grid-row: 3;
    margin: 0;
  }
  .browser-notice {
    font-size: 11px;
    text-align: center;
    max-width: none;
    margin: 0;
  }
  #footnote {
    grid-row: 4;
    grid-column: 1/-1;
    margin: 0;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
  }
}
@media (max-width: 999px) {
  html:not(.clock-focus) .app {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
    max-width: 760px;
  }
  .studio-brand {
    margin-bottom: 12px;
  }
  .brand-caption {
    display: none;
  }
  .clock-hm {
    font-size: clamp(90px, 20vw, 170px);
  }
  #setupCard,
  #alarmsCard {
    padding: 24px;
  }
  .sound-tests {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
  }
  .sound-settings,
  .wake-settings {
    display: block;
  }
  .wake-settings {
    padding: 0;
    border: 0;
  }
  .clock-top {
    margin-top: 14px;
  }
  .alarms-panel {
    display: block !important;
  }
  .sidebar-toggle {
    display: none;
  }
  .studio-brand #focusClock {
    font-size: 11px;
  }
}
@media (max-width: 560px) {
  .sound-tests {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .test-tiles {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .test-tile {
    font-size: 9px;
    min-height: 86px;
    gap: 12px;
  }
  .test-tile > span {
    font-size: 24px;
  }
  .dialog-top {
    gap: 8px;
  }
  .dialog-top h2 {
    font-size: 18px;
  }
  .studio-dialog,
  .mission-dialog {
    padding: 22px;
  }
  .brand-caption {
    display: none;
  }
  .choice-row {
    gap: 5px;
  }
  .choice {
    font-size: 12px;
    min-width: 32px;
  }
  .mission-dialog .dialog-top {
    top: -22px;
  }
  .mission-dialog .problem {
    font-size: 48px !important;
  }
  .day-choice {
    height: 36px;
  }
  .sound-tests {
    display: flex !important;
    flex-direction: column;
  }
  .setting-group {
    padding: 16px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}

.clock-hm {
  font-family: "Wake Clock", sans-serif;
  font-weight: 200;
}
.editor-meta {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  align-items: end;
}
.editor-meta .field-label {
  margin-top: 0 !important;
}
.editor-meta .repeat-caption {
  margin: 0;
  min-height: 14px;
}
.editor-meta .weekday-row {
  margin-top: 11px;
}
.editor-meta:has(#repeatControls[hidden]) {
  grid-template-columns: 1fr;
}
.editor-meta .text-input {
  display: block;
  height: 44px;
  font-size: 13px;
}
.create-switch {
  margin-bottom: 22px;
}
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  .app > .clock-card {
    container-type: inline-size;
  }
  .clock-hm {
    font-size: clamp(64px, 31cqi, 190px);
  }
  .editor-meta .day-choice {
    height: 30px;
    font-size: 11px;
  }
  .editor-meta .weekday-row {
    gap: 4px;
  }
  .editor-meta .day-choice {
    min-width: 0;
  }
  .app #setupCard .sound-tests {
    margin-top: 26px !important;
  }
  .editor-heading {
    margin-bottom: 20px;
  }
}
@media (max-width: 560px) {
  .editor-meta {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  html.clock-focus .clock-hm {
    font-size: clamp(64px, 31cqi, 170px);
  }
  .clock-side {
    font-size: 16px;
  }
  html.clock-focus .clock-face {
    padding-inline: 0;
  }
  .brand-caption {
    display: none;
  }
}

/* Keep weekday selection on one line, even in the smallest supported window. */
.routine-footer > span {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.day-dot {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.editor-heading .card-title {
  color: var(--text);
}
.jigsaw-shape {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 0.5;
  stroke-opacity: 0.45;
}
.puzzle-slot {
  position: relative;
  overflow: visible;
}
.puzzle-slot.placed {
  z-index: 1;
}
:root[data-theme="nord"] {
  --glow-a: #88c0d022;
  --glow-b: #b48ead18;
}
@media (max-width: 560px) {
  .test-tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .test-tile {
    font-size: 11px;
  }
  .day-dot {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }
}
.puzzle-piece {
  aspect-ratio: calc(3.6 / var(--cols));
}

/* Dialogs use desktop space too; phone widths remain bounded by the viewport. */
.studio-dialog,
.mission-dialog {
  max-width: min(600px, calc(100vw - 32px));
}
#themeDialog {
  width: min(680px, calc(100vw - 32px));
  max-width: 680px;
  max-height: 85dvh;
  overflow: auto;
  border-radius: 24px;
}
@media (min-width: 600px) {
  #themeDialog .theme-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* A narrow editor stacks its settings without shrinking test names. */
@container alarm-setup (max-width:540px) {
  .app #setupCard .sound-tests {
    grid-template-columns: 1fr;
  }
  .app #setupCard .wake-settings {
    border-left: 0;
    border-top: 1px solid var(--card-border);
    padding-left: 0;
    padding-top: 20px;
  }
}

/* Clock navigation: plain iOS-style chevrons and a generous click target. */
#alarmPickerText {
  display: none;
}
#clockAlarmsToggle,
.sidebar-label,
#alarmsToggle {
  display: none !important;
}
.clock-actions,
html.clock-focus .clock-actions {
  width: 100%;
  min-height: 84px;
  margin-top: 8px;
  cursor: pointer;
}
.clock-picker-toggle,
html.clock-focus .clock-picker-toggle {
  display: grid;
  place-items: center;
  width: 64px;
  height: 56px;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.clock-picker-toggle:hover,
html.clock-focus .clock-picker-toggle:hover {
  color: var(--text);
  background: transparent;
  transform: translateY(2px);
}
#alarmPickerIcon {
  display: flex;
}
.clock-top {
  justify-content: flex-end;
}
.studio-brand {
  gap: 0;
}
.editor-heading {
  margin-bottom: 18px;
}

/* The selected underlined tabs retain clear keyboard focus, without pills. */
.create-switch {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 24px;
}
.create-switch button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 4px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.create-switch svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.create-switch [aria-pressed="true"] {
  background: transparent;
  color: var(--text);
}
.create-switch [aria-pressed="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-2);
  border-radius: 2px;
}
.create-switch [aria-pressed="true"] svg {
  color: var(--accent-2);
}

/* Base weekday layout, extended by the native boxed treatment below. */
.editor-meta .weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  max-width: 294px;
  margin-top: 10px;
  align-items: center;
  justify-items: center;
}
.editor-meta .day-choice {
  display: grid;
  place-items: center;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  max-width: 34px;
  min-width: 0;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: "Wake Clock", var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}
.editor-meta .day-choice[aria-pressed="true"] {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
}
.editor-meta .day-choice:hover {
  background: var(--hover);
  color: var(--text);
}

.volume-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.volume-preview {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.volume-preview svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.volume-preview:hover,
.volume-preview[aria-pressed="true"] {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

/* Upcoming items remain text, with no card, border or filled background. */
.focus-agenda {
  align-self: center;
  width: 100%;
  max-height: 65dvh;
  overflow: auto;
  scrollbar-width: thin;
  padding: 12px 4px;
}
.focus-agenda h2 {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  margin: 0 0 16px;
}
.focus-agenda section + section {
  margin-top: 34px;
}
.agenda-item {
  display: flex;
  align-items: baseline;
  gap: 20px;
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.agenda-time {
  font-family: "Wake Clock", var(--font);
  font-size: 24px;
  font-weight: 300;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.agenda-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
}
.agenda-info > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-info small {
  color: var(--muted);
  font-size: 11px;
}
.agenda-item:hover .agenda-time {
  color: var(--accent-2);
}
html:not(.clock-focus) .focus-agenda {
  display: none;
}

/* Let the original View Transition do all the moving, with no competing
   grid tween or reveal transform changing geometry during its snapshots. */
.app.picker-open #setupCard,
.app.picker-open #alarmsCard {
  animation: none;
}
html:not(.clock-focus) .app {
  transition: none;
  grid-template-areas: none;
}
.clock-face {
  view-transition-name: none;
}
.clock-hm {
  view-transition-name: clock-digits;
}
.clock-side {
  view-transition-name: clock-seconds;
}
#dateText {
  view-transition-name: clock-date;
}
#zoneText {
  view-transition-name: clock-zone;
}
.clock-actions {
  view-transition-name: clock-navigation;
}
::view-transition-group(clock-digits),
::view-transition-group(clock-seconds),
::view-transition-group(clock-date),
::view-transition-group(clock-zone),
::view-transition-group(clock-navigation),
::view-transition-group(clock-toolbar) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}
::view-transition-old(clock-digits),
::view-transition-new(clock-digits),
::view-transition-old(clock-seconds),
::view-transition-new(clock-seconds) {
  height: 100%;
  width: 100%;
  object-fit: fill;
  mix-blend-mode: normal;
}
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  html:not(.clock-focus) .app {
    grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.3fr) minmax(
        250px,
        0.8fr
      );
  }
  .studio-brand {
    grid-row: 1;
  }
}
@media (min-width: 1100px) {
  html.clock-focus .app:has(#focusAgenda:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    grid-template-rows: 40px minmax(0, 1fr) auto;
    grid-template-areas: none;
    column-gap: clamp(32px, 5vw, 100px);
    max-width: 1900px;
  }
  html.clock-focus .app:has(#focusAgenda:not([hidden])) .studio-brand {
    grid-column: 1/-1;
    grid-row: 1;
    max-width: none;
  }
  html.clock-focus .app:has(#focusAgenda:not([hidden])) .clock-card {
    grid-column: 1;
    grid-row: 2;
    height: 100%;
    padding: 0;
  }
  html.clock-focus .app:has(#focusAgenda:not([hidden])) #focusAgenda {
    grid-column: 2;
    grid-row: 2;
  }
  html.clock-focus .app:has(#focusAgenda:not([hidden])) #footnote {
    grid-column: 1/-1;
    grid-row: 3;
  }
}
@media (max-width: 1099px) {
  html.clock-focus .focus-agenda {
    width: min(390px, 100%);
    max-height: 24dvh;
    margin: 0 auto;
    padding: 8px 12px;
  }
  html.clock-focus .focus-agenda h2 {
    margin-bottom: 4px;
  }
  html.clock-focus .focus-agenda section + section {
    margin-top: 14px;
  }
  .agenda-item {
    padding: 7px 0;
  }
  .agenda-time {
    font-size: 20px;
  }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-duration: 0s !important;
  }
}
/* Snapshot only each small control, rather than scaling its empty hit area. */
.clock-top,
.clock-actions {
  view-transition-name: none;
}
.clock-buttons {
  view-transition-name: clock-toolbar;
}
.clock-picker-toggle {
  view-transition-name: clock-navigation;
}
/* Shared text columns keep names aligned across both upcoming sections. */
.focus-agenda {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 20px;
}
.focus-agenda section {
  display: grid;
  grid-column: 1/-1;
  grid-template-columns: subgrid;
}
.focus-agenda h2 {
  grid-column: 1/-1;
}
.agenda-item {
  display: grid;
  grid-column: 1/-1;
  grid-template-columns: subgrid;
}

/* Move the clock first, then reveal the editor behind its settled position.
   This avoids the large digits crossing freshly visible form controls. */
.studio-brand {
  view-transition-name: clock-brand;
}
::view-transition-group(clock-brand) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}
::view-transition-old(root),
::view-transition-old(clock-navigation) {
  animation: clock-scene-out 0.12s ease-out both;
  mix-blend-mode: normal;
}
::view-transition-new(root),
::view-transition-new(clock-navigation) {
  animation: clock-scene-in 0.16s ease-out 0.2s both;
  mix-blend-mode: normal;
}
@keyframes clock-scene-out {
  to {
    opacity: 0;
  }
}
@keyframes clock-scene-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
html.clock-focus .studio-brand {
  order: 0;
}
html.clock-focus .clock-card {
  order: 1;
}
html.clock-focus .focus-agenda {
  order: 2;
}
html.clock-focus #footnote {
  order: 3;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}

/* Remove the duplicate visual heading; keep the editor labelled for assistive tech. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#cancelEdit {
  margin-left: auto;
  padding: 8px 12px;
  min-height: 36px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  font-size: 12px;
}
#cancelEdit::after {
  display: none;
}
.sound-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.sound-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sound-select > svg {
  flex: none;
  color: var(--muted);
}

/* Repeat controls match the iOS editor: dark unset boxes, filled selected boxes. */
.editor-meta .weekday-row {
  max-width: none;
  gap: 6px;
  justify-items: stretch;
}
.editor-meta .day-choice {
  max-width: none;
  height: 44px;
  aspect-ratio: auto;
  border-radius: 12px;
  background: var(--field);
  color: var(--muted);
  font-size: 14px;
  border-color: var(--card-border);
}
.editor-meta .day-choice[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.editor-meta .day-choice[aria-pressed="false"]:hover {
  background: var(--hover);
  color: var(--text);
}
.daily-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}
.daily-toggle input {
  margin: 0;
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
}
@container alarm-setup (max-width:650px) {
  .editor-meta {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* A top-layer menu can escape the schedule's scroll container. */
.routine-menu-trigger {
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.routine-menu-trigger:hover {
  background: var(--hover);
  color: var(--text);
}
.routine-actions {
  display: none;
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 156px;
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 17px;
  background: var(--dialog-bg);
  color: var(--text);
  box-shadow: 0 12px 35px #0004;
  z-index: 1000;
}
.routine-actions:popover-open {
  display: block;
}
.routine-actions[data-open="true"] {
  display: block;
}
.routine-actions > button {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.routine-actions > button:hover {
  background: var(--hover);
}
.routine-actions > button[data-action="delete"] {
  color: var(--accent-2);
}

/* Mobile palette and corner origins, with desktop-sized glow falloff. */
body {
  background-image:
    radial-gradient(
      circle max(280px, min(100vmin, 560px)) at 100% 100%,
      var(--ambient-b),
      transparent
    ),
    radial-gradient(
      circle max(300px, min(100vmin, 560px)) at 0 0,
      var(--ambient-a),
      transparent
    );
}
:root[data-theme="oled"] body,
:root[data-theme="dark"] body {
  background-image: none;
}
:root[data-theme="midnight-cherry"] .routine-card,
:root[data-theme="midnight-cherry"] .sudoku-board {
  --text: #351624;
  --muted: #735567;
  --accent: #91445e;
  --accent-2: #b23d61;
  --field: rgba(0, 0, 0, 0.045);
  --card-border: #3516241a;
  background: #fff8fa;
}
.day-dot.chosen {
  color: var(--day-accent, var(--accent));
  border-color: var(--day-accent, var(--accent));
}

/* Cancel belongs to the save action, rather than the mode-selection tabs. */
.editor-action-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}
.editor-action-row:has(#cancelEdit[hidden]) {
  grid-template-columns: 1fr;
}
.editor-action-row #cancelEdit {
  width: 100%;
  height: 50px;
  min-height: 50px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  font: 500 14px var(--font);
  cursor: pointer;
}
.editor-action-row #cancelEdit:hover {
  background: var(--hover);
  border-color: var(--muted);
}
.editor-action-row .primary {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border-radius: 14px;
}

/* Font files are local; selecting a face changes only the live clock digits. */
@font-face {
  font-family: "Clock Rounded";
  src: url("fonts/quicksand-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Clock Mono";
  src: url("fonts/jetbrains-mono-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  size-adjust: 88%;
}
@font-face {
  font-family: "Clock Digital";
  src: url("fonts/dseg7-classic-light.woff2") format("woff2");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  size-adjust: 80%;
}
:root {
  --clock-font-family: "Wake Clock", sans-serif;
  --clock-font-weight: 200;
}
:root[data-clock-font="rounded"] {
  --clock-font-family: "Clock Rounded", sans-serif;
  --clock-font-weight: 300;
}
:root[data-clock-font="mono"] {
  --clock-font-family: "Clock Mono", monospace;
  --clock-font-weight: 300;
}
:root[data-clock-font="serif"] {
  --clock-font-family: Georgia, "Times New Roman", serif;
  --clock-font-weight: 400;
}
:root[data-clock-font="digital"] {
  --clock-font-family: "Clock Digital", monospace;
  --clock-font-weight: 300;
}
.clock-hm {
  font-family: var(--clock-font-family);
  font-weight: var(--clock-font-weight);
}
.clock-font-group {
  margin: 22px 0 24px;
  padding: 16px 0;
  border-block: 1px solid var(--card-border);
}
.clock-font-group summary {
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  font-size: 14px;
  cursor: pointer;
}
.clock-font-group summary::-webkit-details-marker {
  display: none;
}
#currentClockFont {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.clock-font-group summary svg {
  color: var(--muted);
  transition: transform 0.18s;
}
.clock-font-group[open] summary svg {
  transform: rotate(180deg);
}
.clock-font-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.clock-font-option {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 15px 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.clock-font-option[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 8%, var(--field));
}
.clock-font-sample {
  font-size: 28px;
  line-height: 1.4;
  white-space: nowrap;
}
.clock-font-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: 500 12px var(--font);
}
.clock-font-label small {
  color: var(--muted);
  font-weight: 400;
  font-size: 10px;
}
.theme-section-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
#clockFontStatus:empty {
  display: none;
}
#clockFontStatus {
  margin: 14px 0 0;
  font-size: 12px;
}
@media (max-width: 420px) {
  .editor-action-row {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
  }
  .editor-action-row .primary {
    font-size: 14px;
  }
  .clock-font-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .clock-font-label {
    flex-wrap: wrap;
  }
}

/* Time-led saved cards: one time display, compact metadata, separate controls. */
.routine-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 12px;
  align-items: stretch;
  min-height: 88px;
  padding: 12px 14px;
  container: saved-routine / inline-size;
}
.routine-edit {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 0;
}
.routine-time {
  white-space: nowrap;
  line-height: 1.15;
}
.routine-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  padding-left: 12px;
  border-left: 1px solid var(--card-border);
}
.routine-name {
  font-size: 12px;
  line-height: 1.35;
}
.routine-repeat {
  display: flex;
  align-items: center;
  gap: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.routine-repeat .day-dot {
  width: 16px;
  height: 16px;
  font-size: 9px;
}
.routine-copy .routine-tests {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.routine-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 60px;
}
.routine-card.is-timer .routine-controls {
  justify-content: center;
}
@container saved-routine (max-width:300px) {
  .routine-edit {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 5px;
  }
  .routine-copy {
    border-left: 0;
    padding-left: 0;
    min-height: 0;
    gap: 3px;
  }
  .routine-time {
    font-size: clamp(18px, 8cqi, 30px);
    letter-spacing: -0.6px;
  }
}
