:root {
  --ink: #1b1f24;
  --muted: #5b6470;
  --line: #d9dee5;
  --accent: #1f5fbf;
  --paper: #fbfbfa;
  --card: #ffffff;
  --soft: #f3f5f8;
  --ok: #1f7a3a;
  --pending: #c98a00;
  --mark: #fff3a6;
  --mark-current: #ffd166;
  --shared: #8a929c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--paper); display: flex; flex-direction: column;
}
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1.1rem; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
[hidden] { display: none !important; }

button {
  font: inherit; padding: 0.4rem 0.9rem; border: 1px solid var(--accent); background: var(--accent);
  color: white; border-radius: 4px; cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.ghost { background: white; color: var(--accent); }
button.linkish { background: none; border: none; color: var(--accent); padding: 0 0.25rem; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 0.3rem; font-size: 0.8rem; background: white; }

.topbar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.progress { display: flex; align-items: center; gap: 0.5rem; }
.progress progress { width: 12rem; }
.filters { display: flex; gap: 0.3rem; }
.filter { background: white; color: var(--muted); border-color: var(--line); padding: 0.2rem 0.7rem; }
.filter.current { color: var(--accent); border-color: var(--accent); }
#who { margin-left: auto; }

.message { margin: 2rem auto; max-width: 40rem; padding: 1rem 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.instructions { margin: 2rem auto; max-width: 44rem; padding: 1.5rem 2rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.instructions li { margin-bottom: 0.4rem; }

.signin { margin: 2rem auto; width: 100%; max-width: 28rem; padding: 0 1rem; }
.signin-step { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.5rem 1.8rem; }
.signin-step p { margin: 0; }
.signin-step label { font-weight: 600; }
.signin-step input { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; }
.signin-step button { align-self: flex-start; }
.signin .message { margin: 1rem 0 0; }
.signin .message p { margin: 0 0 0.5rem; }

.workspace { flex: 1; display: flex; min-height: 0; }
.case-list { width: 9rem; flex: none; overflow-y: auto; border-right: 1px solid var(--line); background: var(--card); }
.case-list ol { list-style: none; margin: 0; padding: 0.4rem 0; }
.case-link {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left;
  background: none; border: none; border-radius: 0; color: var(--ink); padding: 0.35rem 0.8rem;
}
.case-link:hover { background: var(--soft); }
.case-link.current { background: var(--soft); font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.status-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex: none; }
.status-dot.pending { background: var(--pending); }
.status-dot.done { background: var(--ok); }

.case { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0.8rem 1rem; gap: 0.7rem; }
.case-bar { display: flex; align-items: center; gap: 0.8rem; }
.pill { margin-left: auto; padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 0.85rem; }
.case-body { flex: 1; display: flex; gap: 1rem; min-height: 0; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.panel-title {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--line); font-weight: 600;
}
.note { flex: 3; display: flex; flex-direction: column; min-width: 0; }
.search { display: flex; align-items: center; gap: 0.3rem; font-weight: normal; }
.search input { font: inherit; padding: 0.2rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; width: 14rem; }
.chart-text {
  flex: 1; overflow-y: auto; padding: 0.8rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; line-height: 1.5;
}
.chart-text .heading { font-weight: 700; }
.chart-text mark { background: var(--mark); color: inherit; }
.chart-text mark.current { background: var(--mark-current); }

.judging { flex: 2; display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; overflow-y: auto; }
.sets { display: flex; flex-direction: column; gap: 0.8rem; }
.sets-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.legend { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--shared); }
.swatch { width: 0.8rem; height: 0.8rem; border-radius: 2px; background: var(--shared); }
.sets-bar label { display: inline-flex; align-items: center; gap: 0.3rem; }
.panel-title .small { font-weight: normal; }
.code-list { list-style: none; margin: 0; padding: 0.3rem 0; }
.code-list li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.6rem; padding: 0.25rem 0.8rem; }
.code-list li.shared { color: var(--shared); }

.answer { flex: none; padding: 0.6rem 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
.answer fieldset { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; }
.answer legend { font-weight: 600; margin-bottom: 0.3rem; padding: 0; }
.answer .comment { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }
.answer textarea { font: inherit; font-weight: normal; padding: 0.4rem; border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.save-row { display: flex; align-items: center; gap: 0.8rem; }

@media (min-width: 1500px) {
  .sets { flex-direction: row; }
  .sets .set { flex: 1; min-width: 0; }
}

@media (max-width: 900px) {
  .workspace { flex-direction: column; }
  .case-list { width: auto; max-height: 8rem; border-right: none; border-bottom: 1px solid var(--line); }
  .case-body { flex-direction: column; }
  .note { min-height: 50vh; }
}
