/* ============ ToolStack design system ============ */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #0f172a;
  --muted: #5b6b82;
  --border: #dde5ef;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-2: #7c3aed;
  --good: #059669;
  --bad: #dc2626;
  --fair: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 30px -12px rgba(15, 23, 42, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a111f;
    --surface: #111a2e;
    --surface-2: #18233c;
    --text: #e2e8f0;
    --muted: #8fa1bd;
    --border: #223051;
    --accent: #3b82f6;
    --accent-strong: #60a5fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono, .mono-output { font-family: var(--mono); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ header ============ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }

.logo-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.logo-mark svg { width: 18px; height: 18px; }

.logo-text {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.site-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

.lang-switch {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.lang-btn {
  padding: 5px 11px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent); color: #fff; }

/* ============ hero ============ */

.hero {
  padding: 64px 0 40px;
  text-align: center;
  background:
    radial-gradient(600px 240px at 20% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    radial-gradient(600px 240px at 80% -10%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent);
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.hero-sub { max-width: 560px; margin: 0 auto 26px; font-size: 1.05rem; }

.searchbox { max-width: 480px; margin: 0 auto; }
.searchbox input {
  width: 100%;
  padding: 13px 18px;
  font-size: 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  outline: none;
}
.searchbox input:focus { border-color: var(--accent); }

/* ============ cards & grids ============ */

.cat-section { padding: 26px 0 8px; }
.cat-section h2 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cat-section h2::before {
  content: "";
  width: 4px;
  height: 22px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}

.tool-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }

.card-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--accent);
}
.card-icon svg { width: 22px; height: 22px; }

.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-body strong { font-size: 0.98rem; line-height: 1.3; }
.card-body span { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }

.feature-cards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.feature-card { padding: 18px; }
.feature-card strong { display: block; margin-bottom: 6px; font-size: 1rem; }
.feature-card span { color: var(--muted); font-size: 0.9rem; }

/* ============ tool page ============ */

.breadcrumb { padding: 18px 0 0; font-size: 0.85rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 6px; }

.tool-hero { padding: 18px 0 6px; }
.tool-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  letter-spacing: -0.02em;
}
.tool-hero p { margin: 0; max-width: 700px; }

.tool-wrap { padding: 22px 0 10px; }

.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px;
  margin: 0 0 18px;
}
.panel legend {
  padding: 2px 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-strong);
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 14px 0 10px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; min-width: 0; }
.field label { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.field output { font-weight: 700; color: var(--text); }

input[type="text"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input.invalid { border-color: var(--bad); }
textarea { resize: vertical; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"].color-input { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 18px;
  margin: 8px 0 12px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-ghost {
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: 0.8rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.chips { display: flex; gap: 8px; margin: 10px 0; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  padding: 7px 14px;
  font-size: 0.87rem;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin-bottom: 6px; }
.segmented .seg {
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
}
.segmented .seg.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18); }

/* results */
.result { margin: 14px 0 4px; font-size: 1.02rem; }
.result strong { color: var(--accent-strong); font-size: 1.15em; font-variant-numeric: tabular-nums; }

.result-box {
  margin-top: 16px;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.big-stat { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.stat-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.big-stat strong { font-size: clamp(1.6rem, 3vw, 2.1rem); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat span { font-size: 0.8rem; color: var(--muted); }
.stat strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat strong[data-state="good"] { color: var(--good); }
.stat strong[data-state="bad"] { color: var(--bad); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stat-card strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat-card span { font-size: 0.8rem; color: var(--muted); }

/* ratio bar (loan) */
.ratio-bar { height: 10px; margin-top: 14px; background: color-mix(in srgb, var(--accent-2) 35%, var(--surface)); border-radius: 999px; overflow: hidden; }
.ratio-bar .ratio-a { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.2s ease; }

/* bmi scale */
.bmi-scale {
  position: relative;
  display: flex;
  height: 14px;
  margin-top: 16px;
  border-radius: 999px;
  overflow: hidden;
  font-size: 0;
}
.bmi-scale .bs { flex: 1; }
.bs.uw { background: #60a5fa; width: 17.3%; }
.bs.nw { background: #34d399; width: 25%; }
.bs.ow { background: #fbbf24; width: 23%; }
.bs.ob { background: #f87171; flex: 1; }
.bmi-marker {
  position: relative;
  width: 0; height: 0;
  margin-top: -22px;
  transition: left 0.25s ease;
}
.bmi-marker::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 0;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  background: var(--text);
  border: 2px solid var(--surface);
  border-radius: 3px;
}

/* strength bar (password) */
.strength { height: 8px; margin-top: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.strength-bar { height: 100%; width: 0; background: var(--bad); transition: width 0.2s ease, background 0.2s ease; }
.strength-bar[data-state="fair"] { background: var(--fair); }
.strength-bar[data-state="good"] { background: var(--good); }
.strength-bar[data-state="great"] { background: linear-gradient(90deg, #059669, #10b981); }

/* output rows */
.output-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin-top: 8px; }
.output-row .mono-output { flex: 1 1 220px; min-height: 46px; }
.mono-output { font-size: 0.95rem; letter-spacing: 0.02em; }

.inline-calc { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.inline-calc .field { flex: 1 1 130px; margin-bottom: 0; }
.math-x { font-weight: 700; color: var(--muted); padding-bottom: 12px; }

/* unit converter */
.convert-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto 1.4fr;
  gap: 12px;
  align-items: end;
}
.swap-col { display: flex; padding-bottom: 4px; }
.convert-grid .field { margin-bottom: 0; }
@media (max-width: 640px) {
  .convert-grid { grid-template-columns: 1fr 1fr; }
  .swap-col { justify-content: center; width: 100%; order: 3; }
}

/* color converter */
.swatch { height: 84px; margin: 12px 0; border-radius: 12px; border: 1px solid var(--border); background: #888; transition: background 0.15s ease; }
.color-outputs { margin-top: 4px; }
.color-outputs .stat { gap: 6px; }
.color-outputs .btn-copy { align-self: flex-end; }

/* qr */
.qr-preview {
  display: grid;
  place-items: center;
  min-height: 300px;
  margin-top: 12px;
  padding: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}
.qr-preview svg { max-width: 100%; height: auto; }

/* dropzone */
.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 36px 20px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.dropzone p { margin: 0; }

.ic-compare { margin-top: 12px; }
.ic-pane { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ic-pane img { max-width: min(420px, 100%); border: 1px solid var(--border); border-radius: 10px; background: #fff; }

/* prose sections */
.prose { padding: 26px 0 6px; max-width: 760px; }
.prose h1 { letter-spacing: -0.02em; margin: 0 0 10px; }
.prose h2 { font-size: 1.4rem; letter-spacing: -0.01em; margin: 0 0 12px; }
.prose h3 { font-size: 1.08rem; margin: 20px 0 8px; }
.prose p, .prose ul { color: var(--muted); }
.prose li { margin: 6px 0; }
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.prose strong { color: var(--text); }

.prose details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 18px;
  margin-bottom: 10px;
}
.prose details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 14px 0;
  list-style-position: outside;
}
.prose details summary:hover { color: var(--accent); }
.prose details p { margin: 0 0 16px; padding-right: 8px; }

.home-prose { max-width: none; }
.home-prose h2 { margin-top: 30px; }
.static-prose { max-width: 720px; }

.related { padding: 30px 0 20px; }
.related h2 { font-size: 1.3rem; margin: 0 0 14px; }

.contact-card { padding: 20px; margin: 18px 0 26px; }
.contact-card p { margin: 0 0 8px; }

/* ============ footer ============ */

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1fr;
  gap: 28px;
  padding: 36px 20px 20px;
}
.footer-brand { font-weight: 800; font-size: 1.1rem; margin: 0 0 8px; }
.footer-h { font-weight: 700; margin: 0 0 10px; font-size: 0.92rem; }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin: 0 0 7px; }
.site-footer a { display: inline-block; margin: 0 0 7px; color: var(--muted); font-size: 0.9rem; }
.site-footer a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 16px; padding-bottom: 20px; }
.footer-bottom p { margin: 0; }

@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* ============ misc ============ */

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto; }
}
