/* ============================================================
   36nine Design Hub : component layer
   Built on tokens.css (the canonical 36nine design system).
   Square geometry, corner brackets, notched badges, hairline
   borders, Exo 2. No pills, no rounded cards, no colored shadows.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg-muted);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.appbar {
  height: 64px; flex: 0 0 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-8);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brandlock { display: flex; align-items: center; gap: var(--space-3); }
.brandmark {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-creation); color: #fff;
}
.brandmark svg { width: 20px; height: 20px; }
.brandtext { display: flex; flex-direction: column; line-height: 1.05; }
.brandtext .name { font-size: var(--text-lg); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); }
.brandtext .sub { font-size: 10px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--fg-subtle); }

.appmeta { display: flex; align-items: center; gap: var(--space-8); }
.metacol { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.metacol .k { font-size: 9px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--fg-muted); }
.metacol .v { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--fg); }

.main { flex: 1; padding: var(--space-8); overflow: auto; }
.wrap { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }

.footer {
  height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-8);
  background: var(--bg); border-top: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--fg-muted);
}

/* ---------- Framed card + corner brackets ---------- */
.card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: var(--space-6);
  display: flex; flex-direction: column;
}
.card::before, .card::after, .card > .c1, .card > .c2 {
  content: ""; position: absolute; width: 8px; height: 8px;
  border: 1.5px solid var(--fg); pointer-events: none; z-index: 2;
}
.card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.card::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.card > .c1   { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.card > .c2   { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ---------- Surfaces (the named container set) ----------
   One menu of containers, each with one job. Do not invent frames outside this set.
   - .surface            plain hairline. The default container for dense content.
   - .surface--framed    L-shaped corner brackets. The signature, reserved for
                         primary / hero / branded surfaces only (needs .c1 + .c2 spans).
                         (.card is the legacy alias of the framed surface.)
   - .surface--elevated  hairline + restrained shadow. For lifted things (modals, menus).
   - .surface--solid     filled deep navy. For emphasis, code, dark callouts.
   - .surface--dashed    dashed hairline. For empty states and "nothing yet" placeholders. */
.surface { position: relative; background: var(--bg); border: 1px solid var(--border); }
.surface--framed::before, .surface--framed::after, .surface--framed > .c1, .surface--framed > .c2 {
  content: ""; position: absolute; width: 8px; height: 8px; border: 1.5px solid var(--fg); pointer-events: none; z-index: 2;
}
.surface--framed::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.surface--framed::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.surface--framed > .c1   { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.surface--framed > .c2   { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.surface--elevated { box-shadow: var(--shadow-md); }
.surface--solid { background: var(--brand-secondary); color: #E9EEF5; border-color: var(--brand-secondary); }
.surface--solid .card-sub, .surface--solid .caption { color: #9FB3C8; }
.surface--dashed { border-style: dashed; border-color: var(--border-strong); }

/* .card keeps its padding + flex but drops the corner brackets: a plain padded card.
   Use where a container needs card layout but is not a primary surface. */
.card--plain::before, .card--plain::after, .card--plain > .c1, .card--plain > .c2 { display: none; }

.card-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.card-title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.card-title.big { font-size: var(--text-xl); text-transform: none; letter-spacing: var(--tracking-tight); }
.card-sub { font-size: var(--text-xs); color: var(--fg-subtle); line-height: var(--lh-normal); margin-top: 4px; }

/* Vertical accent marker */
.marker { width: 2px; height: 13px; background: var(--brand-creation); display: inline-block; flex: 0 0 auto; }

/* ---------- Eyebrow / labels ---------- */
.eyebrow { font-size: 10px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--fg-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, monospace; }
.idx { font-family: ui-monospace, SFMono-Regular, monospace; font-size: var(--text-xs); color: var(--fg-muted); padding-right: var(--space-2); margin-right: var(--space-2); border-right: 1px solid var(--border); }

/* ---------- Badge (notched, one shape) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-wide); text-transform: uppercase;
  padding: 3px 10px; background: var(--bg-muted); color: var(--fg); border: 1px solid var(--border);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
}
.badge .dot { width: 6px; height: 6px; background: var(--brand-creation); }
.badge--accent { color: var(--brand-creation); border-color: color-mix(in srgb, var(--brand-creation) 30%, var(--border)); background: var(--creation-50); }
.badge--success { color: var(--status-positive); border-color: color-mix(in srgb, var(--status-positive) 30%, var(--border)); background: var(--status-positive-bg); }
.badge--success .dot { background: var(--status-positive); }
.badge--warn { color: var(--status-warn); border-color: var(--status-warn-edge); background: var(--status-warn-bg); }
.badge--warn .dot { background: var(--status-warn); }
.badge--danger { color: #b42318; border-color: #f0c6c1; background: #fdecea; }
.badge--danger .dot { background: #b42318; }

/* ---------- Buttons (notched, uppercase tracked) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--fw-bold);
  letter-spacing: 0.06em; text-transform: uppercase;
  min-height: 44px; padding: 8px 16px; cursor: pointer; border: 1px solid var(--border-strong); background: var(--bg); color: var(--fg);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
  transition: all var(--dur-fast) var(--ease-standard);
}
.btn:hover { background: var(--bg-muted); }
.btn--accent { background: var(--brand-creation); border-color: var(--brand-creation); color: #fff; }
.btn--accent:hover { background: var(--creation-600); }
.btn svg { width: 14px; height: 14px; }
/* Variants: ghost (borderless) and danger/remove (red, the one colour exception). */
.btn--ghost { background: transparent; border-color: transparent; clip-path: none; color: var(--fg); }
.btn--ghost:hover { background: transparent; color: var(--brand-creation); }
.btn--danger { background: var(--bg); border-color: var(--status-danger-edge); color: var(--status-danger); }
.btn--danger:hover { background: var(--status-danger-bg); }
/* Sizes: default is 44px (touch/primary standard). Small is a compact desktop
   variant (36px, above the WCAG 2.2 AA 24px pointer floor); large is 52px. */
.btn--sm { min-height: 36px; font-size: 11px; padding: 5px 12px; }
.btn--lg { min-height: 52px; font-size: var(--text-sm); padding: 11px 22px; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%); }
/* Optional monospace index prefix inside a button. */
.btn .n { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 10px; opacity: 0.55; padding-right: 8px; border-right: 1px solid currentColor; }

/* ---------- Segmented tabs ---------- */
.tabs { display: inline-flex; border: 1px solid var(--border); background: var(--bg-muted); padding: 3px; }
.tab {
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  padding: 7px 14px; cursor: pointer; border: 0; background: transparent; color: var(--fg-subtle);
  transition: all var(--dur-fast) var(--ease-standard);
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--bg); color: var(--brand-creation); box-shadow: var(--shadow-xs); }

/* ---------- Layout grids (equal-height by default) ---------- */
.grid { display: grid; gap: var(--space-6); align-items: stretch; }
.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-12 { grid-template-columns: repeat(12, 1fr); }
.col-4 { grid-column: span 4; } .col-8 { grid-column: span 8; }
.stack { display: flex; flex-direction: column; gap: var(--space-6); }
.spread { display: flex; flex-direction: column; justify-content: space-between; height: 100%; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-12 { grid-template-columns: 1fr; }
  .col-4, .col-8 { grid-column: 1 / -1; }
  .lg-preview { order: -1; } /* logo generator: the preview leads when the panel stacks, so a brand with many forms never buries it */
}

/* ---------- Metric / stat tile (uniform) ---------- */
.tile { border: 1px solid var(--border); background: var(--bg-muted); padding: var(--space-4); display: flex; flex-direction: column; gap: 4px; min-height: 118px; }
.tile .k { font-size: 10px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--fg-muted); }
.tile .v { font-size: var(--text-2xl); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); }
.tile .d { font-size: var(--text-xs); color: var(--fg-subtle); line-height: var(--lh-normal); }
.tile .v .num { font-variant-numeric: tabular-nums; }
.tile.up .d { color: var(--status-positive); font-weight: var(--fw-bold); }
.tile.down .d { color: var(--status-danger); font-weight: var(--fw-bold); }
.tile.accent .v { color: var(--brand-creation); }

/* ---------- Data table (neutral, hairline) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl thead th {
  text-align: left; font-size: 10px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-wide);
  text-transform: uppercase; color: var(--fg-muted); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); background: var(--bg-muted);
}
.tbl tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-family: ui-monospace, SFMono-Regular, monospace; }
.tbl .pass { color: var(--brand-harmony); font-weight: var(--fw-bold); }
.tbl .fail { color: #b42318; font-weight: var(--fw-bold); }

/* ---------- Swatch row ---------- */
.swatch { width: 20px; height: 20px; border: 1px solid var(--border); flex: 0 0 auto; }
.swatch-lg { width: 34px; height: 34px; border: 1px solid var(--border); flex: 0 0 auto; }
.colorrow { display: flex; align-items: center; gap: var(--space-3); }

/* ---------- Range control ---------- */
.control { display: flex; flex-direction: column; gap: var(--space-3); }
.control-hd { display: flex; justify-content: space-between; font-family: ui-monospace, SFMono-Regular, monospace; font-size: var(--text-xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--fg-subtle); }
.control-hd .cur { color: var(--fg); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 2px; background: var(--border-strong); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; background: var(--brand-creation); border: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--brand-creation); border: 0; border-radius: 0; }

/* ---------- Segmented option buttons ---------- */
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.opt { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 10px; font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 6px; border: 1px solid var(--border); background: var(--bg-muted); color: var(--fg-subtle); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; }
.opt:hover { color: var(--fg); }
.opt.active { border-color: var(--brand-creation); color: var(--brand-creation); background: var(--creation-50); }
.opt .sw { width: 9px; height: 9px; border: 1px solid var(--border-strong); }

select.field { width: 100%; font-family: ui-monospace, SFMono-Regular, monospace; font-size: var(--text-xs); padding: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); }

/* ---------- Stage (render preview area) ---------- */
.stage { display: flex; align-items: center; justify-content: center; padding: var(--space-8); min-height: 320px; border: 1px solid var(--border); background: var(--bg-muted); position: relative; }
.stage--dark { background: var(--brand-secondary); }
.stage--grid { background-image: radial-gradient(var(--border-strong) 1px, transparent 1px); background-size: 22px 22px; background-color: var(--bg); }
.stagebar { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-bottom: 0; background: var(--bg-muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: var(--text-xs); color: var(--fg-subtle); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.readout { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-top: 0; background: var(--bg-muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; color: var(--fg-subtle); }
.readout strong { color: var(--fg); }

/* ---------- Code block ---------- */
.code { background: var(--brand-secondary); color: #E9EEF5; padding: var(--space-4); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; line-height: var(--lh-relaxed); overflow: auto; max-height: 200px; white-space: pre-wrap; }

/* ---------- Palette selector cards ---------- */
.spec { text-align: left; cursor: pointer; border: 1px solid var(--border); background: var(--bg); padding: var(--space-5); display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-4); position: relative; transition: border-color var(--dur-fast) var(--ease-standard); }
.spec:hover { border-color: var(--border-strong); }
.spec.active { border-color: var(--brand-creation); box-shadow: inset 0 0 0 1px var(--brand-creation); }
.spec .spec-check { position: absolute; top: 0; right: 0; width: 20px; height: 20px; background: var(--brand-creation); color: #fff; display: flex; align-items: center; justify-content: center; }
.spec .spec-check svg { width: 12px; height: 12px; }
.spec .spec-name { font-size: var(--text-sm); font-weight: var(--fw-bold); }
.spec .spec-desc { font-size: 11px; color: var(--fg-subtle); line-height: var(--lh-normal); margin-top: 4px; }
.spec .spec-sw { display: flex; align-items: center; gap: 6px; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.spec .spec-hex { margin-left: auto; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 10px; font-weight: var(--fw-bold); color: var(--fg-muted); }

/* ---------- Gallery card ---------- */
.gallery-card { text-align: left; cursor: pointer; align-items: flex-start; transition: border-color var(--dur-fast) var(--ease-standard); }
.gallery-card:hover { border-color: var(--brand-creation); }

/* ---------- Embedded studio ---------- */
.studio-embed { display: flex; flex-direction: column; gap: var(--space-6); }
.studio-hd { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  border: 1px solid var(--border); background: var(--bg); padding: var(--space-4) var(--space-5); }

/* ---------- Node blueprint ---------- */
.node { cursor: pointer; }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-5) 0; }
.fade-in { animation: fade 200ms var(--ease-standard); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } }
