/* ===== reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== design tokens ===== */
:root {
  --c-primary:   #5C6BC0;
  --c-primary-d: #3949AB;
  --c-primary-l: #E8EAF6;
  --c-bg:        #F4F5FB;
  --c-white:     #FFFFFF;
  --c-text:      #1C1C2E;
  --c-muted:     #7B7B9A;
  --c-border:    #DDDDE8;
  --r:           16px;
  --r-sm:        10px;
  --shadow:      0 4px 20px rgba(60,60,120,.11);
  --shadow-sm:   0 2px 8px  rgba(60,60,120,.07);
  --btn-h:       68px;
}

/* ===== base ===== */
html, body {
  height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 600px;
  margin: 0 auto;
}

/* ===== screen toggling ===== */
.screen              { display: none; min-height: 100vh; flex-direction: column; }
.screen.active       { display: flex; }

/* accessibility: visually hidden but readable by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===================== HOME ===================== */
.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 64px;
  gap: 52px;
}

.home-hero    { text-align: center; }
.home-icon    { font-size: 80px; line-height: 1; margin-bottom: 20px; }
.home-title   {
  font-size: 2rem;
  font-weight: 900;
  color: var(--c-primary-d);
  line-height: 1.3;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}
.home-sub     { font-size: 1.05rem; color: var(--c-muted); }

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 380px;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--btn-h);
  padding: 14px 24px;
  border: none;
  border-radius: var(--r);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  word-break: keep-all;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 3px; }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 6px 20px rgba(92,107,192,.35);
}
.btn-primary:hover { background: var(--c-primary-d); }

.btn-outline {
  background: var(--c-white);
  color: var(--c-primary);
  border: 2.5px solid var(--c-primary-l);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { background: var(--c-primary-l); }

/* ===================== TOP BAR ===================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.top-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-primary);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  min-height: 50px;
  min-width: 88px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.top-btn:hover       { background: var(--c-primary-l); }
.top-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.top-title { font-size: 1.05rem; font-weight: 700; color: var(--c-text); }

/* ===================== PROGRESS BAR ===================== */
.prog-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
}

.prog-track {
  flex: 1;
  height: 10px;
  background: var(--c-border);
  border-radius: 99px;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary), #9C27B0);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.prog-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--c-muted);
  min-width: 40px;
  text-align: right;
}

/* ===================== FORM BODY ===================== */
.form-body {
  flex: 1;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.question {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--c-text);
  word-break: keep-all;
}

/* ===================== OPTION BUTTONS ===================== */
.opts { display: flex; flex-direction: column; gap: 12px; }

.opts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.opts-col { flex-direction: column; gap: 14px; }

.opt-btn {
  min-height: var(--btn-h);
  padding: 16px 10px;
  border: 2.5px solid var(--c-border);
  border-radius: var(--r);
  background: var(--c-white);
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  word-break: keep-all;
  line-height: 1.35;
}

.opt-btn:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-l);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(92,107,192,.18);
}

.opt-btn:active {
  transform: scale(0.97);
  border-color: var(--c-primary-d);
}

.opt-btn:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 2px;
}

/* choice buttons (tall, left-aligned) */
.opt-choice {
  padding: 22px 20px;
  min-height: 116px;
  align-items: flex-start;
  text-align: left;
}

/* ===== ROLE BUTTONS (학생 / 선생님) ===== */
.opts-role {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.opt-role-btn {
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px;
}

.role-icon  { font-size: 3.2rem; line-height: 1; }
.role-label { font-size: 1.4rem; font-weight: 800; }

.oi { font-size: 2.2rem; line-height: 1; }
.ol { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
.os { font-size: 0.9rem; color: var(--c-primary); font-weight: 600; margin-top: 2px; }

/* ===================== DONE ===================== */
.done-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 64px;
  gap: 28px;
  text-align: center;
}

.done-icon  { font-size: 88px; line-height: 1; }
.done-title {
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.4;
  color: var(--c-primary-d);
  word-break: keep-all;
}

.done-card {
  background: var(--c-white);
  border-radius: var(--r);
  padding: 20px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}
.sum-row:last-child { border-bottom: none; }
.sum-row span   { color: var(--c-muted); flex-shrink: 0; }
.sum-row strong { font-weight: 700; color: var(--c-primary-d); text-align: right; }

.already-msg {
  color: var(--c-muted);
  font-size: 1rem;
  line-height: 1.8;
  text-align: center;
}

/* ===================== STATUS ===================== */
.status-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
}

.status-tab {
  padding: 14px 10px;
  font-size: 1rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--c-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.status-tab.active {
  background: var(--c-primary-l);
  color: var(--c-primary-d);
  font-weight: 800;
  border-bottom-color: var(--c-primary);
}
.status-tab:hover:not(.active) { background: var(--c-bg); }

.status-view         { display: none; }
.status-view.active  { display: block; }

.status-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-sel {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 1rem;
  background: var(--c-white);
  color: var(--c-text);
  cursor: pointer;
  appearance: auto;
}
.filter-sel:focus { outline: 2px solid var(--c-primary); border-color: var(--c-primary); }

/* ---- 마을별 보기 테이블 ---- */
.sv-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-white);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-sm);
  overflow: hidden;
  font-size: 0.9rem;
}
.sv-table th,
.sv-table td {
  border: 1px solid var(--c-border);
  padding: 8px 10px;
  text-align: center;
}
.sv-village-hd {
  background: #E0E0E0;
  font-weight: 800;
  font-size: 1rem;
  color: var(--c-text);
}
.sv-col-hd th {
  background: #F5F5F5;
  font-weight: 700;
  color: var(--c-muted);
  font-size: 0.85rem;
}
.sv-sep {
  width: 20px;
  color: #C8C8C8;
  font-size: 0.75rem;
  background: #FAFAFA;
}
.sv-name   { text-align: left; padding-left: 12px; }
.sv-status { font-weight: 700; }
.sv-done   { color: #2E7D32; background: #E8F5E9; }
.sv-undone { color: #9E9E9E; }

/* ---- 표로 보기 ---- */
.excel-btn-wrap { display: flex; justify-content: flex-end; }
.excel-btn {
  padding: 8px 18px;
  background: #217346;
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.excel-btn:hover { background: #185c37; }

.table-scroll { overflow-x: auto; }
.ft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 480px;
  background: var(--c-white);
  box-shadow: var(--shadow-sm);
}
.ft-table th {
  padding: 10px 12px;
  background: #F0F0F0;
  font-weight: 700;
  text-align: left;
  border: 1px solid var(--c-border);
  white-space: nowrap;
}
.ft-table td {
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  white-space: nowrap;
}
.ft-table tr:nth-child(even) td { background: #FAFAFA; }
.ft-done   { color: #2E7D32; font-weight: 700; }
.ft-undone { color: #C62828; font-weight: 700; }

.empty {
  text-align: center;
  color: var(--c-muted);
  padding: 56px 0;
  font-size: 1rem;
  line-height: 2;
}

/* ===================== RESPONSIVE ===================== */
@media (min-width: 480px) {
  .home-title  { font-size: 2.3rem; }
  .question    { font-size: 1.65rem; }
  .form-body   { padding: 32px 28px 52px; }
  .opts-grid   { gap: 14px; }
}

@media (min-width: 768px) {
  :root { --btn-h: 76px; }
  .home-inner   { padding: 64px 40px 80px; gap: 60px; }
  .home-icon    { font-size: 90px; }
  .home-title   { font-size: 2.6rem; }
  .form-body    { padding: 40px 36px 60px; }
  .question     { font-size: 1.85rem; }
  .opts-grid    { gap: 18px; }
  .opt-btn      { font-size: 1.1rem; }
  .opt-choice   { min-height: 130px; }
  .done-title   { font-size: 2.1rem; }
  .done-icon    { font-size: 100px; }
}
