/* Network: shared design system (tokens, type, controls). Light + dark. */
@font-face { font-family: 'Inter'; src: url(../fonts/inter.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url(../fonts/jetbrains-mono.woff2) format('woff2'); font-weight: 400 600; font-display: swap; }

:root {
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --radius-sm: 6px; --radius: 8px; --radius-lg: 12px; --radius-xl: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bg: #f4f4f5;
  --bg-grid: rgba(9, 9, 11, .045);
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;
  --hover: rgba(9, 9, 11, .045);
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-fg: #fafafa;
  --ring: rgba(24, 24, 27, .14);
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, .05);
  --shadow: 0 1px 2px rgba(9, 9, 11, .04), 0 4px 16px rgba(9, 9, 11, .06);
  --shadow-lg: 0 2px 6px rgba(9, 9, 11, .04), 0 18px 48px rgba(9, 9, 11, .10);
  --green: #16a34a; --green-bg: #dcfce7;
  --orange: #ea580c; --orange-bg: #ffedd5;
  --blue: #2563eb; --blue-bg: #dbeafe;
  --violet: #7c3aed; --violet-bg: #ede9fe;
  --red: #dc2626; --red-bg: #fee2e2;
  --accent-a: #f97316; --accent-b: #e11d48;

  /* code colors */
  --c-kw: #a626a4; --c-str: #50a14f; --c-num: #986801; --c-fn: #4078f2; --c-com: #a0a1a7; --c-glob: #c18401;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --bg-grid: rgba(250, 250, 250, .035);
  --surface: #0f0f11;
  --surface-2: #131316;
  --surface-3: #18181b;
  --hover: rgba(250, 250, 250, .05);
  --border: #222226;
  --border-strong: #2e2e33;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;
  --primary: #f4f4f5;
  --primary-hover: #e4e4e7;
  --primary-fg: #09090b;
  --ring: rgba(250, 250, 250, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .5), 0 24px 64px rgba(0, 0, 0, .5);
  --green: #4ade80; --green-bg: rgba(74, 222, 128, .12);
  --orange: #fb923c; --orange-bg: rgba(251, 146, 60, .12);
  --blue: #60a5fa; --blue-bg: rgba(96, 165, 250, .12);
  --violet: #a78bfa; --violet-bg: rgba(167, 139, 250, .12);
  --red: #f87171; --red-bg: rgba(248, 113, 113, .12);
  --accent-a: #fb923c; --accent-b: #f43f5e;

  --c-kw: #c678dd; --c-str: #98c379; --c-num: #d19a66; --c-fn: #61afef; --c-com: #6b7280; --c-glob: #e5c07b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; color: var(--text); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
code, pre, kbd, .mono { font-family: var(--mono); font-feature-settings: normal; }
::selection { background: color-mix(in srgb, var(--blue) 25%, transparent); }
[hidden] { display: none !important; }
.icon { flex: none; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-size: 14.5px; font-weight: 500; white-space: nowrap; user-select: none;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow-sm); }
.btn-primary:not(:disabled):hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-outline:not(:disabled):hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:not(:disabled):hover { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 7px; gap: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-left: 38px; }
.input-wrap:has(> .input-action) > .input { padding-right: 44px; }
.input-wrap > .input-action { position: absolute; right: 6px; }
.field-error { font-size: 13px; color: var(--red); }

/* ---------- custom select (replaces the browser's plain dropdown; see Net.select) ---------- */
.sel { position: relative; }
.sel-trigger {
  width: 100%; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--text); font-size: 14.5px; text-align: left; cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.sel-trigger:hover { border-color: var(--border-strong); }
.sel.open .sel-trigger, .sel-trigger:focus-visible { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.sel-label { font-weight: 500; white-space: nowrap; }
.sel-sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.sel-chev { color: var(--muted); transition: transform .25s var(--ease); }
.sel.open .sel-chev { transform: rotate(180deg); }
.sel-menu {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top center;
  transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
}
.sel.open .sel-menu { opacity: 1; visibility: visible; transform: none; }
.sel-opt { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 8px; font-size: 14.5px; cursor: pointer; user-select: none; }
.sel-opt.hl { background: var(--hover); }
.sel-opt .sel-sub { flex: 1; }
.sel-check { color: var(--text); opacity: 0; transform: scale(.7); transition: opacity .15s, transform .15s var(--ease); }
.sel-opt[aria-selected="true"] .sel-check { opacity: 1; transform: none; }
.sel-opt[aria-selected="true"] .sel-label { color: var(--text); }

/* ---------- cards, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { padding: 18px 22px 0; }
.card-head h3 { font-size: 16px; }
.card-head p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.card-body { padding: 18px 22px 22px; }
.card-sep { border-top: 1px solid var(--border); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap;
}
.badge-green { background: var(--green-bg); border-color: transparent; color: var(--green); }
.badge-orange { background: var(--orange-bg); border-color: transparent; color: var(--orange); }
.badge-blue { background: var(--blue-bg); border-color: transparent; color: var(--blue); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.dot-pulse { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* tinted icon tiles (feature tabs, menus) */
.tile { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none; }
.tile-lg { width: 40px; height: 40px; border-radius: 10px; }
.tile-dark { background: var(--primary); color: var(--primary-fg); }
.tile-green { background: var(--green-bg); color: var(--green); }
.tile-orange { background: var(--orange-bg); color: var(--orange); }
.tile-blue { background: var(--blue-bg); color: var(--blue); }
.tile-violet { background: var(--violet-bg); color: var(--violet); }
.tile-gray { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }

/* segmented control (General / Manage, modes) */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* theme toggle (sun / moon pill) */
.theme-toggle { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme-toggle button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.on { background: var(--surface-3); color: var(--text); }

/* toast */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: toast-in .25s var(--ease);
}
.toast.err .icon { color: var(--red); }
.toast.ok .icon { color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* code highlighting (shared by landing mockup + dashboard output) */
.code { font: 13px/1.7 var(--mono); color: var(--text-2); tab-size: 4; }
.code .kw { color: var(--c-kw); }
.code .str { color: var(--c-str); }
.code .num { color: var(--c-num); }
.code .fn { color: var(--c-fn); }
.code .com { color: var(--c-com); font-style: italic; }
.code .glob { color: var(--c-glob); }

/* editor pieces (dashboard tool + landing demo) */
.file-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 8px; background: var(--surface-3); font-size: 14px; color: var(--text-2); max-width: 320px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-head { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--border); }
.editor-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.editor-head .meta { font-size: 13px; color: var(--muted); }
.editor-head .actions { margin-left: auto; display: flex; gap: 6px; }
.out-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14.5px; padding: 20px; }
.out-empty .tile { margin: 0 auto 14px; }
.run-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.run-status.err { color: var(--red); }
.run-status.ok { color: var(--green); }

/* ---------- motion ---------- */
html { scroll-behavior: smooth; }
.btn:not(:disabled):active { transform: translateY(1px) scale(.985); }
/* smooth colour change when switching light/dark */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease), fill .35s var(--ease), box-shadow .35s var(--ease) !important;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade-in { from { opacity: 0; } }
/* scroll reveal: hidden only when JS is running (html.js is set in <head>) */
.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
