/* ============================================================
   TextKit Design System v1.0
   All tool pages MUST use these tokens & components.
   No external fonts, no CDN, no framework. Pure CSS.
   ============================================================ */

:root {
  /* Colors — light theme */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6eb;
  --text: #1a202c;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2330;
  --border: #2a2f3d;
  --text: #e5e9f0;
  --text-muted: #94a3b8;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #23264d;
  --success-soft: #12291a;
  --danger-soft: #2d1416;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header / Nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .inner {
  max-width: 1100px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 16px;
}
.logo {
  font-weight: 800; font-size: 20px; color: var(--text);
  text-decoration: none; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px;
}
.logo .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900;
}
.site-header nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-header nav a {
  color: var(--text-muted); text-decoration: none; font-size: 14px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: all .15s;
}
.site-header nav a:hover { color: var(--text); background: var(--surface-2); }
.site-header nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 34px; height: 34px;
  cursor: pointer; font-size: 16px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 32px 20px 64px; }
main.narrow { max-width: 860px; }

.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

h1.page-title { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 8px; }
p.page-subtitle { color: var(--text-muted); font-size: 16px; margin-bottom: 28px; max-width: 640px; }
section h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 40px 0 12px; }
section h3 { font-size: 17px; font-weight: 700; margin: 24px 0 8px; }
section p, section li { color: var(--text-muted); font-size: 15px; }
section ul, section ol { padding-left: 22px; margin: 8px 0; }
section li { margin: 4px 0; }
section strong { color: var(--text); }
section a { color: var(--accent); }
article { max-width: 760px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  text-decoration: none; color: var(--text);
  transition: all .15s; display: flex; flex-direction: column; gap: 8px;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-card .icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 4px;
}
.tool-card .name { font-weight: 700; font-size: 15px; }
.tool-card .desc { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* ---------- Form controls ---------- */
textarea, input[type="text"], input[type="number"], select {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: inherit; font-size: 14px;
  transition: border-color .15s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 180px; resize: vertical; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
textarea.plain { font-family: inherit; font-size: 14px; }

label.field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 18px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.checkbox-row {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text); cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius-sm); user-select: none;
}
.checkbox-row:hover { background: var(--surface-2); }
.checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- Stats / output ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-top: 16px; }
.stat {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 14px; text-align: center;
}
.stat .value { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.stat .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.output-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; min-height: 60px;
  margin-top: 12px; max-height: 400px; overflow: auto;
}
.output-box mark { background: #fde68a; color: #1a202c; border-radius: 3px; padding: 0 2px; }
[data-theme="dark"] .output-box mark { background: #a16207; color: #fff; }
.output-box ins { background: var(--success-soft); color: var(--success); text-decoration: none; border-radius: 3px; }
.output-box del { background: var(--danger-soft); color: var(--danger); border-radius: 3px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: var(--bg); padding: 10px 20px;
  border-radius: 99px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: all .25s; z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- FAQ (SEO) ---------- */
details.faq {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px; padding: 0 16px;
}
details.faq summary {
  font-weight: 600; font-size: 15px; padding: 14px 0; cursor: pointer; color: var(--text);
}
details.faq[open] summary { color: var(--accent); }
details.faq .a { padding: 0 0 14px; }
details.faq .a p { margin: 0 0 8px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  margin-top: auto;
}
.site-footer .inner {
  max-width: 1100px; margin: 0 auto; padding: 24px 20px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.site-footer p { color: var(--text-muted); font-size: 13px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer nav a { color: var(--text-muted); font-size: 13px; text-decoration: none; }
.site-footer nav a:hover { color: var(--accent); }

@media (max-width: 640px) {
  h1.page-title { font-size: 26px; }
  .site-header nav a { padding: 5px 7px; font-size: 13px; }
  main { padding: 20px 14px 48px; }
}
