/* ═══════════════════════════════════════════════
   LUNA NOTE · Magazine Kiosk + A4 Editor
   Style: Monocle official (white paper + black ink + yellow accent)
   ═══════════════════════════════════════════════ */

:root {
    /* White paper — Monocle 정체성 */
    --paper: #FFFFFF;
    --paper-deep: #FAFAFA;
    --card: #FFFFFF;
    --card-edge: #E5E5E5;

    /* Pure ink */
    --ink: #000000;
    --ink-soft: #333333;
    --ink-faint: #999999;
    --ink-rule: #000000;

    /* Monocle accents */
    --accent-red: #D9001F;     /* Monocle red (선명) */
    --accent-yellow: #FFD300;  /* Monocle yellow (SUBSCRIBE) */
    --accent-sage: #B8D4C0;    /* sidebar brand */
    --accent-coral: #F4A78F;   /* magazine cover variant */

    /* Spacing & motion */
    --gutter: clamp(16px, 3vw, 32px);
    --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Type */
    --serif: 'Cormorant Garamond', 'Times New Roman', serif;
    --sans: 'Plus Jakarta Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --korean: 'Jua', 'Plus Jakarta Sans', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

html, body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ═══ Layout — centered + sidebar offset via padding ═══ */
.brand-nav,
.masthead,
.hero-bar,
.subject-nav,
.kiosk,
.masthead-footer {
    max-width: 1280px;
    margin: 0 auto;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
    position: relative;
    z-index: 1;
    box-sizing: content-box;
}
@media (min-width: 768px) {
    body { padding-left: 80px; }  /* compensate fixed sidebar */
    .brand-nav,
    .masthead,
    .hero-bar,
    .subject-nav,
    .kiosk,
    .masthead-footer {
        max-width: 1200px;
    }
}

/* ═══ TOP BRAND NAV (Monocle: hamburger + MAGAZINE | RADIO | SHOP + LOG IN + SUBSCRIBE) ═══ */
.brand-nav {
    padding-top: 18px;
    padding-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 24px;
    border-bottom: 1px solid var(--card-edge);
}

.brand-hamburger {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    color: var(--ink);
}
.brand-hamburger .material-symbols-rounded { font-size: 22px; }

.brand-menu {
    display: flex;
    align-items: center;
    gap: 22px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.brand-menu a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.15s ease;
    position: relative;
    padding: 4px 0;
}
.brand-menu a.active::after,
.brand-menu a:hover::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0; right: 0;
    height: 2px;
    background: var(--accent-red);
}

.brand-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-search {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ink);
    display: inline-flex;
    padding: 4px;
}
.brand-search .material-symbols-rounded { font-size: 20px; }

.brand-login {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    text-decoration: none;
    padding: 4px 6px;
}
.brand-login:hover { color: var(--accent-red); }

.brand-subscribe {
    background: var(--accent-yellow);
    color: var(--ink);
    padding: 9px 18px;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    border: 1px solid var(--ink);
    transition: all 0.15s ease;
}
.brand-subscribe:hover {
    background: var(--ink);
    color: var(--accent-yellow);
}

@media (max-width: 640px) {
    .brand-menu { display: none; }
    .brand-login { display: none; }
}

/* ═══ MASTHEAD ═══ */
.masthead {
    padding-top: clamp(28px, 5vw, 56px);
    padding-bottom: clamp(20px, 3vw, 32px);
    border-bottom: 1px solid var(--ink);
    text-align: center;
}

.masthead-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 24px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: clamp(8px, 1vw, 14px);
    flex-wrap: wrap;
}

.masthead-issue { display: flex; gap: 16px; align-items: baseline; }
.issue-no { color: var(--accent-red); font-weight: 700; }
.issue-date { color: var(--ink); font-weight: 500; }

.masthead-tagline {
    font-family: var(--serif);
    font-style: italic;
    text-transform: none;
    font-size: 14px;
    letter-spacing: 0;
    color: var(--ink-soft);
    flex: 1;
    text-align: center;
}

.masthead-meta { display: flex; gap: 8px; }
.meta-item {
    background: var(--accent-yellow);
    color: var(--ink);
    padding: 2px 8px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

/* Masthead main row: left decoration + centered title + right decoration */
.masthead-main {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    gap: clamp(16px, 3vw, 40px);
    width: 100%;
    margin: 0 auto;
}

.masthead-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--serif);
    font-size: 14px;
    font-style: italic;
    line-height: 1.3;
    color: var(--ink);
}
.masthead-side-illust {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.masthead-side-illust svg { width: 100%; height: 100%; }
.masthead-side-text {
    font-style: italic;
    font-weight: 400;
}
.masthead-side-text small {
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-style: normal;
    color: var(--ink-faint);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .masthead-main { grid-template-columns: 1fr; }
    .masthead-side { display: none; }
}

.masthead-title {
    font-family: var(--serif);
    font-weight: 700;
    line-height: 0.92;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0;
    text-align: center;
}

.title-main {
    font-size: clamp(56px, 10vw, 140px);
    display: inline-block;
    color: var(--ink);
    font-weight: 700;
    white-space: nowrap;
}
@media (max-width: 768px) {
    .title-main {
        font-size: clamp(48px, 14vw, 84px);
        white-space: normal;
    }
}

.masthead-bottom {
    margin-top: clamp(12px, 2vw, 20px);
    display: flex;
    justify-content: center;
}

.masthead-strap {
    font-family: var(--serif);
    font-style: italic;
    font-size: clamp(16px, 1.8vw, 22px);
    color: var(--ink-soft);
    letter-spacing: 0.02em;
}

/* ═══ HERO BAR ═══ */
.hero-bar {
    padding: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--card-edge);
}

.hero-stats {
    display: flex;
    gap: clamp(20px, 4vw, 48px);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.stat-num {
    font-family: var(--serif);
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}

.stat-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.hero-actions { display: flex; gap: 12px; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-yellow);
    color: var(--ink);
    padding: 14px 26px;
    border: 1px solid var(--ink);
    border-radius: 0;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-primary:hover {
    background: var(--ink);
    color: var(--accent-yellow);
}
.btn-primary .material-symbols-rounded { font-size: 18px; }

.btn-large { padding: 18px 32px; font-size: 14px; }

/* ═══ SUBJECT NAV ═══ */
.subject-nav {
    padding: 20px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: auto;
    border-bottom: 1px solid var(--card-edge);
}

.subject-tab {
    --sc: var(--ink);
    background: transparent;
    color: var(--ink-soft);
    border: 1.5px solid var(--card-edge);
    padding: 8px 16px;
    border-radius: 999px;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.subject-tab:hover {
    border-color: var(--sc);
    color: var(--ink);
}
.subject-tab.active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.subject-tab[data-subject="all"].active { background: var(--ink); border-color: var(--ink); }

/* ═══ KIOSK (Section grids) ═══ */
.kiosk {
    padding: 32px 0 80px;
}

.kiosk-section {
    margin-bottom: clamp(40px, 6vw, 80px);
}

/* Black bar header — Monocle "LATEST ISSUES" style */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--ink);
    color: #FFFFFF;
    padding: 10px 20px;
    margin-bottom: 28px;
}

.section-title {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.section-line { display: none; }

.section-meta {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-yellow);
}

/* ═══ NOTES GRID (Monocle magazine cover layout) ═══ */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: clamp(20px, 2.5vw, 36px) clamp(20px, 2.5vw, 32px);
}

.note-card-wrap {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 14px;
    cursor: pointer;
}

.note-card {
    --sc: var(--accent-sage);
    background: var(--card);
    border: 1px solid var(--ink);
    overflow: hidden;
    position: relative;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    aspect-ratio: 210 / 280; /* magazine cover */
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}

/* Top black masthead inside the card (mini Monocle cover) */
.note-cover {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.note-cover-masthead {
    font-family: var(--serif);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.04em;
    border-bottom: 1.5px solid var(--ink);
    padding-bottom: 6px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.note-cover-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.note-subject {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink);
    padding: 3px 7px;
    background: var(--sc);
    border-radius: 0;
    font-weight: 700;
}

.note-pub-badge {
    font-size: 14px;
    color: var(--accent-red);
    display: flex;
    align-items: center;
    font-family: var(--mono);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.note-pub-badge .material-symbols-rounded { font-size: 14px; }

.note-title {
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-preview {
    font-family: var(--sans);
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink-soft);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-cover-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--ink);
    margin-top: auto;
}

.note-date {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    color: var(--ink);
    font-weight: 600;
    text-transform: uppercase;
}

.note-hearts {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-red);
}
.note-hearts .material-symbols-rounded { font-size: 12px; }

/* Worksheet card variant */
.note-card-wrap.is-worksheet .note-card {
    background: linear-gradient(135deg, #FFFFFF 0%, #FFFBEF 100%);
    border-color: var(--accent-red);
}
.note-card-wrap.is-worksheet .note-cover-masthead {
    color: var(--accent-red);
    border-bottom-color: var(--accent-red);
}
.note-ws-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink);
    background: var(--accent-yellow);
    padding: 2px 8px;
    border: 1px solid var(--ink);
}
.note-ws-badge .material-symbols-rounded { font-size: 12px; }

/* Category badge on kiosk card */
.note-cat-badge {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 700;
    color: var(--ink);
    background: rgba(255,255,255,0.92);
    border-top: 1px solid var(--card-edge);
    padding: 4px 6px;
    z-index: 2;
    letter-spacing: 0.04em;
}

/* Caption below card (Monocle: Title + ISSUE meta) */
.note-caption {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
}
.note-caption .caption-title {
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-caption .caption-meta {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 600;
}

/* Move hover effect to the wrap */
.note-card-wrap:hover .note-card {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}
.note-card-wrap:hover .caption-title {
    color: var(--accent-red);
}
.note-card { transform: translateY(0); transition: transform 0.25s ease, box-shadow 0.25s ease; }

/* ═══ EMPTY STATE ═══ */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 72px 24px;
    background: var(--paper-deep);
    border: 1px solid var(--card-edge);
    border-radius: 0;
    gap: 16px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 0;
    background: var(--accent-yellow);
    border: 1px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}
.empty-icon .material-symbols-rounded { font-size: 44px; color: var(--ink); }

.empty-title {
    font-family: var(--serif);
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
}

.empty-desc {
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink-soft);
    max-width: 520px;
    margin-bottom: 16px;
}

/* ═══ COMING SOON SECTION ═══ */
.coming-soon { opacity: 0.85; }

.coming-card {
    background: var(--paper-deep);
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: clamp(24px, 4vw, 40px);
    position: relative;
    overflow: hidden;
}

.coming-card::before {
    content: "V2";
    position: absolute;
    top: 0; right: 0;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink);
    background: var(--accent-yellow);
    padding: 6px 14px;
    border-radius: 0;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.coming-card p {
    font-family: var(--serif);
    font-size: 20px;
    line-height: 1.55;
    color: var(--ink);
    margin-bottom: 20px;
    max-width: 640px;
}

.coming-list {
    list-style: none;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.coming-list li {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--paper);
    padding: 8px 14px;
    border-radius: 0;
    border: 1px solid var(--ink);
    font-weight: 600;
}

/* ═══ FOOTER ═══ */
.masthead-footer {
    padding: 24px 0 32px;
    border-top: 3px double var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    flex-wrap: wrap;
    gap: 12px;
}

/* ═══════════════════════════════════════════════
   EDITOR — PS menu bar + Word ribbon + Notion sidebar + A4 canvas
   ═══════════════════════════════════════════════ */

body.editor-mode {
    background-color: #F4F4F4;
    padding-left: 80px;
}

/* ═══ PHOTOSHOP-STYLE MENU BAR (top, ultra slim) ═══ */
.ps-menu-bar {
    position: sticky;
    top: 0;
    z-index: 70;
    display: flex;
    height: 30px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--card-edge);
    align-items: center;
    padding: 0 8px;
    gap: 2px;
    font-family: var(--sans);
    font-size: 12.5px;
    user-select: none;
}

.ps-menu-bar .menu-item {
    position: relative;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 3px;
    color: var(--ink);
    transition: background 0.1s ease;
}
.ps-menu-bar .menu-item:hover { background: #EFEFEF; }
.ps-menu-bar .menu-item.open { background: var(--ink); color: var(--accent-yellow); }

.ps-menu-bar .menu-dropdown {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    background: #FFFFFF;
    border: 1px solid var(--ink);
    min-width: 240px;
    padding: 4px 0;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    border-radius: 0;
}
.ps-menu-bar .menu-item.open > .menu-dropdown { display: block !important; }
.ps-menu-bar .submenu .menu-dropdown { display: none !important; }
.ps-menu-bar .submenu:hover > .menu-dropdown { display: block !important; }

.menu-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 16px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--ink);
    transition: background 0.1s ease;
}
.menu-action:hover { background: var(--accent-yellow); }
.menu-action .shortcut {
    color: var(--ink-faint);
    margin-left: 32px;
    font-family: var(--mono);
    font-size: 11px;
}
.menu-action:hover .shortcut { color: var(--ink); }

.menu-sep {
    height: 1px;
    background: var(--card-edge);
    margin: 4px 0;
}

.ps-menu-bar .submenu { position: relative; }
.ps-menu-bar .submenu > .menu-action::after {
    content: '▶';
    font-size: 8px;
    margin-left: 8px;
}
.ps-menu-bar .submenu .menu-dropdown {
    left: 100%;
    top: -5px;
    border-left: 1px solid var(--ink);
}
@media (max-width: 768px) {
    body.editor-mode { padding-left: 0; }
}

/* ─── Editor topbar (slim) ─── */
.editor-topbar {
    position: sticky;
    top: 30px;
    z-index: 60;
    background: #FFFFFF;
    border-bottom: 1px solid var(--ink);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
}

.editor-back {
    background: transparent;
    border: 1px solid var(--card-edge);
    color: var(--ink);
    width: 32px;
    height: 32px;
    border-radius: 0;
    text-decoration: none;
    font-family: var(--sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    cursor: pointer;
    padding: 0;
}
.editor-back:hover { background: var(--ink); color: var(--accent-yellow); border-color: var(--ink); }

.editor-title-input {
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    flex: 1;
    min-width: 160px;
    padding: 6px 4px;
    border-bottom: 1px dashed transparent;
}
.editor-title-input:focus { border-bottom-color: var(--ink); }
.editor-title-input::placeholder { color: var(--ink-faint); font-style: italic; }

.editor-subject {
    background: var(--paper);
    border: 1px solid var(--card-edge);
    border-radius: 0;
    padding: 6px 10px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    outline: none;
    cursor: pointer;
}

.editor-meta {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-faint);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    min-width: 56px;
    text-align: right;
}

.editor-actions { display: flex; gap: 6px; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--card-edge);
    color: var(--ink);
    width: 32px;
    height: 32px;
    border-radius: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.btn-ghost:hover { background: var(--ink); color: var(--accent-yellow); }
.btn-ghost .material-symbols-rounded { font-size: 18px; }

/* ═══ WORD RIBBON ═══ */
.word-ribbon {
    position: sticky;
    top: 78px;
    z-index: 55;
    background: #FAFAFA;
    border-bottom: 1px solid var(--ink);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    overflow-x: auto;
}

.ribbon-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ribbon-sep {
    width: 1px;
    height: 24px;
    background: var(--card-edge);
    margin: 0 4px;
}

.ribbon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink);
    width: 30px;
    height: 30px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.ribbon-btn:hover {
    background: #E8E8E8;
}
.ribbon-btn:active,
.ribbon-btn.active {
    background: var(--ink);
    color: var(--accent-yellow);
}
.ribbon-btn .material-symbols-rounded { font-size: 18px; }
.ribbon-btn b, .ribbon-btn i, .ribbon-btn u, .ribbon-btn s {
    font-size: 14px;
}

.ribbon-select {
    background: #FFFFFF;
    border: 1px solid var(--card-edge);
    border-radius: 3px;
    padding: 6px 6px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    outline: none;
    cursor: pointer;
    min-width: 96px;
    height: 30px;
}
.ribbon-select-sm { min-width: 50px; }
.ribbon-select-md { min-width: 130px; }

.ribbon-color-btn {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    width: 30px;
    height: 30px;
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}
.ribbon-color-btn:hover { background: #E8E8E8; }
.ribbon-color-letter {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
    margin-top: 2px;
}
.ribbon-color-btn .material-symbols-rounded { font-size: 14px; margin-top: 2px; }
.ribbon-color-bar {
    width: 18px;
    height: 4px;
    margin-top: 1px;
    border: 1px solid var(--ink);
}
.ribbon-color-btn input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    border: none;
}

.ribbon-group-grid {
    display: flex;
    align-items: center;
    gap: 4px;
}
.ribbon-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-right: 2px;
}
.ribbon-grid {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 12px;
}

/* ═══ EDITOR SHELL ═══ */
.editor-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 126px);
}

@media (max-width: 900px) {
    .editor-shell { grid-template-columns: 1fr; }
    .notion-sidebar { display: none; }
}

/* ═══ NOTION-STYLE LEFT SIDEBAR ═══ */
.notion-sidebar {
    background: #FAFAFA;
    border-right: 1px solid var(--card-edge);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 126px);
    position: sticky;
    top: 126px;
}

.notion-sidebar-header {
    padding: 12px 12px 10px;
    border-bottom: 1px solid var(--card-edge);
    display: flex;
    gap: 6px;
    align-items: center;
}

.notion-search {
    flex: 1;
    background: #FFFFFF;
    border: 1px solid var(--card-edge);
    border-radius: 3px;
    padding: 6px 10px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    outline: none;
}
.notion-search:focus { border-color: var(--ink); }
.notion-search::placeholder { color: var(--ink-faint); }

.notion-newbtn {
    background: var(--accent-yellow);
    border: 1px solid var(--ink);
    width: 30px;
    height: 30px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    transition: all 0.15s ease;
}
.notion-newbtn:hover { background: var(--ink); color: var(--accent-yellow); }
.notion-newbtn .material-symbols-rounded { font-size: 18px; }

.notion-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.tree-group {
    margin-bottom: 4px;
}
.tree-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 4px;
    user-select: none;
}
.tree-group-label {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.tree-group-count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-faint);
    background: #FFFFFF;
    border: 1px solid var(--card-edge);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 600;
}

.tree-group-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px 5px 22px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink-soft);
    transition: background 0.1s ease;
    user-select: none;
}
.tree-item:hover { background: #EFEFEF; color: var(--ink); }
.tree-item.active {
    background: var(--accent-yellow);
    color: var(--ink);
    font-weight: 700;
}

.tree-item-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--ink);
    flex-shrink: 0;
    opacity: 0.4;
}
.tree-item.active .tree-item-dot { opacity: 1; }

.tree-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-empty {
    text-align: center;
    padding: 40px 16px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink-faint);
    line-height: 1.6;
}

.notion-sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--card-edge);
}

.notion-footer-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--card-edge);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.notion-footer-btn:hover { background: var(--ink); color: var(--accent-yellow); border-color: var(--ink); }
.notion-footer-btn .material-symbols-rounded { font-size: 16px; }

/* ═══ A4 CANVAS ═══ */
.canvas-scroll {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 24px 80px;
    overflow-x: auto;
    background: #F4F4F4;
}

.a4-page {
    --zoom: 0.75;
    --grid-cols: 1;
    width: calc(210mm * var(--zoom));
    min-height: calc(297mm * var(--zoom));
    background: white;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
    position: relative;
    transform-origin: top center;
}

.a4-content {
    padding: calc(20mm * var(--zoom)) calc(18mm * var(--zoom));
    min-height: calc(297mm * var(--zoom) - 40mm * var(--zoom));
    outline: none;
    font-family: var(--sans);
    font-size: calc(11pt * var(--zoom));
    line-height: 1.7;
    color: var(--ink);
    column-count: var(--grid-cols);
    column-gap: calc(8mm * var(--zoom));
    column-rule: 1px solid transparent;
}

.a4-content:empty::before {
    content: attr(placeholder);
    color: var(--ink-faint);
    font-style: italic;
}

.a4-content p {
    margin: 0 0 calc(8px * var(--zoom));
    break-inside: avoid;
}
.a4-content h1 {
    font-family: var(--serif);
    font-size: calc(24pt * var(--zoom));
    font-weight: 700;
    line-height: 1.2;
    margin: calc(12px * var(--zoom)) 0 calc(8px * var(--zoom));
    column-span: all;
}
.a4-content h2 {
    font-family: var(--serif);
    font-size: calc(18pt * var(--zoom));
    font-weight: 700;
    line-height: 1.25;
    margin: calc(10px * var(--zoom)) 0 calc(6px * var(--zoom));
}
.a4-content h3 {
    font-family: var(--serif);
    font-size: calc(14pt * var(--zoom));
    font-weight: 700;
    line-height: 1.3;
    margin: calc(8px * var(--zoom)) 0 calc(4px * var(--zoom));
}
.a4-content blockquote {
    font-family: var(--serif);
    font-style: italic;
    font-size: calc(12pt * var(--zoom));
    color: var(--ink-soft);
    border-left: 3px solid var(--accent-red);
    padding-left: calc(12px * var(--zoom));
    margin: calc(8px * var(--zoom)) 0;
}
.a4-content ul,
.a4-content ol {
    margin: calc(6px * var(--zoom)) 0;
    padding-left: calc(22px * var(--zoom));
}
.a4-content li { margin-bottom: calc(3px * var(--zoom)); }
.a4-content ul.checklist {
    list-style: none;
    padding-left: 0;
}
.a4-content ul.checklist li {
    display: flex;
    align-items: flex-start;
    gap: calc(6px * var(--zoom));
    margin-bottom: calc(4px * var(--zoom));
}
.a4-content ul.checklist input[type="checkbox"] {
    margin-top: calc(4px * var(--zoom));
    accent-color: var(--ink);
}
.a4-content hr {
    border: none;
    border-top: 1.5px solid var(--ink);
    margin: calc(16px * var(--zoom)) 0;
    opacity: 0.6;
    column-span: all;
}
.a4-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: calc(8px * var(--zoom)) 0;
}
.a4-content table.note-table {
    width: 100%;
    border-collapse: collapse;
    margin: calc(8px * var(--zoom)) 0;
}
.a4-content table.note-table td {
    border: 1px solid var(--ink);
    padding: calc(6px * var(--zoom)) calc(8px * var(--zoom));
    vertical-align: top;
    min-width: calc(60px * var(--zoom));
}
.a4-content mark {
    background: var(--accent-yellow);
    padding: 0 2px;
}
.a4-content a {
    color: var(--accent-red);
    text-decoration: underline;
}

/* Floating zoom bar */
.canvas-zoom {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #FFFFFF;
    border: 1px solid var(--ink);
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 70;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.canvas-zoom button {
    background: transparent;
    border: 1px solid var(--card-edge);
    width: 28px;
    height: 28px;
    border-radius: 0;
    cursor: pointer;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    transition: all 0.1s ease;
}
.canvas-zoom button:hover { background: var(--ink); color: var(--accent-yellow); }
.canvas-zoom span {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--ink);
    padding: 0 8px;
    min-width: 44px;
    text-align: center;
}
#zoomFit {
    width: auto;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--ink);
    color: var(--paper);
    padding: 12px 20px;
    border-radius: 999px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.3s var(--spring);
    pointer-events: none;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Print rules — A4 exact size */
@media print {
    body { background: white; padding-left: 0 !important; }
    .ps-menu-bar, .editor-topbar, .word-ribbon, .notion-sidebar, .canvas-zoom,
    .quiz-topbar, .quiz-filterbar, .quiz-shop, .quiz-empty,
    .quiz-slot-actions, .quiz-slot-remove, .canvas-zoom { display: none !important; }
    .editor-shell, .quiz-shell { padding: 0 !important; grid-template-columns: 1fr !important; }
    .canvas-scroll, .quiz-canvas-scroll { padding: 0; overflow: visible; background: white; }
    .a4-page, .quiz-page {
        --zoom: 1 !important;
        width: 210mm; min-height: 297mm;
        box-shadow: none; page-break-after: always;
    }
}

/* ═══════════════════════════════════════════════
   QUIZ BUILDER — 학습지 모드
   ═══════════════════════════════════════════════ */

body.quiz-mode {
    background: #F4F4F4;
    padding-left: 80px;
    overflow-x: hidden;
}
@media (max-width: 768px) { body.quiz-mode { padding-left: 0; } }

/* ─── Topbar (quiz-specific) ─── */
.quiz-topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    background: #FFFFFF;
    border-bottom: 1px solid var(--ink);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
}

.quiz-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-right: 1px solid var(--card-edge);
    padding-right: 16px;
    margin-right: 4px;
}
.quiz-brand .material-symbols-rounded { font-size: 24px; color: var(--accent-red); }
.quiz-brand-title {
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}
.quiz-brand-sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
@media (max-width: 900px) { .quiz-brand-sub { display: none; } }

.quiz-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    letter-spacing: 0.05em;
    padding: 0 12px;
    border-left: 1px solid var(--card-edge);
    border-right: 1px solid var(--card-edge);
    margin: 0 4px;
}
.quiz-meta span { color: var(--accent-red); font-weight: 700; }

/* ─── Quiz Word Ribbon (sticky below topbar, above filterbar) ─── */
.quiz-word-ribbon {
    position: sticky;
    top: 56px;
    z-index: 56;
    background: #FAFAFA;
    border-bottom: 1px solid var(--card-edge);
    padding: 6px 12px;
}
.ribbon-hint {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    padding-left: 12px;
    border-left: 1px solid var(--card-edge);
    white-space: nowrap;
}

/* ─── Filterbar (now below word ribbon) ─── */
.quiz-filterbar {
    position: sticky;
    top: 100px;
    z-index: 55;
    background: #FAFAFA;
    border-bottom: 1px solid var(--ink);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.quiz-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.quiz-filter-group label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
}
.quiz-filter-group select,
.quiz-filter-group input[type="text"] {
    background: #FFFFFF;
    border: 1px solid var(--card-edge);
    border-radius: 3px;
    padding: 6px 10px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    outline: none;
    cursor: pointer;
}
.quiz-filter-group select:hover,
.quiz-filter-group select:focus { border-color: var(--ink); }

.quiz-filter-search input { width: 220px; }
.quiz-filter-info {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    background: var(--accent-yellow);
    padding: 4px 10px;
    border: 1px solid var(--ink);
    font-weight: 700;
}

/* ─── Main shell (3-col: shop | canvas | categories) ─── */
.quiz-shell {
    display: grid;
    grid-template-columns: 320px 1fr 260px;
    min-height: calc(100vh - 150px);
}
@media (max-width: 1280px) {
    .quiz-shell { grid-template-columns: 300px 1fr 240px; }
}
@media (max-width: 1100px) {
    .quiz-shell { grid-template-columns: 300px 1fr; }
    .cat-sidebar { display: none; }
}
@media (max-width: 900px) {
    .quiz-shell { grid-template-columns: 1fr; }
    .quiz-shop { display: none; }
}

/* ─── Problem shop (left sidebar) ─── */
.quiz-shop {
    background: #FAFAFA;
    border-right: 1px solid var(--card-edge);
    height: calc(100vh - 150px);
    position: sticky;
    top: 150px;
    overflow-y: auto;
    padding: 12px;
}

.shop-loading {
    text-align: center;
    padding: 48px 16px;
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.shop-loading .material-symbols-rounded { font-size: 32px; }

.shop-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.shop-card {
    background: #FFFFFF;
    border: 1px solid var(--card-edge);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 0;
}
.shop-card:hover {
    border-color: var(--ink);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.shop-card.inserted {
    background: var(--accent-yellow);
    border-color: var(--ink);
    opacity: 0.7;
    cursor: default;
}

.shop-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.shop-card-topic {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink);
    background: #F0F0F0;
    padding: 2px 6px;
}
.shop-card.inserted .shop-card-topic { background: rgba(0,0,0,0.1); }
.shop-card-grade {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-faint);
    font-weight: 600;
}
.shop-card-question {
    font-family: var(--serif);
    font-size: 13px;
    line-height: 1.4;
    color: var(--ink);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.shop-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 6px;
    border-top: 1px solid var(--card-edge);
}
.shop-card.inserted .shop-card-bottom { border-top-color: rgba(0,0,0,0.2); }
.shop-card-stars { font-size: 10px; }
.shop-card-action {
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--accent-red);
    letter-spacing: 0.04em;
}
.shop-card.inserted .shop-card-action { color: var(--ink); }

.shop-empty, .shop-more {
    text-align: center;
    padding: 32px 16px;
    color: var(--ink-faint);
    font-family: var(--sans);
    font-size: 12px;
    line-height: 1.6;
}

/* ─── A4 canvas (center) ─── */
.quiz-canvas-scroll {
    position: relative;
    overflow-y: auto;
    padding: 24px 24px 80px;
    background: #EFEFEF;
}

.quiz-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--ink-soft);
    max-width: 560px;
    margin: 0 auto;
}
.quiz-empty > .material-symbols-rounded {
    font-size: 64px;
    color: var(--accent-yellow);
    margin-bottom: 16px;
}
.quiz-empty h3 {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--ink);
}
.quiz-empty p {
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-soft);
    max-width: 460px;
}
.quiz-empty p b { color: var(--ink); font-weight: 700; }
.quiz-empty .empty-hint {
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--card-edge);
    width: 100%;
}

.empty-folder-head {
    font-family: var(--serif);
    font-size: 16px;
    color: var(--ink-soft);
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}
.empty-folder-head b { color: var(--ink); font-weight: 700; }

.empty-start-btn {
    background: var(--accent-yellow);
    border: 2px solid var(--ink);
    color: var(--ink);
    padding: 18px 28px;
    font-family: var(--sans);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease;
    margin-bottom: 14px;
}
.empty-start-btn:hover {
    background: var(--ink);
    color: var(--accent-yellow);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.empty-start-btn .material-symbols-rounded {
    font-size: 24px !important;
    color: inherit !important;
    margin: 0 !important;
}

.empty-pages-list {
    width: 100%;
    max-width: 480px;
    margin-top: 12px;
    background: white;
    border: 1px solid var(--card-edge);
    text-align: left;
}
.empty-pages-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding: 8px 12px;
    background: #FAFAFA;
    border-bottom: 1px solid var(--card-edge);
    font-weight: 700;
}
.empty-pages-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--card-edge);
    transition: background 0.1s ease;
}
.empty-pages-item:last-child { border-bottom: none; }
.empty-pages-item:hover { background: var(--accent-yellow); }
.empty-pages-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-faint);
}

/* Folder active state (clicked in tree) */
.cat-row.folder-active {
    background: rgba(255, 211, 0, 0.25);
    box-shadow: inset 3px 0 0 var(--accent-yellow);
}
.cat-row.folder-active.active {
    background: var(--accent-yellow);
}

.quiz-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.quiz-page {
    --zoom: 0.7;
    width: calc(210mm * var(--zoom));
    min-height: calc(297mm * var(--zoom));
    background: white;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
    padding: calc(16mm * var(--zoom)) calc(18mm * var(--zoom));
    display: flex;
    flex-direction: column;
    gap: calc(10mm * var(--zoom));
}

.quiz-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: calc(6mm * var(--zoom));
    border-bottom: 1.5px solid var(--ink);
    font-family: var(--mono);
    font-size: calc(9pt * var(--zoom));
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.quiz-page-masthead {
    font-family: var(--serif);
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.05em;
    text-transform: none;
    font-size: calc(13pt * var(--zoom));
}

/* ─── Problem slot ─── */
.quiz-slot {
    flex: 1;
    padding: calc(4mm * var(--zoom)) 0;
    border-bottom: 1px dashed var(--card-edge);
}
.quiz-slot:last-child { border-bottom: none; }

.quiz-slot-inner {
    display: flex;
    flex-direction: column;
    gap: calc(4mm * var(--zoom));
}

.quiz-slot-header {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--zoom));
    margin-bottom: calc(2mm * var(--zoom));
}
.quiz-slot-no {
    font-family: var(--serif);
    font-size: calc(16pt * var(--zoom));
    font-weight: 700;
    color: var(--ink);
}
.quiz-slot-topic {
    font-family: var(--mono);
    font-size: calc(8pt * var(--zoom));
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink);
    background: var(--accent-yellow);
    padding: calc(1px * var(--zoom)) calc(6px * var(--zoom));
}
.quiz-slot-stars { font-size: calc(9pt * var(--zoom)); }
.quiz-slot-grade {
    font-family: var(--mono);
    font-size: calc(8pt * var(--zoom));
    color: var(--ink-faint);
    margin-left: auto;
}
.quiz-slot-remove,
.quiz-slot-tts {
    background: transparent;
    border: 1px solid var(--card-edge);
    color: var(--ink-faint);
    width: calc(22px * var(--zoom));
    height: calc(22px * var(--zoom));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0;
}
.quiz-slot-remove:hover { background: #D9001F; color: white; border-color: #D9001F; }
.quiz-slot-tts:hover { background: var(--accent-yellow); color: var(--ink); border-color: var(--ink); }

.quiz-passage {
    background: #FAFAF7;
    border-left: 3px solid var(--ink);
    padding: calc(12px * var(--zoom)) calc(16px * var(--zoom));
    margin: calc(8px * var(--zoom)) 0 calc(10px * var(--zoom));
    font-family: var(--korean, 'Noto Serif KR'), serif;
    font-size: calc(11pt * var(--zoom));
    line-height: 1.75;
    color: var(--ink);
}
.quiz-passage .qp-head {
    font-size: calc(9pt * var(--zoom));
    color: #888;
    letter-spacing: 0.5px;
    margin-bottom: calc(8px * var(--zoom));
    padding-bottom: calc(6px * var(--zoom));
    border-bottom: 1px solid #E5E5E5;
}
.quiz-passage .qp-title {
    font-weight: 700;
    color: #0A0A0A;
    font-family: var(--korean, 'Noto Serif KR'), serif;
}
.quiz-passage .qp-author {
    color: #C8102E;
    font-weight: 600;
}
.quiz-passage .qp-text {
    white-space: pre-wrap;
    color: var(--ink);
}

.quiz-question {
    font-family: var(--sans);
    font-size: calc(13pt * var(--zoom));
    font-weight: 600;
    color: var(--ink);
    line-height: 1.5;
}

/* 도형/과학 이미지 영역 — Monocle 흑백 박스 */
.quiz-drawing {
    margin: calc(8px * var(--zoom)) 0;
    padding: calc(10px * var(--zoom));
    border: 1.5px solid var(--ink);
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
}
.quiz-drawing .luna-drawing {
    display: inline-block;
    line-height: 0;
}
.quiz-drawing canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.quiz-choices {
    list-style: none;
    padding: 0;
    margin: calc(4px * var(--zoom)) 0;
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--zoom));
}
.quiz-choice {
    display: flex;
    align-items: flex-start;
    gap: calc(8px * var(--zoom));
    padding: calc(8px * var(--zoom)) calc(12px * var(--zoom));
    border: 1px solid var(--card-edge);
    cursor: pointer;
    font-family: var(--sans);
    font-size: calc(11.5pt * var(--zoom));
    line-height: 1.4;
    transition: all 0.1s ease;
    background: white;
}
.quiz-choice:hover { border-color: var(--ink); background: #FAFAFA; }
.quiz-choice.selected {
    border-color: var(--ink);
    background: var(--accent-yellow);
    font-weight: 600;
}
.choice-letter {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--accent-red);
    flex-shrink: 0;
}
.choice-text { flex: 1; }

.quiz-shortans {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--zoom));
    padding: calc(6px * var(--zoom)) 0;
}
.quiz-shortans label {
    font-family: var(--sans);
    font-size: calc(11pt * var(--zoom));
    font-weight: 700;
    color: var(--ink);
}
.quiz-answer-input {
    flex: 1;
    border: none;
    border-bottom: 1.5px solid var(--ink);
    background: transparent;
    padding: calc(6px * var(--zoom)) calc(4px * var(--zoom));
    font-family: var(--sans);
    font-size: calc(11pt * var(--zoom));
    color: var(--ink);
    outline: none;
}

.quiz-memo {
    margin-top: calc(4px * var(--zoom));
    background: #FFFBEF;
    border: 1px dashed var(--accent-yellow);
    padding: calc(8px * var(--zoom)) calc(12px * var(--zoom));
}
.quiz-memo label {
    font-family: var(--mono);
    font-size: calc(8.5pt * var(--zoom));
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
    display: block;
    margin-bottom: calc(4px * var(--zoom));
}
.quiz-memo-area {
    outline: none;
    min-height: calc(40px * var(--zoom));
    font-family: var(--sans);
    font-size: calc(10pt * var(--zoom));
    line-height: 1.6;
    color: var(--ink);
}
.quiz-memo-area:empty::before {
    content: attr(data-placeholder);
    color: var(--ink-faint);
    font-style: italic;
}

.quiz-slot-actions {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--zoom));
    padding-top: calc(4px * var(--zoom));
    flex-wrap: wrap;
}
.quiz-btn-check,
.quiz-btn-ai {
    display: inline-flex;
    align-items: center;
    gap: calc(4px * var(--zoom));
    padding: calc(7px * var(--zoom)) calc(14px * var(--zoom));
    font-family: var(--sans);
    font-size: calc(10.5pt * var(--zoom));
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid var(--ink);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}
.quiz-btn-check {
    background: var(--accent-yellow);
    color: var(--ink);
}
.quiz-btn-check:hover { background: var(--ink); color: var(--accent-yellow); }
.quiz-btn-ai {
    background: white;
    color: var(--ink);
}
.quiz-btn-ai:hover { background: var(--ink); color: var(--accent-yellow); }

.quiz-mark {
    font-family: var(--mono);
    font-size: calc(11pt * var(--zoom));
    font-weight: 700;
    padding: calc(4px * var(--zoom)) calc(10px * var(--zoom));
    border-radius: 0;
}
.quiz-mark.correct { background: #10B981; color: white; }
.quiz-mark.wrong { background: #D9001F; color: white; }

/* ─── AI Modal ─── */
.ai-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    align-items: center;
    justify-content: center;
}
.ai-modal.show { display: flex; }
.ai-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}
.ai-modal-card {
    position: relative;
    background: white;
    border: 1px solid var(--ink);
    width: 90%;
    max-width: 720px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
    z-index: 1;
}
.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--ink);
    color: white;
}
.ai-modal-header h3 {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-yellow);
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-modal-header .material-symbols-rounded { font-size: 20px; }
.ai-modal-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
}
.ai-modal-close:hover { color: var(--accent-yellow); }
.ai-modal-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
}

.ai-section { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--card-edge); }
.ai-section:last-child { border-bottom: none; }
.ai-section-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
    margin-bottom: 8px;
}
.ai-answer {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    background: var(--accent-yellow);
    display: inline-block;
    padding: 4px 14px;
    border: 1px solid var(--ink);
}
.ai-solution, .ai-intent {
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink);
}
.ai-myanswer {
    font-family: var(--sans);
    font-size: 16px;
    font-weight: 600;
    padding: 6px 14px;
    border: 1px solid var(--card-edge);
    display: inline-block;
}
.ai-myanswer.correct { background: #ECFDF5; border-color: #10B981; color: #065F46; }
.ai-myanswer.wrong { background: #FEF2F2; border-color: #D9001F; color: #991B1B; }

.ai-deeper-btn {
    width: 100%;
    padding: 14px 16px !important;
    justify-content: center;
    font-size: 14px !important;
}
.ai-deeper-hint {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 8px;
    text-align: center;
    letter-spacing: 0.05em;
}

.ai-deeper-result h3 {
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--ink);
}
.ai-deeper-content p { margin: 8px 0; line-height: 1.7; font-size: 13.5px; font-family: var(--sans); }
.ai-deeper-content ul { margin: 8px 0 8px 20px; }
.ai-deeper-content code { background: #F0F0F0; padding: 1px 5px; font-family: var(--mono); font-size: 12px; }

.ai-label {
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 4px;
    font-weight: 700;
}

/* ═══ AUTONOMY HERO — 자율 학습 허브 (가판대 메인) ═══ */
.autonomy-hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(40px, 6vw, 72px) var(--gutter) clamp(28px, 4vw, 48px);
    text-align: center;
}
@media (min-width: 768px) {
    .autonomy-hero { padding-left: calc(80px + var(--gutter)); max-width: 1280px; }
}
.autonomy-hero-inner {
    margin-bottom: clamp(28px, 4vw, 48px);
}
.autonomy-tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--accent-yellow);
    padding: 4px 14px;
    border: 1px solid var(--ink);
    font-weight: 700;
    margin-bottom: 18px;
}
.autonomy-h2 {
    font-family: var(--serif);
    font-size: clamp(28px, 5vw, 56px);
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}
.autonomy-sub {
    font-family: var(--sans);
    font-size: clamp(13px, 1.4vw, 16px);
    color: var(--ink-soft);
    margin: 0;
    line-height: 1.6;
}

.autonomy-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(14px, 2vw, 28px);
    max-width: 880px;
    margin: 0 auto;
}
@media (max-width: 640px) {
    .autonomy-cards { grid-template-columns: 1fr; }
}

.autonomy-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 4vw, 48px) 24px;
    border: 2px solid var(--ink);
    text-decoration: none;
    transition: all 0.25s var(--spring);
    cursor: pointer;
    background: white;
    color: var(--ink);
    min-height: clamp(220px, 28vw, 280px);
    position: relative;
    overflow: hidden;
}
.autonomy-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.16);
}
.autonomy-card-left {
    background: var(--accent-yellow);
}
.autonomy-card-left:hover {
    background: var(--ink);
    color: var(--accent-yellow);
}
.autonomy-card-right {
    background: var(--ink);
    color: white;
    border-color: var(--ink);
}
.autonomy-card-right:hover {
    background: white;
    color: var(--ink);
}

.autonomy-card-icon {
    font-size: 64px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.autonomy-card-icon .material-symbols-rounded {
    font-size: 64px;
    font-variation-settings: 'wght' 300, 'opsz' 48;
}
.autonomy-card-title {
    font-family: var(--serif);
    font-size: clamp(22px, 3vw, 32px);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}
.autonomy-card-sub {
    font-family: var(--sans);
    font-size: 13px;
    margin-bottom: 16px;
    opacity: 0.8;
}
.autonomy-card-cta {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    padding-top: 12px;
    border-top: 1.5px solid currentColor;
    width: 100%;
    text-align: center;
}

.autonomy-sub-actions {
    margin-top: clamp(20px, 3vw, 32px);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-faint);
    letter-spacing: 0.08em;
}
.autonomy-link {
    color: var(--ink-soft);
    text-decoration: none;
    border-bottom: 1px dashed var(--ink-faint);
    padding: 0 4px;
    transition: all 0.15s ease;
}
.autonomy-link:hover {
    color: var(--ink);
    border-bottom-color: var(--ink);
}
.autonomy-link-sep {
    opacity: 0.4;
    margin: 0 6px;
}

/* ═══ MOBILE/iPAD — 학습지 빌더 드로어 ═══ */
@media (max-width: 1024px) {
    .quiz-shell {
        grid-template-columns: 1fr !important;
    }
    /* Left shop = drawer slide-in from left */
    .quiz-shop {
        position: fixed !important;
        top: 0; bottom: 0; left: 0;
        height: 100vh !important;
        width: 320px;
        max-width: 88vw;
        z-index: 7000;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
        display: block !important;
    }
    .quiz-shop.open { transform: translateX(0); }
    /* Right cat sidebar = drawer slide-in from right */
    .cat-sidebar {
        position: fixed !important;
        top: 0; bottom: 0; right: 0;
        height: 100vh !important;
        width: 320px;
        max-width: 88vw;
        z-index: 7000;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -4px 0 24px rgba(0,0,0,0.25);
        display: flex !important;
    }
    .cat-sidebar.open { transform: translateX(0); }
    /* Backdrop */
    .drawer-backdrop {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 6999;
        display: none;
    }
    .drawer-backdrop.show { display: block; }
    /* Toggle buttons on topbar */
    .mobile-drawer-toggle {
        display: inline-flex !important;
    }
}
@media (min-width: 1025px) {
    .mobile-drawer-toggle { display: none; }
    .drawer-backdrop { display: none; }
}
.mobile-drawer-toggle {
    display: none;
    background: var(--accent-yellow);
    border: 1px solid var(--ink);
    color: var(--ink);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.mobile-drawer-toggle:hover { background: var(--ink); color: var(--accent-yellow); }
.mobile-drawer-toggle .material-symbols-rounded { font-size: 20px; }

/* Mobile topbar — compress */
@media (max-width: 640px) {
    .quiz-topbar { padding: 8px 10px; gap: 6px; height: auto; flex-wrap: wrap; }
    .quiz-brand-sub, .quiz-meta { display: none; }
    .quiz-filterbar { padding: 6px 10px; gap: 8px; top: 56px; }
    .quiz-filter-search { display: none; }
    .quiz-word-ribbon { padding: 4px 8px; overflow-x: auto; }
    .quiz-canvas-scroll { padding: 14px 8px 80px; }
    .quiz-page { width: 100% !important; min-height: auto !important; padding: 12px 14px; }
    .quiz-page > * { --zoom: 0.95; }
}

/* PWA install hint */
.pwa-install-hint {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--accent-yellow);
    padding: 10px 18px;
    border: 1px solid var(--accent-yellow);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.05em;
    z-index: 8000;
    cursor: pointer;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.pwa-install-hint.show { display: inline-flex; align-items: center; gap: 8px; }
.pwa-install-hint .close { margin-left: 8px; opacity: 0.6; cursor: pointer; padding: 0 4px; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══ RESULT MODAL — 학습 결과 페이지 ═══ */
.btn-results {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.btn-results.active {
    opacity: 1;
    pointer-events: auto;
    background: var(--accent-yellow);
    border-color: var(--ink);
    color: var(--ink);
}
.btn-results.active:hover {
    background: var(--ink);
    color: var(--accent-yellow);
}

.result-score {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 16px;
    border: 2px solid var(--ink);
    background: linear-gradient(135deg, #FFFBEF 0%, #FFFFFF 100%);
    margin-bottom: 20px;
}
.score-grade {
    font-family: var(--serif);
    font-size: 72px;
    font-weight: 700;
    line-height: 1;
    border: 4px solid;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.score-detail { flex: 1; }
.score-num {
    font-family: var(--serif);
    font-size: 36px;
    line-height: 1.2;
    color: var(--ink);
}
.score-num b { font-weight: 700; }
.score-pct {
    font-family: var(--mono);
    font-size: 18px;
    color: var(--ink-soft);
}
.score-msg {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink-soft);
    margin-top: 4px;
    font-weight: 600;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}
.stat-cell {
    background: #FAFAFA;
    border: 1px solid var(--card-edge);
    padding: 12px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-cell-label {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
}
.stat-cell-val {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.result-callout {
    padding: 10px 14px;
    margin-bottom: 8px;
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.5;
    border-radius: 0;
}
.result-callout.weak {
    background: #FEF2F2;
    border-left: 4px solid #D9001F;
    color: #991B1B;
}
.result-callout.strong {
    background: #ECFDF5;
    border-left: 4px solid #10B981;
    color: #065F46;
}

.result-section { margin: 18px 0; }
.result-section-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
    margin-bottom: 10px;
}

.topic-bars { display: flex; flex-direction: column; gap: 8px; }
.topic-row {}
.topic-row-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--sans);
    font-size: 12px;
    margin-bottom: 3px;
}
.topic-name { color: var(--ink); font-weight: 600; }
.topic-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-faint);
}
.topic-row-bar {
    display: flex;
    height: 10px;
    background: #F0F0F0;
    border: 1px solid var(--card-edge);
    overflow: hidden;
}
.bar-correct { background: #10B981; transition: width 0.4s ease; }
.bar-wrong { background: #D9001F; transition: width 0.4s ease; }

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--card-edge);
}
.result-actions button {
    width: 100%;
    padding: 12px 16px !important;
    justify-content: center;
    font-size: 13px !important;
    font-weight: 700;
}

/* Worksheet score stamp on kiosk card */
.note-ws-score {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--accent-yellow);
    border: 2px solid var(--ink);
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 700;
    font-size: 14px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: rotate(-8deg);
    z-index: 3;
    line-height: 1;
}
.note-ws-score.perfect { background: #10B981; color: white; border-color: #047857; }
.note-ws-score.good    { background: var(--accent-yellow); color: var(--ink); }
.note-ws-score.fair    { background: #FFA500; color: white; border-color: #B8860B; }
.note-ws-score.poor    { background: #D9001F; color: white; border-color: #991B1B; }
.note-ws-score-pct {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 1px;
    opacity: 0.85;
}

/* ═══ CATEGORY SIDEBAR (노션 스타일) ═══ */
.cat-sidebar {
    background: #FAFAFA;
    border-left: 1px solid var(--card-edge);
    height: calc(100vh - 150px);
    position: sticky;
    top: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.cat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--card-edge);
    position: sticky;
    top: 0;
    background: #FAFAFA;
    z-index: 1;
}
.cat-sidebar-title {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink);
    font-weight: 700;
}
.cat-add-root {
    background: var(--accent-yellow);
    border: 1px solid var(--ink);
    width: 26px;
    height: 26px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    transition: all 0.1s ease;
}
.cat-add-root:hover { background: var(--ink); color: var(--accent-yellow); }
.cat-add-root .material-symbols-rounded { font-size: 16px; }

.cat-current {
    padding: 10px 14px;
    border-bottom: 1px solid var(--card-edge);
    font-family: var(--sans);
    font-size: 11px;
    color: var(--ink-soft);
    background: #FFFFFF;
    line-height: 1.5;
    word-break: keep-all;
}
.cat-current.has-cat {
    background: linear-gradient(135deg, #FFFBEF 0%, #FFFFFF 100%);
    color: var(--ink);
    font-weight: 600;
}

.cat-tree {
    flex: 1;
    padding: 6px 0;
    overflow-y: auto;
}

.cat-node {
    user-select: none;
}

.cat-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 4px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 12.5px;
    color: var(--ink);
    transition: background 0.1s ease;
    position: relative;
}
.cat-row:hover { background: #EFEFEF; }
.cat-row.active {
    background: var(--accent-yellow);
    font-weight: 700;
}

.cat-caret {
    width: 14px;
    text-align: center;
    font-size: 10px;
    color: var(--ink-soft);
    flex-shrink: 0;
    cursor: pointer;
}
.cat-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.cat-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}
.cat-count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-faint);
    font-weight: 600;
    min-width: 16px;
    text-align: right;
}
.cat-row.active .cat-count { color: var(--ink); }

.cat-more,
.cat-add-child,
.cat-add-page {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft);
    padding: 0;
    flex-shrink: 0;
}
.cat-row:hover .cat-more,
.cat-row:hover .cat-add-child,
.cat-row:hover .cat-add-page { display: inline-flex; }
.cat-more:hover { background: rgba(0,0,0,0.1); color: var(--ink); }
.cat-add-child:hover { background: rgba(0,0,0,0.1); color: var(--ink); }
.cat-add-page {
    background: var(--accent-yellow);
    color: var(--ink);
    border: 1px solid var(--ink);
    width: 24px;
    height: 22px;
}
.cat-add-page:hover {
    background: var(--ink);
    color: var(--accent-yellow);
}

/* Page (worksheet) inside category tree */
.cat-page {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 11.5px;
    color: var(--ink-soft);
    transition: background 0.1s ease;
    user-select: none;
}
.cat-page:hover { background: #EFEFEF; color: var(--ink); }
.cat-page.active {
    background: var(--accent-yellow);
    color: var(--ink);
    font-weight: 700;
}
.cat-page .cat-icon { font-size: 12px; opacity: 0.7; }
.cat-page .cat-label { font-size: 11.5px; line-height: 1.4; }
.cat-page-score {
    font-family: var(--mono);
    font-size: 9.5px;
    color: var(--accent-red);
    font-weight: 700;
    background: white;
    border: 1px solid var(--accent-red);
    padding: 1px 4px;
    border-radius: 2px;
    flex-shrink: 0;
}
.cat-page-meta {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--ink-faint);
    flex-shrink: 0;
}

.cat-caret { cursor: default; }
.cat-caret.has-children { cursor: pointer; }
.cat-row { cursor: pointer; }

.cat-children {
    /* Vertical guide line for nesting */
    position: relative;
}

.cat-unassigned {
    margin-top: 8px;
    padding: 8px 12px;
    border-top: 1px dashed var(--card-edge);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--sans);
    font-size: 11px;
    color: var(--ink-faint);
}

.cat-sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--card-edge);
    background: #FAFAFA;
}
.cat-help {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.05em;
    color: var(--ink-faint);
    display: block;
    line-height: 1.6;
}

/* Floating context menu */
.cat-menu {
    display: none;
    position: fixed;
    z-index: 8000;
    background: white;
    border: 1px solid var(--ink);
    box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    min-width: 200px;
    padding: 4px 0;
}
.cat-menu.show { display: block; }
.cat-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink);
    transition: background 0.1s ease;
}
.cat-menu-item:hover { background: var(--accent-yellow); }
.cat-menu-item.primary {
    background: var(--ink);
    color: var(--accent-yellow);
    font-weight: 700;
}
.cat-menu-item.primary:hover { background: #333; color: var(--accent-yellow); }
.cat-menu-item.danger { color: #D9001F; }
.cat-menu-item.danger:hover { background: #FEF2F2; }
.cat-menu-item .material-symbols-rounded { font-size: 16px; }
.cat-menu-sep { height: 1px; background: var(--card-edge); margin: 4px 0; }

/* Wrong-note variant (오답노트) */
.note-card-wrap[data-wrongnote="true"] .note-card {
    background: linear-gradient(135deg, #FFFFFF 0%, #FEF2F2 100%);
    border-color: #D9001F;
}
.note-card-wrap[data-wrongnote="true"] .note-cover-masthead {
    color: #D9001F;
    border-bottom-color: #D9001F;
}
