/* ============================================================
   MACROS · editorial theme (ported from the hi-fi design tokens)
   Scoped to the Macros app layout; isolated from Breeze/auth pages.
   ============================================================ */

:root,
[data-theme="editorial"] {
  --bg:        #efe7d4;
  --bg-2:      #e8dfca;
  --bg-3:      #ddd3bb;
  --surface:   #fbf6e9;
  --surface-2: #f5eed9;
  --surface-3: #ece4cf;

  --ink:       #1f1c17;
  --ink-2:     #4a443b;
  --ink-3:     #8a8275;
  --ink-4:     #b8b0a0;

  --rule:      #d3c8ad;
  --rule-2:    #e3d8bf;
  --rule-3:    #f0e9d6;

  --prot:      #c8542a;
  --carb:      #c89000;
  --fat:       #6b7a2c;

  --prot-soft: #f6dccd;
  --carb-soft: #f3e3b8;
  --fat-soft:  #e0e5c7;

  --prot-ink:  #7a2e10;
  --carb-ink:  #6b4a00;
  --fat-ink:   #3d4615;

  --ok:        #2f7a4d;
  --warn:      #b85c00;
  --bad:       #a83a2a;
  --info:      #2a5a8a;

  --accent:      var(--prot);
  --accent-soft: var(--prot-soft);
  --accent-ink:  var(--prot-ink);

  --font-display: "Newsreader", Georgia, serif;
  --font-body:    "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num:     "Geist", ui-sans-serif, system-ui, sans-serif;

  --letter-display: -0.02em;
  --weight-display: 400;
  --eyebrow-tt: uppercase;
  --eyebrow-ls: 0.16em;

  --r-xs: 4px;  --r-sm: 6px;  --r: 10px;  --r-md: 12px;
  --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;

  --shadow-1: 0 1px 0 rgba(31,28,23,0.04), 0 1px 2px rgba(31,28,23,0.04);
  --shadow-2: 0 1px 0 rgba(31,28,23,0.05), 0 8px 24px rgba(31,28,23,0.08);
  --shadow-3: 0 12px 40px rgba(31,28,23,0.15), 0 2px 4px rgba(31,28,23,0.05);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
.macros-body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.macros-body button,
.macros-body input,
.macros-body select,
.macros-body textarea { font: inherit; color: inherit; }
.macros-body button { cursor: pointer; }
.macros-body a { color: inherit; text-decoration: none; }

/* ---------- typography ---------- */
.serif   { font-family: var(--font-display); }
.h1      { font-family: var(--font-display); font-weight: var(--weight-display); font-size: 28px; line-height: 1.1; letter-spacing: var(--letter-display); }
.h2      { font-family: var(--font-display); font-weight: var(--weight-display); font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; }
.eyebrow { font-size: 10.5px; font-weight: 600; letter-spacing: var(--eyebrow-ls); text-transform: var(--eyebrow-tt); color: var(--ink-3); white-space: nowrap; }
.body    { font-size: 14px; line-height: 1.5; }
.small   { font-size: 13px; line-height: 1.45; }
.tiny    { font-size: 11px; line-height: 1.4; }
.muted   { color: var(--ink-3); }
.num     { font-family: var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }

/* ---------- layout primitives ---------- */
.row     { display: flex; align-items: center; gap: 8px; }
.col     { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow    { flex: 1; min-width: 0; }
.grid    { display: grid; gap: 14px; }
.grid-2  { grid-template-columns: 1fr 1fr; }
.grid-3  { grid-template-columns: repeat(3, 1fr); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card.flush  { background: var(--surface-2); }
.card-pad    { padding: 18px 20px; }
.card-pad-sm { padding: 12px 14px; }
.card.hover:hover { border-color: var(--ink-3); box-shadow: var(--shadow-2); }
.card.dashed { border-style: dashed; background: transparent; box-shadow: none; }

.divider      { height: 1px; background: var(--rule); border: 0; margin: 16px 0; }
.divider.thin { background: var(--rule-2); margin: 10px 0; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip.solid  { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip.olive  { background: var(--fat-soft);  border-color: transparent; color: var(--fat-ink); }
.chip.warn   { background: var(--carb-soft); border-color: transparent; color: var(--warn); }
.chip.bad    { background: #f6dada; border-color: transparent; color: var(--bad); }
.chip.ok     { background: var(--fat-soft); border-color: transparent; color: var(--ok); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.dot.prot { background: var(--prot); }
.dot.carb { background: var(--carb); }
.dot.fat  { background: var(--fat); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--bg-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: #2d2925; border-color: #2d2925; }
.btn.accent { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--rule-2); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; font-size: 12px; padding: 0 10px; }
.btn.sm.icon { width: 28px; padding: 0; }

/* ---------- inputs ---------- */
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg-3);
}
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; font-family: var(--font-num); }
.label {
  display: block; font-size: 11.5px; font-weight: 600;
  letter-spacing: var(--eyebrow-ls); text-transform: var(--eyebrow-tt);
  color: var(--ink-3); margin-bottom: 6px;
}
.field-error { color: var(--bad); font-size: 12px; margin-top: 6px; }

/* ---------- macro bar ---------- */
.mbar { display: flex; height: 10px; width: 100%; border-radius: 999px; overflow: hidden; background: var(--rule-2); }
.mbar > i { display: block; height: 100%; }
.mbar > i.p { background: var(--prot); }
.mbar > i.c { background: var(--carb); }
.mbar > i.f { background: var(--fat); }
.mbar.thin { height: 5px; }

/* ---------- metric ---------- */
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric .l { font-size: 10.5px; letter-spacing: var(--eyebrow-ls); text-transform: var(--eyebrow-tt); color: var(--ink-3); font-weight: 600; }
.metric .v { font-family: var(--font-display); font-weight: var(--weight-display); font-size: 26px; line-height: 1; letter-spacing: var(--letter-display); }
.metric .d { font-size: 11.5px; color: var(--ink-2); }

/* ---------- table ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th {
  text-align: left; font-weight: 600; color: var(--ink-3);
  font-size: 10.5px; letter-spacing: var(--eyebrow-ls); text-transform: var(--eyebrow-tt);
  border-bottom: 1px solid var(--rule); padding: 10px 8px;
  background: var(--surface-2);
}
table.t td { padding: 11px 8px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: var(--surface-2); }

/* ---------- library category list ---------- */
.lib-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  background: transparent; color: var(--ink);
  border: none; text-align: left; cursor: pointer;
  font: inherit; font-size: 13px; width: 100%;
}
.lib-cat:hover { background: var(--bg-2); }
.lib-cat.on { background: var(--ink); color: var(--bg); }

/* ---------- timeline tick ---------- */
.tick {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; padding: 3px 8px;
  font-size: 11px; color: var(--ink-2);
  background: var(--bg-2); border-radius: 6px; border: 1px solid var(--rule);
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}

/* ---------- swap projection track ---------- */
.track { position: relative; height: 10px; background: var(--rule-2); border-radius: 999px; overflow: hidden; }
.track > .cur  { position: absolute; left: 0; top: 0; bottom: 0; background: var(--rule); }
.track > .next { position: absolute; left: 0; top: 0; bottom: 0; opacity: .85; border-right: 2px solid var(--ink); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-right: 1px solid var(--rule);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; white-space: nowrap; }
.brand .glyph {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 18px; font-weight: 500; letter-spacing: -0.04em;
}
.brand .name { font-family: var(--font-display); font-weight: var(--weight-display); font-size: 19px; letter-spacing: -0.015em; line-height: 1.1; }
.brand .sub  { font-size: 10px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.2; }

.day-card { margin: 4px 4px 12px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--rule-2); border-radius: var(--r); }
.nav-section { font-size: 10.5px; letter-spacing: var(--eyebrow-ls); text-transform: var(--eyebrow-tt); color: var(--ink-4); font-weight: 600; padding: 12px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-2);
  background: transparent; border: 1px solid transparent;
  cursor: pointer; width: 100%; text-align: left;
  transition: background .15s, color .15s; white-space: nowrap;
}
.nav-item > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.nav-item .badge { margin-left: auto; font-size: 10.5px; background: var(--bg-2); color: var(--ink-3); padding: 1px 6px; border-radius: 999px; }
.nav-item.active .badge { background: rgba(255,255,255,0.15); color: var(--bg); }
.nav-item.muted-link { color: var(--ink-4); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--rule-2); display: flex; flex-direction: column; gap: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px;
  background: color-mix(in oklab, var(--bg), transparent 30%);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: saturate(180%) blur(12px);
}
.topbar .crumbs { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.topbar .crumbs .sep { opacity: 0.4; }
.topbar .crumbs b { color: var(--ink-2); font-weight: 500; }

.page { padding: 24px 28px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-weight: var(--weight-display); font-size: 36px; line-height: 1.05; letter-spacing: var(--letter-display); }
.page-head .sub { color: var(--ink-2); font-size: 14px; max-width: 60ch; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px;
  box-shadow: var(--shadow-3); font-size: 13px; font-weight: 500;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 16, 10, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  max-width: 520px; width: 100%; max-height: 88vh; overflow: auto;
}
.modal-head { padding: 20px 24px 12px; border-bottom: 1px solid var(--rule-2); }
.modal-body { padding: 18px 24px; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--rule-2); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- empty state ---------- */
.empty {
  border: 1.5px dashed var(--rule);
  border-radius: var(--r-lg);
  background: transparent;
  padding: 48px 32px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
