:root {
  --ink: #18212b;
  --muted: #6d7783;
  --line: #dfe4e8;
  --panel: #ffffff;
  --wash: #f4f6f7;
  --nav: #17242a;
  --green: #1f765c;
  --green-2: #e5f3ee;
  --red: #b73d45;
  --amber: #aa6b15;
  --blue: #3569a8;
  --shadow: 0 12px 36px rgba(25, 36, 43, .11);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--wash); font: 14px/1.55 Inter, "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9eeec; }
.login-panel { width: min(400px, 100%); padding: 40px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-panel h1 { margin: 18px 0 2px; font-size: 27px; }
.login-panel p { margin: 0 0 28px; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 20px; padding: 4px; border-radius: 6px; background: #edf1f0; }
.auth-tabs button { border: 0; border-radius: 4px; padding: 8px; color: var(--muted); background: transparent; }
.auth-tabs button.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(25, 36, 43, .12); font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 7px; color: white; background: var(--green); font: 700 22px/1 Georgia, serif; }
.brand-mark.small { width: 34px; height: 34px; font-size: 17px; }
label { display: grid; gap: 7px; margin-bottom: 16px; font-weight: 600; }
input, textarea, select { width: 100%; border: 1px solid #cfd6da; border-radius: 5px; padding: 10px 11px; color: var(--ink); background: white; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31, 118, 92, .11); }
textarea { min-height: 100px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.primary, .secondary, .danger { border: 0; border-radius: 5px; padding: 9px 14px; font-weight: 650; }
.primary { color: white; background: var(--green); }
.primary:hover { background: #185f4b; }
.secondary { color: var(--ink); background: #e9edef; }
.danger { color: white; background: var(--red); }
.full { width: 100%; padding: 11px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; color: #dce5e4; background: var(--nav); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 26px; font-size: 17px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 5px; color: #b9c6c6; background: transparent; text-align: left; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255, 255, 255, .09); }
.nav-icon { width: 18px; text-align: center; font-size: 16px; }
.sidebar-bottom { margin-top: auto; }
.current-user { margin: 0 10px 14px; padding-bottom: 13px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.current-user span, .current-user strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-user span { color: #879697; font-size: 11px; }
.current-user strong { color: #e8eeee; font-size: 13px; }
.judge-state { display: flex; align-items: center; gap: 8px; margin: 0 10px 12px; color: #aebbbb; font-size: 12px; }
.judge-state span { width: 8px; height: 8px; border-radius: 50%; background: #8d9699; }
.judge-state.online span { background: #42c78f; box-shadow: 0 0 0 3px rgba(66, 199, 143, .14); }
.judge-state.offline span { background: #e36a70; }
.workspace { min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .88); }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.content { width: min(1260px, 100%); margin: 0 auto; padding: 28px 34px 48px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 20px; border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 6px; background: var(--panel); }
.stat:nth-child(2) { border-top-color: var(--blue); }
.stat:nth-child(3) { border-top-color: var(--amber); }
.stat:nth-child(4) { border-top-color: #7a568e; }
.stat strong { display: block; font-size: 28px; line-height: 1.2; }
.stat span { color: var(--muted); }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h3 { margin: 0; font-size: 16px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf0f2; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #fafbfb; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: #f6faf8; cursor: pointer; }
.title-cell { min-width: 210px; max-width: 430px; white-space: normal; font-weight: 650; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; color: #45515b; background: #edf0f2; font-size: 12px; font-weight: 650; }
.badge.AC, .badge.solved { color: #176249; background: #dff2e9; }
.badge.WA, .badge.RE, .badge.CE, .badge.OLE, .badge.JE { color: #96323a; background: #f9e2e4; }
.badge.TLE { color: #875512; background: #f7ecd8; }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) 140px 140px; gap: 10px; margin-bottom: 14px; }
.empty { padding: 48px 20px; color: var(--muted); text-align: center; }
.problem-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 46%); gap: 18px; align-items: start; }
.paper, .judge-panel { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.paper { padding: 25px; }
.problem-head { display: flex; justify-content: space-between; gap: 16px; }
.problem-head h3 { margin: 0 0 7px; font-size: 22px; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); }
.actions { display: flex; gap: 7px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: white; font-size: 18px; }
.prose h4 { margin: 24px 0 7px; font-size: 14px; }
.prose pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.problem-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.problem-images a { display: block; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #f7f8f8; }
.problem-images img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: white; }
.sample { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sample div { min-width: 0; }
.sample label { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.sample pre { min-height: 54px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: #f7f8f8; font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.judge-panel { position: sticky; top: 106px; overflow: hidden; }
.language-tabs { display: flex; padding: 8px 10px 0; border-bottom: 1px solid var(--line); background: #fafbfb; overflow-x: auto; }
.language-tabs button { padding: 8px 11px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; white-space: nowrap; }
.language-tabs button.active { color: var(--green); border-color: var(--green); font-weight: 700; }
.code-editor { display: block; min-height: 390px; border: 0; border-radius: 0; padding: 15px; background: #152126; color: #e9f0ef; line-height: 1.6; tab-size: 4; }
.code-editor:focus { box-shadow: none; }
.judge-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border-top: 1px solid var(--line); }
.result { margin: 12px; padding: 12px; border-left: 3px solid var(--line); background: #f7f8f8; }
.result.AC { border-color: var(--green); background: var(--green-2); }
.result.fail { border-color: var(--red); background: #fbecee; }
.result pre { max-height: 160px; overflow: auto; white-space: pre-wrap; font: 12px/1.5 ui-monospace, Consolas, monospace; }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12, 20, 23, .56); }
.modal-card { z-index: 1; width: min(900px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; border-radius: 7px; background: white; box-shadow: var(--shadow); }
.modal-card > header { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-card h3 { margin: 0; }
.modal-body { overflow: auto; padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }
.image-uploader { margin-bottom: 16px; padding: 14px; border: 1px dashed #aebbb8; border-radius: 6px; background: #f8faf9; }
.image-uploader-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.image-uploader-head strong, .image-uploader-head span { display: block; }
.image-uploader-head span, .image-uploader small { color: var(--muted); font-size: 12px; font-weight: 400; }
.image-previews { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 12px 0 8px; }
.image-preview { position: relative; aspect-ratio: 4 / 3; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: white; }
.image-preview.pending { border-style: dashed; }
.image-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.image-remove { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; color: white; background: rgba(24, 33, 43, .78); font-size: 18px; line-height: 1; }
.image-empty { grid-column: 1 / -1; padding: 18px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; background: white; text-align: center; }
.compact-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.test-case { margin-bottom: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #fafbfb; }
.test-case-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.test-case-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.test-case textarea { min-height: 84px; margin: 0; }
.check { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 500; }
.check input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.toast { position: fixed; right: 20px; top: 18px; z-index: 50; max-width: 380px; padding: 11px 15px; border-radius: 5px; color: white; background: #25343a; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.loading { padding: 60px; color: var(--muted); text-align: center; }
@media (max-width: 900px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .brand strong, .nav-item:not(.active) { font-size: 0; }
  .brand { padding-left: 5px; }
  .nav-item { justify-content: center; }
  .nav-item.active { font-size: 0; }
  .nav-icon { font-size: 19px; }
  .judge-state { display: none; }
  .problem-layout { grid-template-columns: 1fr; }
  .judge-panel { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .app { display: block; padding-bottom: 60px; }
  .sidebar { position: fixed; top: auto; bottom: 0; z-index: 10; width: 100%; height: 58px; padding: 5px 10px; flex-direction: row; }
  .brand, .sidebar-bottom { display: none; }
  .sidebar nav { width: 100%; grid-template-columns: repeat(3, 1fr); }
  .nav-item, .nav-item.active, .nav-item:not(.active) { display: grid; gap: 0; justify-items: center; padding: 3px; font-size: 11px; }
  .nav-icon { line-height: 1; }
  .topbar { height: auto; padding: 16px; }
  .topbar p { display: none; }
  .content { padding: 16px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat { padding: 14px; }
  .filters, .form-grid, .compact-row, .test-case-grid, .sample { grid-template-columns: 1fr; }
  .problem-images { grid-template-columns: 1fr; }
  .image-previews { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-uploader-head { align-items: flex-start; }
  .span-2 { grid-column: span 1; }
  .modal { padding: 8px; }
  .modal-card { max-height: calc(100vh - 16px); }
}
