/* RONCE Design System — Core tokens */

:root {
  /* Color — Light */
  --bg: #FAFAFA;
  --bg-elevated: #FFFFFF;
  --surface: #F4F4F3;
  --surface-2: #EEEEEC;
  --border: #E4E4E1;
  --border-strong: #D4D4D0;
  --text: #1F1F1F;
  --text-secondary: #55554F;
  --text-muted: #8A8A84;
  --text-faint: #B8B8B2;

  /* Accent — Industrial blue (muted, desaturated) */
  --accent: #2F4858;
  --accent-hover: #263A48;
  --accent-weak: #E6ECEF;
  --accent-fg: #FFFFFF;

  /* Signals */
  --signal-ok: #4A7B4E;
  --signal-warn: #A07A2E;
  --signal-err: #8E3A3A;

  /* Radius */
  --r-xs: 2px;
  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(30, 30, 30, 0.04), 0 0 0 1px rgba(30, 30, 30, 0.04);
  --shadow-2: 0 2px 6px rgba(30, 30, 30, 0.05), 0 0 0 1px rgba(30, 30, 30, 0.05);
  --shadow-3: 0 12px 32px rgba(30, 30, 30, 0.08), 0 0 0 1px rgba(30, 30, 30, 0.05);

  /* Spacing scale (4px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 48px;
  --s-10: 64px;
  --s-11: 80px;
  --s-12: 96px;
  --s-13: 128px;

  /* Type */
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --t-body: 15px;
  --t-small: 13px;
  --t-micro: 11px;

  /* Density (affects paddings) */
  --density: 1;
  --pad-y: calc(10px * var(--density));
  --pad-x: calc(14px * var(--density));

  /* Layout */
  --content-max: 1200px;
}

[data-theme="dark"] {
  --bg: #0E0F10;
  --bg-elevated: #141516;
  --surface: #181A1B;
  --surface-2: #1E2022;
  --border: #25272A;
  --border-strong: #2E3134;
  --text: #E8E8E5;
  --text-secondary: #A8A8A2;
  --text-muted: #78787A;
  --text-faint: #4E4E50;

  --accent: #7A9DB3;
  --accent-hover: #92B0C4;
  --accent-weak: #1B2328;
  --accent-fg: #0E0F10;

  --signal-ok: #8CB48E;
  --signal-warn: #C7A566;
  --signal-err: #C58B8B;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.005em;
}

/* Type system */
.t-display {
  font-size: clamp(44px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 500;
}
.t-h1 {
  font-size: clamp(36px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.028em;
  font-weight: 500;
}
.t-h2 {
  font-size: clamp(28px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.022em;
  font-weight: 500;
}
.t-h3 {
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.014em;
  font-weight: 500;
}
.t-h4 {
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.008em;
  font-weight: 500;
}
.t-body { font-size: var(--t-body); line-height: 1.55; font-weight: 400; }
.t-body-lg { font-size: 17px; line-height: 1.55; font-weight: 400; color: var(--text-secondary); }
.t-small { font-size: var(--t-small); line-height: 1.5; }
.t-micro { font-size: var(--t-micro); line-height: 1.4; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; color: var(--text-muted); }
.t-mono { font-family: var(--font-mono); font-feature-settings: 'ss02'; font-size: 12.5px; letter-spacing: -0.005em; }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* Sections & layout */
.shell {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--s-6);
}
.shell-wide { max-width: 1400px; margin: 0 auto; padding: 0 var(--s-6); }

.section { padding: var(--s-13) 0; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; }

.section-head {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--s-10);
  margin-bottom: var(--s-9);
  align-items: start;
}
.section-head .index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0;
  padding-top: 8px;
}
.section-head .kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--s-3);
  display: block;
}

/* Grid utility */
.grid { display: grid; gap: var(--s-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 900px) {
  .grid-3, .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .section-head { grid-template-columns: 1fr; gap: var(--s-3); }
}

/* Primitives */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: var(--pad-y) var(--pad-x);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface); }
.btn-ghost {
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 15px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
}
.chip-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.chip-ok { color: var(--signal-ok); }
.chip-warn { color: var(--signal-warn); }
.chip-err { color: var(--signal-err); }
.chip-accent { color: var(--accent); background: var(--accent-weak); border-color: transparent; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-6);
  box-shadow: var(--shadow-1);
}
.card-lg { padding: var(--s-7); }
.card-flat { background: var(--surface); box-shadow: none; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.003em;
}

.hr { height: 1px; background: var(--border); border: 0; margin: var(--s-8) 0; }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  color: var(--text-secondary);
}

/* Blueprint/tech motif bits */
.tick-rule {
  height: 12px;
  background-image: repeating-linear-gradient(
    to right,
    var(--border-strong) 0,
    var(--border-strong) 1px,
    transparent 1px,
    transparent 8px
  );
  background-size: 100% 6px;
  background-repeat: no-repeat;
  background-position: bottom;
}

.bp-grid {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(to right, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
}

.crosshair {
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
}
.crosshair::before, .crosshair::after {
  content: '';
  position: absolute;
  background: var(--text-faint);
}
.crosshair::before { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px); }
.crosshair::after { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-0.5px); }

/* Corner bracket */
.corner-tl, .corner-tr, .corner-bl, .corner-br {
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--text-faint);
  border-style: solid;
  border-width: 0;
}
.corner-tl { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.corner-tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.corner-bl { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
.corner-br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--surface);
}
.table td.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); }
.table tbody tr:hover { background: var(--surface); }

/* Scrollbar tidy (desktop) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Density variants */
[data-density="compact"] {
  --pad-y: 7px;
  --pad-x: 11px;
}
[data-density="airy"] {
  --pad-y: 13px;
  --pad-x: 18px;
}
[data-density="compact"] .card { padding: var(--s-5); }
[data-density="airy"] .card { padding: var(--s-8); }
[data-density="compact"] .section { padding: var(--s-11) 0; }
[data-density="airy"] .section { padding: var(--s-13) 0 var(--s-13); }

/* Radius variants */
[data-radius="sharp"] { --r-xs: 0; --r-sm: 0; --r-md: 0; --r-lg: 0; }
[data-radius="medium"] { --r-xs: 3px; --r-sm: 5px; --r-md: 7px; --r-lg: 10px; }
[data-radius="round"] { --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; }

/* Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
