/* Design pass informed by unslop by Damir Sokolovsky, CC BY 4.0.
   https://heydamir.design/unslop */
:root {
  --sky-top: #e2f0f6;
  --sky-mist: #f5f3e6;
  --sky-edge: #cddfe0;
  --cta-accent: #8ee9c2;
  --night-paper: #0e151a;
  --night-surface: #1b282e;
  --night-inset: #172229;
  --night-ink: #edf0ea;
  --night-text: #d1d8d2;
  --night-muted: #adbab0;
  --night-line: #384952;
  --night-accent: #78d9b7;
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --sky-top: #173249;
    --sky-mist: #235447;
    --sky-edge: #416162;
    --cover-spine: #79aa9c;
    --cover-depth: inset 4px 0 var(--cover-spine), inset 7px 0 #243937, 0 12px 26px -12px #070f14;
    --card-depth: inset 0 1px rgb(205 236 225 / 13%), 0 5px 14px -9px #05090d;
    --paper: var(--night-paper);
    --white: var(--night-surface);
    --sage: var(--night-inset);
    --ink: var(--night-ink);
    --text: var(--night-text);
    --muted: var(--night-muted);
    --line: var(--night-line);
    --green: var(--night-accent);
    --green-dark: #c1e4cd;
    --green-soft: #273d31;
    --on-accent: #14281d;
    --amber: #e8c183;
    --amber-soft: #3a3023;
    --red: #ffb4a8;
    --red-soft: #412d2b;
  }
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="system"] {
    color-scheme: dark;
    --sky-top: #173249;
    --sky-mist: #235447;
    --sky-edge: #416162;
    --cover-spine: #79aa9c;
    --cover-depth: inset 4px 0 var(--cover-spine), inset 7px 0 #243937, 0 12px 26px -12px #070f14;
    --card-depth: inset 0 1px rgb(205 236 225 / 13%), 0 5px 14px -9px #05090d;
    --paper: var(--night-paper);
    --white: var(--night-surface);
    --sage: var(--night-inset);
    --ink: var(--night-ink);
    --text: var(--night-text);
    --muted: var(--night-muted);
    --line: var(--night-line);
    --green: var(--night-accent);
    --green-dark: #c1e4cd;
    --green-soft: #273d31;
    --on-accent: #14281d;
    --amber: #e8c183;
    --amber-soft: #3a3023;
    --red: #ffb4a8;
    --red-soft: #412d2b;
  }
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.theme-picker select {
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}
.auth-theme {
  display: flex;
  justify-content: flex-end;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
}
.auth-theme + .auth-page { min-height: calc(100vh - 53px); }
.question-body img, .question-figure img, .source-pages img { background: #fff; }
@media (max-width: 760px) {
  .public-nav { flex-wrap: wrap; padding-block: 12px; }
  .topbar, .account-menu { flex-wrap: wrap; }
  .theme-picker > span { display: none; }
}
@media print {
  .theme-picker, .auth-theme { display: none !important; }
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 0;
  background-color: var(--ink);
  -webkit-mask: url("/static/library/haehwan.f71f88a82849.png") center / 128% auto no-repeat;
  mask: url("/static/library/haehwan.f71f88a82849.png") center / 128% auto no-repeat;
}
.study-header { position: relative; padding-right: 72px; }
.bookmark-icon { position: absolute; top: 20px; right: 24px; width: 40px; height: 40px; display: grid; place-items: center; padding: 8px; color: var(--muted); background: transparent; border: 0; }
.bookmark-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.bookmark-icon[aria-pressed="true"] { color: #d64b4b; }
.bookmark-icon[aria-pressed="true"] svg { fill: currentColor; }
.source-list { display: flex; flex-wrap: wrap; gap: 0 4px; color: var(--muted); font-size: 12px; }
.occurrence { white-space: nowrap; }
.question-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; max-height: 360px; overflow-y: auto; }
.question-index { position: relative; min-height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--white); }
.question-index.current { outline: 2px solid var(--green); outline-offset: 1px; }
.question-index.correct { background: #d7eddb; color: #1d5c32; }
.question-index.incorrect { background: #f7d6d3; color: #8a2525; }
.index-bookmark { position: absolute; top: 3px; right: 3px; width: 7px; height: 9px; background: #d64b4b; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }

/* Study surfaces and controls */
.study-card, .toolbar {
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.05), 0 8px 20px rgb(0 0 0 / 0.04);
}
.question-card, .aside-card, .stat-card {
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}
.question-stem, #answer-text > strong, .explanation > strong { font-weight: 700; }
.question-grid { padding: 4px; }
.question-index.current { outline-offset: -3px; }
#answer-form .study-actions { justify-content: flex-start; }
#answer-form .grade-button { margin-left: auto; }
#answer-status { flex-basis: 100%; order: 3; }
.lecture-visibility { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lecture-visibility h1 { margin-bottom: 8px; }
.contact-form { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.contact-form textarea { width: 100%; max-width: 100%; resize: none; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--text); }
.build-label { display: inline-flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; font-weight: 600; }
.build-label span { color: var(--muted); font-size: 10px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.card-meta [data-lecture-toggle] { margin-left: 4px; }
.explanation > strong { display: block; margin-bottom: 8px; }
.explanation #explanation > :first-child { margin-top: 0; }

/* Selected wrong choices must override the selected-state styling. */
.choice.incorrect:has(input:checked), .choice.incorrect.selected {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}
.choice.incorrect:has(input:checked) .choice-number,
.choice.incorrect.selected .choice-number {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}
.question-stem { font-size: 18px; line-height: 1.7; }
.contest-button, .contest-button:hover {
  background: #a93232;
  border-color: #a93232;
  color: #fff;
}
@media (max-width: 760px) {
  .question-stem { font-size: 17px; }
  #answer-form .study-actions .button { flex: 0 1 auto; }
}

.practice-result-row { position: relative; padding-right: 64px; }
.practice-result-row .summary-bookmark { top: 8px; right: 12px; }
@media (max-width: 760px) {
  .practice-result-row { padding-right: 60px; }
}

.library-shortcuts { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-bottom: 20px; }
.library-shortcuts .button { min-height: 44px; }
.study-actions.question-navigation { background: transparent; border-top: 0; padding-inline: 0; }
.note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.note-actions .save-status { margin: 0; min-height: 0; color: var(--muted); }
.note-actions .save-status:empty { display: none; }

.topbar { justify-content: flex-end; }

/* Shared controls for the signed-in toolbar. */
.account-menu { gap: 8px; justify-content: flex-end; }
.account-menu .theme-picker > span { display: none; }
.account-menu .theme-picker select,
.account-menu > a,
.account-menu form > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 36px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.account-menu .theme-picker select:hover,
.account-menu > a:hover,
.account-menu form > button:hover {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.account-menu > span {
  padding-inline: 6px;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-menu form > button {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.account-menu form > button:hover {
  background: var(--green);
  color: var(--on-accent);
}

.site-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(15px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.site-masthead .brand { padding: 0; }
.theme-picker > span { display: inline; white-space: nowrap; }
.question-progress .lecture-toggle,
.question-progress .choice-shuffle {
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
}
.question-progress .choice-shuffle[aria-pressed="true"] {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--sage);
}
.question-progress .choice-shuffle[hidden] { display: none; }
.account-menu form > button { border: 1px solid var(--green); }
.public-nav { display: grid; grid-template-columns: 1fr auto auto; }
.public-nav > .theme-picker { justify-self: end; }
@media (max-width: 540px) {
  .public-nav { grid-template-columns: 1fr auto; }
  .public-nav > .theme-picker { grid-row: 1; grid-column: 2; }
  .public-nav > .public-links { grid-column: 1 / -1; }
}

.question-progress { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }

.filter-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 8px;
  grid-column: 1 / -1;
  flex: 1 0 100%;
}
.filter-actions .button { min-height: 44px; }

.brand-caption, .build-label, .nav-count, .cover-heading small {
  font-family: var(--mono);
  font-weight: 500;
}
.brand-title { color: var(--ink); }
.button, .search-button, .account-menu > a, .account-menu form > button, .theme-picker select { border-radius: 999px; }
.button.primary, .search-button { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.button.primary:hover, .search-button:hover { background: var(--text); border-color: var(--text); color: var(--paper); }
.button.secondary { color: var(--ink); background: var(--white); }
.button.secondary:hover { background: var(--sage); color: var(--ink); }
.nav-link.active { color: var(--green-dark); background: var(--green-soft); }
.study-card, .question-card, .toolbar, .aside-card, .stat-card {
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(12 25 18 / 4%);
}
.choice-dilemma { margin-inline: clamp(15px, 3vw, 29px); }
.question-stem { line-height: 1.55; }
.question-body table { font-variant-numeric: tabular-nums; }

.auth-entry {
  display: grid;
  width: min(calc(100% - 48px), 836px);
  margin: 32px auto;
  min-height: 0;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  background: transparent;
}
.auth-theme + .auth-entry { min-height: 0; }
.auth-entry .auth-story { gap: 24px; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--sage); }
.auth-entry .auth-story h1 { font-size: clamp(28px, 2.5vw, 36px); line-height: 1.25; margin-bottom: 14px; }
.auth-entry .auth-story .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
.auth-entry .auth-story .stat-card { box-shadow: none; }
.auth-entry .auth-story > p:last-child { margin: 0; color: var(--muted); }
.auth-entry .auth-panel { min-width: 0; padding: 0; align-items: flex-start; }
.auth-entry .auth-card { max-width: none; }
.auth-entry .auth-card h2 { font-size: 26px; }
.auth-entry .auth-card .subtitle { margin-bottom: 20px; }
.auth-entry .auth-card input:not([type="checkbox"]):not([type="radio"]) { font-size: 16px; background: var(--white); }
@media (max-width: 760px) {
  .auth-entry { width: min(calc(100% - 32px), 480px); margin: 16px auto 32px; grid-template-columns: 1fr; gap: 16px; }
  .auth-entry .auth-story { padding: 14px 16px; gap: 0; }
  .auth-entry .auth-story > div, .auth-entry .auth-story > p { display: none; }
  .auth-entry .auth-panel { padding: 0; }
  .auth-entry .auth-card .button { min-height: 44px; }
}
