:root {
  --green: #00af54;
  --green-hover: #009c4a;
  --text: #262626;
  --muted: #777;
  --border: #e2e2e2;
  --surface: #fff;
  --page: #f3f3f3;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background: var(--page);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
button, textarea, select { font: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.topbar {
  height: 48px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f1f1;
  border-bottom: 1px solid #ddd;
}
.header-left, .header-actions, .editor-title, .editor-tools, .timer { display: flex; align-items: center; }
.brand-logo-crop { width: 120px; height: 40px; overflow: hidden; position: relative; flex: 0 0 auto; }
.brand-logo-crop img { height: 40px; width: auto; position: absolute; right: 0; top: 0; }
.header-divider { width: 1px; height: 22px; margin: 0 12px; background: #d0d0d0; }
.site-title { font-size: 15px; }
.job-title { margin-left: 12px; color: #858585; font-size: 12px; }
.header-actions { gap: 8px; }
.timer { height: 30px; gap: 5px; padding: 0 9px; color: #666; background: #f7f7f7; border: 1px solid #ddd; border-radius: 5px; font-variant-numeric: tabular-nums; font-size: 12px; }
.timer svg { width: 15px; color: var(--green); }
.header-icon, .run-button, .submit-button, .tool-button { height: 30px; border: 1px solid #d7d7d7; border-radius: 5px; background: #fafafa; color: #555; display: flex; align-items: center; justify-content: center; gap: 5px; }
.header-icon { width: 32px; padding: 0; }
.header-icon svg, .run-button svg, .submit-button svg { width: 15px; }
.run-button { padding: 0 11px; }
.run-button:hover, .header-icon:hover, .tool-button:hover { background: #f0f0f0; }
.submit-button { padding: 0 12px; border-color: var(--green); color: #fff; background: var(--green); font-weight: 600; }
.submit-button:hover { background: var(--green-hover); }
.run-button:disabled, .submit-button:disabled { opacity: .55; cursor: wait; }

.workspace {
  height: calc(100dvh - 48px);
  padding: 7px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.panel { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid #dcdcdc; border-radius: 7px; }
.problem-panel { display: flex; flex-direction: column; }
.panel-tabs, .editor-toolbar {
  height: 40px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #fbfbfb;
}
.panel-tabs { padding: 0 14px; }
.panel-tab, .result-tab { height: 100%; border: 0; background: transparent; color: #666; position: relative; }
.panel-tab { padding: 0 3px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.panel-tab svg { width: 15px; color: #2a7fc7; }
.panel-tab.active { color: #222; }
.panel-tab.active::after, .result-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--green); }
.answered { color: #999; font-size: 12px; }

.problem-content { padding: 24px 18px 48px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #aaa transparent; }
.problem-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1 { margin: 0; font-size: 22px; line-height: 1.35; }
.difficulty { flex: 0 0 auto; padding: 4px 9px; border-radius: 12px; color: #e58a00; background: #fff4dc; font-size: 12px; }
.tag-row { display: flex; gap: 8px; margin: 14px 0 18px; }
.tag-row span { padding: 4px 8px; color: #666; background: #f4f4f4; border-radius: 12px; font-size: 12px; }
.description { line-height: 1.85; }
.description p { margin: 0 0 12px; }
code { font-family: Consolas, "Courier New", monospace; }
.description code, .constraints code, .advanced code { padding: 1px 4px; color: #555; background: #f6f6f6; border: 1px solid #e5e5e5; border-radius: 3px; }
.example-section, .constraints, .advanced { margin-top: 28px; }
.example-section h2, .constraints h2, .advanced h2 { margin: 0 0 10px; font-size: 15px; }
.example-lines { padding-left: 14px; border-left: 2px solid #e4e4e4; line-height: 1.7; }
.example-lines p { margin: 2px 0; }
.example-lines code { color: #555; }
.constraints ul { margin: 0; padding-left: 18px; line-height: 2.25; }
.advanced { display: flex; gap: 5px; align-items: flex-start; }
.advanced h2 { flex: 0 0 auto; }
.advanced p { margin: 0; line-height: 1.8; }

.coding-panel { display: grid; grid-template-rows: 40px minmax(260px, 1fr) 190px; }
.editor-toolbar { padding: 0 10px 0 13px; }
.editor-title { gap: 6px; }
.editor-title svg { width: 16px; color: var(--green); }
.editor-tools { gap: 7px; }
.language-select select { height: 28px; padding: 0 22px 0 8px; border: 0; color: #555; background: transparent; opacity: 1; }
.tool-button { padding: 0 8px; font-size: 12px; }
.tool-button svg { width: 13px; }

.editor-wrap { min-height: 0; position: relative; display: grid; grid-template-columns: 46px 1fr; background: #fff; overflow: hidden; }
.line-numbers { padding: 13px 10px 36px 0; color: #2386c8; background: #fafafa; border-right: 1px solid #eee; text-align: right; white-space: pre; user-select: none; overflow: hidden; font: 13px/1.55 Consolas, "Courier New", monospace; }
#codeEditor { width: 100%; height: 100%; min-height: 0; padding: 13px 16px 36px 12px; resize: none; border: 0; outline: 0; color: #111; background: #fff; caret-color: #111; tab-size: 4; white-space: pre; overflow: auto; font: 13px/1.55 Consolas, "Courier New", monospace; }
#codeEditor::selection { background: #cfe8ff; }
.editor-position { position: absolute; right: 10px; bottom: 7px; color: #999; background: rgba(255,255,255,.92); font: 11px Consolas, monospace; pointer-events: none; }

.results-panel { min-height: 0; display: grid; grid-template-rows: 38px 1fr; border-top: 1px solid #dcdcdc; background: #fff; }
.results-tabs { padding: 0 14px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid var(--border); }
.result-tab { padding: 0; font-size: 13px; }
.result-tab.active { color: #222; font-weight: 600; }
#resultBadge { display: inline-block; width: 6px; height: 6px; margin-left: 4px; border-radius: 50%; vertical-align: 1px; }
#resultBadge.pass { background: var(--green); }
#resultBadge.fail { background: #e54848; }
.shortcut-hint { margin-left: auto; color: #999; font-size: 11px; }
kbd { padding: 2px 5px; border: 1px solid #ddd; border-radius: 3px; background: #fafafa; font: 10px inherit; }
.results-body { padding: 12px 14px; overflow: auto; }
.case-pills { display: flex; gap: 8px; }
.case-pill { padding: 4px 10px; border: 1px solid #ddd; border-radius: 4px; color: #666; background: #f7f7f7; font-size: 12px; }
.case-pill.active { border-color: #9ed8b9; color: #18874c; background: #effaf4; }
.case-details { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 7px 8px; align-items: center; margin-top: 11px; color: #888; font-size: 12px; }
.case-details code { padding: 5px 7px; color: #333; background: #f6f6f6; border-radius: 3px; }
.empty-result { height: 100%; display: grid; place-items: center; color: #999; font-size: 12px; }
.run-summary { font-size: 12px; }
.summary-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; margin-bottom: 5px; border-bottom: 1px solid #eee; }
.summary-status { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.summary-status.pass { color: #16924c; }
.summary-status.fail { color: #d93b3b; }
.summary-status .mark, .test-mark { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); }
.summary-status .mark { width: 18px; height: 18px; }
.test-row { display: grid; grid-template-columns: 16px 1fr auto; gap: 7px; align-items: center; padding: 4px 0; color: #555; }
.test-mark { width: 15px; height: 15px; font-size: 9px; }
.test-row.fail .test-mark, .summary-status.fail .mark { background: #e54848; }
.test-row code { color: #999; }
.error-message { margin: 5px 0; padding: 7px; color: #c73636; background: #fff2f2; border: 1px solid #f4d6d6; border-radius: 3px; white-space: pre-wrap; }

.toast { position: fixed; top: 58px; left: 50%; z-index: 20; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; padding: 8px 12px; color: #fff; background: #333; border-radius: 4px; font-size: 12px; transition: .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0,0,0,.35); }
.modal-card { width: min(340px, calc(100% - 30px)); padding: 26px; text-align: center; background: #fff; border-radius: 7px; box-shadow: 0 10px 35px rgba(0,0,0,.18); }
.success-mark { width: 42px; height: 42px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 22px; }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.modal-card p { margin: 0; color: #777; }
.modal-card button { width: 100%; height: 34px; margin-top: 20px; border: 0; border-radius: 4px; color: #fff; background: var(--green); }

body.focus-mode .problem-panel { display: none; }
body.focus-mode .workspace { grid-template-columns: minmax(680px, 1100px); justify-content: center; }

@media (max-width: 1000px) {
  body { overflow: auto; }
  .job-title { display: none; }
  .workspace { height: auto; min-height: calc(100dvh - 48px); grid-template-columns: 1fr; }
  .problem-panel { min-height: 720px; }
  .coding-panel { min-height: 650px; grid-template-rows: 40px 420px 190px; }
  body.focus-mode .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .brand-logo-crop { width: 95px; height: 34px; }
  .brand-logo-crop img { height: 34px; }
  .header-divider { margin: 0 8px; }
  .site-title { font-size: 14px; }
  .timer, .header-icon { display: none; }
  .problem-content { padding-inline: 14px; }
  .shortcut-hint { display: none; }
}
