:root {
  color-scheme: light;
  --bg: #f4f8fc;
  --surface: #ffffff;
  --surface-alt: #edf5fb;
  --surface-raised: #ffffff;
  --input-bg: #ffffff;
  --line: #d7e5f0;
  --text: #1f3140;
  --muted: #687b8b;
  --accent: #006eb4;
  --accent-strong: #00538f;
  --accent-soft: #e7f3fb;
  --danger: #c9364f;
  --danger-soft: #fbeaf0;
  --warning: #a96712;
  --success: #0f7a5a;
  --success-soft: #e4f5ef;
  --row-pass-bg: rgba(15, 122, 90, 0.08);
  --row-fail-bg: rgba(201, 54, 79, 0.08);
  --shadow: 0 10px 26px rgba(0, 74, 122, 0.08);
  --modal-backdrop: rgba(12, 31, 47, 0.72);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #081722;
    --surface: #101f2b;
    --surface-alt: #152c3d;
    --surface-raised: #132635;
    --input-bg: #0b1b27;
    --line: #274358;
    --text: #e8f2f8;
    --muted: #9eb1bf;
    --accent: #4ca3df;
    --accent-strong: #8cc9f2;
    --accent-soft: #173954;
    --danger: #ff7d92;
    --danger-soft: #431a26;
    --warning: #f0b75d;
    --success: #61d0a1;
    --success-soft: #16392e;
    --row-pass-bg: rgba(97, 208, 161, 0.1);
    --row-fail-bg: rgba(255, 125, 146, 0.1);
    --shadow: 0 16px 34px rgba(0, 0, 0, 0.26);
    --modal-backdrop: rgba(3, 10, 16, 0.78);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081722;
  --surface: #101f2b;
  --surface-alt: #152c3d;
  --surface-raised: #132635;
  --input-bg: #0b1b27;
  --line: #274358;
  --text: #e8f2f8;
  --muted: #9eb1bf;
  --accent: #4ca3df;
  --accent-strong: #8cc9f2;
  --accent-soft: #173954;
  --danger: #ff7d92;
  --danger-soft: #431a26;
  --warning: #f0b75d;
  --success: #61d0a1;
  --success-soft: #16392e;
  --row-pass-bg: rgba(97, 208, 161, 0.1);
  --row-fail-bg: rgba(255, 125, 146, 0.1);
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.26);
  --modal-backdrop: rgba(3, 10, 16, 0.78);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(0, 110, 180, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

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

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button,
button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button.secondary,
button.secondary {
  background: var(--surface);
  color: var(--accent-strong);
  border-color: var(--line);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.button[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.text-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font-weight: 700;
  text-align: left;
}

.text-button:hover {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.button.danger:hover,
button.danger:hover {
  background: #a92e43;
  border-color: #a92e43;
}

.theme-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.theme-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-button .icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.dashboard-panel {
  margin-bottom: 16px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

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

.dashboard-subsection {
  margin-top: 2px;
}

.dashboard-subsection h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.search-field {
  margin-bottom: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

.editor-area {
  position: relative;
}

.editor-area.is-disabled [data-requires-set] {
  filter: grayscale(0.08);
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}

.editor-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  min-height: 360px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 248, 252, 0.72);
  backdrop-filter: blur(2px);
  color: var(--text);
  padding: 24px;
  text-align: center;
}

:root[data-theme="dark"] .editor-overlay {
  background: rgba(8, 23, 34, 0.72);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .editor-overlay {
    background: rgba(8, 23, 34, 0.72);
  }
}

.editor-area.is-disabled .editor-overlay {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-overlay strong {
  display: block;
  font-size: 22px;
}

.editor-overlay span {
  max-width: 360px;
  color: var(--muted);
}

.set-list {
  display: grid;
  gap: 10px;
}

.set-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.set-list-row .set-select {
  width: 100%;
  overflow: hidden;
  text-align: left;
}

.set-select-title,
.set-select-description {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-select-description {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.set-list-row .danger {
  min-width: 40px;
  padding: 0;
}

.set-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  text-decoration: none;
}

.set-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.set-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
}

.set-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.participant-list {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 12px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  font-size: 24px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.markdown-import-input {
  min-height: 220px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.column-form {
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 160px) minmax(220px, 2fr) auto;
}

.id-column-options {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(180px, 1fr);
  gap: 8px;
  align-items: end;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-field input {
  width: auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

tr.test-row-pass > td {
  background: var(--row-pass-bg);
}

tr.test-row-fail > td {
  background: var(--row-fail-bg);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.badge.fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.pass {
  background: var(--success-soft);
  color: var(--success);
}

.thumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.issue-image-cell {
  min-width: 180px;
}

.issue-image-cell input[type="file"] {
  margin-top: 8px;
  max-width: 220px;
  font-size: 12px;
}

.thumb-button {
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-alt);
}

.thumb-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--modal-backdrop);
  padding: 24px;
}

.image-modal.open {
  display: flex;
}

.image-modal img {
  max-width: min(960px, 92vw);
  max-height: 86vh;
  border-radius: 8px;
  background: var(--surface);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--modal-backdrop);
  padding: 20px;
}

.modal-card {
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h3,
.modal-header p {
  margin: 0;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
}

.info-list dt {
  color: var(--muted);
  font-size: 13px;
}

.info-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 650;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.message {
  min-height: 24px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

@media (max-width: 860px) {
  .topbar,
  .layout-grid,
  .inline-form,
  .column-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }
}
