:root {
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #e0f2fe;
    --surface: #ffffff;
    --bg: #f1f5f9;
    --bg-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 4px 16px rgba(2, 132, 199, 0.08);
    --shadow-hover: 0 8px 32px rgba(2, 132, 199, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
}
.container-narrow { max-width: 720px; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.brand-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px;
}
.brand-title {
    font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
    color: var(--text);
}
.brand-sub {
    font-size: 12px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky; top: 0; z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 0;
    padding-bottom: 0;
}
.brand-wrap { text-decoration: none; color: inherit; flex-shrink: 0; }
.brand-wrap:hover { text-decoration: none; }

.home-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.home-link:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2,132,199,0.3);
}
.home-link i { font-size: 12px; }

.nav-right { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); margin-left: auto; }
.nav-right .nick { font-weight: 600; color: var(--text); }
.nav-right .role-badge { background: var(--primary-light); color: var(--primary-dark); padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s;
}
.input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2,132,199,0.1); }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #bae6fd; }

/* mode grid */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 20px;
}
.mode-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex; flex-direction: column; gap: 12px;
    text-decoration: none;
    color: var(--text);
}
.mode-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}
.mode-card .mode-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.mode-card h3 {
    font-size: 18px; font-weight: 700;
}
.mode-card p {
    color: var(--text-muted); font-size: 14px;
}
.mode-card.accent-red .mode-icon { background: #fee2e2; color: #dc2626; }
.mode-card.accent-green .mode-icon { background: #dcfce7; color: #16a34a; }

/* subject grid */
.subj-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.subj-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    color: var(--text);
    display: flex; flex-direction: column; gap: 6px;
}
.subj-card:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.subj-card .subj-name { font-size: 16px; font-weight: 700; color: var(--text); }
.subj-card .subj-count { font-size: 13px; color: var(--text-muted); }

/* question rendering */
.q-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 14px;
}
.q-header {
    display: flex; align-items: baseline; gap: 10px;
    margin-bottom: 14px;
}
.q-num {
    font-size: 13px; font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 10px; border-radius: 999px;
    flex-shrink: 0;
}
.q-text {
    font-size: 16px; font-weight: 500; color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}
/* [[박스]]...[[/박스]] 로 감싼 보조 지문용 박스 — 교재형 크림 박스 */
.q-box {
    background: #f4ecd5;
    border: 1px solid #ebdfb9;
    border-radius: 10px;
    padding: 18px 22px;
    margin: 14px 0;
    font-size: 15px;
    line-height: 1.8;
    color: #2b2b2b;
    white-space: pre-wrap;
}
.explain-box .q-box {
    /* 해설 박스 안에서 한 번 더 박스가 쓰일 때 살짝 밝게 */
    background: #faf4e0;
}
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--surface);
}
.opt-item:hover { border-color: var(--primary); background: var(--bg-2); }
.opt-item.selected { border-color: var(--primary); background: var(--primary-light); }
.opt-item .opt-marker {
    flex-shrink: 0;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.opt-item.selected .opt-marker { background: var(--primary); color: #fff; }
.opt-item .opt-text { font-size: 14.5px; line-height: 1.5; flex: 1; white-space: pre-wrap; }
.opt-item input[type=radio] { display: none; }

/* review */
.opt-item.correct { border-color: var(--success); background: var(--success-light); }
.opt-item.correct .opt-marker { background: var(--success); color: #fff; }
.opt-item.incorrect { border-color: var(--danger); background: var(--danger-light); }
.opt-item.incorrect .opt-marker { background: var(--danger); color: #fff; }
.explain-box {
    margin-top: 14px;
    padding: 14px 18px;
    background: var(--bg-2);
    border-left: 3px solid var(--primary);
    border-radius: 0 10px 10px 0;
    font-size: 14px; line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
}
.explain-box .label {
    font-weight: 700; color: var(--primary); font-size: 12px;
    letter-spacing: 0.08em; text-transform: uppercase;
    margin-bottom: 6px; display: block;
}

.toolbar {
    position: sticky;
    bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow-hover);
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    z-index: 10;
}
.toolbar .progress {
    font-size: 14px; color: var(--text-muted);
    font-weight: 600;
}
.toolbar .progress b { color: var(--primary); }

/* score result */
.score-box {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
}
.score-num { font-size: 72px; font-weight: 900; color: var(--primary); line-height: 1; }
.score-label { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-top: 8px; letter-spacing: 0.06em; text-transform: uppercase; }
.score-detail {
    display: flex; gap: 24px; justify-content: center;
    margin-top: 20px; font-size: 15px; color: var(--text-muted);
}
.score-detail .c { color: var(--success); font-weight: 700; }
.score-detail .w { color: var(--danger); font-weight: 700; }

/* slide */
.slide-wrap {
    display: flex; flex-direction: column; gap: 18px;
}
.slide-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    min-height: 480px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 18px;
}
.slide-nav {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
}
.slide-nav .counter {
    font-size: 15px; font-weight: 700; color: var(--text);
}
.slide-nav .counter .total { color: var(--text-muted); font-weight: 500; }
.slide-answer {
    font-size: 22px; font-weight: 800; color: var(--success);
    margin-top: 8px;
}
.slide-opt {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    display: flex; gap: 12px; align-items: flex-start;
}
.slide-opt.is-answer {
    border-color: var(--success);
    background: var(--success-light);
}
.slide-opt .opt-marker {
    flex-shrink: 0;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.slide-opt.is-answer .opt-marker { background: var(--success); color: #fff; }

/* table */
.table-wrap { overflow-x: auto; }
table.simple {
    width: 100%; border-collapse: collapse; font-size: 14px;
    background: var(--surface);
}
table.simple th, table.simple td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
}
table.simple th { background: var(--bg-2); font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
table.simple tr:hover { background: var(--bg-2); }

/* utilities */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row-between { justify-content: space-between; align-items: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
h2.section-title {
    font-size: 20px; font-weight: 800; letter-spacing: -0.3px;
    margin-bottom: 14px;
}
.muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }

/* auth page */
.auth-center {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    overflow: hidden;
}
.auth-body { padding: 32px; }
.tab-bar { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
    flex: 1;
    padding: 14px;
    background: var(--bg-2);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    margin-bottom: -1px;
}

/* 그누보드 아웃로그인 위젯을 우리 카드 안에 감쌀 때 기본 스타일 */
.outlogin-wrap {
    margin: 0;
}
.outlogin-wrap form,
.outlogin-wrap .ol { margin: 0; }
.outlogin-wrap input[type=text],
.outlogin-wrap input[type=password] {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    margin-bottom: 8px;
}
.outlogin-wrap input[type=text]:focus,
.outlogin-wrap input[type=password]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2,132,199,0.1);
}
.outlogin-wrap input[type=submit],
.outlogin-wrap button[type=submit] {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
}
.outlogin-wrap input[type=submit]:hover,
.outlogin-wrap button[type=submit]:hover {
    background: var(--primary-dark);
}
.outlogin-wrap a { color: var(--primary); }
.outlogin-wrap ul { list-style: none; padding: 0; margin: 10px 0 0; }
.outlogin-wrap ul li { padding: 4px 0; font-size: 13px; }

@media (max-width: 640px) {
    .container { padding: 16px 14px; }
    .card, .slide-card { padding: 20px; }
    .q-item { padding: 16px 18px; }
    .score-num { font-size: 56px; }
}

/* ============ 모바일 한손 UI ============ */
.mobile-bottom-nav { display: none; }
.mode-card.is-locked { position: relative; opacity: 0.75; }
.mode-card.is-locked .lock-badge {
    position: absolute; top: 12px; right: 12px;
    background: var(--bg); color: var(--text-muted);
    padding: 4px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
}

.slide-fab {
    display: none;
    position: fixed;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    left: 0; right: 0;
    padding: 0 14px;
    pointer-events: none;
    z-index: 40;
}
.slide-fab-row { display: flex; gap: 10px; pointer-events: auto; }
.slide-fab-btn {
    flex: 1;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    padding: 16px;
    font-size: 16px; font-weight: 700;
    color: var(--text);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer;
    font-family: inherit;
}
.slide-fab-btn[disabled] { opacity: 0.35; }
.slide-fab-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 640px) {
    body { padding-bottom: 84px; }
    .container { padding: 14px 12px; }
    .card, .slide-card { padding: 18px; }
    .q-item { padding: 16px; }

    /* 모바일 상단: 브랜드(좌) + 수린이 사이트 버튼(우) 두 요소만 노출.
       나머지 계정 관련 액션은 하단 네비가 전담. */
    .site-header { padding: 8px 0; }
    .header-inner {
        gap: 8px;
        padding-left: 12px; padding-right: 12px;
        justify-content: space-between;
    }
    .brand-wrap { flex: 1 1 auto; min-width: 0; }
    .brand { gap: 8px; }
    .brand-icon { width: 32px; height: 32px; font-size: 14px; border-radius: 9px; flex-shrink: 0; }
    .brand > div:last-child { min-width: 0; overflow: hidden; }
    .brand-title {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .brand-sub { display: none; }

    .home-link {
        flex-shrink: 0;
        padding: 7px 12px;
        font-size: 12.5px;
        gap: 5px;
    }
    .home-link i { font-size: 12px; }

    /* 하단 고정 네비가 있으므로 상단의 중복 액션은 숨김 */
    .nav-right { display: none; }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        z-index: 60;
    }
    .mobile-bottom-nav .mbn-item {
        flex: 1;
        display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        color: var(--text-muted);
        font-size: 11px; font-weight: 600;
        text-decoration: none;
        min-height: 56px;
        border-radius: 10px;
    }
    .mobile-bottom-nav .mbn-item i { font-size: 20px; }
    .mobile-bottom-nav .mbn-item:active { background: var(--bg); }
    .mobile-bottom-nav .mbn-item.mbn-accent { color: var(--primary); }
    .mobile-bottom-nav .mbn-item.mbn-accent i { color: var(--primary); }
    .mobile-bottom-nav .mbn-item.is-active { color: var(--primary); background: var(--primary-light); }
    .mobile-bottom-nav .mbn-item.is-active i { color: var(--primary); }
    /* 우측 끝 항목(로그아웃 등)을 시각적으로 구분 */
    .mobile-bottom-nav .mbn-item.mbn-end {
        border-left: 1px solid var(--border);
        margin-left: 2px;
        color: var(--danger);
    }
    .mobile-bottom-nav .mbn-item.mbn-end i { color: var(--danger); }
    .mobile-bottom-nav .mbn-item.mbn-end.mbn-accent,
    .mobile-bottom-nav .mbn-item.mbn-end.mbn-accent i { color: var(--primary); }

    .opt-item { padding: 14px; min-height: 52px; }
    .opt-item .opt-marker { width: 32px; height: 32px; font-size: 15px; }
    .opt-item .opt-text { font-size: 15px; }

    .toolbar {
        position: fixed;
        left: 12px; right: 12px;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        margin: 0;
        border-radius: 16px;
        padding: 12px 14px;
    }
    .toolbar .btn { padding: 12px 16px; font-size: 14px; min-height: 44px; }
    .toolbar .progress { font-size: 13px; }

    .slide-nav .btn { display: none; }
    .slide-nav { justify-content: center; }
    .slide-fab { display: block; }
    .slide-card { min-height: auto; padding: 22px 18px; }
    .slide-wrap { padding-bottom: 60px; }

    .auth-center { padding: 16px; }

    h2.section-title { font-size: 17px; }

    .mode-grid { gap: 12px; }
    .mode-card { padding: 18px; }
    .mode-card h3 { font-size: 16px; }
    .mode-card p { font-size: 13px; }

    .subj-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .subj-card { padding: 14px; min-height: 64px; }
    .subj-card .subj-name { font-size: 14px; }
    .subj-card .subj-count { font-size: 12px; }

    .btn-lg { padding: 14px 18px; font-size: 15px; min-height: 48px; }

    table.simple th, table.simple td { padding: 8px 10px; font-size: 13px; }
}

@media (max-width: 380px) {
    .brand-title { font-size: 13px; }
    .home-link { padding: 6px 10px; font-size: 12px; }
    .home-link i { font-size: 11px; }
    .mobile-bottom-nav .mbn-item { font-size: 10px; }
}
/* 초소형: 브랜드 줄이고 수린이 사이트 버튼은 아이콘만 */
@media (max-width: 340px) {
    .brand-title { font-size: 12.5px; }
    .home-link span { display: none; }
    .home-link { padding: 7px 9px; }
}