/* style.css — 생기부 작성 도우미 (바닐라). high_1_1 reference 팔레트 재사용. */
:root {
  --navy: #1f3a5f;
  --teal: #2a9d8f;
  --teal-d: #21867a;
  --blue: #2b6cb0;
  --blue-d: #225a93;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --ink: #1a202c;
  --sub: #5b6b7f;
  --danger: #c53030;
  --danger-bg: #fff5f5;
  --warn-bg: #fff8e6;
  --warn-line: #f0e0a8;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- 버튼 ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
  color: #fff;
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-primary {
  background: var(--teal);
}
.btn-primary:hover:not(:disabled) {
  background: var(--teal-d);
}
.btn-secondary {
  background: var(--blue);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--blue-d);
}
.btn-ghost {
  background: transparent;
  color: var(--sub);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-d);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.back-link {
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  padding: 0 0 8px;
  font-size: 0.9rem;
}
.back-link:hover {
  color: var(--teal-d);
}

/* ---------- 인증/게이트 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(31, 58, 95, 0.08);
}
.brand {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--navy);
  text-align: center;
}
.auth-sub {
  color: var(--sub);
  font-size: 0.9rem;
  text-align: center;
  margin: 6px 0 22px;
}
.auth-err {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 12px 0 0;
  text-align: center;
}

/* ---------- 폼 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy);
}
.field .req {
  color: var(--danger);
  font-style: normal;
}
.field .opt {
  color: var(--sub);
  font-weight: 400;
  font-style: normal;
  font-size: 0.8rem;
}
.field input,
.field textarea,
.field select,
.inline-form input,
.inline-form select {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.12);
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--ink);
}
.check input {
  width: 18px;
  height: 18px;
}
.stack-form .field {
  margin-bottom: 16px;
}
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-form input {
  flex: 1 1 160px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

/* ---------- 앱 셸 ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-brand {
  font-weight: 900;
  font-size: 1.05rem;
}
.app-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-user .who {
  font-size: 0.86rem;
  opacity: 0.95;
}
.who-grade {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 0.78rem;
  margin-left: 4px;
}
.app-header .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.app-header .btn-ghost:hover {
  border-color: #fff;
  color: #fff;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
}
.app-body {
  flex: 1;
  display: flex;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.app-nav {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
}
.nav-btn {
  text-align: left;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--sub);
  font-weight: 500;
}
.nav-btn:hover {
  background: #eef2f6;
  color: var(--navy);
}
.nav-btn.active {
  background: #e9f7f4;
  color: var(--teal-d);
  font-weight: 700;
}
.app-main {
  flex: 1;
  padding: 24px 22px 80px;
  min-width: 0;
}

/* ---------- 뷰 공통 ---------- */
.view-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--navy);
  margin: 0 0 6px;
}
.view-desc {
  color: var(--sub);
  margin: 0 0 18px;
  font-size: 0.95rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}
.card.notice {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}
.card-title {
  font-size: 1.02rem;
  color: var(--navy);
  margin: 0 0 12px;
}
.hint {
  font-size: 0.83rem;
  color: var(--sub);
  margin: 10px 0 0;
}
.empty {
  color: var(--sub);
  padding: 24px 0;
}
.loading {
  color: var(--sub);
  padding: 30px 0;
  text-align: center;
}
.loading.big {
  padding: 60px 0;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error-box {
  background: var(--danger-bg);
  border: 1px solid #feb2b2;
  color: var(--danger);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 10px 0;
}
.error-box.limit {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--navy);
}
.badge {
  display: inline-block;
  background: #e9f7f4;
  color: var(--teal-d);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge.admin {
  background: #eaf1fb;
  color: var(--blue);
}
.muted {
  color: var(--sub);
  font-size: 0.85rem;
}

/* ---------- 프로필 ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
}
.kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kv .k {
  font-size: 0.78rem;
  color: var(--sub);
}
.kv .v {
  font-weight: 700;
  color: var(--navy);
}
.subject-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.subject-row {
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

/* ---------- 생성 흐름 ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.mode-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: 0.15s;
}
.mode-card:hover {
  border-color: var(--teal);
  box-shadow: 0 6px 18px rgba(42, 157, 143, 0.12);
  transform: translateY(-2px);
}
.mode-emoji {
  font-size: 1.8rem;
}
.mode-name {
  font-weight: 800;
  color: var(--navy);
}
.mode-desc {
  font-size: 0.85rem;
  color: var(--sub);
}
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--navy);
  font-weight: 500;
  transition: 0.15s;
}
.chip:hover {
  border-color: var(--teal);
  background: #e9f7f4;
  color: var(--teal-d);
}
.scope-box {
  background: #eaf1fb;
  border: 1px solid #cfe0f5;
  border-radius: 14px;
  padding: 18px 20px;
}
.scope-row {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
}
.scope-row .k {
  flex: 0 0 60px;
  color: var(--sub);
  font-size: 0.85rem;
}
.scope-row .v {
  font-weight: 700;
  color: var(--navy);
}
.scope-msg {
  margin: 10px 0 0;
  color: var(--blue-d);
  font-weight: 600;
}

/* ---------- 결과/보고서 패널 (reference SPA 재사용) ---------- */
.result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cost-badge {
  font-size: 0.78rem;
  color: var(--sub);
  background: #f0f4f8;
  border-radius: 6px;
  padding: 2px 8px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 16px 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head.setuk {
  background: #e9f7f4;
}
.panel-head.jeongsik {
  background: #eaf1fb;
}
.panel-head .label {
  font-weight: 700;
  font-size: 0.98rem;
}
.panel-head.setuk .label {
  color: var(--teal-d);
}
.panel-head.jeongsik .label {
  color: var(--blue);
}
.panel-head .label small {
  font-weight: 400;
  color: var(--sub);
  margin-left: 6px;
  font-size: 0.78rem;
}
.copy-btn {
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: 0.15s;
  white-space: nowrap;
}
.panel-head.setuk .copy-btn {
  background: var(--teal);
}
.panel-head.setuk .copy-btn:hover {
  background: var(--teal-d);
}
.panel-head.jeongsik .copy-btn {
  background: var(--blue);
}
.panel-head.jeongsik .copy-btn:hover {
  background: var(--blue-d);
}
.copy-btn.done {
  background: #48bb78 !important;
}
.md-body {
  padding: 18px 20px;
}
.md-body h1,
.md-body h2 {
  font-size: 1.15rem;
  color: var(--navy);
  margin: 1.1em 0 0.4em;
}
.md-body h3 {
  font-size: 1rem;
  color: var(--teal-d);
  margin: 1em 0 0.35em;
  padding-left: 8px;
  border-left: 3px solid var(--teal);
}
.jeongsik-body h3 {
  color: var(--blue);
  border-left-color: var(--blue);
}
.md-body p {
  margin: 0.5em 0;
}
.md-body strong {
  color: var(--navy);
}
.md-body ul,
.md-body ol {
  margin: 0.4em 0;
  padding-left: 1.3em;
}
.md-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 0.9rem;
}
.md-body th,
.md-body td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}
.md-body th {
  background: #f0f4f8;
  font-weight: 700;
}
.md-body code {
  background: #eef2f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.md-body blockquote {
  border-left: 3px solid var(--line);
  margin: 0.6em 0;
  padding-left: 12px;
  color: var(--sub);
}
.note {
  font-size: 0.82rem;
  color: var(--sub);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 16px 0 0;
}

/* ---------- 리스트 (히스토리/스케줄) ---------- */
.rec-list,
.plan-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rec-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  transition: 0.15s;
}
.rec-item:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(43, 108, 176, 0.1);
}
.rec-date {
  font-size: 0.82rem;
  color: var(--sub);
  flex: 0 0 auto;
}
.rec-topic {
  font-weight: 500;
}
.plan-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.plan-item.done {
  cursor: pointer;
}
.plan-item.done:hover {
  border-color: var(--teal);
}
.plan-name {
  flex: 1;
}
.plan-status {
  font-size: 0.82rem;
  font-weight: 700;
}
.plan-item.done .plan-status {
  color: var(--teal-d);
}
.plan-item.todo .plan-status {
  color: var(--sub);
}

/* ---------- 추천 ---------- */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.rec-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rec-card.diverse {
  border-style: dashed;
}
.rec-card-topic {
  font-weight: 700;
  color: var(--navy);
}
.rec-card-reason {
  font-size: 0.85rem;
  color: var(--sub);
  flex: 1;
}

/* ---------- 가이드 ---------- */
.guide-text {
  margin: 0;
}
.tips {
  margin: 0;
  padding-left: 1.2em;
}
.tips li {
  margin: 4px 0;
}

/* ---------- 관리자 테이블 ---------- */
.table-wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}
.admin-table th {
  color: var(--sub);
  font-size: 0.8rem;
  font-weight: 700;
}
.admin-table td.num {
  text-align: right;
  white-space: nowrap;
}
.limit-input {
  width: 80px;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 11px 20px;
  border-radius: 24px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
}

/* ---------- 반응형 ---------- */
@media (max-width: 720px) {
  .menu-toggle {
    display: block;
  }
  .app-user .who {
    display: none;
  }
  .app-nav {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--card);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 15;
  }
  .app-shell.nav-open .app-nav {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }
  .app-main {
    padding: 18px 14px 80px;
  }
}

/* ── 생성 진행바 (스트리밍 실시간 진행률) ── */
.gen-progress { max-width: 640px; margin: 0 auto; padding: 8px 0; }
.gen-progress .gp-activity {
  font-size: 15px; font-weight: 600; color: #4338ca;
  margin: 4px 0 18px; min-height: 1.4em;
}
.gp-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 14px 0 6px; font-size: 13px; color: #475569;
}
.gp-label { font-weight: 600; }
.gp-pct { font-variant-numeric: tabular-nums; color: #64748b; }
.gp-track { height: 12px; background: #eef2ff; border-radius: 999px; overflow: hidden; }
.gp-fill { height: 100%; width: 0; border-radius: 999px; transition: width .35s ease; }
.gp-overall { background: linear-gradient(90deg, #4f46e5, #7c3aed, #db2777); }
.gp-setuk { background: #10b981; }
.gp-jeongsik { background: #6366f1; }
.gen-progress .gp-note { margin-top: 20px; font-size: 12px; color: #94a3b8; }

/* ── 패널 액션(복사·Word 저장) ── */
.panel-actions { display: inline-flex; gap: 8px; align-items: center; }
.word-btn {
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 5px 12px; border-radius: 8px;
  color: #fff; background: #2563eb; border: 1px solid #2563eb;
  transition: background .15s ease;
}
.word-btn:hover { background: #1d4ed8; }
.word-btn.done { background: #059669; border-color: #059669; }
