/* 시나브로 파이썬 — 밝고 친근한 기본 테마. 글자 16px 이상, 높은 대비, 눈에 잘 띄는 포커스, 움직임 줄이기 존중.
   CSS 변수(SPEC 10-2): --bg --fg --muted --accent --ok --bad --warn --radius --font (다른 화면도 이것을 쓴다) */
@import url("_parts/home.css");
@import url("_parts/learn.css");
@import url("_parts/lesson.css");
@import url("_parts/editor.css");
@import url("_parts/markdown.css");
@import url("_parts/playground.css");

:root {
  --font: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "D2Coding", Menlo, Consolas, monospace;
  --bg: #f5f7fc;
  --bg2: #eef2fa;
  --panel: #ffffff;
  --fg: #1b2440;
  --fg2: #3a4566;
  --muted: #56617f;
  --line: #e0e6f1;
  --line2: #cbd5e6;
  --accent: #3563e9;
  --accent2: #2549b8;
  --accent-soft: #e9efff;
  --sun: #ffd84d;
  --sun-soft: #fff7d6;
  --mint-soft: #e3f8ef;
  --pink-soft: #ffe9f0;
  --lilac-soft: #f1ecff;
  --ok: #157a3c;
  --ok-soft: #e5f6ea;
  --bad: #c42b2b;
  --bad-soft: #fdeceb;
  --warn: #a8540a;
  --warn-soft: #fff3dc;
  --focus: #ffaf1a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22, 34, 70, .06), 0 6px 18px rgba(22, 34, 70, .07);
  --shadow-lg: 0 14px 40px rgba(22, 34, 70, .18);
  --top-h: 60px;
  /* data-lab 이름(같은 값) */
  --ink: var(--fg); --ink2: var(--fg2); --brand: var(--accent); --brand2: var(--accent2); --brand-soft: var(--accent-soft);
  --err: var(--bad); --err-soft: var(--bad-soft); --r: var(--radius); --r-sm: var(--radius-sm);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 12px); }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--fg); background: var(--bg); word-break: keep-all; overflow-wrap: anywhere; }
img, svg { max-width: 100%; }
a { color: var(--accent2); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { line-height: 1.3; letter-spacing: -.02em; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 1000; background: var(--fg); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.small, small { font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: 14px; background: #fff; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
code { font-family: var(--mono); font-size: .92em; background: var(--bg2); padding: 1px 5px; border-radius: 5px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* ------------------------------------------------------------------ 상단 막대 #topbar */
#topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 10px; min-height: var(--top-h);
  padding: 8px clamp(12px, 3vw, 28px); background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #3563e9 0 50%, #ffd84d 50% 100%); box-shadow: 0 2px 6px rgba(53, 99, 233, .3); }
.brand-mark span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #fff; color: #2549b8; font: 800 13px/1 var(--mono); }
.brand-name b { color: var(--accent); }
.topnav { display: flex; gap: 2px; margin-left: 8px; margin-right: auto; }
.topnav-link { padding: 7px 12px; border-radius: 10px; text-decoration: none; color: var(--fg2); font-weight: 700; font-size: 16px; white-space: nowrap; }
.topnav-link:hover { background: var(--bg2); }
.topnav-link.is-active { background: var(--accent-soft); color: var(--accent2); }
.topbar-account { margin-left: auto; }
.topnav + .topbar-account { margin-left: 0; }

/* ------------------------------------------------------------------ 단추·입력 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--line2); background: #fff; color: var(--fg); font-weight: 700; font-size: 16px; text-decoration: none; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s; }
.btn:hover:not(:disabled) { background: var(--bg2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent2); }
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-run { background: #1f9d55; border-color: #1f9d55; color: #fff; box-shadow: 0 2px 0 #157a3c; }
.btn-run:hover:not(:disabled) { background: #157a3c; }
.btn-stop { background: #fff; border-color: #f0b4b4; color: var(--bad); }
.btn-stop:hover:not(:disabled) { background: var(--bad-soft); }
.btn-danger { color: var(--bad); border-color: #f1c4c4; }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ai { background: #fff6ec; border-color: #ffd2a6; color: #8a4500; }
.btn-ai:hover:not(:disabled) { background: #ffeedb; }
.btn-ai img { width: 22px; height: 22px; }
.btn-sm { min-height: 36px; padding: 5px 12px; font-size: 15px; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 10px 24px; font-size: 18px; border-radius: 16px; }
.btn-google { background: #fff; border-color: var(--line2); }
.g-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 13px; color: #fff;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); }
.btn-account { padding: 4px 12px 4px 4px; border-radius: 999px; max-width: 220px; }
.account-name { overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-letter { display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent2); font-weight: 800; }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--bg2); color: var(--fg); }
.link-btn { background: none; border: 0; padding: 2px 4px; color: var(--accent2); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.input { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 12px; background: #fff; font-size: 16px; }
.input:focus { border-color: var(--accent); outline: 3px solid rgba(53, 99, 233, .22); outline-offset: 0; }
.input-sm { min-height: 36px; padding: 5px 10px; font-size: 15px; }
.input-code, textarea.input-code { font-family: var(--mono); font-size: 15px; }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { padding-right: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 700; font-size: 15px; color: var(--fg2); }
.field-help { color: var(--muted); font-size: 15px; }
.check-row { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px 4px 8px; border: 1px solid var(--line2); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.check-row:has(input:checked) { background: var(--accent-soft); border-color: #b8c8fb; }
.copy-row { display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; font-size: 15px; font-weight: 700; color: var(--fg2); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--fg); border-color: var(--fg); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; background: var(--bg2); color: var(--fg2); font-size: 14px; font-weight: 700; white-space: nowrap; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-server { background: var(--lilac-soft); color: #5b3cc4; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 15px; font-weight: 700; }

/* ------------------------------------------------------------------ 카드·알림 띠·진행 막대 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(14px, 2.4vw, 22px); }
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--fg); font-size: 16px; }
.msg-ic { flex: none; }
.msg-warning { background: var(--warn-soft); } .msg-error { background: var(--bad-soft); color: #7f1d1d; } .msg-ok { background: var(--ok-soft); }
.msg-hint { background: var(--lilac-soft); }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px clamp(12px, 3vw, 28px); background: var(--sun-soft); border-bottom: 1px solid #f3df8f; color: #5a4300; font-size: 16px; }
.banner a, .banner .link-btn { color: #6b4c00; font-weight: 800; }
.progress { position: relative; display: block; height: 12px; border-radius: 999px; background: var(--bg2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.progress-sm { height: 8px; }
.progress-bar { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, #3ecf8e, #1f9d55); transition: width .4s ease; }
.empty-box { padding: 22px; border: 2px dashed var(--line2); border-radius: var(--radius); text-align: center; color: var(--muted); background: #fff; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 16px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg2), #f8faff, var(--bg2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); min-height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ 트랙 카드(첫 화면·/learn 공용) */
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.track-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 20px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.track-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #c4d2fb; }
.track-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.track-emoji { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-size: 28px; background: var(--accent-soft); }
.track-card[data-track="al"] .track-emoji { background: var(--lilac-soft); }
.track-card[data-track="ds"] .track-emoji { background: var(--mint-soft); }
.track-card[data-track="ai"] .track-emoji { background: var(--sun-soft); }
.track-card[data-track="ml"] .track-emoji { background: #e6f7e9; }
.track-card[data-track="tf"] .track-emoji { background: var(--pink-soft); }
.track-card[data-track="pt"] .track-emoji { background: #ffeadf; }
.track-card[data-track="pj"] .track-emoji { background: #e5f3ff; }
.track-subject { font-size: 14px; font-weight: 800; color: var(--accent2); text-align: right; }
.track-title { margin: 2px 0 0; font-size: 19px; }
.track-summary { margin: 0; color: var(--fg2); font-size: 15.5px; flex: 1; }
.track-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 15px; color: var(--muted); }
.track-progress { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

/* ------------------------------------------------------------------ 아래 줄 */
.site-foot { margin-top: 40px; padding: 26px 0 40px; border-top: 1px solid var(--line); background: #fff; font-size: 15px; color: var(--fg2); }
.foot-grid { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.foot-brand p { margin: 0 0 6px; }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }
.server-line { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.server-dot { width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; flex: none; }

/* ------------------------------------------------------------------ 알림·창·메뉴 (util.js) */
.toasts { position: fixed; z-index: 900; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; background: var(--fg); color: #fff; box-shadow: var(--shadow-lg); animation: toastIn .2s ease-out; font-size: 16px; }
.toast-ok { background: #14532d; } .toast-warning { background: #7c4a03; } .toast-error { background: #8f1d1d; }
.toast.bye { opacity: 0; transform: translateY(6px); transition: .25s; }
.toast-act { margin-left: auto; border: 0; border-radius: 10px; padding: 4px 10px; background: rgba(255, 255, 255, .18); color: #fff; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; z-index: 800; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.modal-back-closing { position: fixed; inset: 0; z-index: 800; background: rgba(15, 23, 42, .2); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .16s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal, .modal-closing { width: min(540px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-wide { width: min(980px, 100%); }
.modal-full { width: min(1280px, 100%); height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-title { margin: 0; font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
body.has-modal { overflow: hidden; }
.popmenu { position: fixed; z-index: 850; min-width: 230px; max-width: min(380px, calc(100vw - 12px)); max-height: min(70vh, 520px); overflow: auto; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.popmenu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; min-height: 42px; }
.popmenu-item:hover:not(:disabled), .popmenu-item:focus-visible { background: var(--bg2); }
.popmenu-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; font-size: 17px; }
.popmenu-label { flex: 1; font-weight: 700; }
.popmenu-sub { color: var(--muted); font-size: 14px; }
.popmenu-head { padding: 6px 10px; font-size: 15px; font-weight: 700; color: var(--muted); }
.popmenu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ------------------------------------------------------------------ 좁은 화면 */
@media (max-width: 760px) {
  #topbar { gap: 6px; }
  .brand-name { display: none; }
  .topnav { margin-left: 0; }
  .topnav-link { padding: 7px 9px; font-size: 15px; }
  .btn-google .login-label { font-size: 15px; }
  .account-name { display: none; }
  .btn-account { padding: 4px; }
}
@media (max-width: 400px) {
  .topnav-link { padding: 6px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
