:root {
    /* 간격 — 4px 배수의 단일 리듬 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 72px;

    /* 색 — 짙은 남색 바탕에 밝은 강조색.
       배경은 세 단계(가장 뒤 / 패널 / 패널 위 요소)로만 쓴다. */
    --bg: #0e0f26;
    --bg-glow: #1b1746;
    --panel: #191b3d;
    --panel-2: #21244c;
    --line: rgb(255 255 255 / 9%);
    --line-strong: rgb(255 255 255 / 18%);

    --text: #eceefb;
    --text-soft: #b9bde0;
    --muted: #8b90bd;

    --cyan: #22d3ee;
    --cyan-deep: #0e7490;
    --lime: #a3e635;
    --lime-deep: #4d7c0f;
    --amber: #fbbf24;
    --amber-deep: #d97706;
    --pink: #f472b6;
    --red: #fb7185;

    --success: var(--lime);
    --danger: var(--red);
    --focus: var(--cyan);

    /* 본문 기둥과 글이 편히 읽히는 폭 */
    --content-width: 1000px;
    --reading-width: 720px;
    /* 연습 진행 화면. 숫자에 집중하는 화면이라 본문보다 좁게 잡는다. */
    --stage-width: 760px;
    --stage-narrow: 540px;

    --control-height: 48px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --lift: 0 2px 8px rgb(0 0 0 / 30%);
    --lift-strong: 0 18px 44px -20px rgb(0 0 0 / 70%);
    --glow-cyan: 0 0 0 1px rgb(34 211 238 / 55%), 0 0 20px -4px rgb(34 211 238 / 45%);
    --glow-lime: 0 0 0 1px rgb(163 230 53 / 55%), 0 0 20px -4px rgb(163 230 53 / 45%);

    /* 숫자는 이 앱의 주인공이다. 자릿수가 흔들리지 않는 조판을 쓴다. */
    --numeric: "SF Mono", "Cascadia Mono", "Segoe UI Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    /* 스크롤바가 생기고 사라질 때 본문이 좌우로 밀리지 않게 자리를 미리 비운다. */
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background:
        radial-gradient(1100px 600px at 12% -8%, var(--bg-glow), transparent 62%),
        radial-gradient(900px 520px at 92% 4%, #2a1552, transparent 58%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    /* Noto Sans KR 을 쓰되, 못 받아오면 시스템 글꼴로 내려간다. 교실 PC 가
       네트워크 없이 돌아가는 경우가 있어 글꼴이 없어도 그대로 쓸 수 있어야 한다. */
    font-family: "Noto Sans KR", system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { min-height: var(--control-height); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; border-radius: var(--radius-sm); }

h1, h2, h3, p { margin-top: 0; }
h1 {
    margin-bottom: var(--space-3);
    font-size: clamp(2rem, 1.2rem + 3.2vw, 3rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -.035em;
}
h2 { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
h1[tabindex="-1"]:focus { outline: none; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
}
.skip-link {
    position: fixed; left: var(--space-3); top: -80px; z-index: 100;
    padding: var(--space-3) var(--space-4);
    background: var(--cyan); color: #04121a; font-weight: 700;
    border-radius: var(--radius); box-shadow: var(--lift-strong);
}
.skip-link:focus { top: var(--space-3); }

/* 본문은 어느 화면에서나 같은 기둥 안에 놓인다. 화면을 옮길 때 글의 왼쪽
   끝이 움직이면 같은 앱으로 느껴지지 않는다. 좁은 내용은 기둥 폭을 줄이는
   대신 기둥 안에서 왼쪽에 맞춘다. */
.page-shell {
    width: min(var(--content-width), calc(100% - var(--space-7)));
    margin: 0 auto;
    padding: var(--space-7) 0 var(--space-8);
}
.narrow-shell > *, .setup-screen > * { max-width: var(--reading-width); }
.narrow-shell > .setting-sheet, .setup-screen > .setting-sheet { max-width: var(--reading-width); }
.lead { margin-bottom: var(--space-6); max-width: 54ch; color: var(--muted); font-size: 1rem; }

.eyebrow, .section-label {
    display: inline-block; margin-bottom: var(--space-3);
    color: var(--cyan); font-size: .72rem; font-weight: 800;
    letter-spacing: .16em; text-transform: uppercase;
}

/* ===== 사이드바 + 본문 =====
   kani 처럼 왼쪽에 기능을 세로로 세운다. 좁은 화면에서는 상단 가로 바가 된다. */
body { display: grid; grid-template-columns: 216px minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
.site-header { grid-row: 1 / 4; grid-column: 1; }
/* 격자 항목의 min-width 는 기본이 auto 라, 안에 든 가장 넓은 것보다 작아지지
   않는다. 연습 기록의 여섯 칸 표(min-content 585px)가 본문을 통째로 늘려
   좁은 화면에서 페이지가 옆으로 밀렸다. 0 으로 풀면 표를 감싼
   .record-table-wrap 의 overflow-x 가 제 일을 한다. */
#app-content { grid-column: 2; grid-row: 1 / 3; min-width: 0; }
.site-footer { grid-column: 2; grid-row: 3; }

.site-header {
    position: sticky; top: 0; align-self: start;
    height: 100vh; padding: var(--space-5) var(--space-4);
    display: flex; flex-direction: column; gap: var(--space-6);
    border-right: 1px solid var(--line);
    background: rgb(10 11 32 / 72%);
    backdrop-filter: blur(14px);
    overflow-y: auto;
}
.header-inner { display: contents; }
.site-header { --nav-gap: var(--space-5); }
.brand {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-2); border: 0; background: transparent; color: inherit;
    cursor: pointer; text-align: left; border-radius: var(--radius);
}
.brand:hover { background: rgb(255 255 255 / 6%); }
.brand img { width: 36px; height: 36px; border-radius: 12px; object-fit: cover; }
.brand span { display: grid; line-height: 1.2; }
.brand strong { font-size: .98rem; font-weight: 800; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: .72rem; }

.main-nav { display: grid; gap: var(--space-1); align-content: start; }
/* 홈과 같은 묶음으로 나눈다. 연습과 도구가 한 줄에 섞여 있으면 주판
   연습장 같은 인쇄 도구가 연습 사이에 끼어 보인다. */
.nav-group {
    margin: var(--space-4) 0 var(--space-1); padding: 0 var(--space-3);
    color: var(--muted); font-size: .66rem; font-weight: 800;
    letter-spacing: .16em; text-transform: uppercase;
}
.nav-group:first-child { margin-top: 0; }
.main-nav button {
    width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
    display: flex; align-items: center; gap: var(--space-3);
    word-break: keep-all;
    border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--text-soft);
    font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.main-nav button::before { content: attr(data-icon); width: 1.4em; font-size: 1.02rem; text-align: center; flex-shrink: 0; }
.main-nav button:hover { background: rgb(255 255 255 / 7%); color: var(--text); }
.main-nav button.is-current {
    border-color: rgb(34 211 238 / 45%);
    background: rgb(34 211 238 / 12%); color: var(--cyan); font-weight: 700;
}

.site-footer {
    padding: var(--space-5) var(--space-6) var(--space-6);
    display: flex; justify-content: space-between; gap: var(--space-4);
    color: var(--muted); font-size: .8rem;
}
.site-footer p { margin: 0; }

@media (max-width: 900px) {
    body { grid-template-columns: 1fr; }
    .site-header {
        grid-row: 1; grid-column: 1;
        height: auto; padding: var(--space-3) var(--space-4);
        flex-direction: column; gap: var(--space-3);
        border-right: 0; border-bottom: 1px solid var(--line);
    }
    #app-content { grid-column: 1; grid-row: 2; }
    .site-footer { grid-column: 1; grid-row: 3; flex-direction: column; gap: var(--space-2); }
    /* 격자 항목의 min-width 는 기본이 auto 라 내용보다 작아지지 않는다.
       일곱 버튼의 min-content 가 555px 이라 375px 화면에서 헤더가 587px 로
       삐져나오고 페이지 전체가 옆으로 밀렸다. 0 으로 풀어 주면 아래
       overflow-x 가 제 일을 해 바 안에서만 옆으로 넘긴다. */
    .site-header { min-width: 0; }
    .main-nav { grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-1); overflow-x: auto; min-width: 0; }
    /* 가로 바에서는 묶음 이름을 넣을 자리가 없다. 순서만 남긴다. */
    .nav-group { display: none; }
    /* 한글은 단어 안에서 끊지 않는다. "암산 연 습" 처럼 갈라지는 것을 막는다. */
    .main-nav button {
        min-height: 46px; padding: var(--space-2) var(--space-1);
        flex-direction: column; gap: 2px;
        font-size: .68rem; line-height: 1.25; text-align: center;
        word-break: keep-all; overflow-wrap: normal;
    }
    .main-nav button::before { font-size: 1.1rem; }
    .page-shell { padding: var(--space-6) 0 var(--space-7); }
}
