/*
 * 全站公共壳（Phase 1）
 * 只覆盖导航、页脚、页面容器和全局背景；具体页面仍由各自模板/样式控制。
 * 依赖主题已经加载完成，本文件通过 layout/html5.html 在全站最后加载。
 *
 * 注意：ui-default 会在前端再注入一次 theme-*.css（带 ?hash），位置在本文件之后。
 * 因此这里统一用 body 前缀提高优先级，避免被后加载的同名主题规则覆盖。
 */

:root {
    --site-max-width: 1440px;
    --site-nav-height: 64px;
    --site-page-bg: #f5f7fb;
    --site-surface: #ffffff;
    --site-text: #0f172a;
    --site-text-muted: #64748b;
    --site-border: rgba(15, 23, 42, 0.08);
    --site-primary: #2563eb;
    --site-primary-hover: #1d4ed8;
    --site-primary-soft: rgba(37, 99, 235, 0.09);
    --site-radius: 12px;
}

html {
    scroll-padding-top: var(--site-nav-height);
}

body {
    background: var(--site-page-bg);
}

html.theme--dark body {
    background: #0b1120;
}

/* 页面容器：全站统一最大宽度，同时保留 Hydro 原有的栅格行为。 */
body .row {
    max-width: var(--site-max-width);
}

/* 内容不足时把页脚压到视口底部。 */
.slideout-panel {
    min-height: 100vh;
}

body .main {
    flex: 1 0 auto;
}

@media (min-width: 601px) {
    /* ── 顶部导航 ───────────────────────────────────────────────────── */
    html.layout--basic body .main,
    html.layout--immersive body .main {
        padding-top: calc(var(--site-nav-height) + 1.5rem);
    }

    /* 首页 Hero 是全宽深色区块，需要和导航无缝贴合 */
    html.layout--basic.page--homepage body .main {
        padding-top: var(--site-nav-height);
    }

    body .nav--placeholder {
        height: var(--site-nav-height);
    }

    body .nav {
        height: var(--site-nav-height);
        background: rgba(255, 255, 255, 0.9);
        border-bottom: 1px solid var(--site-border);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        backdrop-filter: saturate(180%) blur(12px);
    }

    body .nav .row {
        max-width: var(--site-max-width);
        padding: 0 1.25rem;
    }

    body .nav .nav__item {
        margin: 0.75rem 0.1rem 0;
        padding: 0 0.85rem;
        border-top: 0;
        border-radius: 8px;
        color: #334155;
        font-weight: 500;
        line-height: 2.5rem;
    }

    body .nav .nav__item:before {
        display: none;
    }

    body .nav .nav__item:visited,
    body .nav .nav__item:active {
        color: #334155;
    }

    body .nav .nav__item.nav--active {
        border-color: transparent;
        background: var(--site-primary-soft);
        color: var(--site-primary);
    }

    body .nav .nav__item:hover {
        border-color: transparent;
        background: rgba(15, 23, 42, 0.05);
        color: var(--site-primary);
        text-decoration: none;
    }

    body .nav .nav__item--round {
        margin: 0.75rem 0 0 0.5rem;
        padding: 0 1rem;
        border: 1px solid var(--site-primary);
        border-radius: 999px;
        background: var(--site-primary);
        color: #ffffff;
        line-height: 2.375rem;
    }

    body .nav .nav__item--round:visited,
    body .nav .nav__item--round:active {
        color: #ffffff;
    }

    body .nav .nav__item--round:hover {
        border-color: var(--site-primary-hover);
        background: var(--site-primary-hover);
        color: #ffffff;
    }

    body .nav .nav__logo {
        height: 30px;
        margin: calc((var(--site-nav-height) - 30px) / 2) 0.75rem 0 0;
    }

    html.theme--dark body .nav {
        background: rgba(15, 23, 42, 0.9);
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    html.theme--dark body .nav .nav__item {
        color: #cbd5e1;
    }

    html.theme--dark body .nav .nav__item:visited,
    html.theme--dark body .nav .nav__item:active {
        color: #cbd5e1;
    }

    html.theme--dark body .nav .nav__item.nav--active {
        background: rgba(96, 165, 250, 0.16);
        color: #bfdbfe;
    }

    html.theme--dark body .nav .nav__item:hover {
        background: rgba(255, 255, 255, 0.07);
        color: #ffffff;
    }

    body .nav--shadow {
        height: var(--site-nav-height);
        background: transparent;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
    }
}

/* ── 通用卡片 / 表单圆角 ───────────────────────────────────────────── */

body .section,
body .section__header {
    border-radius: var(--site-radius);
}

body .section__header:first-child {
    border-radius: var(--site-radius) var(--site-radius) 0 0;
}

body .button,
body .textbox,
body textarea,
body select {
    border-radius: 8px;
}

/* ── 页脚 ───────────────────────────────────────────────────────────── */

body .footer {
    margin-top: 2.5rem;
    border-top: 1px solid var(--site-border);
    background: var(--site-surface);
}

body .footer .row {
    max-width: var(--site-max-width);
}

body .footer__category {
    padding-top: 2.5rem;
    padding-bottom: 1.75rem;
}

body .footer__category h1 {
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body .footer__category__list {
    font-size: 0.85rem;
}

body .footer__category__list a {
    color: #475569;
}

body .footer__category__list a:hover {
    color: var(--site-primary);
}

body .footer__extra-link {
    margin-top: 1rem;
    padding: 1.1rem 0 1.5rem;
    border-top: 1px solid var(--site-border);
    color: #94a3b8;
    font-size: 0.78rem;
}

body .footer__extra-link a {
    color: #64748b;
}

html.theme--dark body .footer {
    border-top-color: rgba(255, 255, 255, 0.08);
    background: #0f172a;
}

html.theme--dark body .footer__category h1 {
    color: #64748b;
}

html.theme--dark body .footer__category__list a,
html.theme--dark body .footer__extra-link a {
    color: #cbd5e1;
}

html.theme--dark body .footer__extra-link {
    border-top-color: rgba(255, 255, 255, 0.08);
    color: #64748b;
}

/* ── 首页 ───────────────────────────────────────────────────────────── */

body .home-hero {
    margin-bottom: 1.5rem;
    padding: 3.75rem 1.5rem;
    background:
        radial-gradient(circle at 18% 20%, rgba(96, 165, 250, 0.35), transparent 32rem),
        radial-gradient(circle at 82% 80%, rgba(129, 140, 248, 0.28), transparent 28rem),
        linear-gradient(135deg, #0f172a 0%, #172554 55%, #0f172a 100%);
    color: #ffffff;
}

body .home-hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: center;
    gap: 3rem;
    max-width: var(--site-max-width);
    margin: 0 auto;
}

body .home-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.35);
    color: #bfdbfe;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

body .home-hero h1 {
    margin: 0 0 1rem;
    color: #ffffff;
    font-size: clamp(2rem, 4vw, 3.15rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

body .home-hero__lead {
    max-width: 36rem;
    margin: 0 0 1.75rem;
    color: #cbd5e1;
    font-size: 1.02rem;
    line-height: 1.8;
}

body .home-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

body .home-hero .ui-btn {
    border-color: rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

body .home-hero .ui-btn:hover {
    border-color: rgba(191, 219, 254, 0.7);
    background: rgba(96, 165, 250, 0.16);
    color: #ffffff;
}

body .home-hero .ui-btn--primary {
    border-color: #3b82f6;
    background: #3b82f6;
    color: #ffffff;
}

body .home-hero .ui-btn--primary:hover {
    border-color: #60a5fa;
    background: #60a5fa;
    color: #ffffff;
}

body .home-code {
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 16px;
    background: rgba(2, 6, 23, 0.72);
    box-shadow: 0 28px 70px rgba(2, 6, 23, 0.5);
    backdrop-filter: blur(8px);
}

body .home-code__bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 0.95rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    color: #94a3b8;
    font-size: 0.72rem;
}

body .home-code__bar i {
    width: 0.58rem;
    height: 0.58rem;
    border-radius: 50%;
    background: #f87171;
}

body .home-code__bar i:nth-child(2) {
    background: #fbbf24;
}

body .home-code__bar i:nth-child(3) {
    background: #34d399;
}

body .home-code__bar span {
    margin-left: 0.5rem;
}

body .home-code__pre {
    padding: 1.15rem 1.35rem 1.3rem;
    overflow-x: auto;
    color: #cbd5e1;
    font-family: var(--code-font-family, Consolas, monospace);
    font-size: 0.84rem;
    line-height: 1.9;
    white-space: pre;
}

body .home-code__kw {
    color: #93c5fd;
}

body .home-code__str {
    color: #86efac;
}

html.theme--dark body .home-hero {
    background:
        radial-gradient(circle at 18% 20%, rgba(37, 99, 235, 0.38), transparent 32rem),
        radial-gradient(circle at 82% 80%, rgba(79, 70, 229, 0.3), transparent 28rem),
        linear-gradient(135deg, #020617 0%, #0f172a 55%, #020617 100%);
}

/* ── 登录 / 注册 ────────────────────────────────────────────────────── */

html.page--user_login #panel,
html.page--user_register #panel {
    background:
        radial-gradient(circle at 20% 15%, rgba(96, 165, 250, 0.35), transparent 30rem),
        radial-gradient(circle at 80% 85%, rgba(129, 140, 248, 0.28), transparent 28rem),
        linear-gradient(135deg, #0f172a 0%, #172554 55%, #0f172a 100%);
}

html.theme--dark.page--user_login #panel,
html.theme--dark.page--user_register #panel {
    background:
        radial-gradient(circle at 20% 15%, rgba(37, 99, 235, 0.28), transparent 30rem),
        radial-gradient(circle at 80% 85%, rgba(79, 70, 229, 0.24), transparent 28rem),
        linear-gradient(135deg, #020617 0%, #0f172a 55%, #020617 100%);
}

body .auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--site-nav-height) - 11rem);
    padding: 4.5rem 1.25rem;
}

body .auth-card {
    width: min(27rem, 100%);
    padding: 2.25rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 30px 90px rgba(2, 6, 23, 0.35);
    color: var(--ui-text, #111827);
}

body .auth-card__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.6rem;
    color: var(--site-text-muted);
    font-size: 0.8rem;
}

body .auth-card__brand img {
    height: 26px;
    width: auto;
}

body .auth-card__title {
    margin: 0 0 0.4rem;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

body .auth-card__desc {
    margin: 0 0 1.6rem;
    color: var(--site-text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

body .auth-form .ui-field {
    margin-bottom: 1rem;
}

body .auth-form .ui-btn {
    margin-bottom: 0.7rem;
}

body .auth-links {
    margin-top: 0.9rem;
    text-align: center;
    font-size: 0.82rem;
}

body .auth-links a {
    color: var(--site-text-muted);
}

body .auth-links a:hover {
    color: var(--site-primary);
}

body .auth-form label.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.2rem 0 1rem;
}

body .auth-captcha {
    margin: 0.6rem 0 1.1rem;
}

html.theme--dark body .auth-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: #111827;
    color: #e5e7eb;
}

/* ── 错误页 ─────────────────────────────────────────────────────────── */

body .error-page {
    padding: 3.5rem 0;
}

body .error-card {
    padding: 2.5rem;
    border: 1px solid var(--site-border);
    border-radius: 18px;
    background: var(--site-surface);
    box-shadow: 0 18px 60px rgba(15, 23, 42, 0.1);
}

body .error-card__badge {
    display: inline-flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

body .error-card h1 {
    margin: 0 0 0.6rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

body .error-card__message {
    margin: 0 0 1.4rem;
    color: var(--site-text-muted);
    font-size: 1rem;
    line-height: 1.8;
}

body .error-card__details {
    margin: 1.2rem 0 1.6rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--site-border);
    border-radius: 10px;
    background: var(--site-page-bg);
    color: var(--site-text-muted);
    font-size: 0.82rem;
}

body .error-card__details summary {
    cursor: pointer;
    color: var(--site-text);
    font-weight: 600;
}

body .error-card__details p {
    margin: 0.7rem 0 0.2rem;
}

body .error-card__details ol {
    margin: 0.2rem 0 0;
    padding-left: 1.2rem;
}

body .error-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

html.theme--dark body .error-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: #111827;
}

html.theme--dark body .error-card__details {
    border-color: rgba(255, 255, 255, 0.1);
    background: #0f172a;
}

@media (max-width: 900px) {
    body .home-hero__inner {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
    }

    body .home-hero__art {
        display: none;
    }
}

@media (max-width: 600px) {
    html.layout--basic body .main,
    html.layout--immersive body .main {
        padding-top: 1.25rem;
    }

    html.layout--basic.page--homepage body .main {
        padding-top: 0;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    body .row {
        max-width: none;
    }

    body .nav--shadow {
        display: none;
    }
}

@media (max-width: 1000px) {
    body .header--mobile,
    body .location {
        border-bottom: 1px solid var(--site-border);
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
        color: var(--site-text);
    }

    body .header--mobile a,
    body .header--mobile a:visited,
    body .header--mobile a:hover {
        color: var(--site-text);
    }

    body .header--mobile .hamburger-inner,
    body .header--mobile .hamburger-inner::before,
    body .header--mobile .hamburger-inner::after {
        background-color: #334155;
    }

    html.theme--dark body .header--mobile,
    html.theme--dark body .location {
        border-bottom-color: rgba(255, 255, 255, 0.08);
        background: rgba(15, 23, 42, 0.96);
        color: #e5e7eb;
    }

    html.theme--dark body .header--mobile a,
    html.theme--dark body .header--mobile a:visited,
    html.theme--dark body .header--mobile a:hover {
        color: #e5e7eb;
    }

    html.theme--dark body .header--mobile .hamburger-inner,
    html.theme--dark body .header--mobile .hamburger-inner::before,
    html.theme--dark body .header--mobile .hamburger-inner::after {
        background-color: #cbd5e1;
    }

    body .footer__category h1 {
        color: #94a3b8;
        font-size: 0.78rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    body .footer__extra-link {
        border-top: 1px solid var(--site-border);
    }
}

/* 比赛倒计时：主题默认固定在 48px，导航加高后会压住导航，统一移到导航下方。 */
body .contest-timer {
    top: calc(var(--site-nav-height) + 12px);
    left: 12px;
    z-index: 100;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--site-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--site-text);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
    font-size: 0.85rem;
}

html.theme--dark body .contest-timer {
    border-color: rgba(255, 255, 255, 0.1);
    background: #111827;
    color: #e5e7eb;
}

@media (max-width: 600px) {
    body .contest-timer {
        top: 64px;
    }
}

/* ── 用户中心：设置表单 ─────────────────────────────────────────────── */

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .section__header {
    padding: 1rem 1.3rem;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .section__header .section__title {
    font-size: 1.25rem;
    font-weight: 700;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .section__body {
    padding: 1.1rem 1.3rem;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.2rem;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row {
    flex: 0 0 calc(50% - 0.6rem);
    max-width: calc(50% - 0.6rem);
    margin: 0;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row > .columns {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row:has(textarea) {
    flex-basis: 100%;
    max-width: 100%;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item > label {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item .textbox {
    width: 100%;
    height: 2.35rem;
    border-radius: 8px;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item textarea.textbox {
    min-height: 6rem;
    height: auto;
    resize: vertical;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .help-text {
    margin: 0.25rem 0 0;
    color: #94a3b8;
    font-size: 0.75rem;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form input[type="submit"] {
    height: 2.35rem;
    border-radius: 8px;
}

html.theme--dark :is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item > label {
    color: #9ca3af;
}

html.theme--dark :is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .help-text {
    color: #64748b;
}

@media (max-width: 600px) {
    :is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row {
        flex-basis: 100%;
        max-width: 100%;
    }
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row:not(:has(> .columns)) {
    display: none;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) form > .section__body > .row:has(input[name^="booleanKeys."]) {
    display: none;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item label.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.4rem 0;
    color: #475569;
    font-size: 0.86rem;
    font-weight: 400;
}

:is(.page--home_account, .page--home_preference, .page--home_domain, .page--domain_edit, .page--manage_setting) .form__item label.checkbox input {
    margin: 0;
}

/* 核心模板里的 .primary.button 原来是浅蓝底白字，对比度不足；统一加深。 */
body .button:not(.codicon).primary,
body .primary.button:not(.codicon) {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
    font-weight: 600;
}

body .button:not(.codicon).primary:hover,
body .primary.button:not(.codicon):hover {
    border-color: #1e40af;
    background: #1e40af;
    color: #ffffff;
}

body .button:not(.codicon).primary:visited,
body .primary.button:not(.codicon):visited {
    color: #ffffff;
}

/* ── 用户中心：讨论编辑 / 文件 ─────────────────────────────────────── */

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .section__header {
    padding: 1rem 1.3rem;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .section__body {
    padding: 1.2rem 1.3rem;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .section__header .section__title {
    font-size: 1.35rem;
    font-weight: 700;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) label {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) input[name="title"] {
    height: 2.5rem;
    margin-top: 0.3rem;
    border-radius: 8px;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) label.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 2.35rem;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 400;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) label.checkbox input {
    margin: 0;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .md-editor {
    border-radius: 8px;
}

.page--home_files .section__header {
    padding: 1rem 1.3rem;
}

.page--home_files .section__header .section__title {
    font-size: 1.35rem;
    font-weight: 700;
}

.page--home_files .data-table th {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    background: #f8fafc;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page--home_files .data-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    font-size: 0.86rem;
}

html.theme--dark .page--home_files .data-table th {
    background: #1f2937;
    color: #9ca3af;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html.theme--dark .page--home_files .data-table td {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

/* ui-default 在当前版本里用隐藏 textarea 的 clientHeight 初始化 Monaco，可能只得到 19px 高。 */
:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .monaco-editor {
    height: 200px !important;
}

:is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .monaco-editor {
    overflow: hidden;
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 8px;
    background: #ffffff;
}

html.theme--dark :is(.page--discussion_create, .page--discussion_edit, .page--domain_edit) .monaco-editor {
    border-color: rgba(255, 255, 255, 0.12);
    background: #0f172a;
}

/* md-editor-rt 只暴露这三个颜色变量；暗色下统一编辑器和工具栏背景。 */
html.theme--dark .md-editor {
    --md-bk-color: #0f172a;
    --md-color: #e5e7eb;
    --md-border-color: rgba(255, 255, 255, 0.12);
}

/* 移动端 Markdown 编辑器只保留编辑区，工具栏横向滚动，避免左右两栏各挤一半。 */
@media (max-width: 48em) {
    .md-editor .md-editor-preview-wrapper,
    .md-editor .md-editor-resize-operate {
        display: none !important;
    }

    .md-editor .md-editor-content-wrapper {
        display: block !important;
    }

    .md-editor .md-editor-content-wrapper .md-editor-custom-scrollbar {
        width: 100% !important;
    }

    .md-editor .md-editor-input-wrapper {
        width: 100% !important;
    }

    .md-editor .md-editor-toolbar {
        overflow-x: auto;
    }

    .md-editor .md-editor-toolbar-left,
    .md-editor .md-editor-toolbar-right {
        flex: 0 0 auto;
    }
}

/* ── 用户中心：站内消息 ─────────────────────────────────────────────── */

.page--home_messages .section {
    overflow: hidden;
}

.page--home_messages .messagepad__sidebar {
    border-right: 1px solid rgba(17, 24, 39, 0.1);
    background: #f8fafc;
}

html.theme--dark .page--home_messages .messagepad__sidebar {
    border-right-color: rgba(255, 255, 255, 0.1);
    background: #111827;
}

.page--home_messages .messagepad__list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.25rem 0.5rem;
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}

.page--home_messages .messagepad__list-item:hover {
    background: rgba(37, 99, 235, 0.06);
}

.page--home_messages .messagepad__list-item.active {
    background: rgba(37, 99, 235, 0.1);
    box-shadow: inset 3px 0 0 #1d4ed8;
}

.page--home_messages .messagepad__username {
    margin: 0;
    color: #111827;
    font-size: 0.86rem;
    font-weight: 600;
}

html.theme--dark .page--home_messages .messagepad__username {
    color: #e5e7eb;
}

.page--home_messages .messagepad__desc {
    overflow: hidden;
    color: #6b7280;
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page--home_messages .messagepad__header {
    border-bottom: 1px solid rgba(17, 24, 39, 0.1);
    background: #ffffff;
}

html.theme--dark .page--home_messages .messagepad__header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: #0f172a;
}

.page--home_messages .messagepad__content__header__title {
    color: #111827;
    font-weight: 600;
    text-decoration: none;
}

html.theme--dark .page--home_messages .messagepad__content__header__title {
    color: #e5e7eb;
}

.page--home_messages .messagepad__message__body {
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: #f1f5f9;
    color: #0f172a;
    line-height: 1.6;
}

html.theme--dark .page--home_messages .messagepad__message__body {
    background: #1f2937;
    color: #e5e7eb;
}

.page--home_messages .messagepad__message.side--self .messagepad__message__body {
    background: #1d4ed8;
    color: #ffffff;
}

.page--home_messages .messagepad__message__body time {
    display: inline-block;
    margin-top: 0.25rem;
    color: #94a3b8;
    font-size: 0.7rem;
}

.page--home_messages .messagepad__message.side--self .messagepad__message__body time {
    color: rgba(255, 255, 255, 0.75);
}

.page--home_messages .messagepad__input {
    border-top: 1px solid rgba(17, 24, 39, 0.1);
    background: #ffffff;
}

html.theme--dark .page--home_messages .messagepad__input {
    border-top-color: rgba(255, 255, 255, 0.1);
    background: #0f172a;
}

.page--home_messages .messagepad__input textarea {
    border-radius: 8px;
}

/* ── 管理域：DomainManage 侧栏与表格 ────────────────────────────────── */

html[data-page^="domain_"] .section.side .menu {
    margin: 0;
    padding: 0.35rem;
}

html[data-page^="domain_"] .section.side .menu__link {
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
}

html[data-page^="domain_"] .section.side .menu.collapsed {
    padding-left: 0.4rem;
}

html[data-page^="domain_"] .data-table th {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    background: #f8fafc;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

html[data-page^="domain_"] .data-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    font-size: 0.86rem;
}

html.theme--dark[data-page^="domain_"] .data-table th {
    background: #1f2937;
    color: #9ca3af;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html.theme--dark[data-page^="domain_"] .data-table td {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html[data-page^="domain_"] .section__body dl.large.horizontal {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.45rem 1rem;
    margin: 0;
}

html[data-page^="domain_"] .section__body dl.large.horizontal dt {
    float: none;
    width: auto !important;
    min-width: 5rem;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

html[data-page^="domain_"] .section__body dl.large.horizontal dd {
    float: none;
    width: auto !important;
    min-width: 0;
    margin: 0;
    color: #111827;
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

html.theme--dark[data-page^="domain_"] .section__body dl.large.horizontal dt {
    color: #9ca3af;
}

html.theme--dark[data-page^="domain_"] .section__body dl.large.horizontal dd {
    color: #e5e7eb;
}

/* ── 控制面板：系统管理页 ──────────────────────────────────────────── */

html[data-page^="manage_"] .section__header {
    padding: 1rem 1.3rem;
}

html[data-page^="manage_"] .section__header .section__title {
    font-size: 1.25rem;
    font-weight: 700;
}

html[data-page^="manage_"] .section.side .menu {
    margin: 0;
    padding: 0.35rem;
}

html[data-page^="manage_"] .section.side .menu__link {
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
}

html[data-page^="manage_"] .data-table th {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    background: #f8fafc;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

html[data-page^="manage_"] .data-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.12);
    font-size: 0.86rem;
}

html[data-page^="manage_"] .data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

html[data-page^="manage_"] .section__body dl.large.horizontal {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.45rem 1rem;
    margin: 0;
}

html[data-page^="manage_"] .section__body dl.large.horizontal dt {
    float: none;
    width: auto !important;
    min-width: 5rem;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

html[data-page^="manage_"] .section__body dl.large.horizontal dd {
    float: none;
    width: auto !important;
    min-width: 0;
    margin: 0;
    color: #111827;
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

html.theme--dark[data-page^="manage_"] .data-table th {
    background: #1f2937;
    color: #9ca3af;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html.theme--dark[data-page^="manage_"] .data-table td {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

html.theme--dark[data-page^="manage_"] .section__body dl.large.horizontal dt {
    color: #9ca3af;
}

html.theme--dark[data-page^="manage_"] .section__body dl.large.horizontal dd {
    color: #e5e7eb;
}

/* Markdown 编辑器统一高度：ui-default 用隐藏 textarea 初始化，可能只剩 19px。 */
.textarea-container .monaco-editor,
.textbox > .monaco-editor {
    height: 200px !important;
    overflow: hidden;
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 8px;
    background: #ffffff;
}

html.theme--dark .textarea-container .monaco-editor,
html.theme--dark .textbox > .monaco-editor {
    border-color: rgba(255, 255, 255, 0.12);
    background: #0f172a;
}

/* ── 管理/编辑页通用表单 ───────────────────────────────────────────── */

:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) .section__header {
    padding: 1rem 1.3rem;
}

:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) .section__header .section__title {
    font-size: 1.25rem;
    font-weight: 700;
}

:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) .section__body {
    padding: 1.1rem 1.3rem;
}

:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) .section__body label {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
}

:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) .textbox,
:is(html[data-page="contest_create"], html[data-page="contest_edit"],
    html[data-page="homework_edit"], html[data-page="homework_create"],
    html[data-page="training_create"], html[data-page="domain_join_applications"],
    html[data-page="domain_user"], html[data-page="domain_role"],
    html[data-page="domain_permission"], html[data-page="manage_user_import"]) select {
    border-radius: 8px;
}

/* ── Phase 5：插件专项页面 ─────────────────────────────────────────── */

/* 插件页面原先统一使用 large-10 + offset-1，改为占满 1440px 容器。 */
:is(.page--milestone, .page--class_report, .page--solution_review,
    .page--ai_code_review, .page--knowledge, .page--knowledge_list) .row > .large-10.large-offset-1.columns {
    width: 100%;
    margin-left: 0;
}

/* 全站分页器：替换主题默认的红色下划线样式。 */
body .pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin: 0;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--site-border);
    list-style: none;
}

body .pager li {
    display: inline-flex;
}

body .pager .pager__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 8px;
    color: var(--site-text-muted);
    text-decoration: none;
}

body .pager .pager__item.current {
    background: #1d4ed8;
    color: #ffffff;
}

body .pager .pager__item.link:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
}

html[data-page="domain_permission"] .data-table td.col--family {
    padding: 0.65rem 0.9rem;
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
}

html.theme--dark[data-page="domain_permission"] .data-table td.col--family {
    background: #1e293b;
    color: #cbd5e1;
}

/* 配置管理是铺满视口的 React 编辑器，内部按旧导航高度 45px 定位。 */
html[data-page="manage_config"] .fullscreen-content {
    top: var(--site-nav-height);
    height: calc(100vh - var(--site-nav-height));
}

@media (max-width: 600px) {
    html[data-page="manage_config"] .fullscreen-content {
        top: 54px;
        height: calc(100vh - 54px);
    }
}
