:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182230;
  --muted: #667085;
  --line: #d9e0ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #087443;
  --amber: #a15c07;
  --red: #b42318;
  --shadow: 0 14px 30px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
}

button, input, select, textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
}

button:hover {
  border-color: #9aa8bc;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: var(--blue-dark);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 9px;
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: #344054;
  font-weight: 600;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.authbar {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2f7;
  padding: 14px;
  overflow: auto;
}

.content {
  padding: 16px;
  overflow: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check input {
  width: auto;
}

.notice {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.notice.error {
  color: var(--red);
}

.notice.ok {
  color: var(--green);
}

.resultbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

#results {
  display: grid;
  gap: 10px;
}

.pool-card,
.problem {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.pool-head,
.problem-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.pool-title,
.code {
  font-weight: 800;
  font-size: 15px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #d8dee8;
  border-radius: 999px;
  background: #f8fafc;
  color: #344054;
  padding: 3px 8px;
  font-size: 12px;
}

.badge.ok {
  color: var(--green);
  background: #ecfdf3;
  border-color: #b7e4c7;
}

.badge.warn {
  color: var(--amber);
  background: #fff7ed;
  border-color: #fed7aa;
}

.problem-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.problem-summary {
  margin-top: 10px;
  padding: 9px 10px;
  border-left: 3px solid #8bb4ff;
  background: #f7faff;
  line-height: 1.55;
}

.problem-summary strong {
  margin-right: 8px;
}

.problem-details {
  display: none;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.problem.open .problem-details {
  display: block;
}

.text {
  white-space: pre-wrap;
  line-height: 1.65;
}

.solution {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.selection-box {
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcff;
  color: var(--muted);
}

.selection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 4px;
  align-items: center;
  margin-top: 5px;
}

.download-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.empty {
  border: 1px dashed #b7c1d1;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: #fff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .45);
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(980px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.form-grid label {
  margin: 0;
}

.wide {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar,
  .resultbar,
  .pool-head,
  .problem-top {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
