:root {
  --bg: #f5f3ec;
  --surface: #ffffff;
  --text: #19332d;
  --muted: #66736f;
  --primary: #245c4f;
  --primary-dark: #17473c;
  --accent: #e4a94f;
  --border: #d9dedb;
  --danger: #a33a38;
  --danger-bg: #fae9e8;
  --success: #277456;
  --success-bg: #e5f4ed;
  --shadow: 0 10px 30px rgba(31, 60, 52, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--primary); }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.08; letter-spacing: -0.035em; }
h2 { font-size: 1.25rem; }
code { background: #edf0ee; padding: 0.15rem 0.35rem; border-radius: 0.25rem; }

.site-header {
  min-height: 68px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #fff;
  background: var(--primary);
}
.brand { color: #fff; font-weight: 800; text-decoration: none; font-size: 1.15rem; }
.site-header nav { display: flex; gap: 0.3rem; }
.site-header nav a {
  color: #dceae6;
  text-decoration: none;
  padding: 0.55rem 0.8rem;
  border-radius: 0.5rem;
}
.site-header nav a:hover, .site-header nav a.active { background: rgba(255,255,255,.13); color: #fff; }
.container { width: min(1180px, 90vw); margin: 0 auto; padding: 3rem 0 5rem; }
.site-footer { text-align: center; color: var(--muted); padding: 2rem; font-size: .9rem; }

.hero { max-width: 750px; margin: 2rem auto 3rem; text-align: center; }
.hero p:not(.eyebrow) { font-size: 1.15rem; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; color: var(--primary); }
.two-column, .admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.card, .quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.narrow, .quiz-card { max-width: 680px; margin-left: auto; margin-right: auto; }
.page-heading, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.page-heading h1 { margin-bottom: 0; }
.section-heading { margin-bottom: 1rem; }
.section-heading h2, .section-heading p { margin-bottom: .2rem; }
.section-heading p, .form-divider p, .import-export p { color: var(--muted); }

label, legend { font-weight: 700; }
input, select, textarea, button, .button {
  font: inherit;
  border-radius: .55rem;
}
input, select, textarea {
  width: 100%;
  padding: .75rem .85rem;
  color: var(--text);
  background: #fff;
  border: 1px solid #bfc9c5;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(36, 92, 79, .16);
  border-color: var(--primary);
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: .68rem 1rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--primary-dark); }
.secondary { background: #fff; color: var(--primary); }
.secondary:hover { background: #eef4f1; }
.danger { border-color: #d9aaa8; background: #fff; color: var(--danger); }
.danger:hover { background: var(--danger-bg); }
.small { padding: .48rem .7rem; font-size: .86rem; }
.large { min-height: 52px; font-size: 1.05rem; }
.block { display: flex; width: 100%; }
.stack { display: grid; gap: .75rem; }
.stack button { margin-top: .5rem; }
.inline-form, .actions { display: flex; align-items: center; gap: .65rem; }
.grow { flex: 1; }
.actions { flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: .6rem; padding: .85rem 1rem; }
.radio { display: block; font-weight: 500; margin: .4rem 0; }
.radio input { width: auto; margin-right: .45rem; }
.optional { color: var(--muted); font-size: .82rem; font-weight: 500; }
.origin-fields, .stack fieldset { display: grid; gap: .65rem; }
.origin-fields p, .stack fieldset p { margin-bottom: .2rem; }
.origin { margin: .8rem 0 0; font-size: .9rem; }
.retry-setting { align-items: end; }
.retry-setting label { flex: 1; }
.setting-help { margin: .75rem 0 0; font-size: .9rem; }

.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .75rem; }
.profile-button { width: 100%; min-height: 125px; flex-direction: column; gap: .65rem; background: #f8faf9; color: var(--text); border-color: var(--border); }
.profile-button:hover, .profile-button.selected { color: var(--primary); background: #edf6f2; border-color: var(--primary); }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--primary); font-size: 1.25rem; }
.notice { padding: .85rem 1rem; border-radius: .6rem; margin-bottom: 1.5rem; }
.notice.success { background: var(--success-bg); color: #18563e; border: 1px solid #a8d8c3; }
.notice.error { background: var(--danger-bg); color: #7c2927; border: 1px solid #e2b5b3; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1.5rem; }
.stats div { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; padding: 1rem; }
.stats strong, .stats span { display: block; }
.stats strong { font-size: 1.35rem; }
.stats span { color: var(--muted); font-size: .86rem; }
.stats.compact { grid-template-columns: repeat(3, 1fr); margin: 0; }

.quiz-meta, .level-summary { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .9rem; }
.direction { text-align: center; color: var(--muted); margin: 2.5rem 0 .6rem; }
.prompt { text-align: center; font-size: clamp(2.4rem, 8vw, 4.5rem); margin-bottom: 2.5rem; }
.answer-form { display: grid; gap: .7rem; }
.answer-form input { font-size: 1.3rem; text-align: center; min-height: 58px; }
.answer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.progress-line { height: 10px; overflow: hidden; background: #e5eae8; border-radius: 99px; margin-top: 1.5rem; }
.progress-line span { display: block; height: 100%; min-width: 2%; border-radius: inherit; background: var(--accent); }
.centered { text-align: center; }
.muted { color: var(--muted); }
.feedback { text-align: center; }
.feedback.correct { border-top: 7px solid var(--success); }
.feedback.incorrect { border-top: 7px solid var(--danger); }
.feedback.assisted { border-top: 7px solid var(--accent); }
.result-icon { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1.2rem; color: #fff; font-size: 2.5rem; font-weight: 800; background: var(--success); }
.incorrect .result-icon { background: var(--danger); }
.assisted .result-icon { background: var(--accent); }
.solution { font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 800; }
.review { border-top: 7px solid var(--accent); }
.review-answer { font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 750; }
.answer-hint { margin: 1.5rem 0 2rem; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 800; letter-spacing: .08em; overflow-wrap: anywhere; }
.notice-hint { margin: 1.25rem 0 0; color: var(--danger); font-weight: 700; text-align: center; }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 2rem; }
.level-summary { margin-top: 2rem; }
.text-link { display: inline-block; margin-top: 1rem; }

.item-list { display: grid; gap: .65rem; }
.editable-item { display: flex; align-items: center; gap: .5rem; padding-bottom: .65rem; border-bottom: 1px solid #edf0ee; }
.add-form { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid var(--border); }
.code-input { max-width: 90px; }
.set-item .badge { white-space: nowrap; }
.badge, .language-code { background: #edf2f0; color: var(--muted); border-radius: 99px; padding: .2rem .55rem; font-size: .78rem; font-weight: 700; }
.form-divider { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1.5rem; }
.form-divider h2 { margin-bottom: .3rem; }
.import-export { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.import-export h2 { margin-bottom: .2rem; }
.import-export input[type=file] { max-width: 280px; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: #edf2f0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.translations { margin: 0; min-width: 210px; }
.translations div { display: grid; grid-template-columns: 35px 1fr; gap: .4rem; }
.translations dt { font-weight: 800; color: var(--primary); }
.translations dd { margin: 0; }
.row-actions { display: flex; gap: .45rem; }

@media (max-width: 800px) {
  .container { width: min(94vw, 680px); padding-top: 2rem; }
  .two-column, .admin-grid { grid-template-columns: 1fr; }
  .page-heading, .section-heading, .import-export { align-items: stretch; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .editable-item, .set-item, .editable-item form { align-items: stretch; flex-direction: column; }
  .editable-item > form:last-child button { width: 100%; }
  .add-form { align-items: stretch; flex-direction: column; }
  .code-input { max-width: none; }
  .row-actions { min-width: 130px; flex-direction: column; }
  .review-actions, .answer-actions { grid-template-columns: 1fr; }
  .retry-setting { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
  .site-header { padding: .6rem 3vw; }
  .site-header nav a { padding: .45rem .55rem; font-size: .9rem; }
  .card, .quiz-card { border-radius: .75rem; }
  .quiz-meta { flex-direction: column; gap: .15rem; }
  .actions > * { width: 100%; }
  .actions form { flex-direction: column; align-items: stretch; }
}
