/* ── 기본 색상과 글꼴 ─────────────────────────────── */
:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #2b2723;
  --muted: #7a726a;
  --line: #e4ddd3;
  --brand: #5b6f8f;
  --brand-ink: #ffffff;
  --brand-soft: #e8edf5;
  --ok: #3f7d5b;
  --ok-soft: #e3f1e8;
  --warn-soft: #fbefe2;
  --danger: #b4483c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 30, .06), 0 4px 16px rgba(60, 45, 30, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.3; margin: .2em 0 .3em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1.02rem; margin: 1.2em 0 .4em; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.print-only, .print-area, .print-head { display: none; }

/* ── 상단 메뉴 ─────────────────────────────────────── */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); }
.menu { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.menu a, .menu-right .admin-link { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.menu a:hover, .menu-right .admin-link:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.menu a.on, .menu-right .admin-link.on { background: var(--brand-soft); color: var(--brand); }
.menu-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu-right .admin-link { border: 1px solid var(--line); }
.linklike { background: none; border: 0; padding: 8px; color: var(--muted); font: inherit; cursor: pointer; }
.linklike:hover { color: var(--ink); }
.linklike.danger { color: var(--danger); }

/* ── 레이아웃 ──────────────────────────────────────── */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 80px; }
.page-head { margin-bottom: 20px; }
.back { display: inline-block; font-size: .9rem; margin-bottom: 4px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.stack > * + * { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.section-title { margin: 28px 0 10px; }
.flash { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 600; }
.alert { background: var(--warn-soft); color: #8a4b1a; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.note { background: var(--brand-soft); border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: .92rem; }

/* ── 목록 ─────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--ink); box-shadow: var(--shadow); }
.list-item:hover { border-color: var(--brand); text-decoration: none; }
.list-item.slim { padding: 12px 16px; }
.list-title { font-weight: 700; font-size: 1.08rem; }
.list-desc { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }
.chev { font-size: 1.6rem; color: var(--muted); }
.tool-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--ink); border-color: var(--brand); }
.tool-card:hover { text-decoration: none; background: var(--brand-soft); }
.doc-card { display: flex; flex-direction: column; gap: 4px; color: var(--ink); margin: 0; }
.doc-card:hover { text-decoration: none; border-color: var(--brand); }
.badge { display: inline-block; font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.badge.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* ── 폼 ───────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .95rem; padding: 0; }
.gender label { display: inline-flex; align-items: center; gap: 6px; margin: 10px 16px 0 0; font-weight: 400; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.big-btn { padding: 14px 32px; font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 5; }
.danger-zone { margin-top: 16px; }
details > summary { cursor: pointer; font-weight: 700; }
details[open] > summary { margin-bottom: 12px; }

.qlist { padding-left: 1.2em; margin: 0; }
.qlist li { margin-bottom: 14px; }
.qlist label { font-weight: 500; }
.instruction .big { font-size: 1.12rem; font-weight: 600; }

/* 자존감 검사 문항 */
.yesno { list-style: none; padding: 0; margin: 0; }
.yesno li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.yesno li:last-child { border-bottom: 0; }
.yn-text { flex: 1; }
.yn-no { display: inline-block; min-width: 2em; color: var(--muted); font-weight: 600; }
.yn-opts { display: flex; gap: 6px; flex-shrink: 0; }
.yn input { position: absolute; opacity: 0; pointer-events: none; }
.yn span { display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); font-weight: 500; font-size: .9rem; cursor: pointer; background: #fff; }
.yn input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.yn input:focus-visible + span { outline: 2px solid var(--brand); }

/* 탭 */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab:hover { text-decoration: none; }
.tabs.big .tab { padding: 10px 18px; }

/* ── 그림 그리기 ───────────────────────────────────── */
.draw-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.tool { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .9rem; cursor: pointer; }
.tool.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.tool-size { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: .9rem; padding: 0 6px; }
.canvas-wrap { margin: 0 auto 8px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.canvas-wrap.portrait { aspect-ratio: 3 / 4; max-width: min(100%, 560px); }
.canvas-wrap.landscape { aspect-ratio: 4 / 3; max-width: min(100%, 760px); }
#pad { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#upload-preview { max-width: 100%; max-height: 480px; margin-top: 12px; border-radius: 8px; border: 1px solid var(--line); }
.drawing-img { display: block; max-width: 100%; max-height: 640px; margin: 0 auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* ── 결과 / 분석 ──────────────────────────────────── */
.score-card { text-align: center; }
.score { font-size: 3.2rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.score small { font-size: 1.2rem; margin-left: 2px; }
.qa dt { font-weight: 600; margin-top: 12px; }
.qa dd { margin: 4px 0 0; padding: 8px 12px; background: var(--bg); border-radius: 8px; }
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #faf8f5; }
.table.compact th, .table.compact td { padding: 7px 10px; }
.table tr.diff td { background: var(--warn-soft); }
.row-link { cursor: pointer; }
.row-link:hover td { background: #faf8f5; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.checkgroup { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.checkgroup legend { font-weight: 700; padding-right: 8px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; padding: 4px 0; cursor: pointer; }
.check input { margin-top: 5px; }
.report-text { white-space: normal; line-height: 1.75; }

/* 문서 */
.doc h1 { margin-bottom: .6em; }
.doc h2 { margin-top: 1.6em; padding-top: .6em; border-top: 1px solid var(--line); }
.doc li { margin-bottom: .4em; }
.doc ol.num { list-style: none; padding-left: 0; }
.doc q { font-weight: 600; }

/* ── 로그인 ───────────────────────────────────────── */
body.bare { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
body.bare .wrap { width: 100%; }
.login-box { max-width: 380px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 1.4rem; }
.login-box form .btn { width: 100%; margin-top: 14px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 24px 0 14px; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.g_id_signin { display: flex; justify-content: center; }

/* ── 포트폴리오 기록지 ─────────────────────────────── */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 28px; box-shadow: var(--shadow); }
.sheet-title { text-align: center; font-weight: 800; font-size: 1.35rem; letter-spacing: .3em; padding: 12px 0; border-top: 4px double #222; border-bottom: 4px double #222; margin-bottom: 0; }
.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th, .sheet-table td { border: 1px solid #222; padding: 10px 12px; vertical-align: top; }
.sheet-table tr:first-child th, .sheet-table tr:first-child td { border-top: 0; }
.sheet-label { width: 88px; text-align: center; vertical-align: middle !important; font-weight: 700; background: #fafafa; }
.sheet-q { font-weight: 700; margin-bottom: 6px; }
.sheet-input, .sheet-area { border: 1px dashed transparent !important; background: #fcfbf8 !important; margin: 0 !important; }
.sheet-input:focus, .sheet-area:focus { border-color: var(--brand) !important; background: #fff !important; }
.sheet-foot { text-align: right; font-size: .85rem; color: #444; margin-top: 10px; }

/* PDF로 만들 때 쓰는 기록지 (화면에서는 숨겨진 영역 안에 있음) */
.sheet-print { width: 186mm; padding: 0; border: 0; box-shadow: none; border-radius: 0; font-size: 11pt; color: #111; }
.sheet-print .sheet-title { font-size: 17pt; }
.sheet-print .sheet-cell-title { font-size: 12pt; font-weight: 600; height: 14mm; vertical-align: middle; }
/* A4 한 장(위아래 여백 12mm)에 들어가도록 높이를 맞춤: 18+14+98+62+62+6 = 260mm */
.sheet-print .sheet-cell { height: 62mm; }
.sheet-print .sheet-cell.big { height: 98mm; }
.sheet-print .sheet-text { line-height: 1.75; word-break: keep-all; overflow-wrap: anywhere; }

/* ── 모바일 ───────────────────────────────────────── */
@media (max-width: 760px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .split { grid-template-columns: 1fr; }
  .yesno li { flex-direction: column; align-items: stretch; }
  .yn-opts { justify-content: flex-end; }
  .topbar-in { gap: 8px; padding: 6px 12px; }
  .menu { order: 3; width: 100%; flex: none; }
  .sheet { padding: 14px; }
  .sheet-label { width: 56px; font-size: .85rem; }
}

/* ── 인쇄 ─────────────────────────────────────────── */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .no-print, .topbar, .flash { display: none !important; }
  .print-only { display: block; }
  .print-head { display: block; margin-bottom: 8mm; }
  .print-head h1 { font-size: 15pt; margin: 0; }
  .wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .split { grid-template-columns: 1fr 1fr; }
  .drawing-img { max-height: 120mm; }
  .print-area { display: block; }
  #counsel { break-before: page; }
  .sheet-print { width: 100%; }
}
