:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --fg: #1f2933;
  --accent: #2563eb;
  --muted: #6b7280;
  --border: #d1d5db;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

header {
  background: var(--card-bg);
  padding: 1.5rem 1.5rem 0;
  border-bottom: none;
}

header h1 {
  margin: 0 0 0.25rem 0;
}

.tabs {
  margin-top: 1rem;
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 1rem;
}

.tabs .tab {
  border: none;
  border-radius: 0;
  background: none;
  color: var(--muted);
  padding: 0.75rem 0;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tabs .tab.active {
  color: var(--accent);
  border-color: var(--accent);
}

.tabs .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main {
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

footer {
  max-width: 1100px;
  margin: 2rem auto 3rem;
  padding: 0 1.5rem;
  display: flex;
  justify-content: flex-end;
}

footer button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.95rem;
}

footer button.active {
  color: var(--accent);
}

.view {
  display: none;
}

.view.visible {
  display: block;
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  max-width: 100%;
  flex: 1 1 260px;
}

.controls label span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

select {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  min-width: 0;
  width: 100%;
}

button {
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.panel-info {
  margin-bottom: 1rem;
  color: var(--muted);
}

.card-list {
  display: grid;
  gap: 0.75rem;
}

.card-list button,
.card-list .option {
  text-align: left;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(37, 99, 235, 0.08);
  color: inherit;
  transition: transform 0.1s ease;
}

.card-list button:hover,
.card-list button:focus {
  transform: translateY(-2px);
}

.numeric-character {
  display: grid;
  gap: 0.75rem;
}

.numeric-range {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.numeric-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.numeric-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
}

.numeric-form input {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  min-width: 120px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(255,255,255,0.7);
  margin-bottom: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.result {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(34,197,94,0.1);
  display: none;
}

.result.visible {
  display: block;
}

.result h3 {
  margin-top: 0;
}

#status {
  min-height: 1.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

code {
  background: rgba(15,23,42,0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 0.35rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --fg: #f8fafc;
    --accent: #38bdf8;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.3);
    --card-bg: rgba(15, 23, 42, 0.85);
  }

  .card-list button,
  .card-list .option {
    background: rgba(56, 189, 248, 0.12);
  }

  .card {
    background: rgba(15,23,42,0.65);
  }
}
