:root {
  --bg: #f1f5f4;
  --card: #ffffff;
  --ink: #1f2d2b;
  --muted: #6b7c79;
  --line: #dde5e3;
  --accent: #0f766e;       /* teal-700 */
  --accent-dark: #115e57;
  --accent-soft: #d7f0ec;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #15803d;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 6px 18px rgba(15,118,110,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.app-header {
  background: linear-gradient(135deg, #0f766e 0%, #115e57 100%);
  color: #fff;
  padding: 18px 0 10px;
  box-shadow: 0 2px 12px rgba(15,118,110,.25);
}
.header-inner {
  max-width: 920px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 34px; }
.brand-text h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.slogan { margin: 0; font-size: 13px; opacity: .9; }
.header-actions { display: flex; gap: 8px; }
.credit {
  max-width: 920px; margin: 4px auto 0; padding: 0 20px;
  text-align: right; font-size: 11px; font-style: italic; opacity: .8;
  font-family: Georgia, serif;
}

/* ===== Layout ===== */
.container { max-width: 920px; margin: 0 auto; padding: 22px 20px 80px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-head h2 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
}
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; }

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--line); border-radius: 12px;
  padding: 26px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafdfc;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: var(--accent-soft);
}
.dz-icon { font-size: 34px; display: block; margin-bottom: 6px; }
.dz-inner p { margin: 4px 0; font-size: 14px; }
.dz-inner small { color: var(--muted); font-size: 12px; }

/* ===== Fields ===== */
.field { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; margin-top: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field label small { font-weight: 400; color: var(--muted); }
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  background: #fff; width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

/* ===== Buttons ===== */
.primary-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 11px 22px; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .05s;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-dark); }
.primary-btn:active:not(:disabled) { transform: translateY(1px); }
.primary-btn:disabled { background: #9bb5b1; cursor: not-allowed; }
.ghost-btn {
  background: rgba(255,255,255,.14); color: inherit; border: 1px solid rgba(255,255,255,.3);
  border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.ghost-btn:hover { background: rgba(255,255,255,.26); }
.card .ghost-btn, .modal .ghost-btn, .results-actions .ghost-btn {
  background: #eef4f3; color: var(--accent-dark); border: 1px solid var(--line);
}
.card .ghost-btn:hover, .modal .ghost-btn:hover { background: var(--accent-soft); }

/* ===== Action bar ===== */
.action-bar { display: flex; align-items: center; gap: 14px; margin: 4px 0 20px; }
.action-status { font-size: 13.5px; color: var(--muted); }
.action-status.busy { color: var(--accent); font-weight: 600; }
.action-status.error { color: var(--danger); font-weight: 600; }

/* ===== Answer list ===== */
.answer-list { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.student-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fafdfc; }
.student-group-head { font-size: 13.5px; font-weight: 700; color: var(--accent-dark); margin-bottom: 10px; }
.student-group-head small { font-weight: 400; color: var(--muted); }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.answer-thumb {
  position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
}
.answer-thumb img { width: 100%; height: 110px; object-fit: cover; display: block; }
.answer-thumb .name { font-size: 11.5px; padding: 6px 8px 2px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.answer-thumb .student-select { font-size: 12px; padding: 5px 6px; border-radius: 0; border: none; border-top: 1px solid var(--line); width: 100%; }
.answer-thumb .student-select:focus { box-shadow: none; }
.answer-thumb .remove {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; font-size: 12px; line-height: 1;
}

/* ===== Results ===== */
.results-card { scroll-margin-top: 20px; }
.results-actions { display: flex; gap: 8px; }
.results-summary {
  background: var(--accent-soft); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
  font-size: 14px; color: var(--accent-dark); font-weight: 600;
}
.results-list { display: flex; flex-direction: column; gap: 16px; }
.result-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.result-top {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: #f7fbfa; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.result-top .student { font-weight: 700; font-size: 15px; }
.result-score {
  margin-left: auto; font-size: 20px; font-weight: 800; color: var(--accent-dark);
}
.result-score small { font-size: 13px; color: var(--muted); font-weight: 600; }
.result-body { padding: 14px 16px; }
.rubric-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 12px; }
.rubric-table th, .rubric-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rubric-table th { background: #f3f7f6; font-weight: 600; color: var(--muted); }
.rubric-table td.score-cell { font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.fb-block { margin-top: 10px; }
.fb-block h4 { margin: 0 0 4px; font-size: 13px; color: var(--accent-dark); }
.fb-block p, .fb-block ul { margin: 0; font-size: 13.5px; color: var(--ink); }
.fb-block ul { padding-left: 18px; }
.result-error { color: var(--danger); font-size: 13.5px; padding: 6px 0; }
.result-img-toggle { font-size: 12px; color: var(--accent); cursor: pointer; background: none; border: none; padding: 0; margin-top: 8px; }
.result-img { max-width: 100%; margin-top: 10px; border-radius: 8px; border: 1px solid var(--line); }
.sheet-hint-field { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; margin-top: 16px; }
.sheet-hint-field label { color: #92400e; }
.hint-sub { display: block; color: #b45309; font-size: 12px; margin-top: 5px; line-height: 1.5; }
.sheet-hint-field textarea { background: #fff; border-color: #fde68a; }
.sheet-hint-field textarea:focus { border-color: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }

.transcription-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.transcription-box h4 { margin: 0 0 6px; font-size: 13px; color: #92400e; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.verify-tag { font-size: 11px; font-weight: 600; color: var(--warn); background: #fef3c7; padding: 2px 7px; border-radius: 99px; }
.transcription-text { margin: 0; font-size: 14px; white-space: pre-wrap; color: var(--ink); }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; background: rgba(15,30,28,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 460px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.model-hint { color: var(--muted); font-size: 12px; }
.settings-status { font-size: 13px; margin-top: 10px; min-height: 18px; }
.settings-status.ok { color: var(--ok); }
.settings-status.error { color: var(--danger); }
.guide-list { padding-left: 20px; font-size: 14px; }
.guide-list li { margin-bottom: 8px; }

/* ===== Print ===== */
@media print {
  .app-header, .action-bar, #step-criteria, #step-answers, .results-actions,
  .header-actions, .modal, .result-img-toggle, .result-img { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
  .result-item { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .header-inner { flex-direction: column; align-items: flex-start; }
}
