:root {
  color-scheme: dark;
  font-family: Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans CJK KR", system-ui, sans-serif;
  font-synthesis: none;
  --text: #f5f5f5;
  --muted: #b8c1ca;
  --line: #3b454f;
  --mint: #83e8cf;
  --blue: #83c7f5;
  --lilac: #c49af1;
  --page-space: clamp(16px, 1.65vw, 68px);
  --header-size: clamp(77px, 10.7vh, 225px);
  --toolbar-size: clamp(43px, 6.3vh, 128px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 15% -28%, #303b45 0%, transparent 52%),
    radial-gradient(ellipse at 100% 115%, #202b35 0%, transparent 52%),
    #14181e;
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent, var(--mint));
  outline-offset: 3px;
}

.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  display: block;
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: var(--header-size) 1fr;
  padding: 0 var(--page-space) var(--page-space);
}

.topbar, .brand, .brand-text, .toolbar { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 12px; padding-inline: clamp(0px, 1.05vw, 46px); }
.brand { gap: clamp(10px, 1.45vw, 54px); min-width: 0; }
.brand-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--toolbar-size);
  aspect-ratio: 1;
  border: 1px solid #80b9b231;
  border-radius: 27%;
  background: linear-gradient(175deg, #53777b, #294148 66%, #2a4146);
  box-shadow: inset 0 1px 0 #bdf9ef47, inset 0 -5px 12px #84e5cf0b;
  color: #c6f7ee;
  font-size: calc(var(--toolbar-size) * .64);
}
.brand-text { gap: clamp(12px, 1.65vw, 64px); min-width: 0; }
h1, h2, h3, p { margin: 0; }
h1 {
  color: #f4f6f7;
  font-family: "Segoe UI", Arial, system-ui, sans-serif;
  font-size: clamp(1.25rem, 2.42vw, 6rem);
  font-weight: 800;
  letter-spacing: -.045em;
  white-space: nowrap;
}
.brand-subtitle {
  border-left: 1px solid #56616a;
  padding-left: clamp(12px, 1.65vw, 64px);
  color: var(--muted);
  font-size: clamp(.875rem, 1.45vw, 3.6rem);
  white-space: nowrap;
}
.toolbar { gap: clamp(8px, 1.25vw, 46px); }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  transition: filter 150ms ease, background-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}
.button {
  border: 1px solid #8793a64d;
  border-radius: clamp(12px, 1.12vw, 42px);
  background: linear-gradient(180deg, #4a535e, #303841 58%, #333d47);
  box-shadow: inset 0 1px 0 #e1e9ff26, inset 0 -4px 12px #c3d4f20b, 0 3px 7px #0002;
  font-weight: 680;
  white-space: nowrap;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { filter: brightness(1.16); }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled, .icon-button:disabled { opacity: .43; }
.toolbar .button, .button-restore {
  height: var(--toolbar-size);
  font-size: clamp(.875rem, 1.32vw, 3.25rem);
}
.toolbar .icon-button { width: var(--toolbar-size); font-size: calc(var(--toolbar-size) * .56); }
.button-add, .button-restore {
  padding-inline: clamp(12px, 1.55vw, 60px);
  border-color: #75cabc48;
  background: linear-gradient(180deg, #3d5d61, #2b4348 65%, #2f4b4e);
  color: #edf9f7;
}
.button-add .icon, .button-restore .icon { color: #baf2e5; font-size: 1.18em; }
.button-restore { opacity: .32; }
.button-restore:hover, .button-restore:focus-visible, .app[data-controls-awake] .button-restore { opacity: 1; }
.app[data-mode="display"] .controls-only { display: none; }

.board {
  display: grid;
  grid-template-columns: repeat(var(--count, 1), minmax(0, 1fr));
  gap: clamp(12px, 1.18vw, 46px);
  min-width: 0;
  min-height: 0;
}
.board-empty {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 2rem);
}

.exam-card {
  --accent: var(--mint);
  --number-size: min(20cqi, 18.25vh);
  position: relative;
  container-type: inline-size;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, #35404b);
  border-top: 0;
  border-radius: clamp(22px, 1.9vw, 75px);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 14%, #212934), transparent 19%),
    radial-gradient(ellipse at 50% 104%, color-mix(in srgb, var(--accent) 6%, #222a33), transparent 66%),
    linear-gradient(130deg, #222a33, #1b222a 58%, #202830);
  box-shadow: inset 0 0 0 1px #eef7ff06, inset 0 -9px 30px #b0d3f309, 0 6px 16px #080d131c;
}
.exam-card::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: clamp(7px, 1.2vh, 25px);
  border-top: 1px solid color-mix(in srgb, var(--accent) 66%, white);
  border-radius: inherit;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, white), color-mix(in srgb, var(--accent) 82%, #28434b));
  box-shadow: 0 2px 14px color-mix(in srgb, var(--accent) 19%, transparent);
  pointer-events: none;
}
.exam-card[data-color="blue"] { --accent: var(--blue); }
.exam-card[data-color="lilac"] { --accent: var(--lilac); }
.board[data-count="2"] .exam-card { --number-size: min(19.25cqi, 14.7vh); }
.board[data-count="3"] .exam-card { --number-size: min(18.7cqi, 11.05vh); }

.exam-inner {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(9px, 1.5vh, 31px);
  padding: clamp(24px, 4.15vh, 89px) clamp(16px, 5.9cqi, 76px) clamp(19px, 4.1vh, 89px);
}
.exam-header, .exam-meta {
  display: flex;
  align-items: center;
  min-width: 0;
}
.exam-header { justify-content: space-between; gap: clamp(7px, 1.5cqi, 32px); }
.exam-meta { flex: none; gap: clamp(5px, 1.15cqi, 24px); }
.exam-title {
  min-width: 0;
  font-size: clamp(1.1rem, 6.5cqi, 4.25vh);
  font-weight: 790;
  letter-spacing: -.045em;
  line-height: 1.25;
}
.editable {
  display: block;
  margin: 0;
  border: 0;
  padding: 0;
  border-radius: .18em;
  background: transparent;
  text-align: inherit;
  box-shadow: 0 0 0 0 transparent;
  transition: background-color 130ms ease, box-shadow 130ms ease;
}
.app[data-mode="control"] .editable:hover {
  background-color: color-mix(in srgb, var(--accent) 8%, transparent);
  box-shadow: 0 0 0 .16em color-mix(in srgb, var(--accent) 8%, transparent);
}
.app[data-mode="display"] .editable { cursor: default; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; font: inherit; letter-spacing: inherit; }
.total, .timer-number {
  font-family: "Segoe UI", Arial, system-ui, sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}
.total {
  display: flex;
  align-items: center;
  gap: .34em;
  border-left: 1px solid var(--line);
  padding-left: clamp(6px, 2.05cqi, 40px);
  color: var(--muted);
  font-size: clamp(.9rem, 4.7cqi, 3.15vh);
  font-weight: 570;
  line-height: 1.1;
}
.total .icon { font-size: 1.12em; }
.icon-button:not(.button) {
  flex: none;
  width: 2em;
  height: 2em;
  padding: 0;
  border: 1px solid transparent;
  border-radius: .64em;
  background: transparent;
  color: var(--muted);
}
.icon-button:not(.button):hover:not(:disabled) { background: #e7f2ff12; color: var(--text); }
.card-menu { font-size: clamp(.875rem, 3.3cqi, 2.3vh); }
.progress {
  height: clamp(7px, 1.85vh, 40px);
  flex: none;
  margin-top: clamp(0px, .5vh, 12px);
  overflow: hidden;
  border-radius: 100vw;
  background: #414a54;
  box-shadow: inset 0 1px 2px #10172138;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 87%, white), color-mix(in srgb, var(--accent) 85%, #394e61));
  box-shadow: inset 0 1px 0 #fff3;
  transition: width 230ms linear;
}

.readouts {
  flex: 1 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: clamp(6px, .7vh, 17px);
  text-align: center;
}
.readout { min-width: 0; }
.readout-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .66em;
  margin-bottom: clamp(3px, .6vh, 13px);
  color: var(--muted);
  font-size: clamp(.95rem, 4.45cqi, 2.85vh);
  font-weight: 560;
  line-height: 1.2;
}
.timer-number {
  display: inline-block;
  vertical-align: top;
  font-weight: 800;
  font-size: var(--number-size);
  letter-spacing: -.047em;
  line-height: .99;
}
.timer-number.remaining { color: var(--accent); }
.timer-number.elapsed { font-size: calc(var(--number-size) * .78); }
.finished {
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 100vw;
  padding: .24em .56em;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: .65em;
  line-height: 1;
  white-space: nowrap;
}

.checkpoints {
  flex: 0 1 clamp(100px, 21vh, 445px);
  min-height: clamp(69px, 10vh, 170px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, .85vh, 20px);
  border-top: 1px solid #54616d;
  padding-top: clamp(8px, 1.55vh, 34px);
}
.checkpoint-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.checkpoint-title {
  display: inline-flex;
  align-items: center;
  gap: .46em;
  width: fit-content;
  border-radius: 100vw;
  padding: .23em .72em .23em .37em;
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  color: var(--accent);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: clamp(.8rem, 4.2cqi, 2.44vh);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.022em;
  white-space: nowrap;
}
.check-symbol {
  display: grid;
  place-items: center;
  width: 1.34em;
  height: 1.34em;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 66%, #253342);
  color: #15262c;
}
.check-symbol .icon { width: .87em; height: .87em; stroke-width: 3; }
.checkpoint-edit { font-size: clamp(.875rem, 3.35cqi, 2.4vh); }
.checkpoint-list {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #5a6875 transparent;
  margin: 0;
  padding: 2px 4px 2px .25em;
  list-style: none;
  font-size: clamp(.91rem, 4.05cqi, 2.53vh);
  line-height: 1.42;
}
.checkpoint-list li {
  display: grid;
  grid-template-columns: .86em minmax(0, 1fr);
  gap: .7em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.checkpoint-list li + li { margin-top: .25em; }
.checkpoint-list li::before {
  content: "";
  width: .81em;
  height: .81em;
  margin-top: .3em;
  border: .105em solid var(--accent);
  border-radius: .18em;
}
.checkpoint-empty {
  align-self: flex-start;
  margin-left: .18em;
  color: var(--muted);
  font-size: clamp(.875rem, 3.6cqi, 2.15vh);
  line-height: 1.4;
}

.exam-actions { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr); gap: clamp(10px, 4.5cqi, 36px); }
.exam-actions .button {
  min-height: clamp(48px, 8.6vh, 187px);
  border-radius: clamp(15px, 2.5vh, 54px);
  font-size: clamp(1rem, 4.15cqi, 2.75vh);
}
.exam-actions .icon { font-size: 1.42em; }
.button-primary {
  border-color: color-mix(in srgb, var(--accent) 56%, #46545d);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 68%, #324750), color-mix(in srgb, var(--accent) 42%, #183439) 61%, color-mix(in srgb, var(--accent) 36%, #273a42));
  color: #fff;
  text-shadow: 0 1px 2px #13232d55;
}
.button-reset .icon { font-size: 1.62em; }

.dialog {
  --accent: var(--mint);
  width: min(540px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  max-height: calc(100dvh - 24px);
  padding: clamp(18px, 4vw, 30px);
  overflow: auto;
  border: 1px solid #52616b;
  border-radius: 22px;
  background: linear-gradient(150deg, #27323b, #1b232b 70%);
  box-shadow: 0 18px 65px #060a1080, inset 0 1px 0 #eff7ff12;
  color: var(--text);
}
.dialog::backdrop { background: #080d13a8; }
.dialog[data-color="blue"] { --accent: var(--blue); }
.dialog[data-color="lilac"] { --accent: var(--lilac); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-header h2 { font-size: 1.27rem; line-height: 1.3; }
.dialog .icon-button { font-size: 1.35rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog .button { min-height: 43px; padding: 0 15px; border-radius: 11px; font-size: .94rem; }
.button-apply {
  border-color: color-mix(in srgb, var(--accent) 65%, #4c5d62);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  color: #17272c;
}
.dialog .danger { border-color: #c67f86; background: #652f38; color: #fff0f2; }
.dialog p, .settings-detail { color: var(--muted); font-size: .94rem; line-height: 1.55; }
.dialog .form-error { margin-top: 12px; color: #ffadad; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.field input, .checkpoint-row textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #53616e;
  border-radius: 9px;
  padding: 9px 10px;
  background: #141c23;
  color: var(--text);
  font-size: 1rem;
}
.time-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.time-fields input { text-align: center; font-variant-numeric: tabular-nums; }
.settings-list { display: grid; gap: 13px; }
.settings-option, .option-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid #46535f;
  border-radius: 11px;
  background: #182129;
  text-align: left;
  font-size: .96rem;
}
.option-button:hover { background: #2d3944; }
.option-button.danger-option { color: #ffb5bc; }
.settings-option input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.settings-detail { margin-top: -7px; padding-inline: 3px; }
.checkpoint-editor-list {
  display: grid;
  gap: 9px;
  max-height: min(46vh, 380px);
  overflow: auto;
  padding: 4px;
  margin: 9px -4px 12px;
}
.checkpoint-editor-list:empty { margin: 0 0 12px; padding: 0; }
.checkpoint-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px; }
.checkpoint-row label { display: block; padding: 3px; }
.checkpoint-row textarea { display: block; min-height: 60px; resize: vertical; }
.checkpoint-row-buttons { display: flex; gap: 0; }
.checkpoint-row-buttons .icon-button { width: 34px; }
.notice {
  position: fixed;
  z-index: 5;
  bottom: 20px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  border: 1px solid #576773;
  border-radius: 12px;
  padding: 12px 17px;
  background: #26323d;
  color: var(--text);
  font-size: .92rem;
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 761px) and (min-height: 620px) {
  .app { height: 100svh; }
}

@media (max-width: 1050px) and (min-width: 761px) {
  .exam-inner { padding-inline: clamp(11px, 4.3cqi, 35px); }
  .total { padding-left: 5px; }
  .exam-meta { gap: 2px; }
  .card-menu { font-size: .81rem; }
  .board[data-count="3"] .exam-title { font-size: clamp(.86rem, 6.2cqi, 1.25rem); }
  .board[data-count="3"] .total { font-size: clamp(.73rem, 4.9cqi, 1rem); }
}

@media (max-width: 760px) {
  :root { --page-space: 12px; --header-size: 69px; --toolbar-size: 40px; }
  .brand-subtitle { display: none; }
  .board { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .board[data-count] .exam-card {
    --number-size: min(20.1cqi, 110px);
    display: flex;
    flex-direction: column;
    min-height: 435px;
  }
  .board[data-count="1"] .exam-card { min-height: max(435px, calc(100svh - var(--header-size) - var(--page-space))); }
  .exam-inner { flex: 1 0 auto; height: auto; gap: 10px; padding: 24px clamp(14px, 5.1cqi, 36px) 18px; }
  .exam-title { font-size: clamp(1.16rem, 6.1cqi, 1.75rem); }
  .total { font-size: clamp(.9rem, 4.65cqi, 1.2rem); }
  .readouts { gap: 8px; }
  .checkpoints { flex-basis: clamp(88px, 17vh, 130px); }
  .exam-actions { gap: 10px; }
}

@media (max-width: 480px) {
  .topbar { gap: 8px; padding-inline: 0; }
  .toolbar { gap: 5px; }
  .brand { gap: 7px; }
  h1 { font-size: 1.08rem; }
  .toolbar .button-add { width: var(--toolbar-size); padding: 0; font-size: 1.25rem; }
  .button-add span { display: none; }
  .brand-icon { width: 34px; font-size: 22px; }
}

@media (max-width: 350px) {
  :root { --toolbar-size: 37px; }
  h1 { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}
