:root {
  color-scheme: dark;
  --background: #1e1d1a;
  --header: #181715;
  --surface: #252420;
  --surface-raised: #2c2a25;
  --surface-hover: #333128;
  --border: #48453e;
  --border-strong: #625f52;
  --text: #f6f1e6;
  --muted: #bfb9aa;
  --muted-dim: #a39d8e;
  --accent: #deef65;
  --accent-hover: #eaf68a;
  --accent-edge: #8e9d30;
  --accent-soft: #dfee6319;
  --danger: #ffb7a1;
  --radius: 17px;
  --control-radius: 11px;
  --spring: cubic-bezier(.2, .82, .28, 1.25);
  font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { min-width: 280px; min-height: 100vh; margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button[aria-busy='true'] { cursor: wait; }
button:focus-visible, a:focus-visible, :where(input,select,textarea):focus-visible, label:has(:is(input[type='radio'],input[type='checkbox']):focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; }
h1 { font-size: clamp(2.1rem, 4.5vw, 3.55rem); font-weight: 790; letter-spacing: -.055em; overflow-wrap: anywhere; }
h2 { font-size: 1.35rem; font-weight: 740; letter-spacing: -.028em; }
h3 { font-size: 1.02rem; font-weight: 690; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #171813; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.skip-link { position: fixed; z-index: 10; top: 12px; left: 12px; padding: 10px 14px; transform: translateY(-150%); background: var(--header); border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }
.icon { flex: none; display: inline-block; width: 21px; height: 21px; vertical-align: middle; }
.muted { color: var(--muted); }
.site-header { border-bottom: 1px solid #35322c; background: var(--header); }
.header-inner { min-height: 73px; max-width: 1184px; padding: 0 30px; margin: auto; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-size: 2.07rem; line-height: 1; letter-spacing: -.065em; font-weight: 850; white-space: nowrap; }
.wordmark img { display: block; }
.brand-button { min-height: 48px; padding: 0; background: none; border: 0; border-radius: 9px; color: var(--text); }
.main-content { max-width: 1184px; padding: 28px 30px 66px; margin: 0 auto; outline: none; }
.startup { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 13px; color: var(--muted); }
.startup-mark { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 2.35rem; letter-spacing: -.065em; font-weight: 850; }
.loading { padding: 72px 0; display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.spinner { width: 21px; height: 21px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.button, .icon-button {
  display: inline-flex;
  min-width: 44px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--control-radius);
  padding: 10px 15px;
  color: var(--text);
  background: transparent;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  transition: transform 150ms var(--spring), box-shadow 150ms var(--spring), background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--surface-hover); border-color: #85816d; }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: translateY(2px); }
.button.primary {
  min-height: 50px;
  padding-inline: 19px;
  color: #181b10;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 5px 0 var(--accent-edge);
  font-weight: 800;
}
.button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.primary:active:not(:disabled) { transform: translateY(5px) scale(.99); box-shadow: 0 0 0 var(--accent-edge); }
.button.primary:disabled { opacity: .7; }
.button.quiet { border-color: transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { border-color: transparent; color: var(--text); }
.button.danger { color: var(--danger); border-color: #785248; }
.button.wide { width: 100%; }
.button.back-button { margin-left: -11px; padding-inline: 10px; color: var(--text); }
.icon-button { padding: 0; width: 44px; height: 44px; min-height: 44px; }
.icon-button:disabled { opacity: .42; }

.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 30px; }
.page-heading p { margin-top: 8px; color: var(--muted); font-size: 1.04rem; overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: center; gap: 10px; }
.section-heading > .icon { color: var(--accent); }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; margin: 0 0 17px; color: var(--muted); font-weight: 600; font-size: .94rem; }
.breadcrumb-divider { width: 1px; height: 18px; background: var(--border-strong); }
.screen-catalog, .screen-admin, .screen-password { padding-top: 42px; }

.auth-panel { width: min(100%, 450px); margin: clamp(12px, 8vh, 74px) auto 0; padding: 31px 30px 13px; }
.auth-emblem, .empty-icon {
  display: flex; align-items: center; justify-content: center; width: 49px; height: 49px; color: var(--accent); border-radius: 12px; background: var(--accent-soft); border: 1px solid #616739;
}
.auth-emblem { margin-bottom: 20px; }
.auth-panel h1 { font-size: clamp(2rem, 7vw, 2.8rem); }
.auth-panel > p { margin-top: 7px; color: var(--muted); }
.auth-form { display: grid; gap: 15px; margin-top: 24px; }
.auth-form .button { margin-top: 4px; }
.auth-links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 20px; color: var(--muted); font-size: .91rem; }
.auth-links .button { color: var(--accent); padding-inline: 9px; }
.subject-section + .subject-section { margin-top: 30px; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.test-card { display: flex; align-items: center; gap: 15px; min-height: 105px; padding: 9px 15px 9px 9px; color: var(--text); text-align: left; transition: background-color 150ms ease, border-color 150ms ease, transform 150ms var(--spring); }
.test-card:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.test-card:active { transform: translateY(2px); }
.test-preview { display: block; flex: 0 0 124px; align-self: stretch; min-height: 83px; position: relative; overflow: hidden; border-radius: 10px; background: var(--world-ground); }
.test-preview .world-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.test-card-copy { flex: 1; min-width: 0; display: grid; gap: 5px; overflow-wrap: anywhere; }
.test-card-copy strong { font-size: 1.16rem; line-height: 1.3; }
.test-card-copy > span { color: var(--muted); font-size: .91rem; line-height: 1.4; }
.test-card-arrow { color: var(--accent); }
.empty { display: flex; min-height: 225px; flex-direction: column; align-items: center; justify-content: center; gap: 11px; padding: 23px; text-align: center; }
.empty p { max-width: 46ch; color: var(--muted); }
.empty .button { margin-top: 9px; }
.empty-icon { margin-bottom: 3px; }
.error-back { display: flex; justify-content: center; margin-top: 12px; }
.compact-panel { max-width: 620px; padding: 23px; }

.progress { display: flex; align-items: center; justify-content: flex-end; gap: 13px; color: var(--muted); font-size: .92rem; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-track { overflow: hidden; min-width: 100px; width: clamp(100px, 12vw, 155px); height: 7px; background: #565247; border-radius: 20px; }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 300ms ease; }
.screen-path { padding-top: 15px; }
.screen-path .breadcrumb { margin-bottom: 9px; }
.screen-path .page-heading { margin-bottom: 17px; }
.screen-path .page-heading h1 { font-size: clamp(2.1rem, 4.2vw, 3.25rem); }
.screen-path .page-heading .progress { padding-bottom: 4px; }
.question-shell { max-width: 710px; margin: 0 auto; }
.question-scene { position: relative; isolation: isolate; display: flex; align-items: end; min-height: 94px; overflow: hidden; margin: 7px 0 23px; border-radius: 12px; border: 1px solid var(--border); padding: 11px 14px; background: var(--world-ground); }
.question-scene .world-art, .practice-art .world-art { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.question-scene .world-art { object-position: 55% 56%; }
.question-scene::before { position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, #181e17f2, #181d1733 100%); content: ''; }
.question-progress { width: 100%; }
.question-progress .practice-label, .question-progress .progress { color: var(--text); text-shadow: 0 1px 5px #171c15; }
.question-progress .progress { flex-direction: column-reverse; align-items: stretch; gap: 8px; text-align: right; }
.question-progress .progress-track { width: 100%; height: 9px; }
.question-prompt { margin: 0 0 24px; font-size: clamp(1.9rem, 5vw, 3rem); white-space: pre-wrap; }
.answer-form { display: grid; gap: 15px; }
.text-answer-fields { min-width: 0; display: grid; gap: 12px; }
.text-answer-fields textarea { font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.answer-list { display: grid; gap: 11px; min-width: 0; margin: 0; padding: 0; border: 0; }
.answer-instructions { margin-bottom: 10px; padding: 0; color: var(--muted); font-size: .92rem; }
.answer-option { display: flex; gap: 13px; align-items: center; min-height: 58px; padding: 13px 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--control-radius); cursor: pointer; transition: border-color 130ms ease, background-color 130ms ease; overflow-wrap: anywhere; }
.answer-option:hover, .difficulty-option:hover { background: var(--surface-hover); }
.answer-option:has(input:checked), .difficulty-option:has(input:checked) { border-color: var(--accent); background: #30331d; }
.answer-option input { flex: none; width: 21px; height: 21px; margin: 0; accent-color: var(--accent); }
.answer-option input:focus-visible { outline: none; }
.question-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 6px; }
.answer-grading { font-size: .86rem; }
.practice-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.practice-label .icon { color: var(--accent); }
.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .72fr); align-items: stretch; gap: 12px; max-width: 920px; }
.practice-art { position: relative; isolation: isolate; min-height: 160px; overflow: hidden; background: var(--world-ground); }
.difficulty-list { display: flex; gap: 9px; min-width: 0; margin: 17px 0 20px; padding: 0; border: 0; }
.difficulty-option { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1; min-height: 54px; padding-inline: 10px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-raised); cursor: pointer; }
.difficulty-option input { position: absolute; opacity: 0; }
.difficulty-bars { display: inline-flex; gap: 2px; align-items: end; }
.difficulty-bars i { background: var(--accent); width: 3px; height: 7px; border-radius: 2px; }
.difficulty-bars i:nth-child(2) { height: 11px; }
.difficulty-bars i:nth-child(3) { height: 15px; }
.difficulty-option:nth-of-type(1) i:not(:first-child), .difficulty-option:nth-of-type(2) i:last-child { opacity: .25; }
.feedback { padding: 20px; outline: none; }
.feedback.correct { border-color: #65733b; }
.feedback.incorrect { border-color: #784f43; }
.feedback-title { display: flex; align-items: center; gap: 9px; color: var(--accent); }
.feedback.incorrect .feedback-title { color: var(--danger); }
.feedback > p { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback h3 { margin-top: 17px; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.feedback.revealed { border-color: #827445; }
.feedback.revealed .feedback-title { color: #e9ce88; }
.exercise-help { display: grid; justify-items: start; gap: 8px; }
.feedback + .exercise-help { margin-top: 14px; }
.exercise-help .button { min-height: 44px; }
.help-note { width: 100%; padding: 10px 12px; border: 1px solid #73633c; border-radius: var(--control-radius); background: #302b20; color: #eadfc7; overflow-wrap: anywhere; }
.help-note h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: #f2d994; font-size: .94rem; }
.help-note .icon { width: 17px; height: 17px; }
.help-note p { white-space: pre-wrap; }

.field { min-width: 0; display: grid; gap: 6px; color: var(--text); font-size: .94rem; font-weight: 650; }
.field :is(input, select, textarea) { width: 100%; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--control-radius); padding: 10px 12px; background: #2b2a25; color: var(--text); font-weight: 450; }
.field :is(input, select, textarea):focus { border-color: #8d9571; background-color: #302f29; }
.field input[readonly] { color: var(--muted); }
.field :is(input, textarea)::placeholder { color: var(--muted-dim); opacity: 1; }
.field textarea { min-height: 83px; resize: vertical; }
.field small { color: var(--muted); font-size: .83rem; font-weight: 450; }
.field input[type='file'] { padding: 6px; overflow: hidden; }
.field input[type='file']::file-selector-button { min-height: 34px; margin-right: 8px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 4px 8px; color: var(--text); background: var(--surface-hover); font: inherit; cursor: pointer; }
.notice { display: flex; align-items: flex-start; gap: 9px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: var(--control-radius); padding: 9px 12px; color: var(--muted); font-size: .91rem; overflow-wrap: anywhere; }
.notice .icon { width: 18px; height: 18px; margin-top: 1px; }
.notice.success { color: var(--accent); border-color: #68763e; background: #2a3020; }
.notice.error, .form-error { color: var(--danger); }
.notice.error { border-color: #825243; background: #372821; }
.form-error { font-size: .91rem; }
.action-error { margin-bottom: 13px; }
.editor-form { display: grid; gap: 16px; padding: 22px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 3px 0 5px; }
.form-actions.left { justify-content: flex-start; }
.admin-subjects { display: grid; gap: 15px; }
.admin-subject { overflow: hidden; }
.admin-subject-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.admin-subject-actions { display: flex; gap: 7px; align-items: center; }
.admin-test-list, .material-list { padding: 0; margin: 0; list-style: none; }
.admin-test-list li { border-top: 1px solid var(--border); }
.admin-test { display: flex; width: 100%; gap: 12px; align-items: center; min-height: 68px; border: 0; padding: 10px 16px; background: transparent; color: var(--text); text-align: left; }
.admin-test:hover { background: var(--surface-hover); }
.admin-test-title { flex: 1; display: grid; min-width: 0; overflow-wrap: anywhere; }
.admin-test-title small { color: var(--muted); font-size: .82rem; }
.admin-test-arrow { color: var(--muted); }
.admin-blank { border-top: 1px solid var(--border); padding: 12px 16px; color: var(--muted); font-size: .91rem; }
.status { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 20px; color: var(--muted); font-size: .77rem; font-weight: 650; white-space: nowrap; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.published { color: var(--accent); background: #30361f; border-color: #5d6b34; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, 1fr); align-items: start; gap: 15px; }
.editor-sidebar { display: grid; gap: 15px; }
.materials-panel, .generation-panel { display: grid; gap: 14px; padding: 17px; }
.learning-job-list { display: grid; margin: 0; }
.learning-job-list > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 14px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.learning-job-list dt { font-weight: 700; }
.learning-job-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.learning-job-list small { display: block; }
.learning-job-list .job-error { color: var(--danger); }
.material-list:empty { display: none; }
.material-list li { display: flex; gap: 8px; align-items: center; min-width: 0; padding: 7px 0; border-bottom: 1px solid var(--border); }
.material-list li > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.material-icon { display: grid; flex: none; width: 36px; height: 36px; place-items: center; border-radius: 8px; background: var(--surface-raised); color: var(--muted); }
.material-icon .icon { width: 18px; height: 18px; }
.upload-form { display: grid; gap: 8px; }
.upload-form .button { justify-self: start; }
.switch-label { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; border-radius: 9px; }
.switch-label > span:first-child { display: grid; }
.switch-label small { color: var(--muted); font-size: .82rem; }
.switch-label input { position: absolute; right: 0; width: 49px; height: 32px; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { flex: none; width: 49px; height: 27px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 20px; background: #3d3b34; transition: background-color 150ms ease; }
.switch-track::after { display: block; width: 21px; height: 21px; border-radius: 50%; background: var(--text); content: ''; transition: transform 170ms var(--spring); }
.switch-label input:checked + .switch-track { border-color: var(--accent); background: var(--accent); }
.switch-label input:checked + .switch-track::after { transform: translateX(22px); background: #202415; }
.screen-settings > .notice { width: fit-content; margin-bottom: 11px; }

@media (max-width: 760px) {
  .header-inner { min-height: 64px; padding-inline: 20px; }
  .wordmark { font-size: 1.82rem; }
  .wordmark img { width: 31px; height: 31px; }
  .main-content { padding: 22px 20px 48px; }
  .test-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 500px) {
  .header-inner { min-height: 62px; padding-inline: 14px; gap: 4px; }
  .main-content { padding-inline: 14px; }
  .wordmark { gap: 7px; font-size: 1.62rem; }
  .wordmark img { width: 28px; height: 28px; }
  .auth-panel { width: min(100%, 450px); margin: clamp(12px, 8vh, 74px) auto 0; padding: 24px 19px 12px; }
  .test-preview { flex-basis: 78px; min-height: 78px; }
  .page-heading { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
  .page-heading p { font-size: .98rem; }
  .breadcrumb { margin-bottom: 13px; gap: 8px; }
  .screen-path .page-heading { gap: 10px; margin-bottom: 12px; }
  .screen-path .page-heading .progress { padding-bottom: 0; }
  .screen-path { padding-bottom: calc(107px + env(safe-area-inset-bottom)); }
  .screen-question { display: flex; min-height: calc(100svh - 62px); padding-bottom: 16px; }
  .question-shell { display: flex; width: 100%; flex-direction: column; }
  .question-scene { min-height: 67px; margin: 3px 0 16px; padding: 6px 9px; }
  .answer-form { display: flex; flex: 1; flex-direction: column; }
  .question-actions { position: sticky; bottom: 0; z-index: 2; display: block; margin: auto -14px -16px; padding: 11px 14px calc(16px + env(safe-area-inset-bottom)); background: var(--background); border-top: 1px solid var(--border); }
  .question-actions .button, .feedback-actions .button { width: 100%; }
  .answer-grading { margin-bottom: 5px; }
  .compact-panel, .editor-form, .materials-panel, .generation-panel { padding: 16px; }
  .practice-layout { grid-template-columns: minmax(0, 1fr); }
  .practice-art { grid-row: 1; min-height: 106px; }
  .difficulty-list { gap: 5px; }
  .difficulty-option { min-width: 0; gap: 5px; padding-inline: 5px; font-size: .91rem; }
  .admin-subject-heading, .admin-test { padding-inline: 11px; }
  .admin-test { gap: 7px; }
  .admin-test-arrow { display: none; }
  .admin-subject-actions .button { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; }
}
