/* ===== YZOJ Web SPA Styles ===== */
/* Preserves original YZOJ visual identity (georgia title, username colors, Lv.X, status badges)
   with modern card-based beautified UI. */

:root {
  /* Aligned with plugin webview palette (#007acc blue, Georgia titles, card 10px) */
  --primary: #007acc;
  --primary-dark: #005999;
  --primary-light: #e6f0fa;
  --bg: #f7f9fb;
  --card: #ffffff;
  --border: #d8dee4;
  --border-light: #eef1f6;
  --text: #333333;
  --text-secondary: #474d57;
  --muted: #666666;
  --accent: #6366f1;
  --gold: #e8d11d;
  --orange: #fa5a05;
  --green: #2ea043;
  --red: #cf222e;
  --yellow: #d4920b;
  --purple: #8957e5;
  --blue: #007acc;
  --gray: #666666;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --shadow-lg: 0 6px 24px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-title: georgia, "Times New Roman", serif;
  --font-mono: "Consolas", "SF Mono", "Liberation Mono", "Menlo", monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.7;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, pre { font-family: var(--font-mono); }

/* ===== Header ===== */
.oj-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.oj-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.oj-logo {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.oj-logo:hover { text-decoration: none; color: var(--primary); }
.oj-logo-text { color: var(--primary); }
.oj-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.oj-nav a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  transition: background .15s, color .15s;
}
.oj-nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.oj-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.oj-nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.oj-nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform .2s;
}

/* ===== User Area ===== */
.oj-user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.oj-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  transition: background .15s;
}
.oj-user-info:hover { background: var(--bg); }
.oj-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}
.oj-avatar img { width: 100%; height: 100%; object-fit: cover; }
.oj-lv-badge {
  display: inline-block;
  padding: 2px 8px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-title);
  white-space: nowrap;
}
.oj-username {
  font-weight: 600;
  font-size: 13px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.oj-user-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oj-is-admin {
  padding: 2px 7px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

/* ===== 桌面端设置按钮 / 设置表单 ===== */
.oj-settings-btn {
  background: none;
  border: none;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 7px 9px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.oj-settings-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.oj-settings-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.oj-settings-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
.oj-settings-form input[type="text"]:focus { border-color: var(--primary); }
.oj-settings-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.6;
}
.oj-settings-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 18px;
}

/* ===== 背景图设置 ===== */
/* 背景层挂在 body::before（z-index:-1），位于页面内容之下、body 底色之上，
   铺满视口且不溢出；透明度由 --oj-bg-opacity 控制（数值越低越透出底色）。 */
body.oj-bg-on::before {
  content: '';
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  background-image: var(--oj-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--oj-bg-opacity, 1);
}
.oj-settings-form input[type="range"] { flex: 1; accent-color: var(--primary); }
.oj-bg-preview { margin-top: 12px; }
.oj-bg-preview img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.oj-download-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.oj-download-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ===== Buttons ===== */
.oj-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
}
.oj-btn:hover { background: var(--bg); text-decoration: none; }
.oj-btn:disabled { opacity: .55; cursor: not-allowed; }
.oj-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}
.oj-btn-primary:hover { background: var(--primary-dark); }
.oj-btn-danger { background: var(--red); color: #fff; border-color: transparent; }
.oj-btn-danger:hover { background: #e0443c; }
.oj-btn-sm { padding: 5px 12px; font-size: 13px; }

/* 评测详情页工具栏（重测按钮等） */
.oj-detail-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.oj-detail-toolbar .oj-btn {
  background: var(--btn-bg, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
}
.oj-detail-toolbar .oj-btn:hover { opacity: .9; }
.oj-detail-toolbar .oj-btn:disabled { opacity: .5; cursor: not-allowed; }
.oj-btn-lg { padding: 11px 24px; font-size: 15px; }
.oj-btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.oj-btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ===== Main Layout ===== */
.oj-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.oj-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.oj-page-title .oj-badge-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

/* ===== Card ===== */
.oj-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
}
.oj-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  background: #fafbfc;
}
.oj-card-title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.oj-card-body { padding: 16px 18px; }
.oj-card-body.tight { padding: 8px 0; }

/* ===== Plugin-rendered page container (照搬插件 webview 输出) ===== */
/* Mimics the plugin's body{font-family;background;padding;color} base styling. */
.oj-plugin-page {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f7f9fb;
  padding: 16px;
  color: #333;
  font-size: 14px;
  line-height: 1.7;
  border-radius: var(--radius);
  min-height: 200px;
}
.oj-plugin-page img { max-width: 100%; }
.oj-plugin-page a { color: #007acc; }
.oj-plugin-page table { border-collapse: collapse; }
/* Hide VSCode-only "创建工作区" button on contest detail (web has no workspace) */
.oj-plugin-page button.pb#bf { display: none !important; }

/* ===== Contest list tabs (计划中/进行中/过去) ===== */
.oj-contest-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  padding: 0 4px;
}
.oj-contest-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.oj-contest-tab:hover { color: var(--primary); }
.oj-contest-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== WASM Online IDE Modal ===== */
#oj-ide-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; }
.oj-ide-backdrop { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.5); }
.oj-ide-window {
  position: relative; width: 96%; max-width: 1400px; height: 92%; margin: 2vh auto;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
  display: flex; flex-direction: column; overflow: hidden;
}
.oj-ide-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  background: #f8f9fa; flex-shrink: 0;
}
.oj-ide-title { font-weight: 600; font-size: 15px; color: var(--text); }
.oj-ide-controls { display: flex; align-items: center; gap: 8px; }
.oj-ide-lang-sel {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; cursor: pointer;
}
.oj-ide-btn-run {
  padding: 5px 18px; border: none; border-radius: 6px; background: var(--green);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.oj-ide-btn-run:hover { opacity: .9; }
.oj-ide-btn-submit {
  padding: 5px 18px; border: none; border-radius: 6px; background: var(--primary);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.oj-ide-btn-submit:hover { opacity: .9; }
.oj-ide-btn-submit:disabled { opacity: .5; cursor: not-allowed; }
.oj-ide-btn-close {
  width: 28px; height: 28px; border: none; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.oj-ide-btn-close:hover { background: var(--bg); color: var(--red); }
.oj-ide-body { display: flex; flex: 1; overflow: hidden; }
.oj-ide-editor-wrap { flex: 1; overflow: hidden; border-right: 1px solid var(--border-light); }
.oj-ide-editor { width: 100%; height: 100%; }
.oj-ide-sidebar { width: 380px; display: flex; flex-direction: column; flex-shrink: 0; }
.oj-ide-panel { flex: 1; display: flex; flex-direction: column; border-bottom: 1px solid var(--border-light); min-height: 0; }
.oj-ide-panel:last-child { border-bottom: none; }
.oj-ide-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: #f8f9fa; font-size: 12px; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
.oj-ide-btn-sm {
  padding: 2px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; font-size: 11px; color: var(--primary); cursor: pointer;
}
.oj-ide-btn-sm:hover { background: var(--primary-light); }
.oj-ide-textarea {
  flex: 1; border: none; padding: 10px; font-family: var(--font-mono); font-size: 13px;
  resize: none; outline: none; line-height: 1.5; color: var(--text);
}
.oj-ide-output {
  flex: 1; margin: 0; padding: 10px; font-family: var(--font-mono); font-size: 13px;
  overflow: auto; white-space: pre-wrap; word-break: break-all; color: var(--text);
  background: #fafbfc;
}
.oj-ide-status { font-size: 11px; font-weight: 400; }
.oj-ide-status.ok { color: var(--green); }
.oj-ide-status.error { color: var(--red); }
.oj-ide-status.running { color: var(--yellow); }
.oj-ide-status.tle { color: var(--yellow); }
.oj-ide-status.ole { color: var(--purple); }
@media (max-width: 768px) {
  .oj-ide-body { flex-direction: column; }
  .oj-ide-sidebar { width: 100%; height: 40%; }
  .oj-ide-editor-wrap { height: 60%; }
}

/* ===== Tables ===== */
.oj-table-wrap { overflow-x: auto; }
.oj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.oj-table th {
  text-align: left;
  padding: 10px 14px;
  background: #fafbfc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.oj-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
.oj-table tbody tr:hover { background: #fafbff; }
.oj-table tbody tr:last-child td { border-bottom: none; }
.oj-table .num { font-family: var(--font-mono); color: var(--muted); }
.oj-table .center { text-align: center; }

/* ===== Status Badges ===== */
.oj-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.oj-status-ac, .oj-status-accepted { background: #dcfce7; color: #166534; }
.oj-status-wa, .oj-status-wrong { background: #fee2e2; color: #991b1b; }
.oj-status-tle { background: #fef3c7; color: #92400e; }
.oj-status-mle { background: #ede9fe; color: #5b21b6; }
.oj-status-re { background: #fee2e2; color: #991b1b; }
.oj-status-ce { background: #dbeafe; color: #1e40af; }
.oj-status-pe { background: #fef3c7; color: #92400e; }
.oj-status-ole, .oj-status-rf { background: #fee2e2; color: #991b1b; }
.oj-status-wt, .oj-status-waiting, .oj-status-pending, .oj-status-running, .oj-status-judging {
  background: #f1f5f9; color: #475569;
}
.oj-status-sk { background: #dcfce7; color: #166534; }

/* ===== Difficulty Badges ===== */
.oj-difficulty {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.oj-diff-1, .oj-diff-2 { background: #dcfce7; color: #166534; }
.oj-diff-3, .oj-diff-4 { background: #dbeafe; color: #1e40af; }
.oj-diff-5, .oj-diff-6 { background: #fef3c7; color: #92400e; }
.oj-diff-7, .oj-diff-8 { background: #ffedd5; color: #9a3412; }
.oj-diff-9, .oj-diff-10 { background: #fee2e2; color: #991b1b; }

/* ===== Forms ===== */
.oj-form-group { margin-bottom: 16px; }
.oj-form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.oj-input, .oj-textarea, .oj-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.oj-input:focus, .oj-textarea:focus, .oj-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9,105,218,.1);
}
.oj-textarea { resize: vertical; min-height: 100px; line-height: 1.6; font-family: var(--font-mono); }
.oj-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.oj-form-row > * { flex: 1; min-width: 180px; }
.oj-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ===== Tabs ===== */
.oj-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 16px;
}
.oj-tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.oj-tab:hover { color: var(--text); }
.oj-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Pagination ===== */
.oj-pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.oj-pagination a, .oj-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all .12s;
}
.oj-pagination a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.oj-pagination .current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.oj-pagination .disabled { opacity: .4; cursor: not-allowed; }

/* ===== Search Box ===== */
.oj-search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.oj-search-box .oj-input { max-width: 320px; }

/* ===== Filter Chips ===== */
.oj-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.oj-chip {
  padding: 5px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .12s;
}
.oj-chip:hover { border-color: var(--primary); color: var(--primary); }
.oj-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Loading / Error / Empty States ===== */
.oj-loading-wrap {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.oj-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: oj-spin .8s linear infinite;
  margin-bottom: 12px;
}
@keyframes oj-spin { to { transform: rotate(360deg); } }
.oj-loading-tip { font-size: 14px; color: var(--muted); }

.oj-error-wrap {
  text-align: center;
  padding: 40px 20px;
  color: var(--red);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.oj-error-wrap h3 { font-size: 16px; margin-bottom: 8px; }
.oj-error-wrap p { font-size: 13px; color: var(--muted); }

.oj-empty-wrap {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.oj-empty-wrap .icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }

/* ===== Toast ===== */
.oj-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 11px 22px;
  background: #1f2328;
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: opacity .22s, transform .22s;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  font-weight: 500;
  pointer-events: none;
  max-width: 90vw;
}
.oj-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.oj-toast.error { background: var(--red); }
.oj-toast.success { background: var(--green); }

/* ===== Modal ===== */
.oj-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
  padding: 20px;
}
.oj-modal-overlay.active { display: flex; }
.oj-modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: oj-pop-in .18s ease-out;
}
@keyframes oj-pop-in {
  from { transform: scale(.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.oj-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.oj-modal-head h2 { font-size: 17px; font-weight: 700; color: var(--text); }
.oj-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
}
.oj-modal-close:hover { background: var(--bg); color: var(--text); }
.oj-modal-body { padding: 20px; }

/* ===== Profile Edit (个人主页编辑，参考 user.html) ===== */
.oj-form-group { margin-bottom: 16px; }
.oj-form-group > label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.oj-input {
  width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: 14px; color: var(--text); background: #fff; font-family: inherit;
}
.oj-input:focus { outline: none; border-color: var(--primary); }
textarea.oj-input { resize: vertical; line-height: 1.6; }
.oj-pe-row { display: flex; align-items: center; gap: 12px; }
.oj-pe-av { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; background: #f0f0f0; }
.oj-pe-hd { width: 120px; height: 40px; border-radius: 6px; object-fit: cover; background: #f0f0f0; }
.oj-btn-sec { padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: #fff; color: var(--text); font-size: 13px; cursor: pointer; }
.oj-btn-sec:hover { background: var(--bg); }
.oj-btn-primary { padding: 8px 22px; border: 1px solid var(--primary); border-radius: var(--radius-xs); background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.oj-btn-primary:hover { opacity: .9; }
.oj-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.oj-pe-preview-label { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.oj-pe-preview {
  min-height: 60px; border: 1px dashed var(--border); border-radius: var(--radius-xs);
  padding: 10px 12px; font-size: 13px; line-height: 1.7; color: var(--text);
  background: var(--bg); word-break: break-word; overflow: auto;
}
.oj-pe-preview img { max-width: 100%; border-radius: 4px; }
.oj-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ===== Floating Toolbar ===== */
.oj-ftoolbar {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
}
.oj-ftoolbar button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.oj-ftoolbar button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* ===== Footer ===== */
.oj-footer {
  background: #fff;
  border-top: 1px solid var(--border-light);
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.oj-footer a { color: var(--muted); }
.oj-footer a:hover { color: var(--primary); }

/* ===== Markdown Content (题面/讨论/题解) ===== */
.oj-md { font-size: 14.5px; line-height: 1.8; color: var(--text); word-break: break-word; }
.oj-md h1, .oj-md h2, .oj-md h3, .oj-md h4, .oj-md h5, .oj-md h6 {
  margin: 18px 0 10px;
  font-weight: 700;
  line-height: 1.3;
}
.oj-md h1 { font-size: 24px; border-bottom: 1px solid var(--border-light); padding-bottom: 8px; }
.oj-md h2 { font-size: 20px; border-bottom: 1px solid var(--border-light); padding-bottom: 6px; }
.oj-md h3 { font-size: 17px; }
.oj-md h4 { font-size: 15px; }
.oj-md p { margin: 10px 0; }
.oj-md ul, .oj-md ol { padding-left: 24px; margin: 10px 0; }
.oj-md li { margin: 4px 0; }
.oj-md code {
  background: #eff1f3;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.oj-md pre {
  background: #f6f8fa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.6;
}
.oj-md pre code { background: none; padding: 0; font-size: 13px; }
.oj-md blockquote {
  border-left: 3px solid var(--primary);
  padding: 4px 0 4px 14px;
  margin: 12px 0;
  color: var(--muted);
  background: var(--primary-light);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.oj-md table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 13.5px;
}
.oj-md table th, .oj-md table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.oj-md table th { background: #fafbfc; font-weight: 600; }
.oj-md img { max-width: 100%; border-radius: var(--radius-xs); }
.oj-md a { color: var(--primary); }
.oj-md hr { border: none; border-top: 1px solid var(--border-light); margin: 18px 0; }
.oj-md font { /* preserve legacy <font> tags from YZOJ */ }

/* ===== Sample I/O Block ===== */
.oj-sample {
  background: #f6f8fa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  overflow: hidden;
}
.oj-sample-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.oj-sample-copy {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.oj-sample-copy:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.oj-sample-body {
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* ===== Problem Detail Layout ===== */
.oj-problem-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.oj-problem-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.oj-problem-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.oj-problem-meta dt { color: var(--muted); font-weight: 500; }
.oj-problem-meta dd { color: var(--text); }

/* ===== Tag Pills ===== */
.oj-tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px;
  text-decoration: none;
}
.oj-tag:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ===== Username (with YZOJ color system) ===== */
.oj-uname {
  font-family: var(--font-title);
  font-weight: 600;
  text-decoration: none;
}
.oj-uname:hover { text-decoration: underline; }

/* ===== Code Block (源码查看) ===== */
.oj-code-block {
  background: #1f2328;
  color: #e6edf3;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* ===== Testcase Result Grid ===== */
.oj-testcases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.oj-testcase {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 8px;
  text-align: center;
  font-size: 12px;
}
.oj-testcase-num { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.oj-testcase-result { font-weight: 700; font-size: 13px; }

/* ===== Contest Card ===== */
.oj-contest-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: box-shadow .15s, transform .15s;
  cursor: pointer;
}
.oj-contest-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.oj-contest-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.oj-contest-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.oj-contest-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}
.oj-contest-status.active { background: #dcfce7; color: #166534; }
.oj-contest-status.scheduled { background: #dbeafe; color: #1e40af; }
.oj-contest-status.ended { background: #f1f5f9; color: #475569; }

/* ===== Login Page ===== */
.oj-login-box {
  max-width: 420px;
  margin: 40px auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.oj-login-box h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
}
.oj-login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.oj-login-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
}
.oj-login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: #fff;
  border: none;
  cursor: pointer;
  transition: all .12s;
}
.oj-login-tab.active {
  background: var(--primary);
  color: #fff;
}
.oj-login-tip {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  background: #fafbfc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  margin-top: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .oj-problem-layout { grid-template-columns: 1fr; }
  .oj-problem-sidebar { order: -1; }
}
@media (max-width: 768px) {
  .oj-header-inner { padding: 0 12px; gap: 10px; }
  .oj-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .oj-nav.open { display: flex; }
  .oj-nav a { padding: 12px 16px; }
  .oj-nav-toggle { display: flex; }
  .oj-logo { font-size: 16px; }
  .oj-main { padding: 16px 12px 30px; }
  .oj-page-title { font-size: 18px; }
  .oj-table { font-size: 12px; }
  .oj-table th, .oj-table td { padding: 8px 10px; }
  .oj-username { max-width: 80px; }
  .oj-user-info { padding: 4px; }
  .oj-user-info .oj-username { display: none; }
  .oj-modal { max-width: 100%; }
  .oj-ftoolbar { right: 12px; bottom: 12px; }
}

/* ===== Amazing YZOJ 项目声明弹窗 ===== */
.oj-notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.oj-notice-card {
  background: #fff;
  border-radius: 12px;
  width: min(760px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.oj-notice-head {
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary, #1a73e8);
  flex-shrink: 0;
}
.oj-notice-scroll {
  overflow-y: auto;
  padding: 20px 24px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text, #333);
}
.oj-notice-scroll h1 {
  font-size: 20px;
  text-align: center;
  margin: 0 0 14px;
  color: var(--text, #333);
}
.oj-notice-scroll h2 {
  font-size: 15px;
  margin: 16px 0 8px;
  color: var(--primary, #1a73e8);
}
.oj-notice-scroll p { margin: 6px 0; }
.oj-notice-scroll ol,
.oj-notice-scroll ul { margin: 6px 0 6px 2px; padding-left: 22px; }
.oj-notice-scroll li { margin: 4px 0; }
.oj-notice-sign { text-align: right; font-weight: 600; margin-top: 12px; }
.oj-notice-foot {
  padding: 12px 24px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}
.oj-notice-err {
  text-align: center;
  color: #d93025;
  font-size: 12.5px;
  margin: 0 24px 10px;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .oj-notice-overlay { padding: 10px; }
  .oj-notice-scroll { padding: 14px 16px; }
  .oj-notice-foot { padding: 10px 16px; flex-direction: column-reverse; }
}

/* ===== 个人简介 Markdown + LaTeX 编辑器（同题目编辑款） ===== */
.oj-md-editor-wrap {
  height: 300px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dbeaff;
}
.oj-md-editor-wrap .CodeMirror { height: 100% !important; }
/* ===== 未安装扩展全屏拦截 ===== */
.oj-ext-required {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eff9 100%);
  padding: 20px;
}
.oj-ext-required-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .14);
  max-width: 520px;
  width: 100%;
  padding: 32px 32px 28px;
  text-align: center;
}
.oj-ext-required-icon { font-size: 44px; margin-bottom: 8px; }
.oj-ext-required-card h2 { margin: 0 0 10px; font-family: Georgia, 'Times New Roman', serif; color: #222; }
.oj-ext-required-desc { color: #555; line-height: 1.7; font-size: 13.5px; margin: 0 0 18px; }
.oj-ext-required-steps { text-align: left; background: #f7f9fb; border: 1px solid #e5eaf1; border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; }
.oj-ext-required-steps strong { color: #333; }
.oj-ext-required-steps ol { margin: 8px 0 0; padding-left: 20px; color: #555; line-height: 1.9; font-size: 13px; }
.oj-ext-required-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 480px) {
  .oj-header-inner { gap: 6px; }
  .oj-logo { font-size: 14px; }
  .oj-download-btn { width: 32px; height: 32px; }
  .oj-user-area { gap: 6px; }
  .oj-lv-badge { font-size: 10px; padding: 1px 6px; }
}

/* ===== 首次预处理遮罩（全屏禁止操作 + 进度条） ===== */
.oj-prewarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 246, 255, .92);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.oj-prewarm-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .15);
  max-width: 460px;
  width: 100%;
  padding: 36px 34px 30px;
  text-align: center;
}
.oj-prewarm-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 4px solid #dbe7ff;
  border-top-color: #3b6fe0;
  border-radius: 50%;
  animation: oj-prewarm-spin 0.9s linear infinite;
}
@keyframes oj-prewarm-spin { to { transform: rotate(360deg); } }
.oj-prewarm-title { margin: 0 0 8px; font-size: 17px; font-weight: 600; color: #222; }
.oj-prewarm-sub { margin: 0 0 18px; font-size: 13px; color: #777; line-height: 1.6; }
.oj-prewarm-progress {
  height: 10px;
  border-radius: 5px;
  background: #eef2f9;
  overflow: hidden;
  margin-bottom: 10px;
}
.oj-prewarm-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: linear-gradient(90deg, #3b6fe0, #6aa0ff);
  transition: width .3s ease;
}
.oj-prewarm-count { margin: 0; font-size: 12.5px; color: #8895a8; font-variant-numeric: tabular-nums; }
