:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1d1d1f;
  --muted: #5c5f66;
  --border: #dcdcd6;
  --border-strong: #c4c4bd;
  --accent: #1f6f5c;
  --accent-hover: #185a4a;
  --accent-soft: #e3f1ec;
  --on-accent: #ffffff;
  --ok: #1a7a43;
  --ok-soft: #e5f4ea;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 12px rgba(0, 0, 0, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "BIZ UDGothic", "Cascadia Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141516;
    --surface: #1c1e20;
    --surface-2: #25282b;
    --text: #e8e8e6;
    --muted: #a3a7ad;
    --border: #33363a;
    --border-strong: #474b50;
    --accent: #5cc4a6;
    --accent-hover: #7fd4bb;
    --accent-soft: #1d3832;
    --on-accent: #0c1f1a;
    --ok: #74d39c;
    --ok-soft: #163322;
    --err: #ff8f85;
    --err-soft: #3b1c1a;
    --focus: #7aa7ff;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

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

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 10; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.brand img { display: block; }
.lang-switch a { font-size: 14px; color: var(--muted); text-decoration: none; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
.lang-switch a:hover { color: var(--text); border-color: var(--border-strong); }

.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; }
.footer-inner { padding-top: 24px; padding-bottom: 32px; }
.footer-inner p { margin: 6px 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 10px; }
.footer-links a { color: var(--muted); }

/* Headings and text */
h1, h2, h3 { line-height: 1.35; letter-spacing: .01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0; font-size: 1.05rem; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); margin: 20px 0 12px; }
.crumbs a { color: var(--muted); }
.page-head { margin-bottom: 20px; }

/* Home */
.hero { padding: 40px 0 16px; }
.badges { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 18px 0 0; }
.badges li { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 12px; border-radius: 999px; }
.cat { margin-top: 32px; }
.cat h2 { font-size: 1.1rem; color: var(--muted); margin: 0 0 12px; }
.tool-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card { display: block; height: 100%; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.tool-card-title { display: block; font-weight: 700; margin-bottom: 4px; }
.tool-card-desc { display: block; font-size: 14px; color: var(--muted); line-height: 1.6; }

/* Tool card and controls */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.tool > * + * { margin-top: 16px; }
.tool h2 { font-size: 1.05rem; margin: 0; }
.tool .sub + .sub { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; }
.sub > * + * { margin-top: 12px; }

.field label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-row label { margin: 0; }

textarea, input[type="text"], input[type="number"], input[type="datetime-local"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 8rem; line-height: 1.6; }
textarea.mono, input.mono, .mono { font-family: var(--mono); font-size: 14px; }
textarea[readonly] { background: var(--surface-2); }
select { width: auto; padding-right: 28px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.toolbar .spacer { flex: 1; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin: 0; }
.inline select { padding-top: 6px; padding-bottom: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; border: 0; padding: 0; margin: 0; }
.checks legend, .segmented legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; float: left; width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 16px; min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.small { padding: 4px 12px; min-height: 30px; font-size: 13px; }
.btn.is-done { border-color: var(--ok); color: var(--ok); }

.segmented { display: inline-flex; flex-wrap: wrap; border: 0; padding: 0; margin: 0; }
.segmented .seg-options { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 16px; font-size: 14px; font-weight: 600; color: var(--muted); background: var(--surface); }
.segmented label + label span { border-left: 1px solid var(--border-strong); }
.segmented input:checked + span { background: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }

.status { margin: 0; min-height: 1.75em; font-size: 14px; font-weight: 600; }
.status.is-ok { color: var(--ok); }
.status.is-err { color: var(--err); }
.error-box { color: var(--err); background: var(--err-soft); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 14px; font-weight: 600; margin: 0; }
.error-box:empty { display: none; }

/* Result displays */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.stats > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stats > div.primary { background: var(--accent-soft); }
.stats > div.primary dd { color: var(--accent); }

.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 12em 1fr; gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { font-size: 14px; color: var(--muted); }
.kv dd { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.kv dd > span { font-family: var(--mono); font-size: 15px; word-break: break-all; }
.kv-tz { color: var(--muted); font-size: 12px; }

.now { display: flex; flex-wrap: wrap; gap: 10px; }
.now > div { flex: 1 1 220px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.now .label { margin: 0; color: var(--muted); font-weight: 400; font-size: 13px; }
.now output { display: block; font-family: var(--mono); font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.privacy-note { font-size: 14px; color: var(--muted); margin: 12px 0 0; padding-left: 22px; position: relative; }
.privacy-note::before { content: ""; position: absolute; left: 2px; top: .45em; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); opacity: .8; }

.inline input[type="number"] { width: 6.5em; padding-top: 6px; padding-bottom: 6px; }
.label-inline { font-size: 14px; font-weight: 600; color: var(--muted); }
.pre { white-space: pre-wrap; }
.file-btn { cursor: pointer; }
.file-name { font-size: 13px; color: var(--muted); }
input[type="color"] { width: 46px; height: 42px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex: none; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input[type="text"] { flex: 1; min-width: 0; }

details.more { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.table-scroll { max-height: 420px; overflow: auto; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { border-bottom: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
table.data td.mono { word-break: break-all; }

.swatch { height: 88px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.contrast-preview { border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 16px 18px; }
.contrast-preview .big { font-size: 24px; font-weight: 700; margin: 0; }
.contrast-preview p { margin: 4px 0 0; }
.ratio { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.badges-row { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.badge.pass { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--err-soft); color: var(--err); }

/* Article */
.prose { margin-top: 48px; }
.prose h2 { font-size: 1.3rem; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.05rem; margin: 28px 0 8px; }
.prose p, .prose li, .prose dd { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose dl dt { font-weight: 700; margin-top: 14px; }
.prose dl dd { margin: 2px 0 0; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 12px 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.page { margin-top: 32px; }
.page h1 { margin-bottom: 4px; }

.related { margin-top: 48px; }
.related h2 { font-size: 1.1rem; }
.related-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 20px; }
.related-list li { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--border); }
.related-list span { font-size: 13px; color: var(--muted); }

/* Root language chooser and 404 */
.root-choice { text-align: center; padding-top: 18vh; padding-bottom: 18vh; }
.root-choice img { margin-bottom: 12px; }
.lang-choice { list-style: none; padding: 0; margin: 28px 0 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }

@media (max-width: 560px) {
  .card { padding: 16px; }
  .kv > div { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats dd { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tool-card { transition: none; }
  .tool-card:hover { transform: none; }
}
