/* Data Dev Lab — shared styles. No external fonts or libraries. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c2333;
  --muted: #5b6478;
  --border: #dde1ec;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0fe;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --err: #b42318;
  --err-bg: #fef3f2;
  --warn: #92400e;
  --warn-bg: #fffaeb;
  --code-bg: #f2f4fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 35, 51, 0.05), 0 8px 24px rgba(28, 35, 51, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --surface: #1a1e2a;
    --text: #e7eaf3;
    --muted: #9aa3b8;
    --border: #2c3245;
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-soft: #232741;
    --ok: #4ade80;
    --ok-bg: #12291c;
    --err: #f87171;
    --err-bg: #331b1b;
    --warn: #fbbf24;
    --warn-bg: #332a12;
    --code-bg: #141826;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.site-head-rail {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 67px;
  pointer-events: none;
}

.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  pointer-events: auto;
  transition: width 180ms ease, padding 180ms ease, transform 180ms ease,
    border-radius 180ms ease, box-shadow 180ms ease;
}

.site-head--scrolled {
  width: min(calc(100% - 48px), 880px);
  margin: 0 auto;
  transform: translateY(10px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.site-head .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding-top: 14px;
  padding-bottom: 14px;
  transition: padding 180ms ease;
}

.site-head--scrolled .wrap {
  padding-top: 7px;
  padding-bottom: 7px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  flex: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-left: auto;
  font-size: 14.5px;
}

.site-nav a {
  color: var(--muted);
  padding: 4px 2px;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

/* ---------- layout ---------- */

main.wrap { padding-top: 30px; padding-bottom: 56px; }

.page-head { margin: 0 0 18px; }

h1 {
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lede {
  color: var(--muted);
  margin: 0;
  max-width: 72ch;
  font-size: 17px;
}

.content-section { margin-top: 44px; }

.content-section h2 {
  font-size: 21px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.content-section h3 { font-size: 17px; margin: 22px 0 8px; }

.content-section p, .content-section li { color: var(--text); max-width: 78ch; }
.content-section p { margin: 0 0 12px; }

.content-section ul, .content-section ol { padding-left: 22px; margin: 0 0 12px; }
.content-section li { margin-bottom: 6px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

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

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

.field { margin-bottom: 14px; }

.field > label, .field-label {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 6px;
}

textarea.tool-area, input.tool-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
}

textarea.tool-area { min-height: 170px; }
textarea[readonly] { background: var(--code-bg); }

textarea.tool-area:focus-visible, input.tool-input:focus-visible {
  outline-offset: 0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font: 600 14.5px/1 inherit;
  font-family: inherit;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--border); }
.btn-primary[disabled]:hover { background: var(--accent); border-color: var(--accent); }

.hint { color: var(--muted); font-size: 13.5px; margin-top: 6px; }

/* segmented radio */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.seg label {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* radio list (algorithm picker) */
.radio-list { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.radio-list label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 0;
}
.radio-list input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---------- status / results ---------- */

.status {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 14.5px;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}
.status:empty { display: none; }
.status.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.status.err { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); }
.status.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.status.info { background: var(--accent-soft); color: var(--text); }

.status .sub { color: var(--muted); }

.note {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14.5px;
  margin-top: 16px;
}

.warn-box {
  background: var(--warn-bg);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-top: 10px;
}

.digest-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.progress {
  height: 10px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 10px 0 4px;
}
.progress[hidden] { display: none; }
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

/* key/value info table */
.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  margin-top: 14px;
}
.kv th, .kv td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.kv th { color: var(--muted); font-weight: 600; white-space: nowrap; width: 1%; }
.kv td { overflow-wrap: anywhere; }

/* image preview */
.preview-box {
  margin-top: 16px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.preview-box[hidden] { display: none; }

.preview-frame {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background:
    repeating-conic-gradient(var(--code-bg) 0% 25%, transparent 0% 50%) 50% / 22px 22px;
  max-width: 100%;
  flex: none;
}
.preview-frame img {
  display: block;
  max-width: min(420px, 60vw);
  max-height: 320px;
  height: auto;
}

/* ---------- FAQ ---------- */

details.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 10px;
}
details.faq-item summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  list-style-position: outside;
}
details.faq-item[open] summary { border-bottom: 1px solid var(--border); }
details.faq-item .faq-a {
  padding: 10px 16px 14px;
  color: var(--text);
}
details.faq-item .faq-a p { margin: 0 0 8px; max-width: 78ch; }
details.faq-item .faq-a p:last-child { margin-bottom: 0; }

/* ---------- related links / footer ---------- */

.related-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.related-list a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.related-list a:hover { border-color: var(--accent); text-decoration: none; }
.related-list .rel-title { font-weight: 600; display: block; }
.related-list .rel-desc { color: var(--muted); font-size: 14px; }

.site-foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 0 34px;
  margin-top: 30px;
  color: var(--muted);
  font-size: 14px;
}
.site-foot p { margin: 0 0 8px; max-width: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

@media (max-width: 640px) {
  .site-head-rail { position: relative; height: auto; }
  .site-head--scrolled { width: auto; margin: 0; transform: none; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
  .site-head--scrolled .wrap { padding-top: 14px; padding-bottom: 14px; }
  h1 { font-size: 25px; }
  .site-head .wrap { gap: 6px 16px; }
  .site-nav { margin-left: 0; }
  .card { padding: 14px; }
  .preview-frame img { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .site-head, .site-head .wrap { transition: none; }
}
