:root {
  --ink: #152028;
  --muted: #5a6a76;
  --line: #d7e0e7;
  --paper: #f3f6f8;
  --card: #ffffff;
  --accent: #0f6e6a;
  --accent-deep: #0a4f4c;
  --accent-soft: #d8efed;
  --warn: #b45309;
  --bad: #b42318;
  --good: #027a48;
  --shadow: 0 18px 50px rgba(21, 32, 40, 0.08);
  --radius: 14px;
  --font: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9ecea 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8eef3 0%, transparent 50%),
    var(--paper);
  line-height: 1.55;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 110, 106, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 110, 106, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 85%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(243, 246, 248, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background:
    linear-gradient(135deg, var(--accent) 0%, #1a8f88 55%, #2a9b8f 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.brand-name { margin: 0; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); }
.progress-hint { margin: 0; font-size: 13px; color: var(--muted); }

.app {
  width: min(920px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  letter-spacing: -0.02em;
}
.lead { margin: 0 0 22px; color: var(--muted); max-width: 42em; }

.form-grid {
  display: grid;
  gap: 16px;
}
label.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
input[type="text"], select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 110, 106, 0.15);
}
textarea { min-height: 96px; resize: vertical; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.cat-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 14px 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.cat-btn:hover { transform: translateY(-1px); border-color: #9bb8b5; }
.cat-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.cat-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.cat-meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s, background .12s, opacity .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: #eef3f6; }

.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.meta-chip {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.meta-chip span {
  background: #eef3f6;
  border-radius: 999px;
  padding: 4px 10px;
}

.progress-bar {
  height: 8px;
  background: #e6edf2;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #2aa39a);
  transition: width .25s ease;
}

.q-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px 12px;
  margin-bottom: 14px;
  background: #fcfdfe;
}
.q-type {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 3px 8px;
  margin-bottom: 8px;
}
.q-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 650;
}
.options { display: grid; gap: 8px; }
.opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.opt:hover { border-color: #9bb8b5; }
.opt input { margin-top: 3px; }
.opt.correct-mark { border-color: #86d3b0; background: #f0faf5; }
.opt.wrong-mark { border-color: #f0b4ae; background: #fff5f4; }

.review-block {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f5f8fa;
  font-size: 13px;
  color: var(--muted);
}
.review-block strong { color: var(--ink); }
.tag-ok { color: var(--good); font-weight: 700; }
.tag-bad { color: var(--bad); font-weight: 700; }
.tag-partial { color: var(--warn); font-weight: 700; }

.score-hero {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}
.score-num {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent-deep);
  line-height: 1;
}
.breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: 12px; color: var(--muted); }

.empty-state {
  padding: 18px;
  border: 1px dashed #b7c8d0;
  border-radius: 12px;
  background: #f7fafb;
  color: var(--muted);
}

.site-foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px 28px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}
.btn-warn {
  background: #fff7ed;
  border: 1px solid #f0c9a0;
  color: #9a3412;
}
.btn-warn:hover { background: #ffedd5; }

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.admin-bar .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 28, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h2 { margin: 0 0 8px; font-size: 1.15rem; }
.modal .actions { margin-top: 16px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 12px;
}
table.scores {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
table.scores th,
table.scores td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.scores th {
  background: #eef3f6;
  font-weight: 700;
  position: sticky;
  top: 0;
}
table.scores tr:last-child td { border-bottom: none; }
table.scores .btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.import-box {
  display: grid;
  gap: 14px;
}
.excel-tips {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f5f8fa;
  font-size: 13px;
  color: var(--muted);
}
.excel-tips p {
  margin: 0 0 6px;
}
.excel-tips p:last-child {
  margin-bottom: 0;
}
.excel-tips code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: var(--accent-deep);
  background: #e8f3f1;
  padding: 1px 6px;
  border-radius: 4px;
}
.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 14px;
  font-weight: 500;
}
.mode-row label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}
.fill-blanks {
  display: grid;
  gap: 10px;
}
.fill-blanks .field {
  margin: 0;
}

.toast-ok {
  padding: 10px 12px;
  border-radius: 10px;
  background: #ecfdf3;
  color: var(--good);
  font-size: 13px;
  border: 1px solid #abefc6;
}
.toast-err {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef3f2;
  color: var(--bad);
  font-size: 13px;
  border: 1px solid #fecdca;
}
.sample-link {
  font-size: 13px;
  color: var(--accent-deep);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
}

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .panel { padding: 20px 16px; }
  .quiz-head { flex-direction: column; }
}
