/* IMEI Generator — shared stylesheet. Sober neutral palette, light + dark. */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e3e3df;
  --text: #23262b;
  --muted: #767b83;
  --accent: #3c4650;
  --accent-hover: #2c343c;
  --accent-text: #f8f8f6;
  --ok: #4a7a5c;
  --warn: #9a6b3f;
  --err: #a05252;
  --ring: rgba(60, 70, 80, .35);
  --shadow: 0 1px 2px rgba(20, 24, 28, .05), 0 12px 32px -16px rgba(20, 24, 28, .18);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131518;
    --surface: #1b1e22;
    --border: #2a2e34;
    --text: #e7e8ea;
    --muted: #8d939b;
    --accent: #e7e8ea;
    --accent-hover: #ffffff;
    --accent-text: #16181b;
    --ok: #7fb894;
    --warn: #d3a76c;
    --err: #e08d8d;
    --ring: rgba(231, 232, 234, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -20px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

/* Must outrank the ID selectors below, which would otherwise
   beat the user agent's [hidden] { display: none } rule. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header / nav ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding-top: env(safe-area-inset-top);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  min-height: 58px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}

.site-header nav {
  display: flex;
  gap: 18px;
  font-size: .9rem;
}

.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--text); font-weight: 500; }

/* ---------- tool card ---------- */

main { display: block; }

.hero { padding: 30px 0 0; text-align: center; }

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.05rem + 1.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.tagline {
  margin: 8px auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(.875rem, .84rem + .2vw, .95rem);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 5vw, 26px);
  margin: 22px 0 0;
}

.label {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.field { flex: 1 1 110px; min-width: 0; }

input, textarea {
  width: 100%;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  padding: 12px 14px;
  min-height: 46px;
  transition: border-color .15s ease;
}

input:hover, textarea:hover { border-color: var(--muted); }
input[type="number"] { font-variant-numeric: tabular-nums; }

textarea {
  font-family: var(--mono);
  font-size: .95rem;
  line-height: 1.7;
  resize: vertical;
  min-height: 120px;
}

button {
  appearance: none;
  font: inherit;
  font-weight: 500;
  border-radius: 10px;
  padding: 13px 16px;
  min-height: 46px;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .06s ease;
  touch-action: manipulation;
}

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

.primary { border: 1px solid transparent; background: var(--accent); color: var(--accent-text); }
.primary:hover { background: var(--accent-hover); }

.secondary { border: 1px solid var(--border); background: transparent; color: var(--text); }
.secondary:hover { border-color: var(--muted); }

#generate, #check { flex: 1 1 150px; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.result { margin-top: 18px; }

#single {
  width: 100%;
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 14px;
  font-family: var(--mono);
  font-size: clamp(1.05rem, .82rem + 1.5vw, 1.45rem);
  font-weight: 500;
  letter-spacing: .06em;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease;
}

#list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: min(42vh, 320px);
  overflow: auto;
  cursor: pointer;
  -webkit-overflow-scrolling: touch;
}

#list pre {
  margin: 0;
  padding: 14px;
  font-family: var(--mono);
  font-size: clamp(.8125rem, .74rem + .45vw, .95rem);
  line-height: 1.75;
  letter-spacing: .04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#single:hover, #list:hover { border-color: var(--muted); }

.truncated { margin: 8px 0 0; font-size: .75rem; color: var(--muted); text-align: center; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions button { flex: 1 1 130px; }

.status {
  min-height: 1.25rem;
  margin: 12px 0 0;
  text-align: center;
  font-size: .8125rem;
  color: var(--ok);
  opacity: 0;
  transition: opacity .18s ease;
}

.status.show { opacity: 1; }
.status.is-warn { color: var(--warn); }

/* ---------- validator verdict ---------- */

.verdict { margin-top: 16px; }

.verdict-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
}

.verdict.is-ok .verdict-head { color: var(--ok); }
.verdict.is-bad .verdict-head { color: var(--err); }
.verdict p { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }

.parts {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: .875rem;
}

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

.parts th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.parts td.val { font-family: var(--mono); letter-spacing: .04em; }
.parts tr:last-child th, .parts tr:last-child td { border-bottom: 0; }

/* ---------- prose ---------- */

.prose { padding: 34px 0 0; }

.prose h2 {
  margin: 34px 0 10px;
  font-size: clamp(1.1rem, 1rem + .5vw, 1.3rem);
  font-weight: 600;
  letter-spacing: -.015em;
  scroll-margin-top: 20px;
}

.prose h2:first-child { margin-top: 0; }

.prose h3 {
  margin: 22px 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.prose p, .prose li { color: var(--text); }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }

.prose a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.prose a:hover { text-decoration-color: currentColor; }

.prose code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.6;
  margin: 0 0 14px;
}

.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.table-scroll { overflow-x: auto; margin: 0 0 16px; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 420px;
}

.prose th, .prose td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.prose thead th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.prose td.mono, .prose th.mono { font-family: var(--mono); letter-spacing: .03em; }

.note {
  border-left: 3px solid var(--border);
  padding: 2px 0 2px 14px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: .9rem;
}

.faq { margin: 0; }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 5px 0 0; color: var(--text); }

.card-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.card-links a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease;
}

.card-links a:hover { border-color: var(--muted); }
.card-links strong { display: block; font-weight: 600; font-size: .95rem; }
.card-links span { display: block; margin-top: 3px; color: var(--muted); font-size: .85rem; }

/* ---------- breadcrumbs + hub ---------- */

.crumbs {
  padding: 18px 0 0;
  font-size: .8125rem;
  color: var(--muted);
}

.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs span { margin: 0 4px; }

.crumbs + .hero { padding-top: 12px; text-align: left; }
.crumbs + .hero .tagline { margin-left: 0; }

.section-label {
  margin: 26px 0 0;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- option groups ---------- */

select {
  width: 100%;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  padding: 12px 14px;
  min-height: 46px;
  cursor: pointer;
  transition: border-color .15s ease;
}

select:hover { border-color: var(--muted); }

.opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  font-size: .875rem;
}

.opts legend { float: left; width: 100%; margin-bottom: 8px; }

.opts label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.opts input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.meta-line {
  margin: 10px 0 0;
  font-size: .8125rem;
  color: var(--muted);
  text-align: center;
}

#single { word-break: break-all; }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 46px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0 max(24px, env(safe-area-inset-bottom));
  font-size: .85rem;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 12px;
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer p { margin: 0 0 6px; max-width: 62ch; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 0;
  z-index: 10;
}

.skip-link:focus { left: 0; }
