/* ChiefMind Luxe Kit: base layer. Needs tokens.css (and fonts.css) first.
   Rules: square corners, 1px hairlines, no shadows, gradients, pills or glows.
   No data: URIs, so it works under CSP default-src 'self' (BeeCoder). */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cm-bg);
  color: var(--cm-ink);
  font-family: var(--cm-font-serif);
  font-size: var(--cm-text-lg);
  line-height: var(--cm-leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* App UI (BeeCoder, app, dashboards): set class="cm-ui" on body for D-DIN as base font. */
.cm-ui { font-family: var(--cm-font-din); font-size: var(--cm-text-md); line-height: 1.45; }

::selection { background: var(--cm-gold); color: var(--cm-black); }

/* ---------- type ---------- */

h1, h2, h3, h4, .cm-display {
  font-family: var(--cm-font-serif);
  font-weight: 400;
  line-height: var(--cm-leading-tight);
  letter-spacing: -0.01em;
  margin: 0 0 var(--cm-space-4);
  color: var(--cm-ink);
}
h1, .cm-display { font-size: var(--cm-text-4xl); }
h2 { font-size: var(--cm-text-3xl); }
h3 { font-size: var(--cm-text-2xl); }
h4 { font-size: var(--cm-text-xl); font-weight: 500; }
/* Italic accent in headlines. Light: taupe (ok only >= 24px), dark: champagne. */
h1 em, h2 em, h3 em, h4 em, .cm-display em { font-style: italic; color: var(--cm-display-accent); }

p { margin: 0 0 var(--cm-space-4); }
.cm-lead { font-size: var(--cm-text-xl); line-height: 1.4; color: var(--cm-muted); }
.cm-muted { color: var(--cm-muted); }
.cm-sub { color: var(--cm-sub); }

.cm-label {
  font-family: var(--cm-font-din);
  font-size: var(--cm-text-xs);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: var(--cm-tracking-label);
  text-transform: uppercase;
  color: var(--cm-label);
}
.cm-num { font-family: var(--cm-font-din); font-variant-numeric: tabular-nums; }

/* Logo for now: the plain wordmark. */
.cm-wordmark {
  font-family: var(--cm-font-serif);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--cm-ink);
  text-decoration: none;
}

code, kbd, samp, pre, .cm-mono { font-family: var(--cm-font-mono); font-size: 0.875em; }
pre {
  margin: 0 0 var(--cm-space-4);
  padding: var(--cm-space-4);
  background: var(--cm-surface-2);
  border: var(--cm-hairline) solid var(--cm-line);
  overflow-x: auto;
  line-height: 1.5;
}

a {
  color: var(--cm-accent);
  text-decoration: underline;
  text-decoration-color: var(--cm-link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

hr, .cm-rule {
  border: 0;
  border-top: var(--cm-hairline) solid var(--cm-line);
  margin: var(--cm-space-6) 0;
}

/* ---------- focus ---------- */

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--cm-focus);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */

.cm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cm-space-2);
  min-height: var(--cm-control-h);
  padding: 0 var(--cm-space-5);
  border: var(--cm-hairline) solid transparent;
  border-radius: var(--cm-radius);
  background: transparent;
  color: var(--cm-ink);
  font-family: var(--cm-font-din);
  font-size: var(--cm-text-sm);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.cm-btn--primary { background: var(--cm-btn-bg); border-color: var(--cm-btn-bg); color: var(--cm-btn-ink); }
.cm-btn--secondary { border-color: var(--cm-ink); }
.cm-btn--primary:hover,
.cm-btn--secondary:hover { background: var(--cm-ink); border-color: var(--cm-ink); color: var(--cm-bg); }
.cm-btn--ghost {
  min-height: var(--cm-control-h);
  padding: 0 var(--cm-space-1);
  text-decoration: underline;
  text-decoration-color: var(--cm-gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.45em;
}
.cm-btn--ghost:hover { text-decoration-color: currentColor; }
/* Disabled: no opacity trick, stays readable (sub text passes 4.5:1) */
.cm-btn:disabled, .cm-btn[aria-disabled="true"] {
  background: transparent;
  border-color: var(--cm-line);
  color: var(--cm-sub);
  text-decoration: none;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- forms ---------- */

.cm-field { display: grid; gap: var(--cm-space-2); }
.cm-field > label, .cm-field > .cm-label { display: block; }

.cm-input,
.cm-select > select {
  width: 100%;
  min-height: var(--cm-control-h);
  padding: 0 var(--cm-space-3);
  border: var(--cm-hairline) solid var(--cm-line-strong);
  border-radius: var(--cm-radius);
  background: var(--cm-surface);
  color: var(--cm-ink);
  font-family: var(--cm-font-din);
  font-size: var(--cm-text-md); /* 16px stops iOS zoom */
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}
textarea.cm-input { padding: var(--cm-space-3); min-height: 6rem; resize: vertical; }
.cm-input::placeholder { color: var(--cm-sub); opacity: 1; }
.cm-input:hover, .cm-select > select:hover { border-color: var(--cm-ink); }

/* Select: wrap it, <span class="cm-select"><select>...</select></span>. Caret drawn in CSS. */
.cm-select { position: relative; display: block; }
.cm-select > select { padding-right: var(--cm-space-7); cursor: pointer; }
.cm-select::after {
  content: "";
  position: absolute;
  right: var(--cm-space-4);
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--cm-ink);
  border-bottom: 1px solid var(--cm-ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Checkbox: square, hairline; checked = champagne fill with black tick. */
.cm-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cm-space-3);
  min-height: var(--cm-control-h);
  font-family: var(--cm-font-din);
  font-size: var(--cm-text-md);
  cursor: pointer;
}
.cm-check input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  display: grid;
  place-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  border: var(--cm-hairline) solid var(--cm-line-strong);
  border-radius: var(--cm-radius);
  background: var(--cm-surface);
  cursor: pointer;
}
.cm-check input::before {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -3px;
  border-right: 1.5px solid var(--cm-black);
  border-bottom: 1.5px solid var(--cm-black);
  transform: rotate(45deg);
  visibility: hidden;
}
.cm-check input:checked { background: var(--cm-btn-bg); border-color: var(--cm-btn-bg); }
.cm-check input:checked::before { visibility: visible; }

/* ---------- cards ---------- */

.cm-card {
  background: var(--cm-surface);
  border: var(--cm-hairline) solid var(--cm-line);
  border-radius: var(--cm-radius);
  padding: var(--cm-space-5);
}
.cm-card--flat { background: transparent; }

/* ---------- status: dot + word, never color alone ---------- */

.cm-status {
  display: inline-flex;
  align-items: center;
  gap: var(--cm-space-2);
  font-family: var(--cm-font-din);
  font-size: var(--cm-text-sm);
  letter-spacing: 0.04em;
  color: var(--cm-sub);
}
.cm-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%; /* allowed: status dots */
  background: currentColor;
  flex: none;
}
.cm-status--ok { color: var(--cm-ok); }
.cm-status--danger { color: var(--cm-danger); }

/* ---------- icons (Phosphor light, fill = currentColor) ---------- */

.cm-icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; fill: currentColor; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Compat v1: logo rules for pages that still inline the crown as <svg> and do not load logo.css.
   The source is logo.css (loaded after base.css, so it wins). Do not edit here; drop in v2. */
.cm-logo { display: inline-flex; align-items: center; gap: 0.4em; color: var(--cm-ink); text-decoration: none; font-family: var(--cm-font-serif); font-weight: 500; font-size: 1.375rem; letter-spacing: 0.01em; line-height: 1; }
:root { --cm-logo-crown: var(--cm-taupe); }
[data-theme="dark"] { --cm-logo-crown: var(--cm-gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cm-logo-crown: var(--cm-gold); } }
.cm-logo__crown { width: 1.15em; height: 0.7em; flex-shrink: 0; overflow: visible; color: var(--cm-logo-crown); }
.cm-logo--stacked { flex-direction: column; gap: 0.15em; }
.cm-logo--stacked .cm-logo__crown { width: 1.4em; height: 0.85em; }
