/* ──────────────────────────────────────────────────────────────
   Tools Web3 — shared design system
   Quiet, warm-neutral, mostly monochrome. Light + dark.
   ────────────────────────────────────────────────────────────── */

:root {
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --gray1: #fbf8f1;
  --gray2: #f7f3ea;
  --gray3: #f3eee5;
  --gray4: #e8e0d3;
  --gray5: #e2d9cb;
  --gray6: #ded6c9;
  --gray7: #d0c6b6;
  --gray8: #bcb1a1;
  --gray9: #a0978c;
  --gray10: #857d76;
  --gray11: #6f6863;
  --gray12: #292524;

  --surface: #fffdfa;
  --accent: #0d6e4f;
  --accent-hover: #0a5c42;
  --accent-fg: #fffdfa;
  --accent-soft: #e4efe8;
  --accent-soft-border: #bfd9ca;

  --green-bg: #e9f2ec;  --green-border: #bfd9ca;  --green-text: #0d6e4f;
  --red-bg: #fcf0ec;    --red-border: #f0c9bf;    --red-text: #b42318;
  --amber-bg: #fbf3e0;  --amber-border: #ecd8a8;  --amber-text: #8a5a00;
  --blue-bg: #eef3f8;   --blue-border: #c9d8e8;   --blue-text: #2b5c8a;

  --shadow: 0 8px 28px rgba(41, 37, 36, .06);
  --shadow-lg: 0 16px 40px rgba(41, 37, 36, .14);
  --focus: 0 0 0 3px rgba(13, 110, 79, .22);
  --overlay: rgba(41, 37, 36, .28);
  --header-bg: rgba(251, 248, 241, .8);
  --text-gradient: linear-gradient(333deg, #57534e, #1c1917);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 12px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gray1: #09090b; --gray2: #121215; --gray3: #1d1d21; --gray4: #27272a;
    --gray5: #2f2f34; --gray6: #3a3a40; --gray7: #4a4a52; --gray8: #5e5e67;
    --gray9: #71717a; --gray10: #8b8b94; --gray11: #a1a1aa; --gray12: #fafafa;
    --surface: #18181b;
    --accent: #3d9b74; --accent-hover: #4fb086; --accent-fg: #052e1f;
    --accent-soft: #0f241b; --accent-soft-border: #1f4d38;
    --green-bg: #0f1e16; --green-border: #1f4d33; --green-text: #4cc38a;
    --red-bg: #24130f;   --red-border: #5c2420;   --red-text: #ff8f88;
    --amber-bg: #221a08; --amber-border: #4d3a0c; --amber-text: #f1c442;
    --blue-bg: #0f1a2b;  --blue-border: #1e3d66;  --blue-text: #70b8ff;
    --shadow: 0 0 0 1px var(--gray4);
    --shadow-lg: 0 0 0 1px var(--gray5), 0 16px 40px rgba(0, 0, 0, .5);
    --focus: 0 0 0 3px rgba(61, 155, 116, .35);
    --overlay: rgba(0, 0, 0, .6);
    --header-bg: rgba(9, 9, 11, .72);
    --text-gradient: linear-gradient(333deg, #a1a1aa, #fafafa);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --gray1: #09090b; --gray2: #121215; --gray3: #1d1d21; --gray4: #27272a;
    --gray5: #2f2f34; --gray6: #3a3a40; --gray7: #4a4a52; --gray8: #5e5e67;
    --gray9: #71717a; --gray10: #8b8b94; --gray11: #a1a1aa; --gray12: #fafafa;
    --surface: #18181b;
    --accent: #3d9b74; --accent-hover: #4fb086; --accent-fg: #052e1f;
    --accent-soft: #0f241b; --accent-soft-border: #1f4d38;
    --green-bg: #0f1e16; --green-border: #1f4d33; --green-text: #4cc38a;
    --red-bg: #24130f;   --red-border: #5c2420;   --red-text: #ff8f88;
    --amber-bg: #221a08; --amber-border: #4d3a0c; --amber-text: #f1c442;
    --blue-bg: #0f1a2b;  --blue-border: #1e3d66;  --blue-text: #70b8ff;
    --shadow: 0 0 0 1px var(--gray4);
    --shadow-lg: 0 0 0 1px var(--gray5), 0 16px 40px rgba(0, 0, 0, .5);
    --focus: 0 0 0 3px rgba(61, 155, 116, .35);
    --overlay: rgba(0, 0, 0, .6);
    --header-bg: rgba(9, 9, 11, .72);
    --text-gradient: linear-gradient(333deg, #a1a1aa, #fafafa);
    color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray1);
  color: var(--gray12);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; }
img, svg, canvas { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-fg); }
:focus-visible { outline: none; box-shadow: var(--focus); }

.icon {
  width: 16px; height: 16px;
  flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
.icon-sm { width: 14px; height: 14px; }

/* ── Layout ───────────────────────────────────────────────────── */
.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.container-wide { max-width: 1040px; }
main { flex: 1; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 600; text-decoration: none; letter-spacing: -.01em; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--gray10); text-decoration: none; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: color .15s;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--gray12); }

.theme-toggle {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--radius);
  border: 0; background: transparent; color: var(--gray10); cursor: pointer;
  transition: color .15s, background .15s;
}
.theme-toggle:hover { color: var(--gray12); background: var(--gray3); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: inline; }
}

.site-footer { border-top: 1px solid var(--gray4); margin-top: 96px; }
.site-footer .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; padding-bottom: 20px; flex-wrap: wrap; }
.site-footer, .site-footer a { color: var(--gray11); }
.site-footer a { text-underline-offset: 3px; text-decoration-color: var(--gray8); }
.site-footer a:hover { color: var(--gray12); }
.footer-links { display: flex; gap: 16px; }

/* ── Page heading ─────────────────────────────────────────────── */
.page { padding-top: 48px; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--gray10); text-decoration: none; margin-bottom: 32px;
  transition: color .15s, gap .15s;
}
.back:hover { color: var(--gray12); gap: 8px; }
.eyebrow { color: var(--gray10); font-size: 13px; margin-bottom: 4px; }
.title {
  font-size: 32px; line-height: 1.15; font-weight: 600; letter-spacing: -.025em;
  background: var(--text-gradient); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.title-xl { font-size: clamp(36px, 7vw, 48px); line-height: 1.05; letter-spacing: -.03em; }
.lead { color: var(--gray11); margin-top: 8px; max-width: 560px; }
.page-head { margin-bottom: 32px; }

/* ── Sections / cards ─────────────────────────────────────────── */
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 32px; }

.card {
  border: 1px solid var(--gray4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 20px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-desc { color: var(--gray11); margin-top: 2px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.divider { border: 0; border-top: 1px solid var(--gray4); margin: 20px 0; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .title { font-size: 28px; }
  .page { padding-top: 32px; }
}

/* ── Text helpers ─────────────────────────────────────────────── */
.muted { color: var(--gray11); }
.subtle { color: var(--gray10); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.break { word-break: break-all; overflow-wrap: anywhere; }
.center { text-align: center; }
.hidden { display: none !important; }
.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; }
.link { color: var(--gray12); text-underline-offset: 3px; text-decoration-color: var(--gray8); }
.link:hover { text-decoration-color: var(--gray12); }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; text-decoration: none; }
.link-arrow .icon { transition: transform .15s; }
.link-arrow:hover .icon { transform: translateX(2px); }
kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: var(--radius-sm);
  border: 1px solid var(--gray5); background: var(--gray2); color: var(--gray11);
}

/* ── Forms ────────────────────────────────────────────────────── */
.field > label, .label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--gray10); margin-top: 6px; }
.input, .textarea, .select {
  width: 100%;
  background: var(--gray2);
  border: 1px solid var(--gray4);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px; line-height: 1.5;
  color: var(--gray12);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--gray9); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--gray6); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); background: var(--surface); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red-border); }
.textarea { resize: vertical; min-height: 120px; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: 13px; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2390908c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-group { display: flex; gap: 8px; }
.input-group > .input { flex: 1; min-width: 0; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 36px; height: 36px; padding: 2px; border-radius: var(--radius);
  border: 1px solid var(--gray4); background: var(--gray2); cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--gray4);
  background: var(--gray2);
  color: var(--gray12);
  font-size: 14px; font-weight: 500; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { background: var(--gray3); border-color: var(--gray5); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--gray11); }
.btn-ghost:hover { background: var(--gray3); border-color: transparent; color: var(--gray12); }
.btn-danger { color: var(--red-text); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-border); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 42px; padding: 0 18px; }
.btn-block { width: 100%; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-color: transparent; background: transparent; color: var(--gray10); }
.btn-icon:hover { color: var(--gray12); background: var(--gray3); border-color: transparent; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Segmented control / tabs */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--gray3); border-radius: 8px;
}
.segmented button {
  border: 0; background: transparent; color: var(--gray11);
  height: 28px; padding: 0 12px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button:hover { color: var(--gray12); }
.segmented button[aria-selected="true"], .segmented button.active {
  background: var(--surface); color: var(--gray12);
  box-shadow: 0 1px 2px rgba(41,37,36,.08), 0 0 0 1px var(--gray4);
}

/* ── Feedback ─────────────────────────────────────────────────── */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--gray4); background: var(--gray2); color: var(--gray11);
  font-size: 13px;
}
.alert .icon { margin-top: 2px; }
.alert strong { color: var(--gray12); font-weight: 600; }
.alert-warn { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-text); }
.alert-warn strong { color: inherit; }
.alert-danger { background: var(--red-bg); border-color: var(--red-border); color: var(--red-text); }
.alert-danger strong { color: inherit; }
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }
.alert-success strong { color: inherit; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--gray3); color: var(--gray11); border: 1px solid var(--gray4);
}
.badge-green { background: var(--green-bg); color: var(--green-text); border-color: var(--green-border); }
.badge-red { background: var(--red-bg); color: var(--red-text); border-color: var(--red-border); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); border-color: var(--amber-border); }
.badge-blue { background: var(--blue-bg); color: var(--blue-text); border-color: var(--blue-border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.toast-region {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  background: var(--gray12); color: var(--surface);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease both;
}
.toast.leaving { animation: toast-out .2s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }

.progress { height: 4px; background: var(--gray4); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s ease; }

.empty {
  text-align: center; padding: 48px 16px; color: var(--gray10);
  border: 1px dashed var(--gray6); border-radius: var(--radius-lg);
}
.empty .icon { width: 20px; height: 20px; color: var(--gray9); margin-bottom: 8px; }
.empty-title { color: var(--gray12); font-weight: 500; }

/* ── Data display ─────────────────────────────────────────────── */
.list { border: 1px solid var(--gray4); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.list-item { padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.list-item + .list-item { border-top: 1px solid var(--gray4); }
.list-scroll { max-height: 420px; overflow: auto; }

.code {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  background: var(--gray2); border: 1px solid var(--gray4); border-radius: var(--radius);
  padding: 12px 14px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  margin: 0;
}

.stat { border: 1px solid var(--gray4); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.stat-label { font-size: 12px; color: var(--gray10); }
.stat-value { font-size: 20px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.table-wrap { border: 1px solid var(--gray4); border-radius: var(--radius-lg); overflow: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--gray10); font-size: 12px;
  padding: 10px 14px; background: var(--gray2); border-bottom: 1px solid var(--gray4);
  position: sticky; top: 0;
}
.table td { padding: 10px 14px; border-top: 1px solid var(--gray4); vertical-align: top; }
.table tr:first-child td { border-top: 0; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 32px 16px; text-align: center; cursor: pointer;
  border: 1px dashed var(--gray7); border-radius: var(--radius-lg);
  background: var(--gray2); color: var(--gray11);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--gray10); background: var(--gray3); }
.dropzone .icon { width: 20px; height: 20px; color: var(--gray10); }

.checker {
  background-color: var(--gray2);
  background-image:
    linear-gradient(45deg, var(--gray4) 25%, transparent 25%),
    linear-gradient(-45deg, var(--gray4) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--gray4) 75%),
    linear-gradient(-45deg, transparent 75%, var(--gray4) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 900;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); animation: fade .15s ease both; }
.modal-panel {
  position: relative; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--gray4); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 20px;
  animation: pop .18s cubic-bezier(.2, .8, .2, 1) both;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-desc { color: var(--gray11); margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* Menu (popover) */
.menu {
  position: fixed; z-index: 950; min-width: 160px; padding: 4px;
  background: var(--surface); border: 1px solid var(--gray4); border-radius: 8px;
  box-shadow: var(--shadow-lg); animation: pop .12s ease both;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; background: transparent; border-radius: var(--radius-sm);
  font-size: 13px; text-align: left; cursor: pointer; color: var(--gray12);
}
.menu button:hover { background: var(--gray3); }
.menu button.danger { color: var(--red-text); }

/* ── Motion ───────────────────────────────────────────────────── */
.fade-in { animation: fade-up .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Accent badge + links */
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-border); }
.link:hover, .site-footer a:hover { color: var(--accent); }
.eyebrow-accent { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 500; }
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

/* Brand logo */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { width: 22px; height: 22px; flex: none; display: block; border-radius: 6px; }
