:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #eef2f0;
  --text: #18211f;
  --muted: #64716d;
  --line: #d9e1de;
  --primary: #087f73;
  --primary-strong: #05665c;
  --accent: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(20, 32, 30, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  background: var(--primary-strong);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

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

button.secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover:not(:disabled) {
  background: #e4ece8;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  letter-spacing: 0;
}

p {
  margin-bottom: 0;
  color: var(--muted);
  text-wrap: pretty;
}

.status-pill {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.status-pill.ok {
  border-color: rgba(8, 127, 115, 0.35);
  color: var(--primary-strong);
  background: #e8f4f1;
}

.status-pill.bad {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
  background: #fff0ee;
}

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

.auth-panel {
  margin-bottom: 18px;
}

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

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

.panel-heading.compact {
  margin-bottom: 14px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

label,
.wide-field {
  display: grid;
  gap: 6px;
}

label span,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(8, 127, 115, 0.7);
  box-shadow: 0 0 0 3px rgba(8, 127, 115, 0.12);
}

textarea {
  resize: vertical;
}

.wide-field {
  margin-top: 14px;
}

.actions-row,
.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.search-row input {
  flex: 1;
}

.login-notice {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 11px 12px;
}

.login-notice strong {
  color: var(--text);
  font-size: 14px;
}

.login-notice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.login-notice.ok {
  border-color: rgba(8, 127, 115, 0.35);
  background: #e8f4f1;
}

.login-notice.ok strong,
.login-notice.ok span {
  color: var(--primary-strong);
}

.login-notice.bad {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff0ee;
}

.login-notice.bad strong,
.login-notice.bad span {
  color: var(--danger);
}

.login-notice.pending {
  border-color: rgba(183, 121, 31, 0.35);
  background: #fff7e8;
}

.login-notice.pending strong,
.login-notice.pending span {
  color: var(--accent);
}

.button-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.gate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin: 0;
}

.gate-list legend {
  padding: 0 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--text);
}

.check-row input {
  width: 16px;
  height: 16px;
}

.result-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfc;
}

.result-item strong {
  font-size: 14px;
}

.result-item span {
  color: var(--muted);
  font-size: 13px;
}

.empty-line {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 10px 0;
}

.compact-list {
  margin-top: 14px;
  max-height: 220px;
}

.notice {
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
}

.log-panel {
  margin-top: 18px;
}

#logOutput {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111817;
  color: #d8e4e0;
  padding: 14px;
  white-space: pre-wrap;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar,
  .panel-heading,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-grid,
  .form-grid.two,
  .character-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .gate-list {
    grid-template-columns: 1fr;
  }

  .actions-row,
  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
