:root {
  color-scheme: dark;
  --bg: #0f1724;
  --panel: #162235;
  --border: #2a3f5f;
  --text: #e8eef8;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  padding: 1.25rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.app-main {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1400px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.hint code {
  color: var(--accent);
  font-size: 0.85em;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

.button-row,
.list-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

button {
  background: var(--accent);
  color: #041018;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.08);
}

.status {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.length-group {
  margin-bottom: 1.25rem;
}

.length-group h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: var(--accent);
}

.results-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.result-column {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.result-column:last-child {
  border-right: none;
}

.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.column-head h4 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

button.copy-col {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.column-body {
  max-height: 420px;
  overflow: auto;
}

.select-hint {
  margin: 0 0 0.75rem;
}

.select-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  user-select: text;
  font-size: 0.9rem;
}

.select-table td {
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: baseline;
}

.select-table td.word-cell {
  width: 58%;
  font-weight: 500;
}

.select-table td.score-cell {
  width: 42%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.select-table tr:last-child td {
  border-bottom: none;
}

button.copy-col {
  user-select: none;
}

.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.word-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
}

.word-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.word-list button {
  background: transparent;
  color: var(--danger);
  padding: 0.15rem 0.4rem;
  font-size: 0.85rem;
}

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

  .result-column {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .result-column:last-child {
    border-bottom: none;
  }
}

@media (min-width: 901px) {
  .app-main {
    grid-template-columns: minmax(280px, 360px) 1fr;
  }

  .solver-panel {
    grid-row: span 2;
  }

  .lists-panel {
    grid-column: 1 / -1;
  }
}
