/* ==========================================================================
   DevToolBox — shared stylesheet
   Clean, neutral, light theme. System font stack, no external resources.
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e2e5ea;
  --border-strong: #d4d9e0;
  --text: #1c2430;
  --muted: #5c6673;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #e8effc;
  --success: #15803d;
  --success-bg: #e9f7ef;
  --danger: #dc2626;
  --danger-bg: #fdecec;
  --warn: #b45309;
  --warn-bg: #fdf3e3;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 74px; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { vertical-align: middle; }

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

::selection { background: var(--accent-soft); }

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

.container.narrow { max-width: 820px; }

/* ---- Header ------------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

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

.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 7px;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-nav a[aria-current] { color: var(--accent-dark); }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.05); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.btn-row .spacer { flex: 1 1 auto; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Cards / panels ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { margin: 16px 0; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.panel-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}
.panel-label .req { color: var(--danger); }

/* ---- Form fields ------------------------------------------------------- */
.field { margin: 14px 0; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); }

textarea.input,
input.input,
select.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
textarea.input { display: block; resize: vertical; }
textarea.code, input.code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  tab-size: 2;
}
textarea.input:focus, input.input:focus, select.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="range"] { width: 100%; accent-color: var(--accent); }

.field-grid { display: grid; gap: 14px; }
.field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .field-grid.cols-2, .field-grid.cols-3 { grid-template-columns: 1fr; }
}

.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 4px 0; }
.checks label { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; font-size: 14.5px; cursor: pointer; margin: 0; }
.checks input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  flex-wrap: wrap;
}
.seg button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-selected="true"]:hover { background: var(--accent-soft); }

/* ---- Messages ---------------------------------------------------------- */
.msg {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin: 10px 0;
  border: 1px solid transparent;
}
.msg.ok   { background: var(--success-bg); color: var(--success); border-color: #cfeadd; }
.msg.err  { background: var(--danger-bg);  color: var(--danger);  border-color: #f4cccc; }
.msg.warn { background: var(--warn-bg);    color: var(--warn);    border-color: #f0dfc0; }
.msg .mono { font-family: var(--mono); word-break: break-word; }

/* ---- Output ------------------------------------------------------------ */
.output {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
  word-break: break-word;
}
.output.ok { border-color: #cfeadd; }
.output.err { border-color: #f4cccc; }

.kv { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.kv th { width: 32%; color: var(--muted); font-weight: 600; }
.kv td { font-family: var(--mono); font-size: 13.5px; word-break: break-word; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }

/* ---- Tabs -------------------------------------------------------------- */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---- Regex preview ----------------------------------------------------- */
.regex-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 40px;
}
.regex-preview mark {
  background: #fde68a;
  color: #451a03;
  border-radius: 3px;
  padding: 0 1px;
}
.regex-preview mark.m-group-1 { background: #bfdbfe; }
.regex-preview mark.m-group-2 { background: #a7f3d0; }
.regex-preview mark.m-group-3 { background: #ddd6fe; }

/* ---- Diff -------------------------------------------------------------- */
.diff { font-family: var(--mono); font-size: 13px; line-height: 1.6; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.diff .drow { display: flex; }
.diff .drow .dno {
  flex: 0 0 46px;
  text-align: right;
  color: #9aa3ad;
  padding: 1px 10px 1px 4px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  user-select: none;
}
.diff .drow .dtext { padding: 1px 12px; white-space: pre-wrap; word-break: break-word; flex: 1; }
.diff .add { background: var(--success-bg); }
.diff .add .dtext::before { content: "+"; color: var(--success); font-weight: 700; margin-right: 8px; }
.diff .del { background: var(--danger-bg); }
.diff .del .dtext::before { content: "−"; color: var(--danger); font-weight: 700; margin-right: 8px; }
.diff .ctx .dtext { color: var(--muted); }

.stat-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.chip {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.chip b { font-weight: 700; }
.chip.add { background: var(--success-bg); color: var(--success); border-color: #cfeadd; }
.chip.del { background: var(--danger-bg); color: var(--danger); border-color: #f4cccc; }

/* ---- Password ---------------------------------------------------------- */
.pw-output {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}
.pw-output input {
  flex: 1;
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: .02em;
  padding: 12px 14px;
}
.pw-output .btn { padding: 12px 16px; }

.meter { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-top: 4px; }
.meter > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--success); transition: width .2s ease; }
.meter-label { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---- Timestamp live clock --------------------------------------------- */
.nowline { font-family: var(--mono); font-size: 13.5px; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; border: 1px solid var(--border); }

/* ---- Content typography ------------------------------------------------ */
.page-hero { padding: 34px 0 8px; }
.page-hero h1 { font-size: 30px; line-height: 1.25; margin: 6px 0 8px; letter-spacing: -.02em; }
.page-hero .lead { font-size: 17px; color: var(--muted); max-width: 60ch; margin: 0; }
@media (max-width: 640px) { .page-hero h1 { font-size: 25px; } }

.breadcrumb { font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 6px; color: #b6bdc6; }

.tool-zone { margin: 22px 0 8px; padding: 18px; }
.tool-zone .panel { margin-top: 4px; }

.content h2 { font-size: 21px; margin: 34px 0 10px; letter-spacing: -.01em; }
.content h3 { font-size: 17px; margin: 24px 0 8px; }
.content p, .content li { color: #333d4a; }
.content p { margin: 12px 0; }
.content ul, .content ol { padding-left: 22px; margin: 12px 0; }
.content li { margin: 6px 0; }
.content code, .content p code, .content li code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.content pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}
.content .note {
  background: var(--accent-soft);
  border: 1px solid #cfe0f9;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin: 14px 0;
}
.content .note.warn { background: var(--warn-bg); border-color: #f0dfc0; color: var(--warn); }
.content .note.ok { background: var(--success-bg); border-color: #cfeadd; color: var(--success); }

/* ---- FAQ --------------------------------------------------------------- */
.faq { margin: 8px 0 10px; }
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 10px 0;
  padding: 2px 0;
}
.faq details[open] { box-shadow: var(--shadow); }
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 16px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: 20px;
  color: var(--muted);
  font-weight: 400;
  transition: transform .15s ease;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0; padding: 2px 16px 14px; color: #333d4a; }

/* ---- Home tool grid ---------------------------------------------------- */
.home-hero { text-align: center; padding: 46px 0 8px; }
.home-hero h1 { font-size: 34px; letter-spacing: -.02em; margin: 0 0 10px; }
.home-hero .lead { font-size: 18px; color: var(--muted); max-width: 60ch; margin: 0 auto; }
@media (max-width: 640px) { .home-hero h1 { font-size: 27px; } }

.home-search { max-width: 560px; margin: 22px auto 0; }
.home-search input { text-align: center; }

.cat { margin: 34px 0; }
.cat h2 { font-size: 20px; margin: 0 0 6px; }
.cat .cat-desc { color: var(--muted); font-size: 14.5px; margin: 0 0 16px; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.tool-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-1px); }
.tool-card .t-ico {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 20px;
  margin-bottom: 12px;
}
.tool-card .t-name { font-weight: 700; font-size: 16px; color: var(--text); margin: 0 0 4px; }
.tool-card .t-desc { font-size: 14px; color: var(--muted); margin: 0; flex: 1; }
.tool-card .t-go { margin-top: 12px; font-size: 13.5px; font-weight: 600; color: var(--accent); }

/* Home content intro */
.home-about { margin: 30px 0; }
.home-about .content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; }
.home-about .content h2 { margin-top: 8px; }

/* ---- Ad slot ----------------------------------------------------------- */
.ad-slot { display: none; margin: 18px 0; min-height: 90px; }
.ad-slot[data-visible="true"] { display: block; }
.ad-slot .ad-note { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #b6bdc6; text-align: center; margin-bottom: 6px; }

/* ---- Footer ------------------------------------------------------------ */
.site-footer { background: #111827; color: #c7cdd6; margin-top: 60px; font-size: 14px; }
.site-footer a { color: #e2e8f0; }
.site-footer a:hover { color: #fff; }
.foot-main { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 26px; padding: 34px 0 10px; }
@media (max-width: 760px) { .foot-main { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .foot-main { grid-template-columns: 1fr; } }
.foot-col h4 { color: #fff; font-size: 14px; margin: 0 0 10px; letter-spacing: .02em; }
.foot-col p { margin: 0 0 10px; line-height: 1.6; }
.foot-col ul { list-style: none; margin: 0; padding: 0; }
.foot-col li { margin: 6px 0; }
.foot-col li a { font-size: 13.5px; }
.foot-bottom { border-top: 1px solid #1f2937; padding: 16px 0; margin-top: 18px; }
.foot-bottom .container { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between; color: #8b95a1; font-size: 13px; }

/* ---- Toast ------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 10px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Language switch ---------------------------------------------------- */
.lang-switch {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.lang-switch:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }

/* ---- 404 --------------------------------------------------------------- */
.notfound { text-align: center; padding: 70px 0 50px; }
.notfound .code { font-size: 90px; font-weight: 800; color: var(--border-strong); line-height: 1; }
.notfound h1 { font-size: 26px; }

/* ---- Utility ----------------------------------------------------------- */
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
small, .small { font-size: 13px; color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* JSON syntax highlighting (used by formatter / converter / JWT output) */
.j-key { color: #6d28d9; font-weight: 600; }
.j-str { color: #047857; }
.j-num { color: #1d4ed8; }
.j-lit { color: #b45309; font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}
