:root {
    --bg-gradient-a: #eff3fa;
    --bg-gradient-b: #e8eef8;
    --bg-surface: #f7f8ff;
    --surface: #ffffff;
    --surface-soft: #f2f5fb;
    --text: #101828;
    --text-muted: #4f5d74;
    --text-subtle: #69778d;
    --line: #dce3f1;
    --brand: #1e3a8a;
    --brand-strong: #1d4ed8;
    --brand-soft: rgba(30, 58, 138, 0.14);
    --accent: #ff8f1f;
    --accent-strong: #f97316;
    --warn: #0ea5e9;
    --shadow-soft: 0 18px 42px -34px rgb(16 24 40 / 55%);
    --shadow-card: 0 10px 35px -26px rgb(15 23 42 / 57%);
    --radius: 20px;
    --radius-sm: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    background: linear-gradient(180deg, #eff3fa 0%, #e8eef8 100%);
}

#app {
    width: min(1280px, 100% - 2.25rem);
    margin: 0 auto;
    padding: 1.4rem 0 2.2rem;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    flex-wrap: wrap;
    padding: 0.95rem 1.1rem;
    margin-bottom: 1.1rem;
    border: 1px solid rgba(17, 24, 39, 0.09);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.84));
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-soft);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.62rem;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: inherit;
    text-decoration: none;
}

#sub-chapter-selection-card ::selection,
.toc-checklist ::selection {
    background: rgba(30, 58, 138, 0.22);
}

.logo-icon {
    width: 2rem;
    height: 2rem;
    display: block;
    flex: 0 0 auto;
    object-fit: cover;
    border-radius: 0.72rem;
    box-shadow: 0 10px 16px -10px rgba(30, 58, 138, 0.35);
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}

nav a,
.section-link {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background-color 160ms ease, color 160ms ease;
}

nav a:hover,
nav a.section-link--active,
.section-link:hover,
.section-link.section-link--active {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.version {
    font-size: 0.78rem;
    color: var(--text-subtle);
    border-radius: 999px;
    padding: 0.33rem 0.72rem;
    border: 1px solid var(--line);
    background: var(--surface-soft);
}

main {
    display: grid;
    grid-template-columns: minmax(300px, 1.05fr) 1.5fr;
    gap: 1rem;
    align-items: start;
}

.left-column,
.right-column {
    display: grid;
    gap: 1rem;
}

/* Generator first step: full-screen book selection */
body[data-page="generator"].generator-book-stage main {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 180px);
}

body[data-page="generator"].generator-book-stage .right-column {
    display: none;
}

body[data-page="generator"].generator-book-stage #test-config-card {
    display: none !important;
}

body[data-page="generator"].generator-book-stage .book-select-card {
    min-height: calc(100vh - 190px);
    padding: clamp(1.25rem, 2.6vw, 2.2rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body[data-page="generator"].generator-book-stage .book-select-card h2,
body[data-page="generator"].generator-book-stage .book-select-card .subtitle {
    text-align: center;
}

body[data-page="generator"].generator-book-stage .book-library {
    width: min(1080px, 100%);
    margin: 0 auto;
    gap: clamp(0.75rem, 1.4vw, 1.2rem);
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

body[data-page="generator"].generator-book-stage .book-item-name {
    font-size: 0.88rem;
    padding: 0.75rem 0.7rem 0.8rem;
}

body[data-page="generator"]:not(.generator-book-stage) .book-item-name {
    display: none;
}

body[data-page="generator"]:not(.generator-book-stage) .book-option {
    gap: 0;
}

.card {
    position: relative;
    padding: 1.2rem;
    border-radius: var(--radius);
    border: 1px solid rgba(15, 23, 42, 0.1);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 250, 255, 0.98) 100%);
    box-shadow: var(--shadow-card);
    animation: popIn 220ms ease;
}

.card h2 {
    margin: 0 0 0.4rem;
    font-size: 1.08rem;
    letter-spacing: -0.01em;
}

.card .subtitle {
    margin: 0 0 1rem;
    color: var(--text-subtle);
    font-size: 0.9rem;
    max-height: 3rem;
    overflow: hidden;
    transition: max-height 180ms ease, opacity 180ms ease, margin 180ms ease, padding 180ms ease;
}

.book-library {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}

.book-option {
    display: grid;
    align-content: start;
    gap: 0.44rem;
}

.book-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease;
    background: #fff;
    position: relative;
}

.book-item img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    transition: transform 160ms ease;
    transform-origin: center center;
}

.book-item-name {
    display: block;
    padding: 0;
    text-align: center;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #334155;
}

.book-item:hover {
    border-color: rgba(30, 58, 138, 0.45);
    box-shadow: 0 12px 18px -12px rgba(15, 23, 42, 0.5);
}

.book-item.active {
    border-color: var(--brand);
    box-shadow: 0 9px 18px rgba(37, 99, 235, 0.16);
    border: 2px solid #2563EB;
}

.book-item.selected {
    border: 2px solid #2563EB;
    box-shadow: 0 9px 18px rgba(37, 99, 235, 0.16);
}

.book-item:hover img,
.book-item.active img,
.book-item.selected img {
    transform: scale(1.02);
}

.book-item.selected::before,
.book-item.active::before {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #2563EB;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    text-align: center;
    line-height: 24px;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.32);
    z-index: 1;
}

.selected-item,
.selected {
    background: #F2F7FF;
    border: 1px solid #2563EB;
}

.hidden {
    display: none !important;
}

.sub-chapter-options {
    display: grid;
    gap: 0.7rem;
    max-height: 480px;
    overflow: hidden;
    transition: max-height 180ms ease, opacity 180ms ease, margin 180ms ease, padding 180ms ease;
}

.sub-chapter-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 0.8rem;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.sub-chapter-item:hover {
    border-color: rgba(30, 58, 138, 0.35);
    background: #eaf1ff;
}

.sub-chapter-item.selected-item {
    background: #eaf2ff;
    border-color: #2563EB;
    box-shadow: 0 8px 18px -14px rgba(37, 99, 235, 0.45);
}

#sub-chapter-selection-card.compact {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

#sub-chapter-selection-card.compact h2 {
    margin-bottom: 0;
}

#sub-chapter-selection-card.compact .subtitle,
#sub-chapter-selection-card.compact .sub-chapter-options {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
    overflow: hidden;
    border: 0;
    transition: max-height 180ms ease, opacity 180ms ease, margin 180ms ease, padding 180ms ease;
}

.toc-checklist {
    max-height: 430px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.45rem;
    background: #fff;
}

#toc-selection-card.day-mode .toc-checklist {
    max-height: min(620px, 68vh);
}

.toc-checklist-item {
    display: flex;
    align-items: center;
    gap: 0.64rem;
    padding: 0.66rem;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
}

.toc-checklist-item:hover {
    border-color: rgba(30, 58, 138, 0.2);
    background: #edf3ff;
}

.toc-checklist-item.selected-item {
    border-color: #2563EB;
    background: #eaf2ff;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.toc-checklist-item input {
    width: 1rem;
    height: 1rem;
    accent-color: #1e3a8a;
    touch-action: manipulation;
}

.toc-checklist-item .badge {
    margin-left: auto;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    font-size: 0.74rem;
    color: #1e3a8a;
    background: #fff;
    border: 1px solid #d6e2ff;
}

.toc-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0;
}

.toc-derivatives {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.toc-derivatives-label {
    font-size: 0.88rem;
    color: var(--text-subtle);
    font-weight: 600;
}

#toc-summary {
    margin: 0.65rem 0 0;
    text-align: left;
    font-size: 0.88rem;
    color: var(--text-subtle);
    font-weight: 500;
    min-height: 1.2em;
}

.config-group {
    margin-bottom: 0.95rem;
}

.config-group h3 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.output-format-options {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.25rem;
    background: #fff;
}

.output-format-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    padding: 0.42rem 0.82rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 160ms ease;
}

.output-format-options label:hover {
    background: var(--surface-soft);
}

.output-format-options input {
    width: 1rem;
    height: 1rem;
}

.test-type-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.72rem;
}

.test-type-options[data-two-options="true"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.test-type-option {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 0.74rem 0.65rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.test-type-option .label {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.14rem;
    line-height: 1.2;
}

.test-type-option .label-main {
    font-size: 0.9rem;
    font-weight: 600;
}

.test-type-option .label-sub {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-subtle);
}

.test-type-option.active {
    border-color: rgba(13, 107, 122, 0.4);
    background: linear-gradient(160deg, #f4fbfc, #f0f5ff);
}

.test-type-option:hover {
    border-color: rgba(13, 107, 122, 0.2);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.52rem;
}

#num-questions {
    width: 100%;
    max-width: 170px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.58rem 0.7rem;
    background: #fff;
    font: inherit;
    color: var(--text);
}

.field-hint {
    margin: 0.42rem 0 0;
    color: var(--warn);
    font-size: 0.82rem;
    line-height: 1.35;
}

.text-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.58rem 0.7rem;
    background: #fff;
    font: inherit;
    color: var(--text);
}

.toggle-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.78rem;
    background: #fff;
}

.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 23px;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d1dae8;
    transition: 0.22s;
    cursor: pointer;
}

.slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.22s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

input:checked + .slider {
    background: var(--brand);
}

input:checked + .slider::before {
    transform: translateX(19px);
}

.button-primary {
    width: 100%;
    margin-top: 0.35rem;
    border: 0;
    border-radius: 12px;
    padding: 0.88rem;
    font: inherit;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: #1e3a8a;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.button-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
    background: #1d4ed8;
}

.toc-checklist-item:active {
    background: #dce6ff;
}


.button-primary:disabled {
    background: #d1d5db;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.1);
}

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(92vw, 420px);
    pointer-events: none;
}

.toast {
    border-radius: 12px;
    padding: 0.72rem 0.9rem;
    background: #111827;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 12px 28px -14px rgb(15 23 42 / 60%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: auto;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast--error {
    background: #7f1d1d;
    border-color: rgba(255, 255, 255, 0.16);
}

#toast-container .toast {
    max-width: 100%;
    line-height: 1.4;
}

#generate-hint {
    margin-top: 0.9rem;
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.84rem;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-main,
.placeholder-main {
    display: block;
}

.dashboard-intro {
    margin-bottom: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.dashboard-link {
    display: block;
    text-decoration: none;
    color: var(--text);
    min-height: 152px;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.dashboard-link h3 {
    margin: 0 0 0.55rem;
    font-size: 1.02rem;
}

.dashboard-link p {
    margin: 0;
    color: var(--text-subtle);
    font-size: 0.92rem;
}

.dashboard-link:hover {
    transform: translateY(-2px);
    border-color: rgba(30, 58, 138, 0.35);
    box-shadow: 0 16px 28px -22px rgba(15, 23, 42, 0.6);
}

body[data-page="landing"] {
    background:
        radial-gradient(1000px 550px at 8% 0%, rgba(59, 130, 246, 0.16) 0%, transparent 64%),
        radial-gradient(920px 480px at 100% 10%, rgba(79, 70, 229, 0.14) 0%, transparent 67%),
        linear-gradient(180deg, #f6f9fc 0%, #edf2f8 100%);
}

body[data-page="landing"] #app.landing-shell {
    width: min(1180px, 100% - 2rem);
    padding-top: 1rem;
}

body[data-page="landing"] .landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 18px 34px -28px rgba(15, 23, 42, 0.55);
}

body[data-page="landing"] .landing-dashboard-link {
    text-decoration: none;
    min-width: 120px;
}

body[data-page="landing"] .landing-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

body[data-page="landing"] .landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
    gap: 1rem;
    padding: 1.3rem;
}

body[data-page="landing"] .landing-kicker {
    margin: 0 0 0.55rem;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.25rem 0.66rem;
    background: rgba(29, 78, 216, 0.12);
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
}

body[data-page="landing"] .landing-copy h1 {
    margin: 0 0 0.7rem;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

body[data-page="landing"] .landing-copy p {
    margin: 0;
    color: #334155;
    line-height: 1.65;
}

body[data-page="landing"] .landing-cta {
    margin-top: 1rem;
    display: inline-flex;
    width: auto;
    min-width: 220px;
    text-decoration: none;
}

body[data-page="landing"] .landing-books {
    position: relative;
    display: block;
    min-height: 430px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: radial-gradient(560px 260px at 55% 86%, rgba(99, 120, 160, 0.2) 0%, rgba(235, 240, 248, 0.75) 62%, rgba(245, 247, 251, 0.95) 100%);
    overflow: hidden;
    text-decoration: none;
}

body[data-page="landing"] .landing-books::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 10%;
    width: 70%;
    height: 60px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(50, 61, 87, 0.28) 0%, rgba(50, 61, 87, 0.08) 45%, transparent 78%);
    filter: blur(6px);
}

body[data-page="landing"] .landing-book {
    position: absolute;
    margin: 0;
    width: 36%;
    aspect-ratio: 3 / 4;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.24);
    box-shadow: 0 20px 36px -20px rgba(15, 23, 42, 0.6);
    background: #fff;
}

body[data-page="landing"] .landing-book img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body[data-page="landing"] .landing-book-basic {
    left: 8%;
    top: 17%;
    transform: rotate(-8deg);
    z-index: 3;
}

body[data-page="landing"] .landing-book-advanced {
    left: 35%;
    top: 12%;
    transform: rotate(-2deg);
    z-index: 2;
}

body[data-page="landing"] .landing-book-etymology {
    left: 62%;
    top: 20%;
    transform: rotate(4deg);
    z-index: 1;
}

.placeholder-card {
    max-width: 720px;
    margin: 0 auto;
}

.placeholder-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 220px;
    margin-top: 0.35rem;
    text-decoration: none;
}

body[data-page="auth"] {
    background:
        radial-gradient(850px 380px at 8% -12%, rgba(30, 64, 175, 0.2), transparent 68%),
        radial-gradient(760px 360px at 100% 0%, rgba(14, 116, 144, 0.18), transparent 66%),
        linear-gradient(180deg, #eef4ff 0%, #eaf1fb 100%);
}

body[data-page="auth"] #app {
    width: min(100%, 100% - 1.2rem);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    margin: 0 auto;
    display: grid;
    place-items: center;
}

.auth-main {
    display: block;
    width: min(100%, 460px);
    max-width: 460px;
    margin: 0 auto;
    padding: 1rem 0.4rem;
    grid-template-columns: none;
    gap: 0;
    align-items: stretch;
}

.auth-supa-shell {
    width: 100%;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 255, 0.97));
    box-shadow: 0 22px 46px -34px rgba(15, 23, 42, 0.72);
    padding: 1rem;
}

.auth-notice {
    border-radius: 12px;
    border: 1px solid #d5deef;
    background: #f8fbff;
    color: #475569;
    padding: 0.58rem 0.75rem;
    font-size: 0.88rem;
    line-height: 1.36;
    margin-bottom: 0.8rem;
}

.auth-notice--error {
    border-color: rgba(190, 24, 93, 0.32);
    color: #9f1239;
    background: #fff1f5;
}

.auth-notice--success {
    border-color: rgba(21, 128, 61, 0.28);
    color: #166534;
    background: #f0fdf4;
}

.auth-root {
    display: grid;
    justify-items: center;
}

.auth-root > div {
    width: 100%;
}

.auth-root .supabase-auth-ui_ui-container {
    width: 100%;
    color: #0f172a;
    display: grid;
    gap: 0.52rem;
}

.auth-social-stack {
    width: 100%;
    display: grid;
    gap: 0.52rem;
    margin-bottom: 0.55rem;
}

.auth-google-gis-wrap {
    display: none;
    width: 100%;
    min-height: 48px;
    position: relative;
}

.auth-google-gis-wrap.is-ready {
    display: block;
}

.auth-google-gis-slot {
    width: 100%;
    min-height: 48px;
}

.auth-google-gis-slot > div {
    width: 100% !important;
}

.auth-google-gis-slot iframe {
    width: 100% !important;
    border-radius: 999px;
}

.auth-google-gis-overlay {
    position: absolute;
    inset: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    color: transparent;
}

.auth-google-gis-overlay:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.auth-google-gis-wrap.is-loading .auth-google-gis-overlay {
    cursor: wait;
}

.auth-social-btn {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #d5deea;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.62rem;
    padding: 0.62rem 1rem;
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}

.auth-social-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.auth-social-btn:hover {
    background: #f8fafc;
    border-color: #cdd7e7;
}

.auth-social-btn:active {
    transform: translateY(1px);
}

.auth-social-btn:disabled {
    cursor: wait;
    opacity: 0.85;
}

.auth-social-btn.is-loading {
    pointer-events: none;
}

.auth-social-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
}

.auth-social-label {
    line-height: 1;
}

.auth-social-btn--google {
    border-color: #747775;
    color: #1f1f1f;
    background: #fff;
    font-family: Roboto, 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

.auth-social-btn--google:hover {
    background: #f8fafd;
    border-color: #5f6368;
}

.auth-social-btn--google-fallback[hidden] {
    display: none;
}

.auth-social-btn--kakao {
    border-color: #fee500;
    background: #fee500;
    color: rgba(0, 0, 0, 0.85);
}

.auth-social-btn--kakao:hover {
    background: #f7dd00;
    border-color: #f0d700;
}

.auth-social-divider {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.08rem 0 0.62rem;
    color: #64748b;
    font-size: 0.8rem;
}

.auth-social-divider::before,
.auth-social-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: #e2e8f0;
}

.auth-root .supabase-auth-ui_ui-label {
    margin-bottom: 0.12rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
}

.auth-root .supabase-auth-ui_ui-input {
    min-height: 46px;
    border-radius: 10px;
    border: 1px solid #cdd7e7;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.68rem 0.8rem;
}

.auth-root .supabase-auth-ui_ui-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-caps-lock-hint {
    min-height: 1rem;
    margin-top: 0.22rem;
    color: #b45309;
    font-size: 0.74rem;
    line-height: 1.35;
    opacity: 0;
}

.auth-caps-lock-hint.is-visible {
    opacity: 1;
}

.auth-root .supabase-auth-ui_ui-input::placeholder {
    color: #8b98ac;
}

.auth-root .supabase-auth-ui_ui-button {
    width: 100%;
    min-height: 44px;
    border-radius: 10px;
    border: 0;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    cursor: pointer;
}

.auth-root .supabase-auth-ui_ui-button:disabled {
    background: #9fb2da;
    color: #fff;
    cursor: not-allowed;
}

.auth-root .supabase-auth-ui_ui-anchor {
    font-size: 0.82rem;
    color: #64748b;
    text-decoration: none;
}

.auth-root .supabase-auth-ui_ui-anchor:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.auth-root .supabase-auth-ui_ui-divider {
    margin: 0.1rem 0 0.15rem;
}

.auth-root .supabase-auth-ui_ui-message {
    border-radius: 10px;
    border: 1px solid #d5deef;
    background: #f8fbff;
    color: #475569;
    padding: 0.5rem 0.62rem;
    font-size: 0.82rem;
    line-height: 1.35;
}

#supabase-signup-root .supabase-auth-ui_ui-container {
    display: flex;
    flex-direction: column;
    gap: 0.52rem;
}

#supabase-signup-root .supabase-auth-ui_ui-container > .supabase-auth-ui_ui-message {
    order: 90;
}

#supabase-signup-root .supabase-auth-ui_ui-container > .supabase-auth-ui_ui-button {
    order: 100;
}

#supabase-signup-root .supabase-auth-ui_ui-container > .supabase-auth-ui_ui-anchor {
    order: 110;
}

.auth-page-links {
    margin-top: 0.7rem;
    display: grid;
    justify-items: center;
    gap: 0.3rem;
}

.auth-page-link {
    font-size: 0.82rem;
    color: #64748b;
    text-decoration: none;
}

.auth-page-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.auth-page-link-btn {
    border: 0;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0;
}

.auth-page-link-btn:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.signup-form {
    width: 100%;
    display: grid;
    gap: 0.5rem;
}

.signup-label {
    margin-top: 0.08rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
}

.signup-input {
    width: 100%;
    min-height: 46px;
    border-radius: 10px;
    border: 1px solid #cdd7e7;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.68rem 0.8rem;
}

.signup-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.signup-input:disabled {
    background: #f4f6fa;
    color: #8b98ac;
}

.signup-verify-row {
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.signup-verify-timer {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1d4ed8;
}

.signup-verify-timer.is-expired {
    color: #b91c1c;
}

.signup-otp-input {
    letter-spacing: 0.12em;
    font-weight: 700;
}

.signup-help-text {
    margin: 0.05rem 0 0.1rem;
    font-size: 0.76rem;
    color: #64748b;
    line-height: 1.4;
}

.signup-mini-actions {
    margin-top: 0.1rem;
    display: flex;
    justify-content: flex-start;
    gap: 0.38rem;
}

.signup-mini-btn {
    min-height: 32px;
    border-radius: 8px;
    border: 1px solid #cbd6ec;
    background: #f8fbff;
    color: #334155;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 0.2rem 0.56rem;
    cursor: pointer;
}

.signup-mini-btn:hover {
    background: #eef4ff;
}

.signup-mini-btn.signup-mini-btn-secondary {
    border-color: #bfcde8;
    background: #f4f7fe;
}

.signup-mini-btn:disabled {
    color: #93a0b4;
    background: #f2f4f8;
    border-color: #d7deea;
    cursor: not-allowed;
}

.signup-primary-btn {
    width: 100%;
    min-height: 44px;
    margin-top: 0.32rem;
    border-radius: 10px;
    border: 0;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    cursor: pointer;
}

.signup-primary-btn:disabled {
    background: #9fb2da;
    color: #fff;
    cursor: not-allowed;
}

.auth-verify-box {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid #dbe4f2;
    display: grid;
    gap: 0.44rem;
}

.auth-verify-title {
    margin: 0;
    font-size: 0.98rem;
    color: #0f172a;
}

.auth-verify-desc {
    margin: 0 0 0.12rem;
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.45;
}

.auth-verify-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.auth-verify-input {
    width: 100%;
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid #cdd7e7;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 0.88rem;
    padding: 0.62rem 0.76rem;
}

.auth-verify-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-verify-input:disabled {
    background: #f4f6fa;
    color: #8b98ac;
}

.auth-verify-row {
    margin-top: 0.08rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auth-verify-code {
    letter-spacing: 0.12em;
    font-weight: 700;
}

.auth-verify-timer {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1d4ed8;
}

.auth-verify-timer.is-expired {
    color: #b91c1c;
}

.auth-verify-actions {
    margin-top: 0.3rem;
    display: grid;
    gap: 0.45rem;
}

.auth-verify-btn {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    cursor: pointer;
}

.auth-verify-btn.auth-verify-btn-secondary {
    border: 1px solid #cbd6ec;
    color: #334155;
    background: #f8fbff;
}

.auth-verify-btn:disabled {
    background: #9fb2da;
    border-color: #9fb2da;
    color: #fff;
    cursor: not-allowed;
}

.auth-verify-btn.auth-verify-btn-secondary:disabled {
    color: #93a0b4;
    background: #f2f4f8;
    border-color: #d7deea;
}

.test-main {
    display: block;
}

.test-stack {
    display: grid;
    gap: 1rem;
}

#test-setup-view .test-setup-layout {
    display: grid;
    grid-template-columns: minmax(240px, 0.82fr) minmax(0, 1.18fr);
    gap: 0.95rem;
    align-items: start;
    margin-bottom: 1rem;
}

#test-setup-view .test-setup-layout .config-group {
    margin-bottom: 0;
}

.test-setup-scope-column,
.test-setup-controls-column {
    display: grid;
    gap: 0.78rem;
}

#test-setup-view .test-controls-cluster {
    --test-control-cols: repeat(3, minmax(0, 1fr));
    --test-control-gap: 0.55rem;
    border: 1px solid rgba(30, 58, 138, 0.16);
    border-radius: 14px;
    background: linear-gradient(180deg, #fcfdff 0%, #f4f8ff 100%);
    padding: 0.68rem;
    display: grid;
    gap: 0.68rem;
}

#test-setup-view .test-controls-cluster .config-group {
    border: 1px solid rgba(153, 171, 206, 0.34);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    padding: 0.62rem;
}

#test-setup-view #chapter-options {
    grid-template-columns: var(--test-control-cols);
}

#test-setup-view #exam-type-options {
    grid-template-columns: var(--test-control-cols);
}

#test-setup-view #chapter-group h3,
#test-setup-view #include-derivatives-group h3 {
    margin-bottom: 0.45rem;
}

#test-setup-view #chapter-group #chapter-options {
    gap: var(--test-control-gap);
}

#test-setup-view #exam-type-options {
    gap: var(--test-control-gap);
}

#test-setup-view #exam-type-options .test-type-option,
#test-setup-view #chapter-group #chapter-options .test-type-option {
    min-height: 64px;
    padding: 0.6rem 0.56rem;
}

#test-setup-view #chapter-group #chapter-options .test-type-option {
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#test-setup-view #chapter-group #chapter-options .test-type-option .label-main {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    word-break: keep-all;
}

#test-setup-view #chapter-group #chapter-options .test-type-option .label-sub {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-subtle);
}

.test-scope-group {
    border: 1px solid rgba(30, 58, 138, 0.18);
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f3f7ff 100%);
    padding: 0.7rem;
}

#test-setup-view .test-scope-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.48rem;
}

#test-setup-view .test-scope-toolbar h3 {
    margin: 0;
}

#test-setup-view .test-scope-derivatives {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 0.84rem;
    gap: 0.45rem;
    justify-content: flex-start;
}

#test-setup-view #test-toc-checklist {
    max-height: 260px;
    border-color: #cfdbf3;
    background: rgba(255, 255, 255, 0.96);
}

#test-setup-view .test-scope-group .toc-checklist-item {
    padding: 0.52rem 0.55rem;
}

#test-setup-view .test-scope-group .toc-checklist-item .label {
    font-size: 0.87rem;
}

#test-setup-view #test-scope-summary {
    margin: 0 0 0.55rem;
    padding: 0.5rem 0.62rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    min-height: 2.2rem;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #fff;
}

.test-setup-controls-column .test-setup-inline {
    grid-template-columns: var(--test-control-cols);
    align-items: start;
    gap: var(--test-control-gap);
}

.test-inline-chapter {
    grid-column: 1 / -1;
}

.test-inline-shuffle {
    grid-column: auto;
}

#test-setup-view .test-setup-inline .config-group {
    padding: 0.62rem;
    display: grid;
    align-content: start;
}

#test-setup-view .test-setup-inline .config-group h3 {
    margin-bottom: 0.42rem;
}

#test-setup-view .test-setup-inline .toggle-option {
    min-height: 52px;
    padding: 0.62rem 0.66rem;
}

#chapter-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#chapter-options .sub-chapter-item {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 52px;
}

.test-setup-inline {
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
}

#test-question-count,
#test-time-limit {
    width: 100%;
    max-width: 280px;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.72rem 0.85rem;
    background: #fff;
    font: inherit;
    color: var(--text);
}

#test-question-count::-webkit-outer-spin-button,
#test-question-count::-webkit-inner-spin-button,
#test-time-limit::-webkit-outer-spin-button,
#test-time-limit::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#test-question-count,
#test-time-limit {
    -moz-appearance: textfield;
}

.test-inline-actions {
    display: inline-flex;
    gap: 0.4rem;
}

.test-mini-btn {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
}

.test-mini-btn:hover {
    background: var(--surface-soft);
}

.test-mini-btn:disabled {
    background: #f3f4f6;
    color: #8a95a8;
    cursor: not-allowed;
}

#test-choice-list .toc-checklist-item {
    align-items: flex-start;
}

.test-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    border: 0;
    background: transparent;
    max-height: none;
    overflow: visible;
    padding: 0;
}

.test-choice-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    text-align: left;
    padding: 0.78rem 0.82rem;
    cursor: pointer;
    font: inherit;
    min-height: 56px;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.test-choice-card:hover {
    border-color: rgba(30, 58, 138, 0.32);
    background: #f3f7ff;
}

.test-choice-card.is-selected {
    border-color: #2563EB;
    background: #eaf2ff;
    box-shadow: 0 8px 18px -14px rgba(37, 99, 235, 0.45);
}

.test-choice-text {
    display: block;
    line-height: 1.45;
    word-break: keep-all;
}

.test-prompt {
    margin: 0.25rem 0 0.95rem;
    line-height: 1.5;
    font-size: 1.03rem;
}

.test-actions {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.test-link-button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.test-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin: 0.55rem 0 1rem;
}

.test-metric-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.68rem 0.75rem;
    background: #fff;
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.test-metric-item strong {
    color: var(--text-subtle);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.test-code {
    margin: 0.3rem 0 0.65rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.test-history-list,
.test-review-list {
    display: grid;
    gap: 0.6rem;
}

.test-history-item,
.test-review-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem;
    background: #fff;
    display: grid;
    gap: 0.2rem;
    font-size: 0.9rem;
}

.test-history-item strong {
    font-size: 0.9rem;
}

.test-review-item p {
    margin: 0;
}

@media (max-width: 1200px) {
    #app {
        width: min(1100px, 100% - 1.5rem);
    }

    main {
        grid-template-columns: 1fr 1.2fr;
        gap: 0.9rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .test-actions {
        grid-template-columns: 1fr;
    }

    .test-metrics {
        grid-template-columns: 1fr;
    }

    .test-choice-grid {
        grid-template-columns: 1fr;
    }

    .test-setup-inline {
        grid-template-columns: 1fr;
    }

    #test-setup-view .test-setup-layout {
        grid-template-columns: 1fr;
    }

    .test-setup-controls-column .test-setup-inline {
        grid-template-columns: 1fr;
    }

    .test-inline-shuffle {
        grid-column: auto;
    }

    body[data-page="landing"] #app.landing-shell {
        width: min(1100px, 100% - 1.5rem);
    }

    body[data-page="landing"] .landing-hero {
        grid-template-columns: 1fr;
    }

    body[data-page="landing"] .landing-books {
        min-height: 390px;
    }
}

@media (max-width: 920px) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    html {
        scroll-behavior: auto;
    }

    main {
        grid-template-columns: 1fr;
    }

    body[data-page="generator"].generator-book-stage main {
        min-height: calc(100dvh - 170px);
    }

    body[data-page="generator"].generator-book-stage .book-select-card {
        min-height: calc(100dvh - 180px);
        padding: 1.05rem;
    }

    body[data-page="generator"].generator-book-stage .book-library {
        width: 100%;
        gap: 0.7rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .book-library {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .test-type-options {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem;
    }

    header {
        flex-wrap: wrap;
    }

    .version {
        order: 3;
        width: 100%;
        text-align: right;
    }

    body[data-page="landing"] #app.landing-shell {
        width: min(100%, 100% - 1rem);
        padding-top: 0.7rem;
    }

    body[data-page="landing"] .landing-header {
        padding: 0.75rem 0.8rem;
    }

    body[data-page="landing"] .landing-hero {
        padding: 1rem;
    }

    body[data-page="landing"] .landing-books {
        min-height: 330px;
    }

    body[data-page="landing"] .landing-book {
        width: 39%;
    }

    body[data-page="landing"] .landing-book-basic {
        left: 2%;
        top: 21%;
    }

    body[data-page="landing"] .landing-book-advanced {
        left: 31%;
        top: 16%;
    }

    body[data-page="landing"] .landing-book-etymology {
        left: 60%;
        top: 22%;
    }

}
