:root {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --panel2: #faf9f5;
  --ink: #1d2a24;
  --muted: #6b746f;
  --line: #e3e0d6;
  --brand: #1f3a2e;
  --brand2: #2f6b4f;
  --accent: #d9a441;
  --ok: #2f7a4f;
  --okbg: #e5f3ea;
  --bad: #b3402e;
  --badbg: #fbe9e5;
  --warn: #9a6a00;
  --warnbg: #fff3d6;
  --radius: 12px;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--brand2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 30px; font-weight: 500; margin: 0 0 4px; letter-spacing: -0.5px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.boot { padding: 40px; color: var(--muted); }

/* 레이아웃 */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e9efe9; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; padding: 4px 8px 18px; color: #fff; }
.side .logo img { width: 26px; height: 26px; }
.side nav a { display: block; color: #d6e2da; padding: 8px 10px; border-radius: 8px; margin: 1px 0; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.side .group { font-size: 12px; color: #9fb4a8; margin: 14px 10px 4px; }
.side .me { border-top: 1px solid rgba(255,255,255,.12); margin-top: 18px; padding: 12px 10px; font-size: 13px; color: #c5d3ca; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.side .me .btn { background: transparent; color: #e9efe9; border-color: rgba(255,255,255,.3); }
.side .me .btn:hover { background: rgba(255,255,255,.1); }
.main { padding: 32px 40px 80px; max-width: 1280px; width: 100%; }
.sub { color: var(--muted); margin: 0 0 22px; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 50; height: 100vh; }
  .side.open { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .main { padding: 20px 16px 80px; }
  h1 { font-size: 24px; }
}

/* 카드·표 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; margin-bottom: 18px; }
.card.soft { background: var(--panel2); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1000px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stat b { display: block; font-size: 26px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 500; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
.tablewrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* 폼 */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; border: 1px solid #d5d1c4; background: #fff; border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(47,107,79,.12); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 4px; }
.btn { border: 1px solid #d5d1c4; background: #fff; border-radius: 10px; padding: 9px 16px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand2); }
.btn.danger { color: var(--bad); border-color: #e7c2ba; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.radio { display: inline-flex; gap: 6px; align-items: center; margin-right: 22px; cursor: pointer; }

/* 배지 */
.badge { display: inline-block; font-size: 12px; border-radius: 99px; padding: 2px 9px; background: #ecebe5; color: #4d554f; white-space: nowrap; }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.bad { background: var(--badbg); color: var(--bad); }
.badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.dark { background: var(--brand); color: #fff; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--accent); } .dot.bad { background: var(--bad); }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--warnbg); color: #5f4600; margin-bottom: 14px; }
.notice.info { background: #e8efe9; color: #2a4436; }
.notice.bad { background: var(--badbg); color: #7a2a1d; }

/* 토스트·모달 */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast .t { background: #1d2a24; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
#toast .t.bad { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,30,25,.45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* 문항 */
.q { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: #fff; }
.q .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.q .body { font-size: 16px; }
.q .ans { background: var(--panel2); border-left: 3px solid var(--brand2); padding: 8px 10px; margin-top: 8px; border-radius: 4px; }
.crop { border: 1px solid var(--line); border-radius: 8px; background-repeat: no-repeat; background-color: #fff; margin-top: 8px; max-width: 100%; }
.pages { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.pages .pv { position: sticky; top: 16px; }
.pages .pv img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pv .box { position: absolute; border: 2px solid var(--accent); background: rgba(217,164,65,.12); pointer-events: none; }
@media (max-width: 1000px) { .pages { grid-template-columns: 1fr; } .pages .pv { position: static; } }
.progress { height: 6px; background: #ece9df; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand2); width: 30%; animation: slide 1.4s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.verdict-correct { background: var(--okbg); }
.verdict-incorrect, .verdict-blank { background: var(--badbg); }
.verdict-uncertain { background: var(--warnbg); }

/* 로그인 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 380px; max-width: 100%; }
.login .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 700; font-size: 20px; }
.login .brand img { width: 34px; }

/* AI 연결 화면(캡처) */
.conn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .conn-grid { grid-template-columns: 1fr; } }
.conn-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; background: var(--panel2); }
.conn { padding: 10px 0; }
.conn + .conn { border-top: 1px dashed var(--line); }
.conn .title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 8px; }
.conn .title small { font-weight: 400; color: var(--muted); }
.conn .line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 8px; }
.conn .line2 { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 6px; }
.settings-row { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.settings-row:first-of-type { border-top: 0; }
@media (max-width: 860px) { .settings-row { grid-template-columns: 1fr; } .conn .line { grid-template-columns: 1fr; } }

/* 전자칠판 */
.board { position: fixed; inset: 0; background: #e9e6dd; display: grid; grid-template-rows: auto 1fr auto; z-index: 10; }
.board .bar { display: flex; gap: 6px; align-items: center; padding: 8px 12px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.board .bar .sep { width: 1px; height: 26px; background: rgba(255,255,255,.25); margin: 0 4px; }
.board .bar button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; min-width: 36px; }
.board .bar button.on { background: #fff; color: var(--brand); }
.board .bar button:disabled { opacity: .4; }
.board .bar input[type=color] { width: 36px; height: 32px; padding: 0; border: 0; background: none; }
.board .bar input[type=range] { width: 90px; }
.board .bar select { width: auto; padding: 4px 6px; color: var(--ink); }
.board .title { font-weight: 700; margin-right: 8px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .stage { position: relative; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 16px; }
.sheet { position: relative; width: min(1100px, 100%); min-height: calc(100vh - 140px); border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.12); background: #fff; }
.sheet.bg-grid { background-image: linear-gradient(#e7ecef 1px, transparent 1px), linear-gradient(90deg, #e7ecef 1px, transparent 1px); background-size: 28px 28px; }
.sheet.bg-dark { background: #22392f; color: #f2f2e8; }
.sheet.bg-dark .ans { background: rgba(255,255,255,.08); }
.sheet .content { padding: 40px 48px 120px; font-size: 22px; line-height: 1.8; }
.sheet .content .qno { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.sheet.bg-dark .content .qno { color: #b9c9be; }
.sheet .content .speak { border-radius: 6px; }
.sheet .content .speak.reading { background: rgba(217,164,65,.35); }
.sheet .content .ans { font-size: 19px; background: var(--panel2); padding: 12px 16px; border-left: 4px solid var(--accent); margin-top: 18px; border-radius: 6px; }
.sheet canvas { position: absolute; inset: 0; touch-action: none; }
.sheet .sel { position: absolute; border: 2px dashed var(--accent); background: rgba(217,164,65,.12); pointer-events: none; }
.sheet .textbox { position: absolute; min-width: 120px; font-size: 20px; padding: 4px 6px; border: 1px dashed var(--brand2); background: rgba(255,255,255,.85); outline: none; z-index: 3; }
.board .foot { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px; background: #f4f2ec; border-top: 1px solid var(--line); flex-wrap: wrap; }
.board .foot .pg { min-width: 90px; text-align: center; }
.board .thumbs { display: flex; gap: 4px; overflow-x: auto; max-width: 60vw; }
.board .thumbs button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12px; }
.board .thumbs button.on { background: var(--brand); color: #fff; }
.board .thumbs button.has { border-color: var(--accent); }

@media print { .side, .topbar, .btn { display: none !important; } .main { padding: 0; } }
