:root {
    --bg-color: #030712;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #fbbf24;
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --transition-base: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.noise-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.04; pointer-events: none; z-index: 9999;
    filter: contrast(120%) brightness(120%);
}

.cursor-glow {
    position: fixed; 
    width: 600px; 
    height: 600px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.08) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
    z-index: 1;
    transform: translate(-50%, -50%);
    mix-blend-mode: plus-lighter;
    opacity: 0;
    transition: opacity 1s ease;
}
body:hover .cursor-glow { opacity: 1; }

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

/* Hard Reset for Native Elements */
button, input, select, textarea {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    outline: none;
    font-family: inherit;
    color: inherit;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100svh;
    color: var(--text-primary);
    font-family: "Outfit", "Noto Sans SC", sans-serif;
    overflow: hidden !important; 
    -webkit-font-smoothing: antialiased;
    background: transparent;
}

/* Visual Canvas Elements */
.visual-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background-color: var(--bg-color);
    background-image: 
        linear-gradient(to right, rgba(3, 7, 18, 0.8), rgba(3, 7, 18, 0.2), rgba(3, 7, 18, 0.8)),
        url("portal-bg.png?v=1ba37fa397c9");
    background-size: cover;
    background-position: center;
}

.visual-canvas.bg-video-fallback {
    background-image: 
        linear-gradient(to right, rgba(3, 7, 18, 0.8), rgba(3, 7, 18, 0.2), rgba(3, 7, 18, 0.8)),
        url("portal-bg-fallback.webp?v=2026060312");
}

.ambient-glow {
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.2;
}

.g-1 { top: -15%; left: -15%; background: radial-gradient(circle, #3b82f6, transparent 70%); animation: glow-float 25s infinite alternate ease-in-out; }
.g-2 { bottom: -15%; right: -10%; background: radial-gradient(circle, #8b5cf6, transparent 70%); animation: glow-float 20s infinite alternate-reverse ease-in-out; }

/* Floating Symbols Engine */
.symbol {
    position: absolute;
    color: rgba(255, 255, 255, 0.4);
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 300;
    opacity: 0.04; /* Deep hidden state for 'Pick Light' interaction */
    user-select: none;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.p-1 { top: 15%; left: 8%; animation: float-diag 18s infinite alternate; }
.p-2 { top: 75%; left: 12%; animation: float-sway 22s infinite alternate; }
.p-3 { top: 45%; left: 25%; animation: float-diag 28s infinite alternate-reverse; }
.p-4 { top: 10%; left: 45%; animation: float-sway 25s infinite; }
.p-5 { top: 85%; left: 35%; animation: float-diag 30s infinite; }
.p-6 { top: 25%; left: 85%; animation: float-sway 19s infinite; }
.p-7 { top: 65%; left: 92%; animation: float-diag 26s infinite alternate; }
.p-8 { top: 40%; left: 78%; animation: float-sway 23s infinite reverse; }
.p-9 { top: 82%; left: 65%; animation: float-diag 21s infinite; }
.p-10 { top: 18%; left: 72%; animation: float-sway 27s infinite alternate; }

@keyframes glow-float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(8%, 5%) scale(1.1); } }
@keyframes float-diag { 0% { transform: translate(0, 0) rotate(0deg); opacity: 0.1; } 100% { transform: translate(30px, -50px) rotate(15deg); opacity: 0.15; } }
@keyframes float-sway { 0% { transform: translateY(0) rotate(-5deg); } 100% { transform: translateY(-40px) rotate(10deg); } }

/* Main Layout */
.portal-wrapper {
    height: 100vh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    padding: clamp(0.5rem, 2vw, 1.5rem) clamp(1rem, 5vw, 4rem);
    max-width: 1440px;
    margin: 0 auto;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(0.5rem, 2vh, 1.5rem);
    flex-shrink: 0;
}

.brand-logotype { 
    font-size: clamp(1.8rem, 5vw, 2.5rem); 
    font-weight: 900; 
    letter-spacing: -0.05em; 
    color: var(--text-primary); 
    display: flex; 
    align-items: center; 
    gap: clamp(0.8rem, 2vw, 1.5rem);
    text-shadow: 0 4px 20px rgba(0,0,0,0.4);
    white-space: nowrap;
}
.brand-logotype span { 
    font-size: 0.85rem; 
    letter-spacing: 0.5em; 
    font-weight: 300; 
    text-transform: uppercase; 
    color: var(--text-secondary);
    opacity: 0.7;
}
.header-status { 
    font-size: 0.75rem; 
    color: var(--text-secondary); 
    display: flex; 
    align-items: center; 
    gap: 0.6rem; 
    white-space: nowrap; 
    flex-shrink: 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Tablet & Landscape Optimization (e.g. iPad Mini 1024x768, short laptops) */
@media (max-width: 1100px) and (min-width: 901px), (max-height: 850px) and (min-width: 901px) {
    .portal-wrapper { padding: 1rem 3vw !important; }
    .app-header { margin-bottom: 2vh !important; }
    
    /* Give the left column more breathing room by shrinking the right card */
    .view-grid { gap: 1.5rem !important; grid-template-columns: 1fr 380px !important; }
    
    .brand-eyebrow { margin-bottom: 0.2rem !important; }
    .main-title { font-size: clamp(2.2rem, 4vw, 3.2rem) !important; line-height: 1.15 !important; margin-bottom: 0.8rem !important; }
    .main-desc { font-size: 0.9rem !important; margin-bottom: 1.5rem !important; line-height: 1.4 !important; max-width: 420px !important; }
    
    /* Force stats into a 2x2 grid instead of overflowing sequentially */
    .system-stats { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.8rem 1rem !important; }
    .stat-value { font-size: 1.2rem !important; }
    .stat-label { font-size: 0.6rem !important; }
    
    .portal-card { padding: 1.5rem !important; max-width: 380px !important; max-height: calc(100vh - 60px) !important; }
}

@media (max-width: 900px) {
    .app-header { justify-content: center; margin-bottom: 4vh; }
    .header-status { display: none; }
    .brand-logotype span { display: none; }
    /* Foolproof packed flex column logic to absolutely prevent overlapping and huge gaps */
    .view-grid { 
        display: flex !important; 
        flex-direction: column !important; 
        justify-content: center !important; 
        align-items: center !important; 
        gap: 1rem !important; 
        text-align: center; 
    }
    
    .branding-panel, .action-panel {
        flex: 0 0 auto !important;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }

    .brand-eyebrow { margin-bottom: 0.2rem !important; }
    .main-title { margin-bottom: 0 !important; line-height: 1.15; }
    .main-desc { display: none !important; }
    .system-stats { display: none !important; }
    .portal-card { margin-top: 0 !important; margin-bottom: 0 !important; }
}

.status-indicator { 
    width: 6px; 
    height: 6px; 
    background: #10b981; 
    border-radius: 50%; 
    box-shadow: 0 0 12px #10b981; 
    animation: statusPulse 2s infinite alternate;
}
@keyframes statusPulse {
    from { opacity: 0.4; transform: scale(0.9); box-shadow: 0 0 4px #10b981; }
    to { opacity: 1; transform: scale(1.1); box-shadow: 0 0 15px #10b981; }
}

/* Content Grid */
.portal-content { flex: 1; display: flex; align-items: center; min-height: 0; }
.view-grid { width: 100%; display: grid; grid-template-columns: 1fr 420px; gap: 4rem; align-items: center; }

/* Branding */
.brand-eyebrow {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(248, 250, 252, 0.9);
    margin-bottom: 0.45rem;
}

.main-title { font-family: "Noto Serif SC", serif; font-size: clamp(2.5rem, 4.5vw, 4.2rem); font-weight: 600; line-height: 1.1; margin: 0 0 1.2rem; }
.main-desc { font-size: 1rem; line-height: 1.6; color: var(--text-secondary); margin-bottom: 2rem; max-width: 500px; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.system-stats { display: flex; gap: 2rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; }

/* Card */
.portal-card {
    width: 100%;
    max-width: 460px; /* Precise max-width to avoid stretching on iPad */
    margin: 0 auto;
    max-height: calc(100vh - 100px);
    background: #0f172a; 
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    border-radius: 1.2rem;
    padding: 2.2rem 2rem;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.portal-card.portal-stage-login #loginStage {
    display: block !important;
}

.portal-card.portal-stage-login #subjectStage {
    display: none !important;
}

.portal-card.portal-stage-subjects #loginStage {
    display: none !important;
}

.portal-card.portal-stage-subjects #subjectStage {
    display: flex !important;
}

/* Fix duplicate title: hide the step indicator perfectly on the subject stage */
.portal-card.portal-stage-subjects .card-progress {
    display: none !important;
}
/* Removed card::before ambient glows */

.stage {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
}
.stage::-webkit-scrollbar { display: none; }

.card-progress { margin-bottom: 1rem; flex-shrink: 0; }
.step-indicator { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.step { font-size: 0.7rem; font-weight: 800; color: var(--text-secondary); opacity: 0.6; }
.step.active { color: var(--accent-color); opacity: 1; }
.step-line { width: 40px; flex: none; height: 1px; background: var(--glass-border); }

/* Tabs */
.auth-tabs { 
    display: flex; 
    background: rgba(255, 255, 255, 0.03); 
    padding: 0.2rem; 
    border-radius: 0.8rem; 
    margin-bottom: 1.2rem; 
    border: 1px solid rgba(255, 255, 255, 0.02);
}
/* Layout Logic: Hide elements in registration mode */
#loginStage:has(#userRegisterForm:not([hidden])) .auth-tabs { display: none !important; }
/* Stage Headers */
.stage-header { text-align: center; margin-bottom: 1.8rem; width: 100%; }
.stage-header h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.2rem; font-family: "Noto Serif SC", serif; }
.stage-header p { font-size: 0.85rem; color: var(--text-secondary); margin: 0; opacity: 0.8; }

#loginStage:has(#userRegisterForm:not([hidden])) .stage-header { margin-bottom: 1rem; }
#subjectStage {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#subjectStage .stage-header {
    max-width: 320px;
    margin: 0 auto 1.5rem;
    padding-top: 0.8rem;
}

#subjectStage .stage-header h2 {
    margin-bottom: 0.35rem;
}

#subjectStage .stage-header p {
    line-height: 1.6;
}

#subjectStage .subject-container {
    width: 100%;
}

/* --- PREMIUM SUBJECT CARDS --- */
.subject-card, .subject-card-wide {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: none;
    border-radius: 1rem;
    padding: 1.2rem;
    gap: 1.2rem;
    color: white;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1;
}

.subject-card::before, .subject-card-wide::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255,255,255,0.2), rgba(255,255,255,0.02) 40%, rgba(255,255,255,0.05) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    transition: background 0.5s ease;
    z-index: 2;
}

.subject-card:hover:not(.disabled), .subject-card-wide:hover:not(.disabled) {
    transform: translateY(-4px) scale(1.02);
    background: rgba(255, 255, 255, 0.08);
}

.subject-card:hover:not(.disabled)::before, .subject-card-wide:hover:not(.disabled)::before {
    background: linear-gradient(145deg, rgba(56,189,248,0.8), rgba(56,189,248,0.2) 40%, rgba(56,189,248,0.4) 100%);
}

.subject-card:active:not(.disabled), .subject-card-wide:active:not(.disabled) {
    transform: translateY(-1px) scale(0.98);
    background: rgba(56, 189, 248, 0.2);
    box-shadow: 0 0 60px rgba(56,189,248,0.4);
}

.subject-card:active:not(.disabled)::before, .subject-card-wide:active:not(.disabled)::before {
    background: linear-gradient(145deg, rgba(56,189,248,1), rgba(56,189,248,0.4) 40%, rgba(56,189,248,0.6) 100%);
}

.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 1.5rem;
    color: var(--accent-color);
    transition: all 0.4s ease;
    z-index: 3;
    position: relative;
}

.subject-card:hover:not(.disabled) .card-icon {
    transform: scale(1.1);
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
    color: white;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

.card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 3;
    position: relative;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin-bottom: 0.2rem;
    transition: color 0.3s ease;
}

.subject-card:hover:not(.disabled) .card-title {
    color: #38bdf8;
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.card-meta {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
}

.subject-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.card-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 3;
    position: relative;
}

.subject-card:hover:not(.disabled) .card-arrow {
    opacity: 1;
    transform: translateX(0);
    background: rgba(56, 189, 248, 0.8);
} 

.auth-tab { 
    flex: 1; 
    padding: 0.55rem; 
    color: var(--text-secondary); 
    font-size: 0.85rem; 
    font-weight: 700; 
    border-radius: 0.6rem; 
    transition: all 0.3s ease; 
    text-align: center; 
    cursor: pointer;
}
.auth-tab.active { 
    background: rgba(255, 255, 255, 0.08); 
    color: var(--text-primary); 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Form Elements */
.input-group { position: relative; margin-bottom: 1.2rem; }
.input-group input { 
    width: 100%; 
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.5rem;
    padding: 1rem 0.8rem 0.5rem; 
    color: var(--text-primary); 
    font-size: 0.95rem; 
    text-align: left;
    transition: var(--transition-base);
}
.input-group input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
    outline: none;
}
.input-group label { 
    position: absolute; 
    left: 1rem; 
    top: 50%; 
    transform: translateY(-50%);
    color: var(--text-secondary); 
    font-size: 0.95rem; 
    pointer-events: none; 
    transition: var(--transition-base); 
}
.input-group input:focus + label, .input-group input:not(:placeholder-shown) + label { 
    top: 0.8rem; 
    font-size: 0.65rem; 
    color: var(--accent-color); 
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.input-group.input-plain input {
    padding: 0.95rem 1rem;
}

.input-group.input-plain input::placeholder {
    color: rgba(148, 163, 184, 0.8);
}

.sms-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.6rem;
    align-items: center;
}

.btn-inline {
    min-height: 44px;
    padding: 0 1rem;
    border-radius: 0.9rem;
    border: 1px solid rgba(251, 191, 36, 0.38);
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition-base);
}

.btn-inline:hover {
    background: rgba(251, 191, 36, 0.2);
    color: #fff7ed;
}

.btn-inline:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.form-utils { 
    display: flex; 
    justify-content: flex-end; 
    margin-top: -0.5rem; 
    margin-bottom: 1.5rem; 
}
.btn-link-sm { 
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    opacity: 0.6; 
    text-decoration: none; 
    transition: all 0.3s ease;
    cursor: pointer;
}
.btn-link-sm:hover { 
    color: var(--accent-color); 
    opacity: 1; 
}

/* Action Buttons */
.btn-primary { 
    width: 100%; 
    padding: 0.85rem; 
    background: var(--accent-color);
    color: #0f172a; 
    border: none; 
    border-radius: 0.6rem; 
    font-weight: 700; 
    font-size: 0.95rem; 
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}
.btn-primary:hover { 
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* The fix for '立即注册' */
.btn-link {
    cursor: pointer;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: var(--accent-color);
    font-weight: 800;
    font-size: 0.9rem;
    margin-left: 0.5rem;
    display: inline-block;
    transition: var(--transition-base);
    text-decoration: underline rgba(251, 191, 36, 0.2);
    text-underline-offset: 4px;
}
.btn-link:hover { opacity: 0.7; transform: translateX(2px); text-decoration-color: var(--accent-color); }

/* Registration Spacing Fix */
#userRegisterForm .input-group {
    margin-bottom: 0.4rem;
}

#userRegisterForm .btn-primary {
    margin-top: 0.8rem;
    padding: 0.8rem;
}

.form-footer { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: var(--text-secondary); }

.founding-login-link {
    width: max-content;
    max-width: 100%;
    min-height: 0;
    margin: 0.52rem auto 0;
    padding: 0.24rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.34rem;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid rgba(251, 191, 36, 0.15);
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.045);
    box-shadow: none;
    transition: transform 0.24s ease, border-color 0.24s ease, background 0.24s ease;
}

.founding-login-link:hover {
    transform: translateY(-1px);
    border-color: rgba(251, 191, 36, 0.34);
    background: rgba(251, 191, 36, 0.075);
}

.founding-login-mark,
.founding-picker-mark {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fcd34d;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.24);
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.16);
}

.founding-login-mark {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: rgba(251, 191, 36, 0.1);
    box-shadow: none;
    font-size: 0.44rem;
}

.founding-login-copy {
    min-width: 0;
    flex: 0 1 auto;
    display: flex;
    align-items: center;
}

.founding-login-copy span {
    display: none;
}

.founding-login-copy strong {
    color: rgba(252, 211, 77, 0.9);
    font-size: 0.66rem;
    line-height: 1.1;
    letter-spacing: 0.03em;
    font-weight: 700;
}

.founding-login-link em {
    flex: 0 0 auto;
    color: rgba(148, 163, 184, 0.82);
    font-size: 0.56rem;
    font-style: normal;
    font-weight: 700;
    white-space: nowrap;
}

.feedback-msg {
    min-height: 1.35rem;
    margin-top: 0.9rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
}

/* Identity Selector for Register */
.identity-selector { display: flex; gap: 0.8rem; margin-bottom: 0.8rem; }
.id-btn { flex: 1; cursor: pointer; }
.id-btn input { display: none; }
.id-btn-content { 
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid var(--glass-border); 
    padding: 0.4rem; 
    border-radius: 0.6rem; 
    text-align: center; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    transition: var(--transition-base); 
}
.id-btn input:checked + .id-btn-content { background: rgba(251, 191, 36, 0.1); border-color: var(--accent-color); color: var(--accent-color); font-weight: 800; }

/* Dynamic Layout Adjustments */
#loginStage:has(#userRegisterForm:not([hidden])) .auth-tabs { display: none; }

/* Subjects Selection Grid */
.subject-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    grid-auto-rows: 1fr; 
    gap: 0.8rem; 
    width: 100%;
    max-width: 100%;
    margin: 0.5rem auto 0;
}

/* 过渡线优化 */
.subject-divider {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 1.8rem 0;
    opacity: 0.4;
}

.subject-divider::before, .subject-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--glass-border), transparent);
}

.subject-divider span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
    white-space: nowrap;
    filter: brightness(0.8);
}

.special-entrance-container {
    display: grid; 
    grid-template-columns: 1fr; 
    grid-auto-rows: 1fr; 
    gap: 1rem; 
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    justify-content: center;
}

.special-entrance-container.special-entrance-dual {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.special-entrance-container.special-entrance-single {
    max-width: 360px;
}

.special-entrance-container .subject-card {
    width: 100%;
    margin: 0 auto;
}

.special-entrance-container .card-info {
    min-width: 0;
}

.founding-picker-entry {
    width: min(100%, 260px);
    min-height: 34px;
    margin: 0 auto 0.42rem;
    padding: 0.3rem 0.52rem;
    display: flex;
    align-items: center;
    gap: 0.42rem;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid rgba(251, 191, 36, 0.16);
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.045);
    box-shadow: none;
    transition: transform 0.24s ease, border-color 0.24s ease, background 0.24s ease;
}

.founding-picker-entry:hover {
    transform: translateY(-1px);
    border-color: rgba(251, 191, 36, 0.34);
    background: rgba(251, 191, 36, 0.075);
}

.founding-picker-mark {
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 50%;
    background: rgba(251, 191, 36, 0.1);
    box-shadow: none;
    font-size: 0.46rem;
}

.founding-picker-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
}

.founding-picker-copy span {
    color: #f8fafc;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.founding-picker-copy strong {
    display: none;
    color: rgba(148, 163, 184, 0.86);
    font-size: 0.52rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.founding-picker-action {
    flex: 0 0 auto;
    color: rgba(148, 163, 184, 0.82);
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.subject-card-shortcut .card-title {
    font-size: 0.92rem;
    line-height: 1.35;
}

.subject-card-shortcut .card-meta {
    font-size: 0.72rem;
}

.subject-card-shortcut .card-note {
    font-size: 0.62rem;
}

.subject-card-single-line .card-title,
.subject-card-single-line .card-meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-card { 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center;
    text-align: center;
    gap: 0.85rem;
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid rgba(255, 255, 255, 0.08); 
    padding: 1.35rem 1.1rem; 
    border-radius: 1rem; 
    text-decoration: none; 
    transition: var(--transition-base); 
    position: relative;
    overflow: hidden;
    min-height: 104px; /* 设置统一的最小高度 */
}

.subject-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.subject-card:hover { 
    background: rgba(255, 255, 255, 0.07); 
    transform: translateY(-3px); 
    border-color: rgba(255, 255, 255, 0.2); 
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.subject-card:hover::before { opacity: 1; }

.subject-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.subject-card.card-highlight {
    border-color: var(--accent-color);
    background: rgba(251, 191, 36, 0.05);
}

.subject-card {
    gap: 0.72rem;
    padding: 1.25rem 1rem;
    border-radius: 1.05rem;
    min-height: 112px;
    width: 100%;
}

.subject-card-wide {
    min-height: 108px;
}

.card-membership {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.2);
}

.card-membership.status-founding {
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.28);
    color: #fcd34d;
    text-shadow: none;
}

.card-membership.status-trial {
    background: rgba(168, 85, 247, 0.16);
    border: 1px solid rgba(168, 85, 247, 0.28);
    color: #e9d5ff;
}

.card-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--text-primary);
    flex-shrink: 0;
    transition: transform 0.4s ease;
    margin: 0 auto;
}

.card-icon {
    width: 46px;
    height: 46px;
}

.subject-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
    background: rgba(255, 255, 255, 0.1);
}

.card-info {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 0.15rem;
}

.card-info {
    gap: 0.2rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0; 
    line-height: 1.1;
}

.card-title {
    font-size: 1.05rem;
    line-height: 1.2;
}

.card-meta {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-top: 0;
    opacity: 0.7;
    text-align: center;
}

.card-meta {
    font-size: 0.76rem;
}

.card-note {
    font-size: 0.66rem;
    line-height: 1.2;
    color: rgba(148, 163, 184, 0.88);
    letter-spacing: 0.04em;
    text-align: center;
    margin-top: 0.08rem;
}

/* Membership Status Colors */
.status-founding { color: var(--accent-color); font-weight: 800; text-shadow: 0 0 15px rgba(251, 191, 36, 0.3); }
.status-trial { color: #a855f7; }
.status-regular { color: var(--text-secondary); opacity: 0.8; }
.status-online { color: #10b981; }
.status-planned { color: var(--text-secondary); opacity: 0.5; font-style: italic; }
.status-restricted { color: #ef4444; opacity: 0.8; }

.card-arrow { display: none; }

@media (max-width: 480px) {
    .subject-grid { grid-template-columns: 1fr; }
    .special-entrance-container { grid-template-columns: 1fr; }
}

.stage-actions {
    position: static;
    z-index: 20;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
}

.stage-actions {
    margin-top: 1.15rem;
}

.stage-actions .btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.redeem-form {
    width: min(100%, 390px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.6rem;
}

.redeem-form input {
    min-height: 44px;
    border-radius: 0.9rem;
    padding: 0 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.68);
    color: var(--text-primary);
    font-size: 0.86rem;
}

.pricing-panel {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.pricing-group {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.52);
    padding: 0.85rem;
}

.pricing-group-title {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 0.85rem;
}

.pricing-plan-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.pricing-plan {
    padding: 0.4rem 0.55rem;
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
}

.subject-transfer-overlay {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.subject-transfer-overlay.is-visible {
    display: flex;
}

.subject-transfer-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 18%, rgba(14, 165, 233, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 82% 14%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
        linear-gradient(180deg, rgba(8, 14, 26, 0.85) 0%, rgba(4, 9, 16, 0.96) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

.subject-transfer-card {
    position: relative;
    width: min(100%, 430px);
    padding: 1.8rem 1.5rem 1.5rem;
    border-radius: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 15, 26, 0.85);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transform: translateY(18px) scale(0.98);
    opacity: 0;
    transition: transform 0.28s ease, opacity 0.28s ease;
}

.subject-transfer-overlay.is-active .subject-transfer-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.subject-transfer-glow {
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(45px);
}

.subject-transfer-glow-a {
    top: -48px;
    right: -30px;
    width: 200px;
    height: 200px;
    background: rgba(56, 189, 248, 0.12);
}

.subject-transfer-glow-b {
    left: -60px;
    bottom: -80px;
    width: 230px;
    height: 230px;
    background: rgba(14, 165, 233, 0.10);
}

.subject-transfer-visual {
    position: relative;
    width: 90px;
    height: 90px;
    margin: 0 auto 1.2rem;
}

.subject-transfer-orbit,
.subject-transfer-core-ring,
.subject-transfer-core {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.subject-transfer-orbit-a {
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top-color: #38bdf8;
    animation: subjectTransferSpin 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.subject-transfer-orbit-b {
    inset: 12px;
    border: 1px solid transparent;
    border-bottom-color: rgba(14, 165, 233, 0.7);
    border-left-color: rgba(14, 165, 233, 0.2);
    animation: subjectTransferSpinReverse 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.subject-transfer-core-ring {
    display: none;
}

.subject-transfer-core {
    inset: 30px;
    background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    box-shadow: 0 0 24px rgba(14, 165, 233, 0.5);
    animation: subjectTransferPulse 2s ease-in-out infinite;
}

.subject-transfer-kicker {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: rgba(14, 165, 233, 0.8);
    text-transform: uppercase;
}

.subject-transfer-badge {
    position: relative;
    z-index: 1;
    width: fit-content;
    margin: 0.85rem auto 0;
    min-height: 2rem;
    padding: 0 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.2);
    color: #bae6fd;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.subject-transfer-title {
    position: relative;
    z-index: 1;
    margin: 1.2rem 0 0;
    text-align: center;
    font-size: clamp(1.4rem, 2.8vw, 1.8rem);
    font-weight: 700;
    color: #ffffff;
    font-family: inherit;
    letter-spacing: 0.02em;
}

.subject-transfer-desc {
    position: relative;
    z-index: 1;
    margin: 0.6rem auto 0;
    max-width: 300px;
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.6);
}

.subject-transfer-progress {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.subject-transfer-progress span {
    min-height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.subject-transfer-progress .is-done {
    border-color: rgba(56, 189, 248, 0.2);
    background: rgba(56, 189, 248, 0.06);
    color: rgba(56, 189, 248, 0.9);
}

.subject-transfer-progress .is-active {
    border-color: rgba(14, 165, 233, 0.4);
    background: rgba(14, 165, 233, 0.15);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.2);
}

@keyframes subjectTransferSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes subjectTransferSpinReverse {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes subjectTransferPulse {
    0%, 100% { transform: scale(0.9); box-shadow: 0 0 15px rgba(14, 165, 233, 0.3); opacity: 0.8; }
    50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(56, 189, 248, 0.6); opacity: 1; }
}

.portal-modal.hidden {
    display: none;
}

.portal-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.portal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 7, 18, 0.82);
    backdrop-filter: blur(16px);
}

.portal-modal-card {
    position: relative;
    width: min(100%, 460px);
    padding: 1.6rem;
    border-radius: 1.2rem;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.48);
}

.portal-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.portal-modal-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: "Noto Serif SC", serif;
}

.portal-modal-subtitle {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.portal-modal-close {
    width: 2.4rem;
    height: 2.4rem;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: var(--transition-base);
}

.portal-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}

.portal-modal-form .input-group {
    margin-bottom: 0.95rem;
}

.portal-modal-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.1rem;
}

.portal-modal-actions .btn-primary,
.portal-modal-actions .btn-secondary {
    flex: 1;
}

.btn-secondary {
    width: 100%;
    padding: 0.85rem;
    border-radius: 0.6rem;
    font-weight: 700;
    font-size: 0.92rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

/* Footer */
.app-footer { margin-top: auto; padding: 2rem 0; border-top: 1px solid var(--glass-border); color: var(--text-secondary); font-size: 0.8rem; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.footer-links a { color: var(--text-secondary); text-decoration: none; transition: var(--transition-base); }
.footer-links a:hover { color: var(--text-primary); text-shadow: 0 0 10px rgba(255,255,255,0.3); }
.sep { color: rgba(255,255,255,0.1); }

/* Mobile */
@media (max-width: 900px) {
    html, body {
        height: auto;
        min-height: 100svh;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    .portal-wrapper {
        height: auto;
        min-height: 100svh;
        padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
    }
    .portal-content {
        flex: 0 0 auto;
        align-items: flex-start;
    }
    .view-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .branding-panel { text-align: center; }
    .main-title { font-size: 2.22rem; }
    .main-desc, .system-stats, .app-footer, .symbol { display: none; }
    .portal-card {
        max-width: 440px;
        max-height: none;
    }
    .stage {
        overflow: visible;
    }
    .portal-modal-card { padding: 1.35rem; }
    .portal-modal-actions { flex-direction: column-reverse; }

    /* 手机端更换账号按钮居中并消除重叠 */
    .stage-actions {
        position: static;
        text-align: center;
        margin-top: 1.5rem;
        margin-bottom: 0.5rem;
        width: 100%;
    }

    .subject-transfer-card {
        padding: 1.55rem 1.2rem 1.25rem;
        border-radius: 1.35rem;
    }

    .subject-transfer-progress {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .portal-card {
        padding: 1.85rem 1.25rem 1.45rem;
    }

    .card-progress {
        margin-bottom: 0.85rem;
    }

    .step-indicator {
        gap: 0.75rem;
    }

    .step {
        font-size: 0.66rem;
    }

    .step-line {
        width: 32px;
    }

    .stage-actions {
        margin-top: 1.15rem;
        margin-bottom: 0.35rem;
    }
}

@media (max-width: 380px) {
    .portal-card {
        padding: 1.65rem 1rem 1.35rem;
    }

    #subjectStage .stage-header {
        max-width: 290px;
        margin-bottom: 1.3rem;
    }

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

    .special-entrance-container {
        gap: 0.85rem;
    }

    .subject-card,
    .subject-card-wide {
        min-height: 104px;
    }
}

@media (max-width: 600px) {
    .portal-wrapper {
        padding: 0.75rem 0.85rem;
    }

    .app-header {
        margin-bottom: 0.75rem;
    }

    .brand-logotype {
        font-size: 1.45rem;
        gap: 0.55rem;
    }

    .view-grid {
        gap: 0.9rem;
    }

    .main-title {
        font-size: 1.92rem;
        line-height: 1.08;
        margin-bottom: 0.75rem;
    }

    .portal-card {
        max-width: 410px;
        max-height: calc(100svh - 64px);
        padding: 1.2rem 0.95rem 0.95rem;
        border-radius: 1rem;
    }

    .card-progress {
        margin-bottom: 0.65rem;
    }

    .step-indicator {
        gap: 0.55rem;
    }

    .step {
        font-size: 0.62rem;
    }

    .step-line {
        width: 24px;
    }

    .stage-header {
        margin-bottom: 1.15rem;
    }

    .stage-header h2 {
        font-size: 1.55rem;
    }

    .stage-header p {
        font-size: 0.78rem;
    }

    #subjectStage .stage-header {
        max-width: 280px;
        margin-bottom: 1rem;
    }

    .subject-grid {
        max-width: 332px;
        gap: 0.75rem;
        margin-top: 0.25rem;
    }

    .special-entrance-container {
        max-width: 332px;
        gap: 0.75rem;
    }

    .subject-divider {
        gap: 1rem;
        margin: 1.05rem 0;
    }

    .subject-card,
    .subject-card-wide {
        min-height: 88px;
        padding: 0.9rem 0.8rem;
        gap: 0.55rem;
    }

    .card-membership {
        top: 0.55rem;
        right: 0.55rem;
        padding: 3px 7px;
        font-size: 0.58rem;
    }

    .card-icon {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
        border-radius: 0.75rem;
    }

    .card-title {
        font-size: 0.98rem;
        line-height: 1.15;
    }

    .card-meta {
        font-size: 0.7rem;
    }

    .card-note {
        font-size: 0.6rem;
    }

    .stage-actions {
        margin-top: 0.75rem;
        margin-bottom: 0.1rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-content {
        align-items: flex-start;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .view-grid {
        gap: 0.7rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .brand-eyebrow {
        font-size: 0.66rem;
        margin-bottom: 0.2rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .main-title {
        font-size: 1.7rem;
        margin-bottom: 0.35rem;
        max-width: 260px;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-height: calc(100svh - 28px);
        padding: 0.98rem 0.9rem 0.88rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .card-progress {
        margin-bottom: 0.45rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step-indicator {
        gap: 0.38rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step {
        font-size: 0.56rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step-line {
        width: 18px;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.72rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 1.34rem;
        margin-bottom: 0.12rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
        font-size: 0.7rem;
        line-height: 1.45;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
        gap: 0.55rem;
        margin-bottom: 0.55rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 44px;
        padding: 0.35rem 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.76rem;
        border-radius: 0.7rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
        margin-bottom: 0.32rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 48px;
        padding: 0.82rem 0.95rem;
        font-size: 0.9rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        margin-top: 0.5rem;
        padding: 0.82rem;
        font-size: 0.92rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
        margin-top: 0.72rem;
        font-size: 0.82rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-link {
        font-size: 0.84rem;
    }
}

@media (max-width: 600px) and (min-height: 820px) {
    .portal-content {
        align-items: stretch;
    }

    .view-grid {
        min-height: 100%;
        grid-template-rows: auto minmax(0, 1fr);
        align-content: stretch;
        gap: 1rem;
    }

    .branding-panel {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    .action-panel {
        display: flex;
        align-items: center;
        justify-content: center;
        padding-top: 0;
        padding-bottom: clamp(0.4rem, 1.6vh, 0.9rem);
    }

    .portal-card {
        margin: 0 auto;
    }
}

@media (max-width: 480px) and (min-width: 421px) {
    .portal-wrapper {
        padding: 0.6rem 0.75rem;
    }

    .app-header {
        margin-bottom: 0.6rem;
    }

    .portal-content {
        align-items: flex-start;
    }

    .view-grid {
        gap: 0.7rem;
        justify-items: center;
    }

    .branding-panel,
    .action-panel {
        width: 100%;
    }

    .branding-panel {
        display: flex;
        justify-content: center;
    }

    .brand-content {
        width: min(100%, 320px);
        margin: 0 auto;
    }

    .brand-eyebrow {
        font-size: 0.72rem;
        margin-bottom: 0.28rem;
    }

    .main-title {
        font-size: 1.64rem;
        line-height: 1.04;
        margin: 0 auto 0.35rem;
        max-width: 300px;
    }

    .portal-card {
        max-width: 380px;
        max-height: calc(100svh - 52px);
        padding: 0.98rem 0.84rem 0.8rem;
        border-radius: 0.95rem;
    }

    .stage-header {
        margin-bottom: 0.9rem;
    }

    #subjectStage .stage-header {
        max-width: 260px;
        margin-bottom: 0.88rem;
    }

    .subject-grid {
        max-width: 320px;
        gap: 0.65rem;
    }

    .special-entrance-container {
        max-width: 320px;
        gap: 0.65rem;
    }
}

@media (max-width: 420px), (max-width: 600px) and (max-height: 740px) {
    .portal-wrapper {
        padding: 0.45rem 0.6rem;
    }

    .app-header {
        margin-bottom: 0.45rem;
    }

    .brand-logotype {
        font-size: 1.18rem;
        gap: 0.4rem;
    }

    .portal-content {
        align-items: flex-start;
    }

    .view-grid {
        gap: 0.45rem;
    }

    .branding-panel {
        padding-top: 0.05rem;
    }

    .brand-eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.16em;
        margin-bottom: 0.22rem;
    }

    .main-title {
        font-size: 1.48rem;
        line-height: 1.02;
        margin: 0 auto 0.25rem;
        max-width: 280px;
    }

    .portal-card {
        max-width: 352px;
        max-height: calc(100svh - 42px);
        padding: 0.82rem 0.72rem 0.68rem;
        border-radius: 0.9rem;
    }

    .card-progress {
        margin-bottom: 0.42rem;
    }

    .step-indicator {
        gap: 0.34rem;
    }

    .step {
        font-size: 0.54rem;
    }

    .step-line {
        width: 16px;
    }

    .stage-header {
        margin-bottom: 0.75rem;
    }

    .stage-header h2 {
        font-size: 1.28rem;
        margin-bottom: 0.15rem;
    }

    .stage-header p {
        font-size: 0.7rem;
    }

    #subjectStage .stage-header {
        max-width: 238px;
        margin-bottom: 0.72rem;
    }

    .subject-grid {
        max-width: 286px;
        gap: 0.52rem;
        margin-top: 0.1rem;
    }

    .special-entrance-container {
        max-width: 286px;
        gap: 0.52rem;
    }

    .subject-divider {
        gap: 0.75rem;
        margin: 0.7rem 0;
    }

    .subject-divider span {
        font-size: 0.5rem;
        letter-spacing: 0.16em;
    }

    .subject-card,
    .subject-card-wide {
        min-height: 72px;
        padding: 0.66rem 0.58rem;
        gap: 0.38rem;
        border-radius: 0.88rem;
    }

    .card-membership {
        top: 0.42rem;
        right: 0.42rem;
        padding: 2px 6px;
        font-size: 0.54rem;
    }

    .card-icon {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
        border-radius: 0.58rem;
    }

    .card-title {
        font-size: 0.84rem;
        line-height: 1.1;
    }

    .card-meta {
        font-size: 0.6rem;
    }

    .card-note {
        font-size: 0.52rem;
        letter-spacing: 0.03em;
    }

    .stage-actions {
        margin-top: 0.45rem;
        margin-bottom: 0;
    }

    .stage-actions .btn-link {
        font-size: 0.78rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .view-grid {
        gap: 0.3rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .brand-eyebrow {
        font-size: 0.6rem;
        margin-bottom: 0.14rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .main-title {
        font-size: 1.34rem;
        margin: 0 auto 0.18rem;
        max-width: 220px;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-width: 344px;
        max-height: calc(100svh - 18px);
        padding: 0.72rem 0.68rem 0.62rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .card-progress {
        margin-bottom: 0.34rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step-indicator {
        gap: 0.26rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step {
        font-size: 0.5rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .step-line {
        width: 12px;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.56rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 1.12rem;
        margin-bottom: 0.1rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
        font-size: 0.64rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
        gap: 0.45rem;
        margin-bottom: 0.45rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 40px;
        padding: 0.3rem 0.42rem;
        font-size: 0.72rem;
        border-radius: 0.62rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
        margin-bottom: 0.26rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 44px;
        padding: 0.72rem 0.86rem;
        font-size: 0.86rem;
        border-radius: 0.82rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        margin-top: 0.42rem;
        padding: 0.74rem;
        font-size: 0.88rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
        margin-top: 0.56rem;
        font-size: 0.78rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-link {
        font-size: 0.8rem;
    }
}

/* Login UI refresh */
:root {
    --bg-color: #020617;
    --accent-color: #b28e4a;
    --glass-bg: rgba(5, 5, 5, 0.52);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 40px 80px rgba(0, 0, 0, 0.8);
}

.visual-canvas {
    background-color: #020617;
    background-image:
        linear-gradient(to right, rgba(2, 6, 23, 0.8), rgba(2, 6, 23, 0.22), rgba(2, 6, 23, 0.8)),
        url("portal-bg.png?v=1ba37fa397c9");
}

.bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 1;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    filter: saturate(1.04) contrast(1.02);
    transition: opacity 1.5s ease-in-out;
    z-index: 0;
}

.visual-canvas.bg-video-fallback .bg-video {
    opacity: 0 !important;
    visibility: hidden;
}

.video-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0.62) 0%,
        rgba(0, 0, 0, 0.18) 42%,
        rgba(0, 0, 0, 0.34) 100%
    );
    z-index: 2;
    transition: background 0.42s ease, opacity 0.42s ease;
}

.visual-canvas.video-loop-transition .bg-video {
    opacity: 0.82;
    transition-duration: 0.42s;
}

.visual-canvas.video-loop-transition .video-overlay {
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0.76) 0%,
        rgba(0, 0, 0, 0.34) 42%,
        rgba(0, 0, 0, 0.58) 100%
    );
}

.ambient-glow {
    opacity: 0.1;
    z-index: 3;
}

.branding-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
}

.brand-content {
    width: min(100%, 36rem);
    margin: 0;
}

.brand-eyebrow {
    color: var(--accent-color);
    letter-spacing: 0.3em;
    font-size: 0.72rem;
}

.main-title {
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: clamp(3.1rem, 5vw, 4.8rem);
    color: #ffffff;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    background: none;
    -webkit-text-fill-color: initial;
    mix-blend-mode: hard-light;
}

.main-desc {
    max-width: 560px;
    font-size: 1rem;
    line-height: 1.85;
    color: rgba(226, 232, 240, 0.78);
    text-shadow: 0 8px 28px rgba(0, 0, 0, 0.38);
}

.system-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, max-content));
    column-gap: clamp(1.4rem, 2.2vw, 2.35rem);
    row-gap: 1rem;
    justify-content: start;
    align-items: start;
    width: fit-content;
    max-width: 100%;
    margin-top: 2rem;
}

.stat-item {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
    white-space: nowrap;
}

.stat-item:nth-child(2n + 1)::before {
    display: none;
}

.stat-item:nth-child(2n) {
    padding-left: 0.15rem;
}

.stat-item:first-child::before {
    display: none;
}

.stat-item::before {
    content: '';
    position: absolute;
    left: -0.9rem;
    top: 0.15rem;
    width: 1px;
    height: 2rem;
    background: var(--glass-border);
}

.stat-label {
    white-space: nowrap;
}

@supports not (width: fit-content) {
    .system-stats {
        display: inline-grid;
        width: auto;
    }
}

.stat-value {
    font-size: 1.06rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.stat-label {
    font-family: "Noto Serif SC", serif;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.52);
    text-transform: none;
}

.portal-card {
    max-width: 480px;
    max-height: min(760px, calc(100svh - 108px));
    padding: 2.85rem 2.45rem 2.45rem;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.03) 0%, transparent 60%),
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        var(--glass-bg);
    background-size: 100% 100%, 3px 3px, 3px 3px, 100% 100%;
    border: 1px solid var(--glass-border);
    border-radius: 1px;
    box-shadow:
        var(--glass-shadow),
        inset 0 1px 1px rgba(255, 255, 255, 0.12),
        inset 1px 0 0 rgba(255, 255, 255, 0.05),
        inset 0 -10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.portal-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 30%,
        transparent 70%,
        rgba(178, 142, 74, 0.03) 100%
    );
    pointer-events: none;
    z-index: 0;
}

#loginStage,
#subjectStage,
.card-progress {
    position: relative;
    z-index: 1;
}

.stage {
    scrollbar-width: none;
}

.stage::-webkit-scrollbar {
    display: none;
}

.card-progress {
    margin-bottom: 1.2rem;
}

.step-indicator {
    gap: 0.95rem;
}

.step {
    font-size: 0.71rem;
    letter-spacing: 0.18em;
    opacity: 0.55;
}

.step.active {
    color: var(--accent-color);
}

.step-line {
    background: rgba(255, 255, 255, 0.14);
}

.stage-header {
    margin-bottom: 1.85rem;
}

.stage-header h2 {
    font-size: 1.95rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.stage-header p {
    font-size: 0.86rem;
    line-height: 1.7;
    color: rgba(226, 232, 240, 0.68);
}

.auth-tabs {
    background: transparent;
    border-radius: 0;
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.8rem;
}

.auth-tab {
    padding: 0.9rem 0.6rem;
    border-radius: 0;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.42);
}

.auth-tab.active {
    background: transparent;
    color: var(--accent-color);
    box-shadow: inset 0 -2px 0 var(--accent-color);
}

.input-group input {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    padding: 1.12rem 0 0.56rem;
    font-size: 0.96rem;
}

.input-group.input-plain input {
    padding: 1rem 0 0.56rem;
}

.input-group input:focus {
    background: transparent;
    border-color: var(--accent-color);
}

.input-group label {
    left: 0;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: 0.42rem;
    left: 0;
}

.form-utils {
    margin-top: -0.25rem;
    margin-bottom: 1.4rem;
}

.btn-link-sm {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.btn-link-sm:hover {
    color: var(--accent-color);
}

.btn-primary {
    padding: 0.96rem 1rem;
    background: var(--accent-color);
    color: #050505;
    border-radius: 1px;
    font-weight: 600;
    letter-spacing: 0.18em;
    box-shadow: 0 14px 28px rgba(178, 142, 74, 0.16);
    text-transform: uppercase;
}

.btn-primary:hover {
    background: #cbb07a;
    box-shadow: 0 18px 32px rgba(178, 142, 74, 0.25);
    transform: translateY(-2px);
}

.btn-primary span {
    transform: translateY(1px);
}

.btn-link {
    color: #dec28d;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(222, 194, 141, 0.28);
}

.btn-link:hover {
    color: #f3dfb5;
    border-bottom-color: currentColor;
    transform: none;
    opacity: 1;
}

.form-footer {
    margin-top: 1rem;
    color: rgba(226, 232, 240, 0.72);
}

.feedback-msg {
    margin-top: 0.9rem;
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.76);
}

.id-btn-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1px;
    padding: 0.55rem;
}

.id-btn input:checked + .id-btn-content {
    background: rgba(178, 142, 74, 0.12);
    border-color: var(--accent-color);
    color: #f0d7aa;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-content {
    align-items: flex-start;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .view-grid {
    gap: 2rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
    max-height: calc(100svh - 72px);
    padding: 2.1rem 1.85rem 1.55rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #loginStage {
    overflow-y: hidden;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .card-progress {
    margin-bottom: 0.78rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .step-indicator {
    gap: 0.7rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .step {
    font-size: 0.64rem;
    letter-spacing: 0.14em;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .step-line {
    width: 28px;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
    margin-bottom: 0.82rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
    font-size: 1.72rem;
    margin-bottom: 0.12rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
    font-size: 0.74rem;
    line-height: 1.45;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
    gap: 0.62rem;
    margin-bottom: 0.5rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
    min-height: 46px;
    padding: 0.42rem 0.52rem;
    font-size: 0.8rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
    margin-bottom: 0.22rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
    min-height: 40px;
    padding: 0.64rem 0 0.38rem;
    font-size: 0.84rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
    margin-top: 0.42rem;
    padding: 0.72rem 0.88rem;
    font-size: 0.88rem;
    letter-spacing: 0.12em;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
    margin-top: 0.55rem;
    font-size: 0.78rem;
}

.portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-link {
    font-size: 0.8rem;
}

.subject-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    border-radius: 1px;
}

.subject-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.24);
}

.stage-actions {
    margin-top: 1.3rem;
}

.portal-modal-backdrop {
    background: rgba(2, 6, 23, 0.86);
}

.portal-modal-card {
    background: rgba(10, 10, 10, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1px;
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.48),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

.btn-secondary {
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.app-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 1100px) {
    .view-grid {
        gap: 2.6rem;
    }

    .system-stats {
        gap: 2rem;
    }

    .portal-card {
        max-width: 460px;
        padding: 2.45rem 2rem 2.1rem;
    }

    .main-title {
        font-size: clamp(2.6rem, 7vw, 4rem);
        mix-blend-mode: normal;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-height: calc(100svh - 56px);
        padding: 1.8rem 1.5rem 1.3rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.68rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 1.54rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
        margin-bottom: 0.42rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 42px;
        font-size: 0.76rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 38px;
        padding: 0.58rem 0 0.34rem;
        font-size: 0.8rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        padding: 0.68rem 0.82rem;
        font-size: 0.84rem;
    }
}

@media (max-width: 900px) {
    .video-overlay {
        background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.5) 0%,
            rgba(0, 0, 0, 0.34) 55%,
            rgba(0, 0, 0, 0.5) 100%
        );
    }

    .portal-card {
        max-height: calc(100svh - 88px);
        padding: 2rem 1.45rem 1.6rem;
    }

    .main-title {
        font-size: 2.45rem;
        mix-blend-mode: normal;
    }

    .stage-header h2 {
        font-size: 1.8rem;
    }

    .stat-item::before {
        display: none;
    }
}

@media (max-width: 600px) {
    .bg-video {
        object-position: center top;
    }

    .portal-card {
        max-width: 420px;
        max-height: calc(100svh - 66px);
        padding: 1.25rem 0.98rem 1rem;
    }

    .card-progress {
        margin-bottom: 0.75rem;
    }

    .step-indicator {
        gap: 0.55rem;
    }

    .step {
        font-size: 0.58rem;
        letter-spacing: 0.12em;
    }

    .step-line {
        width: 22px;
    }

    .stage-header {
        margin-bottom: 1.05rem;
    }

    .stage-header h2 {
        font-size: 1.56rem;
    }

    .stage-header p {
        font-size: 0.78rem;
        line-height: 1.55;
    }

    .auth-tabs {
        margin-bottom: 1.2rem;
    }

    .auth-tab {
        padding: 0.75rem 0.45rem;
        font-size: 0.78rem;
    }

    .input-group input,
    .input-group.input-plain input {
        padding: 0.84rem 0 0.48rem;
    }

    .btn-primary {
        padding: 0.82rem 0.9rem;
        font-size: 0.9rem;
        letter-spacing: 0.12em;
    }

    .btn-secondary {
        padding: 0.82rem 0.9rem;
    }

    .portal-modal-card {
        padding: 1.3rem 1.1rem;
    }

    .portal-card.portal-stage-subjects {
        padding: 0.98rem 0.9rem 0.78rem;
    }

    .portal-card.portal-stage-subjects .card-progress {
        margin-bottom: 0.5rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        margin-bottom: 0.78rem;
    }

    .portal-card.portal-stage-subjects .subject-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.64rem;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 82px;
        padding: 0.78rem 0.72rem;
        gap: 0.44rem;
    }

    .portal-card.portal-stage-subjects .stage-actions {
        margin-top: 0.5rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-height: calc(100svh - 22px);
        padding: 0.98rem 0.9rem 0.82rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.7rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 1.34rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
        font-size: 0.7rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .auth-tabs {
        margin-bottom: 0.95rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
        margin-bottom: 0.18rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 40px;
        padding: 0.66rem 0 0.34rem;
        font-size: 0.8rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 42px;
        font-size: 0.74rem;
        padding: 0.34rem 0.42rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        margin-top: 0.36rem;
        padding: 0.68rem 0.78rem;
        font-size: 0.84rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
        margin-top: 0.46rem;
        font-size: 0.74rem;
    }
}

@media (max-width: 420px), (max-width: 600px) and (max-height: 740px) {
    .portal-card {
        max-width: 352px;
        max-height: calc(100svh - 42px);
        padding: 0.88rem 0.74rem 0.72rem;
    }

    .portal-card.portal-stage-subjects {
        padding: 0.82rem 0.7rem 0.62rem;
    }

    .stage-header h2 {
        font-size: 1.28rem;
    }

    .stage-header p {
        font-size: 0.7rem;
    }

    .auth-tab {
        padding: 0.68rem 0.38rem;
        font-size: 0.72rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-height: calc(100svh - 14px);
        padding: 0.72rem 0.68rem 0.62rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.5rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 1.1rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
        font-size: 0.62rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
        gap: 0.38rem;
        margin-bottom: 0.34rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 38px;
        padding: 0.26rem 0.34rem;
        font-size: 0.68rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
        margin-bottom: 0.12rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 36px;
        padding: 0.56rem 0 0.28rem;
        font-size: 0.76rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        margin-top: 0.26rem;
        padding: 0.62rem 0.72rem;
        font-size: 0.8rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
        margin-top: 0.34rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 340px), (max-width: 420px) and (max-height: 620px) {
    .portal-wrapper {
        padding: 0.32rem 0.5rem;
    }

    .app-header {
        margin-bottom: 0.28rem;
    }

    .brand-logotype {
        font-size: 1.02rem;
        gap: 0.28rem;
    }

    .portal-content {
        align-items: flex-start;
    }

    .view-grid {
        gap: 0.18rem;
    }

    .branding-panel {
        padding-top: 0;
    }

    .brand-content {
        width: min(100%, 224px);
        margin: 0 auto;
    }

    .brand-eyebrow {
        font-size: 0.54rem;
        letter-spacing: 0.14em;
        margin-bottom: 0.08rem;
    }

    .main-title {
        max-width: 190px;
        margin: 0 auto 0.08rem;
        font-size: 1.08rem;
        line-height: 0.98;
    }

    .portal-card {
        max-width: 308px;
        max-height: calc(100svh - 6px);
        padding: 0.62rem 0.58rem 0.54rem;
        border-radius: 0.8rem;
    }

    .portal-card.portal-stage-subjects {
        padding: 0.58rem 0.54rem 0.48rem;
    }

    .card-progress {
        margin-bottom: 0.28rem;
    }

    .step-indicator {
        gap: 0.22rem;
    }

    .step {
        font-size: 0.46rem;
        letter-spacing: 0.08em;
    }

    .step-line {
        width: 10px;
    }

    .stage-header {
        margin-bottom: 0.46rem;
    }

    .stage-header h2 {
        font-size: 1rem;
        margin-bottom: 0.06rem;
    }

    .stage-header p {
        font-size: 0.58rem;
        line-height: 1.34;
    }

    .auth-tabs {
        margin-bottom: 0.56rem;
    }

    .auth-tab {
        padding: 0.54rem 0.28rem;
        font-size: 0.66rem;
    }

    .input-group input {
        min-height: 34px;
        padding: 0.52rem 0.8rem 0.22rem;
        font-size: 0.72rem;
    }

    .input-group.input-plain input {
        min-height: 34px;
        padding: 0.4rem 0.8rem;
        font-size: 0.72rem;
    }

    .form-utils {
        margin-top: -0.08rem;
        margin-bottom: 0.55rem;
    }

    .btn-link-sm {
        font-size: 0.6rem;
        letter-spacing: 0.06em;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.6rem 0.68rem;
        font-size: 0.78rem;
        letter-spacing: 0.08em;
    }

    .form-footer {
        margin-top: 0.38rem;
        font-size: 0.68rem;
    }

    .founding-login-link {
        width: max-content;
        min-height: 0;
        margin-top: 0.36rem;
        padding: 0.2rem 0.42rem;
        border-radius: 999px;
    }

    .founding-login-mark {
        width: 12px;
        height: 12px;
        font-size: 0.38rem;
        border-radius: 50%;
    }

    .founding-login-copy span {
        font-size: 0.44rem;
        letter-spacing: 0.12em;
    }

    .founding-login-copy strong {
        font-size: 0.66rem;
    }

    .founding-login-link em {
        font-size: 0.54rem;
    }

    .feedback-msg {
        margin-top: 0.45rem;
        font-size: 0.64rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .view-grid {
        gap: 0.08rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .portal-card {
        max-height: calc(100svh - 2px);
        padding: 0.52rem 0.54rem 0.48rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .card-progress {
        margin-bottom: 0.2rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header {
        margin-bottom: 0.28rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header h2 {
        font-size: 0.92rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .stage-header p {
        font-size: 0.54rem;
        line-height: 1.28;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .identity-selector {
        gap: 0.32rem;
        margin-bottom: 0.22rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) .id-btn-content {
        min-height: 34px;
        padding: 0.24rem 0.28rem;
        font-size: 0.62rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group {
        margin-bottom: 0.08rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .input-group.input-plain input {
        min-height: 32px;
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .btn-primary {
        margin-top: 0.18rem;
        padding: 0.56rem 0.64rem;
        font-size: 0.76rem;
    }

    .portal-wrapper:has(#userRegisterForm:not([hidden])) #userRegisterForm .form-footer {
        margin-top: 0.24rem;
        font-size: 0.66rem;
    }

    #subjectStage .stage-header {
        max-width: 210px;
        margin-bottom: 0.4rem;
    }

    .subject-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 100%;
        gap: 0.38rem;
        margin-top: 0;
    }

    .special-entrance-container {
        gap: 0.38rem;
    }

    .founding-picker-entry {
        min-height: 38px;
        margin-bottom: 0.34rem;
        padding: 0.3rem 0.42rem;
        gap: 0.42rem;
        border-radius: 0.62rem;
    }

    .founding-picker-mark {
        width: 22px;
        height: 22px;
        font-size: 0.52rem;
        border-radius: 0.44rem;
    }

    .founding-picker-copy span {
        font-size: 0.66rem;
    }

    .founding-picker-copy strong,
    .founding-picker-action {
        font-size: 0.48rem;
    }

    .subject-card,
    .subject-card-wide {
        min-height: 58px;
        padding: 0.5rem 0.38rem;
        gap: 0.2rem;
        border-radius: 0.78rem;
    }

    .card-icon {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
        border-radius: 0.48rem;
    }

    .card-title {
        font-size: 0.72rem;
        line-height: 1.02;
    }

    .card-meta {
        font-size: 0.52rem;
    }

    .card-note {
        font-size: 0.48rem;
    }

    .stage-actions {
        margin-top: 0.24rem;
    }

    .portal-modal {
        align-items: flex-start;
        overflow-y: auto;
        padding: 0.55rem;
    }

    .portal-modal-card {
        width: min(100%, 300px);
        margin: 0 auto 0.4rem;
        padding: 0.96rem 0.84rem;
        border-radius: 0.9rem;
    }

    .portal-modal-title {
        font-size: 1rem;
    }

    .portal-modal-subtitle {
        font-size: 0.68rem;
        line-height: 1.45;
    }

    .portal-modal-close {
        width: 2rem;
        height: 2rem;
    }

    .portal-modal-form .input-group {
        margin-bottom: 0.68rem;
    }

    .portal-modal-actions {
        gap: 0.5rem;
        margin-top: 0.72rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-video {
        display: none;
    }

    .ambient-glow,
    .cursor-glow {
        animation: none;
        transition: none;
    }
}

/* Final subject-stage compact layout override */
.portal-card.portal-stage-subjects {
    max-width: min(720px, calc(100vw - 3.25rem));
    padding: 1.02rem 0.98rem 0.88rem;
}

.portal-card.portal-stage-subjects #subjectStage .stage-header {
    max-width: 100%;
    margin-bottom: 0.92rem;
}

.portal-card.portal-stage-subjects #availableSubjectGrid {
    width: 100%;
    max-width: 100%;
}

.portal-card.portal-stage-subjects .subject-grid,
.portal-card.portal-stage-subjects .special-entrance-container {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.62rem;
    margin-top: 0;
    justify-items: center;
    align-items: stretch;
}

.portal-card.portal-stage-subjects .subject-divider {
    gap: 0.9rem;
    margin: 0.74rem 0;
}

.portal-card.portal-stage-subjects .subject-divider span {
    font-size: 0.58rem;
    letter-spacing: 0.18em;
}

.portal-card.portal-stage-subjects .subject-card,
.portal-card.portal-stage-subjects .subject-card-wide {
    height: 100%;
    min-height: 92px;
    padding: 1.4rem 0.6rem 0.6rem;
    gap: 0.36rem;
    border-radius: 0.9rem;
}

.portal-card.portal-stage-subjects .subject-card-single-line .card-title,
.portal-card.portal-stage-subjects .subject-card-single-line .card-meta {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.portal-card.portal-stage-subjects .card-membership {
    top: 0.5rem;
    right: 0.5rem;
    padding: 3px 7px;
    font-size: 0.56rem;
}

.portal-card.portal-stage-subjects .card-icon {
    width: 32px;
    height: 32px;
    font-size: 0.96rem;
    border-radius: 0.64rem;
}

.portal-card.portal-stage-subjects .card-title {
    font-size: 0.84rem;
    line-height: 1.2;
}

.portal-card.portal-stage-subjects .subject-card-shortcut .card-title {
    font-size: 0.8rem;
}

.portal-card.portal-stage-subjects .card-meta {
    font-size: 0.61rem;
    line-height: 1.2;
}

.portal-card.portal-stage-subjects .card-note {
    font-size: 0.54rem;
    line-height: 1.35;
}

.portal-card.portal-stage-subjects .stage-actions {
    margin-top: 0.62rem;
}

.portal-card.portal-stage-subjects .founding-picker-entry {
    min-height: 34px;
    margin-bottom: 0.42rem;
    padding: 0.3rem 0.52rem;
}

@media (max-width: 900px) {
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .brand-eyebrow,
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-desc,
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .system-stats {
        display: none !important;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        gap: 1rem;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        margin-bottom: 0.5rem;
        text-align: center;
        font-size: clamp(2rem, 8vw, 2.8rem);
    }

    .portal-card.portal-stage-subjects {
        max-width: min(620px, calc(100vw - 1.6rem));
        padding: 1rem 0.94rem 0.86rem;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.62rem;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 88px;
        padding: 0.8rem 0.66rem 0.74rem;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.88rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-entry {
        width: min(100%, 250px);
        min-height: 32px;
    }
}

@media (max-width: 560px) {
    .portal-card.portal-stage-subjects {
        max-width: min(100%, calc(100vw - 1rem));
        padding: 0.92rem 0.78rem 0.78rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        margin-bottom: 0.72rem;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.52rem;
    }

    /* Auto-span the 3rd lonely item on mobile to perfectly balance the layout */
    .portal-card.portal-stage-subjects .subject-card:last-child:nth-child(odd),
    .portal-card.portal-stage-subjects .subject-card-wide:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .portal-card.portal-stage-subjects .subject-divider {
        margin: 0.68rem 0;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 82px;
        padding: 0.76rem 0.66rem 0.7rem;
        gap: 0.38rem;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.86rem;
    }

    .portal-card.portal-stage-subjects .card-meta {
        font-size: 0.64rem;
    }

    .portal-card.portal-stage-subjects .card-note {
        font-size: 0.56rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-entry {
        width: min(100%, 240px);
        min-height: 30px;
        margin-bottom: 0.36rem;
        padding: 0.25rem 0.42rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-mark {
        width: 14px;
        height: 14px;
        font-size: 0.4rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-copy span {
        font-size: 0.62rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-copy strong,
    .portal-card.portal-stage-subjects .founding-picker-action {
        font-size: 0.48rem;
    }
}

@media (min-width: 901px) {
    .portal-wrapper {
        width: 100%;
        max-width: none;
        margin: 0;
        padding-left: clamp(1.25rem, 3vw, 3.25rem);
        padding-right: clamp(1.25rem, 3vw, 3.25rem);
    }

    .view-grid {
        grid-template-columns: minmax(0, 1fr) minmax(460px, 700px);
        gap: clamp(2rem, 4vw, 5rem);
    }

    .action-panel {
        display: flex;
        justify-content: flex-end;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        grid-template-columns: minmax(300px, 0.92fr) minmax(520px, 0.9fr);
        gap: clamp(1.1rem, 2.4vw, 2.5rem);
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .branding-panel {
        display: flex;
        align-items: center;
        min-width: 0;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .brand-content {
        max-width: min(700px, 100%);
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        font-size: clamp(3rem, 5.2vw, 5.5rem);
        max-width: none;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-desc {
        max-width: 34rem;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .system-stats {
        gap: clamp(1.5rem, 2vw, 2.75rem);
        flex-wrap: wrap;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .action-panel {
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
    }

    .portal-card.portal-stage-subjects {
        width: min(100%, 740px);
        max-width: min(740px, calc(100vw - 5.5rem));
        margin: 0;
        padding: 1rem 0.98rem 0.88rem;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        width: min(100%, 142px);
        min-height: 0;
        aspect-ratio: 0.84 / 1;
        padding: 0.9rem 0.62rem 0.8rem;
        gap: 0.42rem;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.86rem;
        line-height: 1.18;
    }

    .portal-card.portal-stage-subjects .subject-card-shortcut .card-title {
        font-size: 0.82rem;
    }

    .portal-card.portal-stage-subjects .card-meta {
        font-size: 0.6rem;
    }

    .portal-card.portal-stage-subjects .card-note {
        font-size: 0.52rem;
        line-height: 1.28;
    }
}

@media (min-width: 901px) and (max-width: 1280px) {
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        grid-template-columns: minmax(250px, 0.9fr) minmax(500px, 0.92fr);
        gap: clamp(0.95rem, 2vw, 1.8rem);
    }

    .portal-card.portal-stage-subjects {
        width: min(100%, 680px);
        max-width: min(680px, calc(100vw - 3.25rem));
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        width: min(100%, 132px);
        aspect-ratio: 0.82 / 1;
        padding: 0.82rem 0.56rem 0.74rem;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 32px;
        height: 32px;
        font-size: 0.94rem;
    }
}

/* Final desktop subject-stage: portrait outer card, modest inner cards */
@media (min-width: 901px) {
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        grid-template-columns: minmax(280px, 0.95fr) minmax(500px, 560px);
        gap: clamp(1.2rem, 2.6vw, 2.8rem);
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .action-panel {
        justify-content: flex-end;
        align-items: center;
    }

    .portal-card.portal-stage-subjects {
        width: min(100%, 560px);
        max-width: min(560px, calc(100vw - 4rem));
        max-height: calc(100svh - 92px);
        padding: 1.18rem 1rem 0.98rem;
        border-radius: 1.35rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        margin-bottom: 1rem;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        justify-items: stretch;
        align-items: stretch;
        gap: 0.68rem;
    }

    .portal-card.portal-stage-subjects .subject-divider {
        margin: 0.82rem 0 0.78rem;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        width: 100%;
        min-height: 92px;
        aspect-ratio: auto;
        padding: 0.65rem 0.5rem 0.6rem;
        gap: 0.3rem;
        border-radius: 0.8rem;
    }

    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 92px;
    }

    .portal-card.portal-stage-subjects .card-membership {
        top: 0.2rem;
        right: 0.2rem;
        padding: 2px 5px;
        font-size: 0.56rem;
        transform: scale(0.85);
        transform-origin: top right;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 32px;
        height: 32px;
        font-size: 0.96rem;
        border-radius: 0.64rem;
        margin-top: 1rem; /* Fortified push-down to evade badge overlap */
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.8rem;
        line-height: 1.16;
    }

    .portal-card.portal-stage-subjects .subject-card-shortcut .card-title {
        font-size: 0.76rem;
    }

    .portal-card.portal-stage-subjects .card-meta {
        font-size: 0.57rem;
        line-height: 1.16;
    }

    .portal-card.portal-stage-subjects .card-note {
        font-size: 0.49rem;
        line-height: 1.24;
    }

    .portal-card.portal-stage-subjects .stage-actions {
        margin-top: 0.78rem;
    }
}

@media (min-width: 901px) and (max-width: 1280px) {
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        grid-template-columns: minmax(220px, 0.86fr) minmax(470px, 520px);
        gap: clamp(0.95rem, 2vw, 1.8rem);
    }

    .portal-card.portal-stage-subjects {
        width: min(100%, 520px);
        max-width: min(520px, calc(100vw - 3rem));
        max-height: calc(100svh - 88px);
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 86px;
        padding: 0.6rem 0.45rem 0.55rem;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 28px;
        height: 28px;
        font-size: 0.86rem;
    }
}

@media (min-width: 768px) and (max-width: 900px) {
    .portal-wrapper {
        padding: 1.25rem clamp(1.1rem, 3vw, 1.5rem) 1rem !important;
    }

    .app-header {
        margin-bottom: 1.35rem !important;
    }

    .portal-content {
        align-items: flex-start;
    }

    .view-grid {
        gap: 0.95rem !important;
    }

    .branding-panel,
    .action-panel,
    .brand-content {
        width: 100%;
        max-width: 680px;
        margin: 0 auto;
    }

    .main-title {
        font-size: clamp(3rem, 6.8vw, 4.1rem) !important;
        margin-bottom: 0.45rem !important;
    }

    .main-desc {
        display: block !important;
        max-width: 620px !important;
        margin: 0 auto 1.15rem !important;
        font-size: 0.95rem !important;
    }

    .system-stats {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, max-content)) !important;
        justify-content: center !important;
        gap: 0.85rem 1.35rem !important;
    }

    .portal-card {
        width: 100%;
        max-width: min(680px, calc(100vw - 2.5rem)) !important;
        padding: 1.9rem 1.8rem !important;
        max-height: none;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        font-size: clamp(2.6rem, 6vw, 3.5rem) !important;
        margin-bottom: 0.45rem !important;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-desc,
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .system-stats {
        display: none !important;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .view-grid {
        gap: 0.9rem !important;
    }

    .portal-card.portal-stage-subjects {
        width: 100%;
        max-width: min(680px, calc(100vw - 2.5rem)) !important;
        padding: 1.06rem 1rem 0.92rem !important;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        margin-bottom: 0.84rem;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 0.66rem !important;
        justify-items: stretch;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 92px;
        padding: 0.86rem 0.58rem 0.72rem;
    }

    .portal-card.portal-stage-subjects .founding-picker-entry {
        width: min(100%, 280px);
    }
}

@media (max-width: 767px) {
    .portal-wrapper {
        padding: max(0.7rem, env(safe-area-inset-top)) 0.78rem max(0.9rem, env(safe-area-inset-bottom)) !important;
    }

    .app-header {
        margin-bottom: 0.8rem !important;
    }

    .view-grid {
        gap: 0.78rem !important;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .branding-panel,
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .action-panel,
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .brand-content {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        font-size: clamp(2.05rem, 9vw, 2.85rem) !important;
        line-height: 1.02 !important;
        margin-bottom: 0.2rem !important;
    }

    .portal-card.portal-stage-subjects {
        max-width: min(100%, calc(100vw - 0.78rem)) !important;
        padding: 0.78rem 0.68rem 0.64rem !important;
        border-radius: 1rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        margin-bottom: 0.56rem !important;
        padding-top: 0.28rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header h2 {
        font-size: 1.46rem;
        line-height: 1.08;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header p {
        font-size: 0.76rem;
        line-height: 1.4;
    }

    .portal-card.portal-stage-subjects .founding-picker-entry {
        width: min(100%, 220px) !important;
        min-height: 28px !important;
        margin-bottom: 0.28rem !important;
        padding: 0.2rem 0.38rem !important;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        gap: 0.44rem !important;
    }

    .portal-card.portal-stage-subjects .subject-divider {
        gap: 0.66rem;
        margin: 0.56rem 0 !important;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 74px !important;
        padding: 0.64rem 0.56rem 0.56rem !important;
        gap: 0.26rem !important;
        border-radius: 0.76rem;
    }

    .portal-card.portal-stage-subjects .card-membership {
        top: 0.18rem;
        right: 0.18rem;
        padding: 2px 5px;
        font-size: 0.52rem;
        transform: scale(0.82);
        transform-origin: top right;
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.86rem !important;
        margin-top: 0.52rem;
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.8rem !important;
        line-height: 1.12 !important;
    }

    .portal-card.portal-stage-subjects .card-meta {
        font-size: 0.58rem !important;
        line-height: 1.12 !important;
    }

    .portal-card.portal-stage-subjects .card-note {
        font-size: 0.5rem !important;
        line-height: 1.18 !important;
    }

    .portal-card.portal-stage-subjects .stage-actions {
        margin-top: 0.5rem !important;
        margin-bottom: 0.08rem !important;
    }
}

@media (max-width: 430px) {
    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        font-size: clamp(1.92rem, 8.5vw, 2.45rem) !important;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header h2 {
        font-size: 1.34rem;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 70px !important;
        padding: 0.58rem 0.5rem 0.5rem !important;
    }
}

@media (max-width: 430px) and (orientation: portrait) {
    .portal-wrapper {
        padding: max(0.56rem, env(safe-area-inset-top)) 0.62rem max(0.8rem, env(safe-area-inset-bottom)) !important;
    }

    .app-header {
        margin-bottom: 0.62rem !important;
    }

    .view-grid {
        gap: 0.64rem !important;
    }

    .portal-wrapper:has(.portal-card.portal-stage-subjects) .main-title {
        font-size: clamp(1.76rem, 8vw, 2.2rem) !important;
        line-height: 1 !important;
        margin-bottom: 0.12rem !important;
    }

    .portal-card.portal-stage-subjects {
        max-width: min(100%, calc(100vw - 0.56rem)) !important;
        padding: 0.68rem 0.58rem 0.56rem !important;
        border-radius: 0.92rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header {
        max-width: 270px;
        margin-bottom: 0.48rem !important;
        padding-top: 0.18rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header h2 {
        font-size: 1.22rem;
        line-height: 1.06;
        margin-bottom: 0.22rem;
    }

    .portal-card.portal-stage-subjects #subjectStage .stage-header p {
        font-size: 0.7rem;
        line-height: 1.32;
    }

    .portal-card.portal-stage-subjects .founding-picker-entry {
        width: min(100%, 208px) !important;
        min-height: 26px !important;
        margin-bottom: 0.22rem !important;
        padding: 0.16rem 0.34rem !important;
    }

    .portal-card.portal-stage-subjects .subject-grid,
    .portal-card.portal-stage-subjects .special-entrance-container {
        gap: 0.38rem !important;
    }

    .portal-card.portal-stage-subjects .subject-divider {
        gap: 0.54rem;
        margin: 0.46rem 0 !important;
    }

    .portal-card.portal-stage-subjects .subject-card,
    .portal-card.portal-stage-subjects .subject-card-wide {
        min-height: 66px !important;
        padding: 0.54rem 0.46rem 0.46rem !important;
        gap: 0.2rem !important;
        border-radius: 0.68rem;
    }

    .portal-card.portal-stage-subjects .card-membership {
        top: 0.14rem;
        right: 0.14rem;
        padding: 2px 4px;
        font-size: 0.48rem;
        transform: scale(0.78);
    }

    .portal-card.portal-stage-subjects .card-icon {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.8rem !important;
        margin-top: 0.44rem;
    }

    .portal-card.portal-stage-subjects .card-title {
        font-size: 0.74rem !important;
        line-height: 1.08 !important;
    }

    .portal-card.portal-stage-subjects .card-meta {
        font-size: 0.53rem !important;
        line-height: 1.08 !important;
    }

    .portal-card.portal-stage-subjects .card-note {
        font-size: 0.46rem !important;
        line-height: 1.12 !important;
    }

    .portal-card.portal-stage-subjects .stage-actions {
        margin-top: 0.42rem !important;
        margin-bottom: 0 !important;
    }
}
