:root, .theme-xs-light-mode {
    --bg-page: #f9fafb;
    --bg-glow: #ffffff;
    --glass-white: rgba(255, 255, 255, 0.7);
    --border-delicate: 1px solid rgba(0, 0, 0, 0.06);
    --text-main: #1a1a1a;
    --text-sub: #666666;
    --radius-pill: 40px;
    --radius-box: 16px;
    
    --theme-accent: var(--text-main);
    --theme-accent-hover: var(--text-main);
    --theme-asterisk: #ef4444;
    --btn-text: #ffffff;
    
    --input-bg: rgba(0, 0, 0, 0.02);
    --input-bg-focus: rgba(0, 0, 0, 0.04);
    --ui-border: rgba(0, 0, 0, 0.15);
    --divider-bg: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.08) 15%, rgba(0, 0, 0, 0.08) 85%, transparent);
    
    --success-bg: rgba(34, 197, 94, 0.1); --success-text: #166534; --success-border: rgba(34, 197, 94, 0.2);
    --error-bg: rgba(239, 68, 68, 0.1); --error-text: #991b1b; --error-border: rgba(239, 68, 68, 0.2);
}

body {
    font-family: 'Urbanist', sans-serif;
    font-size: 20px;
    line-height: 30px;
    background: var(--bg-page);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px;
    box-sizing: border-box;
    font-weight: 500;
    overflow-x: hidden;
}

::selection {
    background-color: var(--theme-accent);
    color: var(--btn-text);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ui-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-sub); }

body::after { 
    content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: radial-gradient(circle, var(--bg-glow) 0%, var(--bg-page) 100%); 
    pointer-events: none; z-index: -1; 
}

/* ------------------------------------------------ */
/* VIEW STATES (Root & 404)                         */
/* ------------------------------------------------ */
body.error-404-view .header {
    text-align: center;
}
body.error-404-view .header h1,
body.error-404-view .header p {
    text-wrap: balance;
    margin-inline: auto;
}

/* The Master Form Wrapper (Matches forms.son.ski) */
.form-container {
    width: 100%;
    max-width: 576px;
    min-width: 320px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.header { margin-bottom: 48px; padding: 0 15px; }
.header h1 {
    margin: 0 0 16px 0;
    font-size: 45px;
    line-height: 1.2;
    letter-spacing: -0.5px;
    color: var(--text-main);
    font-weight: 500;
}
.header p { margin: 0; font-size: 20px; line-height: 30px; color: var(--text-sub); text-wrap: pretty; }

/* Layout Constraints */
.content-container {
    width: 100%;
    max-width: 720px; /* The "Golden Ratio" width for 20px fonts (approx 70 characters per line) */
    min-width: 320px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* ------------------------------------------------ */
/* MARKDOWN EDITORIAL TYPOGRAPHY                    */
/* ------------------------------------------------ */
.md-content {
    text-wrap: pretty;
}

.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-top: 48px;
    margin-bottom: 16px;
    line-height: 1.2;
    text-wrap: balance;
}

.md-content h1 { font-size: 45px; margin-top: 0; }
.md-content h2 { font-size: 32px; }
.md-content h3 { font-size: 26px; }

.md-content p {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 20px;
    line-height: 34px; /* Slightly looser line-height for long-form reading */
    color: var(--text-sub);
}

.md-content strong {
    color: var(--text-main);
    font-weight: 700;
}

.md-content a {
    color: var(--theme-accent);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    transition: all 0.2s ease;
}

.md-content a:hover {
    color: var(--theme-accent-hover);
    background-color: var(--theme-accent);
    color: var(--btn-text);
    text-decoration: none;
}

.md-content blockquote {
    border-left: 4px solid var(--theme-accent);
    margin: 32px 0;
    padding: 8px 0 8px 24px;
    font-style: italic;
    background: transparent;
    color: var(--text-sub);
}

.md-content blockquote p {
    margin: 0;
}

.md-content ul, .md-content ol {
    margin-top: 0;
    margin-bottom: 24px;
    padding-left: 24px;
    color: var(--text-sub);
}

.md-content li {
    margin-bottom: 8px;
    line-height: 34px;
}

.md-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-box);
    border: 1px solid var(--ui-border);
    margin: 32px 0;
    display: block;
    box-shadow: none;
}

.md-content hr {
    border: none;
    height: 1px;
    background: var(--divider-bg);
    margin: 64px 0; /* Slightly increased margin to give the wider line more breathing room */
    width: 80vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.md-content pre {
    background: var(--input-bg);
    border: var(--border-delicate);
    border-radius: var(--radius-box);
    padding: 20px;
    overflow-x: auto;
    margin: 32px 0;
}

.md-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 16px;
    background: var(--input-bg);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text-main);
}

.md-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-sub);
}

/* ------------------------------------------------ */
/* CMS WRITE FORM UI (Reused from Forms)            */
/* ------------------------------------------------ */
.input-group {
    background: var(--glass-white);
    padding: 40px 45px;
    border-radius: var(--radius-pill);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: var(--border-delicate);
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 14px;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"], 
input[type="password"], 
textarea, 
select {
    width: 100%;
    padding: 16px 20px;
    background: var(--input-bg);
    border: var(--border-delicate);
    border-radius: var(--radius-box);
    font-family: 'Urbanist', sans-serif;
    font-size: 20px;
    font-weight: 500;
    color: var(--text-main);
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    background: var(--input-bg-focus);
    border-color: var(--ui-border);
}

.input-error-pulse {
    border-color: var(--theme-asterisk) !important;
    box-shadow: 0 0 0 1px var(--theme-asterisk) !important;
}

button, .btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 12px 28px;
    background-color: var(--theme-accent);
    color: var(--btn-text);
    border: none;
    border-radius: var(--radius-pill);
    font-family: 'Urbanist', sans-serif;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    box-sizing: border-box;
    letter-spacing: 1px;
}

button:hover, .btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    background-color: var(--theme-accent-hover);
}

.submit-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

/* ------------------------------------------------ */
/* FOOTER & DIVIDER                                 */
/* ------------------------------------------------ */
.form-divider {
    width: 80%;
    height: 1px;
    background: var(--divider-bg);
    border: none;
    margin: 100px 0 80px 0;
}

.footer {
    display: flex; 
    gap: 15px; 
    align-items: center; 
    justify-content: center;
    background-color: var(--glass-white);
    padding: 10px 24px;
    border-radius: var(--radius-pill);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: var(--border-delicate);
    width: fit-content;
    position: relative;
    z-index: 1;
    margin-bottom: 40px;
}

.footer-link {
    font-size: 20px;
    color: var(--text-sub);
    text-decoration: none;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.footer-link:hover { color: var(--text-main); transform: translateY(-1px); }
.separator { color: var(--ui-border); font-size: 20px; user-select: none; }

/* ------------------------------------------------ */
/* MARKDOWN TABLES (Glass Box Aesthetic)            */
/* ------------------------------------------------ */
.md-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 32px 0;
    background: var(--glass-white);
    border-radius: var(--radius-box);
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
    box-shadow: none;
}

.md-content th, .md-content td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--ui-border);
    border-right: 1px solid var(--ui-border);
    line-height: 26px;
}

.md-content th {
    font-weight: 700;
    color: var(--text-main);
    background: var(--input-bg);
}

.md-content th:last-child, .md-content td:last-child { border-right: none; }
.md-content tr:last-child td { border-bottom: none; }

/* ------------------------------------------------ */
/* SYSTEM ALERTS                                    */
/* ------------------------------------------------ */
#error-message {
    margin-top: 20px;
    padding: 14px;
    border-radius: var(--radius-box);
    font-size: 20px;
    text-align: center;
    font-weight: 600;
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

@media (max-width: 768px) {
    .form-container { width: 100%; }
    .form-divider { width: 80%; }
}

/* ================================================ */
/* THEMES                                           */
/* ================================================ */
.theme-xs-purple {
    --theme-accent: #a519e6;
    --theme-accent-hover: #a519e6;
    --theme-asterisk: #a519e6;
}

.theme-xs-green {
    --theme-accent: #067a42;
    --theme-accent-hover: #067a42;
    --theme-asterisk: #067a42;
}

.theme-xs-dark-mode {
    --bg-page: #050505;
    --bg-glow: #1a1a1a;
    --glass-white: rgba(255, 255, 255, 0.06);
    --border-delicate: 1px solid rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-sub: #888888;
    
    --theme-accent: #ffffff;
    --theme-accent-hover: #ffffff;
    --btn-text: #000000;
    
    --input-bg: rgba(255, 255, 255, 0.04);
    --input-bg-focus: rgba(255, 255, 255, 0.08);
    --ui-border: rgba(255, 255, 255, 0.2);
    --divider-bg: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08) 15%, rgba(255, 255, 255, 0.08) 85%, transparent);
}
