/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    background: rgba(254, 247, 255, 0.72);
}

.app-header__inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--md-sys-color-on-surface);
}

.brand__logo {
    color: var(--md-sys-color-primary);
    font-size: 28px;
}

.header-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--shape-full);
    box-shadow: var(--elev-1);
}

.pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--shape-full);
    font-weight: 600;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    transition: background 0.18s var(--motion-standard), color 0.18s var(--motion-standard), transform 0.16s var(--motion-spring);
}

.pill-btn:hover { background: var(--md-sys-color-surface-container-high); }
.pill-btn:active { transform: scale(0.96); }

.pill-btn--accent {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.pill-btn--accent:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary-container) 80%, white);
}

.pill-btn .material-symbols-rounded { font-size: 20px; }

@media (max-width: 520px) {
    .pill-btn__label-desktop { display: none; }
    .pill-btn { padding: 10px 12px; }
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
    padding: 28px 4px 12px;
}

.hero__title {
    font-family: var(--font-display);
    font-size: clamp(28px, 4.5vw, 44px);
    line-height: 1.1;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface);
}

.hero__subtitle {
    color: var(--md-sys-color-on-surface-variant);
    font-size: clamp(15px, 1.8vw, 17px);
    margin: 0;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--shape-full);
    font-weight: 600;
    font-size: 15px;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    transition: background 0.18s var(--motion-standard), transform 0.14s var(--motion-spring), box-shadow 0.2s var(--motion-standard);
}
.btn:hover { background: var(--md-sys-color-surface-container-high); }
.btn:active { transform: scale(0.97); }

.btn--filled {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--elev-1);
}
.btn--filled:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) 90%, black);
    box-shadow: var(--elev-2);
}

.btn--tonal {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.btn--text { background: transparent; padding: 10px 14px; }
.btn--text:hover { background: var(--md-sys-color-surface-container); }

.btn--danger {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.btn .material-symbols-rounded { font-size: 20px; }

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.icon-btn {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--shape-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    transition: background 0.18s var(--motion-standard), transform 0.14s var(--motion-spring);
}
.icon-btn:hover { background: var(--md-sys-color-surface-container); }
.icon-btn:active { transform: scale(0.92); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--shape-lg);
    box-shadow: var(--elev-1);
}

/* ─── Topic Cards ────────────────────────────────────────────────────────── */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 18px;
    margin-top: 8px;
}

.topic-card {
    position: relative;
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--shape-xl);
    padding: 22px 22px 20px;
    cursor: pointer;
    overflow: hidden;
    transition:
        transform 0.28s var(--motion-spring),
        box-shadow 0.28s var(--motion-standard),
        background 0.2s var(--motion-standard);
    box-shadow: var(--elev-1);
    min-height: 156px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
}

.topic-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        radial-gradient(140px 80px at 100% 0%, rgba(255,180,209,0.30), transparent 70%),
        radial-gradient(160px 100px at 0% 100%, rgba(182,157,248,0.22), transparent 70%);
    opacity: 0.9;
    transition: opacity 0.2s var(--motion-standard);
}

.topic-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--elev-2);
}

.topic-card:active { transform: scale(0.985); }

.topic-card.is-pinned {
    box-shadow:
        0 0 0 3px var(--md-sys-color-gold),
        0 0 0 6px var(--md-sys-color-gold-soft),
        0 0 28px var(--md-sys-color-gold-glow),
        var(--elev-2);
}

.topic-card.is-pinned .topic-card__pin-icon {
    color: #B68900;
    transform: rotate(0deg);
}

.topic-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    z-index: 1;
}

.topic-card__title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--md-sys-color-on-surface);
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.topic-card__pin {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--shape-full);
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    transition: background 0.18s var(--motion-standard), transform 0.2s var(--motion-spring);
    flex-shrink: 0;
}

.topic-card__pin:hover { background: var(--md-sys-color-surface-container-high); }

.topic-card__pin-icon {
    font-size: 22px;
    transition: color 0.2s var(--motion-standard), transform 0.3s var(--motion-spring);
    transform: rotate(45deg);
}

.topic-card.is-pinned .topic-card__pin {
    background: var(--md-sys-color-gold-soft);
}

.topic-card__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 1;
}

.topic-card__meta {
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topic-card__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--shape-full);
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-size: 12px;
    font-weight: 600;
}
.topic-card__chip .material-symbols-rounded { font-size: 16px; }

/* ─── Topic Detail (expanded) ────────────────────────────────────────────── */
.topic-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(29, 27, 32, 0.0);
    transition: background 0.28s var(--motion-standard);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.topic-overlay.is-open { background: rgba(29, 27, 32, 0.32); }

.topic-surface {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--shape-2xl);
    max-width: 920px;
    margin: 32px auto;
    box-shadow: var(--elev-3);
    overflow: hidden;
    will-change: transform, opacity;
    transform-origin: top left;
}

.topic-detail {
    padding: 32px 36px 56px;
}

.topic-detail__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.topic-detail__title {
    font-family: var(--font-display);
    font-size: clamp(24px, 4.5vw, 36px);
    line-height: 1.2;
    margin: 0;
    color: var(--md-sys-color-on-surface);
    letter-spacing: -0.015em;
    word-break: break-word;
    overflow-wrap: break-word;
    flex: 1;
    min-width: 0;
}

.topic-detail__close {
    flex-shrink: 0;
    margin-top: 4px;
}

.docx-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px 12px 12px;
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-radius: var(--shape-full);
    font-weight: 600;
    font-size: 14px;
    margin-top: 8px;
    transition: transform 0.16s var(--motion-spring), background 0.18s var(--motion-standard);
    max-width: 100%;
}
.docx-pill:hover {
    background: color-mix(in srgb, var(--md-sys-color-tertiary-container) 85%, white);
}
.docx-pill:active { transform: scale(0.97); }

.docx-pill__icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--shape-full);
    background: var(--md-sys-color-tertiary);
    color: #003E40;
    flex-shrink: 0;
}

.docx-pill__filename {
    max-width: 320px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.docx-pill__hint {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ─── CTA Banner for testing ────────────────────────────────────────────── */
.test-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--md-sys-color-primary-container) 0%, var(--md-sys-color-secondary-container) 100%);
    border-radius: var(--shape-xl);
    margin: 20px 0 8px;
    box-shadow: var(--elev-1);
    animation: fab-pop 0.5s var(--motion-spring);
    position: relative;
    overflow: hidden;
}

.test-cta::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.4) 0%, transparent 60%);
    pointer-events: none;
}

.test-cta__content {
    flex: 1;
    min-width: 0;
    z-index: 1;
}

.test-cta__title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--md-sys-color-on-primary-container);
}

.test-cta__desc {
    font-size: 13.5px;
    line-height: 1.4;
    margin: 0;
    color: color-mix(in srgb, var(--md-sys-color-on-primary-container) 85%, transparent);
    font-weight: 500;
}

.test-cta__btn {
    flex-shrink: 0;
    background: var(--md-sys-color-primary) !important;
    color: var(--md-sys-color-on-primary) !important;
    box-shadow: var(--elev-2);
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    gap: 10px;
    border-radius: var(--shape-full);
    transition: transform 0.16s var(--motion-spring), box-shadow 0.18s var(--motion-standard) !important;
    z-index: 1;
}

.test-cta__btn:hover {
    transform: scale(1.04) translateY(-1px);
    box-shadow: 0 8px 16px rgba(182, 157, 248, 0.4);
}

.test-cta__btn:active {
    transform: scale(0.97);
}

@media (max-width: 680px) {
    .test-cta {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 18px 20px;
    }
    .test-cta__btn {
        width: 100%;
        justify-content: center;
    }
}

.divider {
    height: 1px;
    background: var(--md-sys-color-surface-container-high);
    margin: 24px 0;
}

@media (max-width: 640px) {
    .topic-surface {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    .topic-detail { padding: 18px 18px 80px; }
    .docx-pill__filename { max-width: 180px; }
}

/* ─── Toasts ─────────────────────────────────────────────────────────────── */
.toast-root {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 12px 20px;
    border-radius: var(--shape-md);
    box-shadow: var(--elev-3);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in 0.32s var(--motion-spring);
    max-width: min(420px, 92vw);
}
.toast--error { background: #5C1A14; color: #FFDAD6; }
.toast--success { background: #1B4332; color: #B7E4C7; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(29, 27, 32, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: backdrop-in 0.2s var(--motion-standard);
}

@keyframes backdrop-in {
    from { background: rgba(29, 27, 32, 0); }
    to   { background: rgba(29, 27, 32, 0.4); }
}

.modal {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--shape-xl);
    box-shadow: var(--elev-3);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in 0.32s var(--motion-spring);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__header {
    padding: 22px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal__title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.modal__body { padding: 8px 24px 8px; }
.modal__footer {
    padding: 12px 24px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ─── Form fields ───────────────────────────────────────────────────────── */
.field {
    margin: 14px 0;
}
.field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 6px;
}
.field__input,
.field__textarea {
    width: 100%;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--shape-md);
    padding: 14px 16px;
    font-size: 15px;
    color: var(--md-sys-color-on-surface);
    transition: background 0.18s var(--motion-standard);
    font-family: inherit;
    line-height: 1.45;
    word-break: break-word;
}
.field__input:focus,
.field__textarea:focus {
    background: var(--md-sys-color-surface-container-high);
}
.field__textarea {
    resize: none;
    min-height: 100px;
    max-height: 360px;
    overflow-y: auto;
}
.field__textarea::-webkit-scrollbar { width: 8px; }
.field__textarea::-webkit-scrollbar-thumb {
    background: var(--md-sys-color-surface-container-highest);
    border-radius: var(--shape-full);
}

/* ─── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--md-sys-color-on-surface-variant);
}
.empty-state__icon {
    font-size: 64px !important;
    color: var(--md-sys-color-primary);
    margin-bottom: 16px;
    display: inline-block;
}
.empty-state__title {
    font-family: var(--font-display);
    font-size: 24px;
    margin: 0 0 8px;
    color: var(--md-sys-color-on-surface);
}
.empty-state__text { font-size: 15px; margin: 0; }

/* ─── Skeletons ─────────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--md-sys-color-surface-container) 0%,
        var(--md-sys-color-surface-container-high) 50%,
        var(--md-sys-color-surface-container) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--shape-md);
    animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton--card {
    height: 156px;
    border-radius: var(--shape-xl);
}

/* ─── Auth Badge & Nav ────────────────────────────────────────────────── */
.auth-section {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topic-card__progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--shape-full);
    font-size: 12px;
    font-weight: 600;
    z-index: 1;
}
.topic-card__progress-badge--not-started {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
}
.topic-card__progress-badge--in-progress {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.topic-card__progress-badge--completed {
    background: var(--md-sys-color-success);
    color: var(--md-sys-color-success-on);
}

/* ─── Atomic Layout Utilities ─────────────────────────────────────────── */
.w-100 { width: 100% !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.text-center { text-align: center !important; }
.auth-toggle-btn {
    color: var(--md-sys-color-primary) !important;
    font-weight: 600 !important;
}

