:root {
  --bg: #0f172a;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --blue: #2563eb;
  --red: #ef4444;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #f1f5f9; }
.hidden { display: none !important; }
b { font-weight: 700; }

/* ---------------- 로그인 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, #0f172a);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 30px 30px;
  text-align: center;
}
.brand-badge {
  display: inline-block;
  background: var(--green-soft); color: #15803d;
  font-weight: 700; font-size: 13px;
  padding: 5px 12px; border-radius: 999px; margin-bottom: 12px;
}
.brand-badge.sm { margin-bottom: 0; }
.brand h1 { margin: 4px 0 6px; font-size: 26px; letter-spacing: -0.5px; }
.brand-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.gbtn-slot { display: flex; justify-content: center; min-height: 44px; }

.warn { color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 12px; padding: 12px; font-size: 13px; line-height: 1.5; margin-top: 16px; }
.err { color: var(--red); font-size: 14px; margin-top: 16px; }

.btn-line {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: 0.15s;
}
.btn-line:hover { background: #f8fafc; border-color: #cbd5e1; }

/* 학생 로그인 후 */
.ok-mark {
  width: 64px; height: 64px; margin: 0 auto 12px;
  background: var(--green); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
}
#studentSection h2 { margin: 6px 0 2px; font-size: 24px; }
.stu-meta { color: var(--muted); margin: 0 0 16px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--green-soft); color: #15803d; font-weight: 700;
  padding: 8px 16px; border-radius: 999px; font-size: 14px;
}
.stu-note { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 18px 0; }

/* 학생 과제 화면 */
.stu-head { text-align: center; margin-bottom: 22px; }
.stu-head h2 { margin: 10px 0 2px; font-size: 22px; }
.live-badge.sm { padding: 5px 12px; font-size: 12px; }
.task-title { text-align: left; font-size: 14px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 16px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff; font-family: inherit;
}
.task-card .tc-icon {
  width: 40px; height: 40px; flex: none; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.task-card .tc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.task-card .tc-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.task-card .tc-state { font-size: 12.5px; color: var(--muted); }

/* 잠금(비활성) */
.task-card.locked { background: #f8fafc; border-style: dashed; cursor: not-allowed; opacity: 0.85; }
.task-card.locked .tc-icon { background: #eef2f7; }
.task-card.locked .tc-name { color: #94a3b8; }

/* 열림(활성) */
.task-card.open { cursor: pointer; border-color: #86efac; box-shadow: 0 4px 14px rgba(34,197,94,0.15); transition: 0.15s; }
.task-card.open:hover { background: #f0fdf4; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(34,197,94,0.22); }
.task-card.open .tc-icon { background: var(--green); color: #fff; }
.task-card.open .tc-state.open { color: #15803d; font-weight: 700; }

.stu-hint { color: #94a3b8; font-size: 12px; text-align: center; margin: 14px 0 4px; }

/* 학생 과제 진행 화면 */
.btn-back {
  background: none; border: none; color: var(--muted); font-family: inherit;
  font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 6px;
}
.btn-back:hover { color: var(--ink); }
.task-open-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--green-soft); color: #15803d; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; margin-bottom: 10px;
}
#taskSection h2 { margin: 4px 0 2px; font-size: 22px; text-align: left; }
.task-subtitle { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; margin: 0 0 16px; }
.task-content {
  border: 1px solid var(--line); border-radius: 14px; padding: 20px 20px 24px;
  background: #fff; text-align: left;
}
.task-placeholder { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0; text-align: center; }
.task-note { color: #b45309; font-size: 12.5px; text-align: center; margin: 16px 0 4px; line-height: 1.6; }

/* ===== 과제 작성 폼 (워드 → HTML) ===== */
.login-card.wide { max-width: 760px; }

.id-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.id-item {
  flex: 1 1 130px; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px;
}
.id-item span { font-size: 11px; color: var(--muted); }
.id-item b { font-size: 15px; }

.notice-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 20px;
}
.notice-h { font-weight: 700; color: #b45309; font-size: 14px; margin-bottom: 6px; }
.notice-box p { margin: 0; font-size: 13.5px; line-height: 1.75; color: #78350f; }

.q-section { margin-bottom: 24px; }
.step-h {
  font-size: 16px; font-weight: 800; color: var(--ink);
  border-left: 4px solid var(--green); padding-left: 10px; margin: 0 0 6px;
}
.step-hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.6; }

.req-list { margin: 8px 0 20px; padding-left: 22px; }
.req-list li { font-size: 13.5px; line-height: 1.75; margin-bottom: 9px; color: var(--ink); }

.q-block { margin-bottom: 18px; }
.q-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--ink); line-height: 1.5; }

.answer {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-family: inherit; font-size: 14.5px; line-height: 1.75;
  color: var(--ink); background: #fff; resize: vertical;
  transition: border-color .15s, box-shadow .15s;
  caret-color: var(--green);   /* 깜빡이는 커서를 초록색으로 또렷하게 */
}
.answer::placeholder { color: #cbd5e1; }
.answer:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}
.answer.big { min-height: 340px; }

.char-count {
  text-align: right; font-size: 12px; color: var(--muted);
  margin-top: 5px; font-variant-numeric: tabular-nums;
}
.char-count.under { color: #b45309; }
.char-count.over  { color: var(--red); font-weight: 700; }
.char-count.ok    { color: #15803d; font-weight: 700; }


/* ===== 접기/펼치기 설명 블록 (긴 안내는 접어 두고 답안 칸만 펼쳐 둔다) ===== */
.guide-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }

.fold { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.fold > summary {
  cursor: pointer; list-style: none; padding: 11px 14px;
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "＋"; margin-left: auto; color: var(--muted); font-weight: 700; }
.fold[open] > summary::after { content: "－"; }
.fold > summary:hover { background: #f8fafc; }
.fold[open] > summary { border-bottom: 1px solid var(--line); background: #f1f5f9; }
.fold-body { padding: 14px; }
.fold-ico { font-size: 16px; }

.fold.in-notice { margin-top: 12px; border-color: #fde68a; background: #fffdf5; }
.fold.in-notice > summary { color: #92400e; font-size: 13px; padding: 8px 12px; }
.fold.in-notice > summary::after { color: #d97706; }
.fold.in-notice[open] > summary { border-bottom-color: #fde68a; background: #fef3c7; }
.fold.in-notice .fold-body { background: #fffdf5; }

.fold.in-req, .fold.in-sec { margin: 9px 0 2px; border-color: #dbeafe; background: #f8fbff; }
.fold.in-req > summary, .fold.in-sec > summary {
  font-size: 12.5px; font-weight: 700; color: #1d4ed8; padding: 7px 12px;
}
.fold.in-req > summary::after, .fold.in-sec > summary::after { color: #60a5fa; }
.fold.in-req[open] > summary, .fold.in-sec[open] > summary {
  border-bottom-color: #dbeafe; background: #eff6ff;
}
.fold.in-sec { margin: 0 0 16px; }

.gb-p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.8; color: var(--ink); }
.gb-p:last-child { margin-bottom: 0; }
.gb-k { color: #1d4ed8; margin-right: 4px; }
.gb-k::before { content: "["; }
.gb-k::after { content: "]"; }

.gb-tip {
  border-left: 3px solid var(--green); background: #f0fdf4; border-radius: 0 8px 8px 0;
  padding: 9px 12px; margin: 0 0 10px; font-size: 13px; line-height: 1.8; color: #14532d;
}
.gb-tip:last-child { margin-bottom: 0; }

.gb-note { margin: 9px 0 0; font-size: 12.5px; line-height: 1.7; color: #b45309; }

.gb-frame {
  border: 1px dashed #94a3b8; border-radius: 10px; padding: 11px 13px; margin: 0 0 10px;
  background: #f8fafc; font-size: 13px; line-height: 1.95; color: var(--ink);
}

.gb-list { margin: 0 0 10px; padding-left: 20px; }
.gb-list li { font-size: 13.5px; line-height: 1.8; margin-bottom: 6px; }

.gb-copy-btn {
  border: 0; background: var(--blue); color: #fff; border-radius: 8px;
  padding: 8px 15px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; margin-bottom: 9px;
}
.gb-copy-btn:hover { background: #1d4ed8; }
.gb-copy-text {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 13px 15px;
  font-family: inherit; font-size: 12.5px; line-height: 1.85;
  max-height: 320px; overflow: auto;
}

.gb-table-wrap { overflow-x: auto; margin: 0 0 10px; }
.gb-table { border-collapse: collapse; width: 100%; min-width: 460px; font-size: 12.5px; }
.gb-table th, .gb-table td {
  border: 1px solid var(--line); padding: 8px 10px;
  text-align: left; line-height: 1.65; vertical-align: top;
}
.gb-table th { background: #f1f5f9; font-weight: 700; white-space: nowrap; }
.gb-table td:nth-child(2) { text-align: center; font-weight: 700; white-space: nowrap; }
.gb-table tbody tr:last-child td { background: #f8fafc; font-weight: 700; }

/* 답안 칸 밑에 붙는 자수 안내 */
.q-note { margin: -2px 0 8px; font-size: 12.5px; color: var(--muted); line-height: 1.65; }

.foot { color: #94a3b8; font-size: 12px; margin-top: 20px; }

/* 대시보드 과제 열기/닫기 스위치 */
.task-ctrl {
  margin: 6px 24px 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 18px;
}
.task-ctrl .tc-h { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.task-ctrl .tc-h-sub { font-weight: 500; color: var(--muted); font-size: 12px; }
.tctrl-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-top: 1px solid #f1f5f9;
}
.tctrl-name { font-weight: 600; font-size: 15px; }
.switch {
  display: inline-flex; align-items: center; gap: 9px;
  border: none; background: none; cursor: pointer; font-family: inherit; padding: 0;
}
.switch-track {
  width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1;
  position: relative; transition: 0.18s; flex: none;
}
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: 0.18s;
}
.switch.on .switch-track { background: var(--green); }
.switch.on .switch-knob { left: 23px; }
.switch-label { font-size: 13px; font-weight: 700; min-width: 30px; text-align: left; color: var(--muted); }
.switch.on .switch-label { color: #15803d; }
.switch[disabled] { cursor: not-allowed; opacity: 0.55; }

/* 제어할 반 선택 */
.ctrl-classrow { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; flex-wrap: wrap; }
.ctrl-label { font-size: 13px; font-weight: 700; color: var(--muted); }
#ctrlClass {
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
#ctrlClass:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.ctrl-cur { font-size: 13px; color: #15803d; }
.ctrl-cur b { font-size: 14px; }
.ctrl-cur.muted { color: #94a3b8; }
.ctrl-note { color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 10px; padding: 8px 12px; font-size: 12.5px; margin: 6px 0; }
.ctrl-hint { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.tctrl-row.off { opacity: 0.5; }

/* 전체 마감(빨간) 버튼 */
.btn-close-all {
  width: 100%; margin-top: 12px; padding: 12px 14px;
  background: var(--red); color: #fff; border: none; border-radius: 12px;
  font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35); transition: 0.15s;
}
.btn-close-all:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(239, 68, 68, 0.45); }
.btn-close-all:disabled {
  background: #fca5a5; cursor: not-allowed; box-shadow: none; opacity: 0.75;
}

/* 대시보드 2분할 레이아웃 (왼쪽=과제제어, 오른쪽=출석) */
.dash-split {
  display: grid; grid-template-columns: 380px 1fr; gap: 20px;
  padding: 18px 24px 60px; align-items: stretch;
}
.dash-col-left { min-width: 0; }
.dash-col-right { min-width: 0; }
/* 컬럼 안에서는 기존 24px 좌우 여백 제거 + 왼쪽 패널은 스크롤 시 고정 */
.dash-col-left .task-ctrl { margin: 0; position: sticky; top: 82px; }
.dash-col-right .summary { padding: 4px 0 10px; }
.dash-col-right .tabs { position: static; top: auto; padding: 4px 0 12px; background: transparent; }
.dash-col-right .board { padding: 14px 0 0; }
@media (max-width: 980px) {
  .dash-split { grid-template-columns: 1fr; gap: 14px; padding: 14px 18px 60px; }
  .dash-col-left .task-ctrl { position: static; }
}

/* 접속 표시등 */
.dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #cbd5e1; display: inline-block; flex: none;
}
.dot.live {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---------------- 대시보드 ---------------- */
.dash-body { background: #f1f5f9; }
.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 24px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.dash-title { display: flex; align-items: center; gap: 12px; }
.dash-title h1 { font-size: 20px; margin: 0; letter-spacing: -0.4px; }
.dash-right { display: flex; align-items: center; gap: 14px; }
.self-card {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 12px;
}
.self-name { font-weight: 700; font-size: 14px; }
.self-state { font-size: 12px; color: var(--muted); }
.self-state.ok { color: #15803d; font-weight: 600; }

/* 상단 접속 교사 4명 표시 */
.teacher-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.self-card.mini { padding: 6px 10px; gap: 8px; }
.self-card.mini .self-name { font-size: 13px; }
.self-card.mini .self-state { font-size: 11px; }

.summary {
  display: flex; align-items: baseline; gap: 12px;
  padding: 18px 24px 6px;
}
.sum-num { display: flex; align-items: baseline; gap: 6px; }
.sum-num b { font-size: 32px; color: var(--green); }
.sum-num.muted b { color: var(--muted); font-size: 24px; }
.sum-num span { color: var(--muted); font-size: 14px; }
.sum-sep { color: #cbd5e1; font-size: 22px; }
.sum-updated { margin-left: auto; color: #94a3b8; font-size: 12px; }

.tabs {
  display: flex; gap: 8px; padding: 6px 24px 14px;
  overflow-x: auto; border-bottom: 1px solid var(--line); background: #f1f5f9;
  position: sticky; top: 65px; z-index: 4;
}
.tab {
  white-space: nowrap; border: 1px solid var(--line); background: #fff;
  color: var(--muted); padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.board { padding: 18px 24px 60px; }
.class-block {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; margin-bottom: 16px;
}
.class-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.class-head h2 { font-size: 17px; margin: 0; }
.class-count { font-size: 14px; color: var(--muted); }
.class-count b { color: var(--green); font-size: 17px; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: #f8fafc; font-size: 14px; transition: 0.2s;
}
.chip.on { background: var(--green-soft); border-color: #86efac; }
.chip.off { opacity: 0.72; }
.chip-no { color: var(--muted); font-size: 12px; min-width: 18px; }
.chip-name { font-weight: 600; }
.chip-time {
  margin-left: auto; font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: -0.2px; white-space: nowrap;
}
.chip.logged .chip-time { color: #15803d; }

@media (max-width: 560px) {
  .dash-header { flex-wrap: wrap; }
  .chips { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
