/* 竞赛做题页 — 左题面 / 右编辑器 */

:root {
    --cw-top: #0f2744;
    --cw-bg: #eef2f7;
    --cw-panel: #ffffff;
    --cw-line: #e2e8f0;
    --cw-ink: #0f172a;
    --cw-muted: #64748b;
    --cw-primary: #2563eb;
    --cw-primary-2: #1d4ed8;
    --cw-soft: #f8fafc;
    --cw-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body.cw-body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--cw-bg);
    color: var(--cw-ink);
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.cw {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
}

.cw-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.7fr) auto;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 14px;
    background: linear-gradient(90deg, #0b1f38, #123056);
    color: #e2e8f0;
    flex: 0 0 48px;
}

.cw-top-left,
.cw-top-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cw-top-left {
    overflow: hidden;
}

.cw-top-right {
    justify-content: flex-end;
    flex-shrink: 0;
}

.cw-top-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.cw-back {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    color: #e2e8f0 !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    border: 1px solid rgba(226, 232, 240, 0.18);
}
.cw-back:hover { background: rgba(255,255,255,0.08); color: #fff !important; }

.cw-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.55) transparent;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 2px 2px 4px;
    mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
.cw-tabs::-webkit-scrollbar {
    height: 4px;
}
.cw-tabs::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
}
.cw-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.cw-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 34px;
    height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    color: #cbd5e1 !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 450;
    white-space: nowrap;
}
.cw-tab:hover { background: rgba(255,255,255,0.08); color: #fff !important; }
.cw-tab.is-active {
    background: #fff;
    color: #0f2744 !important;
}

.cw-status {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 450;
    background: rgba(148, 163, 184, 0.22);
    color: #e2e8f0;
}
.cw-status.is-running { background: rgba(34, 197, 94, 0.22); color: #bbf7d0; }
.cw-status.is-upcoming { background: rgba(59, 130, 246, 0.22); color: #bfdbfe; }
.cw-status.is-ended { background: rgba(148, 163, 184, 0.22); color: #e2e8f0; }

.cw-contest-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: rgba(226, 232, 240, 0.8);
}

.cw-nav-btn {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    color: #e2e8f0 !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 400;
    border: 1px solid rgba(226, 232, 240, 0.18);
}
.cw-nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff !important; }
.cw-nav-btn.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.cw-main {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.05fr);
    gap: 0;
    flex: 1;
    min-height: 0;
    background: var(--cw-bg);
}

.cw-left,
.cw-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--cw-panel);
}

.cw-left { border-right: 1px solid var(--cw-line); }

.cw-right {
    background: transparent;
    padding: 0;
    position: relative;
}

.cw-right .sg-ch-workspace {
    height: 100%;
    min-height: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
}

html.cw-ed-focus .cw-top,
html.cw-ed-focus .cw-left {
    visibility: hidden;
}

.cw-left-tabs,
.cw-ed-top,
.cw-io-tabs,
.cw-io-head {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--cw-line);
    background: var(--cw-soft);
}

.cw-left-tabs { padding: 0 10px; height: 42px; }

.cw-left-tab,
.cw-ed-tab,
.cw-io-tab {
    height: 42px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--cw-muted);
    font-size: 13px;
    font-weight: 450;
    cursor: pointer;
}
.cw-left-tab.is-active,
.cw-ed-tab.is-active,
.cw-io-tab.is-active {
    color: var(--cw-primary);
    box-shadow: inset 0 -2px 0 var(--cw-primary);
}

.cw-left-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 18px 20px 28px;
}

.cw-prob-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 450;
    letter-spacing: -0.02em;
}
.cw-prob-no {
    flex-shrink: 0;
    color: var(--cw-muted, #64748b);
    font-weight: 500;
}
.cw-prob-title-sep {
    color: #cbd5e1;
    font-weight: 400;
}
.cw-prob-title-text {
    flex: 1 1 12rem;
    min-width: 0;
    color: inherit;
}

.cw-limits {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--cw-line);
    border-radius: 12px;
    background: #f8fafc;
}
.cw-limits.is-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.cw-limits em {
    display: block;
    margin-bottom: 4px;
    font-style: normal;
    font-size: 12px;
    color: var(--cw-muted);
}
.cw-limits strong {
    font-size: 14px;
    color: var(--cw-ink);
}

.cw-block { margin-top: 18px; }
.cw-block h2 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 450;
}
.cw-md {
    color: #334155;
    font-size: 14.5px;
    line-height: 1.75;
}
.cw-md img { max-width: 100%; height: auto; }
.cw-md pre,
.cw-sample pre {
    margin: 0;
    padding: 12px;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
}

.cw-sample {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.cw-sample-label {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 450;
    color: var(--cw-muted);
}

.cw-empty {
    margin: 40px 0;
    text-align: center;
    color: var(--cw-muted);
}

.cw-ed-top {
    justify-content: space-between;
    padding: 0 12px 0 10px;
    height: 42px;
}
.cw-ed-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cw-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--cw-muted);
    font-weight: 450;
}
.cw-lang select {
    height: 28px;
    border: 1px solid var(--cw-line);
    border-radius: 8px;
    padding: 0 8px;
    background: #fff;
}

.cw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 450;
    cursor: pointer;
}
.cw-btn-primary {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: #fff;
}
.cw-btn-primary:hover { filter: brightness(1.05); }
.cw-btn-ghost {
    background: #fff;
    border: 1px solid var(--cw-line);
    color: #334155;
}
.cw-btn-xs {
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
}

.cw-ed-wrap {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    flex: 1.2;
    min-height: 180px;
    border-bottom: 1px solid var(--cw-line);
}
.cw-gutter {
    margin: 0;
    padding: 12px 6px 12px 4px;
    background: #f8fafc;
    border-right: 1px solid var(--cw-line);
    color: #94a3b8;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 20px;
    text-align: right;
    user-select: none;
    overflow: hidden;
    white-space: pre;
    tab-size: 4;
}
.cw-code {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 12px;
    border: 0;
    resize: none;
    outline: none;
    background: #fff;
    color: #0f172a;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 20px;
    white-space: pre;
    overflow: auto;
    tab-size: 4;
}

.cw-io {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 0 0 240px;
    min-height: 200px;
    border-top: 1px solid var(--cw-line);
}
.cw-io-left,
.cw-io-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.cw-io-left { border-right: 1px solid var(--cw-line); }
.cw-io-tabs,
.cw-io-head {
    height: 38px;
    padding: 0 10px;
}
.cw-io-tabs {
    justify-content: flex-start;
}
.cw-io-tools {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cw-sample-pick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 450;
    color: var(--cw-muted);
}
.cw-sample-pick select {
    height: 26px;
    border: 1px solid var(--cw-line);
    border-radius: 6px;
    padding: 0 6px;
    background: #fff;
}
.cw-io-head {
    justify-content: space-between;
    font-size: 13px;
    font-weight: 450;
    color: var(--cw-muted);
}
.cw-stdin,
.cw-stdout {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    resize: none;
    outline: none;
    background: #fff;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12.5px;
    line-height: 1.5;
    overflow: auto;
}
.cw-stdout {
    color: #64748b;
    white-space: pre-wrap;
    word-break: break-word;
}
.cw-io-actions {
    display: flex;
    justify-content: flex-end;
    padding: 8px 10px;
    border-top: 1px solid var(--cw-line);
    background: var(--cw-soft);
}

.cw-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 50;
    transform: translateX(-50%);
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

@media (max-width: 980px) {
    .cw-top {
        grid-template-columns: 1fr;
        height: auto;
        padding: 8px 10px;
        gap: 8px;
    }
    .cw-top-mid,
    .cw-top-right { justify-content: flex-start; }
    .cw-main {
        grid-template-columns: 1fr;
        overflow: auto;
    }
    .cw-left,
    .cw-right {
        min-height: 70vh;
    }
    .cw-sample { grid-template-columns: 1fr; }
    .cw-io { grid-template-columns: 1fr; flex-basis: auto; }
    .cw-limits.is-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
