:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #64708a;
  --accent: #3b6cf6;
  --accent-hover: #2f57d4;
  --border: #e3e8f2;
  --ok: #14915f;
  --ok-bg: #e5f7ef;
  --no: #c4383f;
  --no-bg: #fdecec;
  --chip-bg: #eef2fb;
  --shadow: 0 1px 3px rgb(20 30 60 / 6%), 0 8px 24px rgb(20 30 60 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141d;
    --card: #181e2b;
    --text: #e8ecf5;
    --muted: #8d97ad;
    --accent: #5b85ff;
    --accent-hover: #7699ff;
    --border: #262e40;
    --ok: #3ecf8e;
    --ok-bg: #12291f;
    --no: #ff7b81;
    --no-bg: #33191b;
    --chip-bg: #212a3d;
    --shadow: 0 1px 3px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

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

header, main, footer {
  max-width: 720px;
  margin: 0 auto;
}

header { text-align: center; margin-bottom: 2rem; }

.lang-switch {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.lang-switch button {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.lang-switch button:hover { background: var(--chip-bg); }
.lang-switch button.active,
.lang-switch button.active:hover { color: #fff; background: var(--accent); }

h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
}

.coverage { margin: 0; color: var(--muted); font-size: 0.95rem; }

main { display: grid; gap: 1.25rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.fields { display: flex; flex-wrap: wrap; gap: 0.75rem; flex: 1; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
  min-width: 130px;
}

input {
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

button {
  padding: 0.6rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: wait; }

.result {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.result .meta { color: var(--muted); margin: 0 0 0.5rem; }

.result .error { color: var(--no); margin: 0; }

.verdict {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
}

.verdict.yes { color: var(--ok); background: var(--ok-bg); }
.verdict.no  { color: var(--no); background: var(--no-bg); }

.result-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.result-head .meta { margin: 0; }

a.download {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 9px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

a.download:hover { color: #fff; background: var(--accent); }

.prime-text {
  margin: 0;
  padding: 0.75rem 1rem;
  max-height: 340px;
  overflow-y: auto;
  background: var(--chip-bg);
  border-radius: 10px;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.prime-text > div {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

.prime-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.prime-grid span {
  padding: 0.2rem 0.55rem;
  background: var(--chip-bg);
  border-radius: 7px;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
}

.neighbors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.neighbor {
  flex: 1;
  min-width: 150px;
  padding: 0.75rem 1rem;
  background: var(--chip-bg);
  border-radius: 10px;
  text-align: center;
}

.neighbor .label { display: block; font-size: 0.8rem; color: var(--muted); }

.neighbor .value {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  font-size: 1.25rem;
  font-weight: 600;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--accent);
  background: transparent;
  border-color: var(--accent);
}

.copy-btn.done,
.copy-btn.done:hover {
  color: var(--ok);
  border-color: var(--ok);
}

footer {
  margin-top: 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

footer code {
  background: var(--chip-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
}
