/* =========================================================================
   HQ — design system
   Dark-first command centre. Light mode is a selected set, not a flip.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* surfaces */
  --plane:        #0d0e11;
  --surface-1:    #16181c;
  --surface-2:    #1c1f25;
  --surface-3:    #23272e;
  --hairline:     rgba(255, 255, 255, 0.09);
  --hairline-2:   rgba(255, 255, 255, 0.055);

  /* ink */
  --text-1:       #f3f5f8;
  --text-2:       #a4abb8;
  --text-3:       #6d7683;

  /* brand */
  --brand:        #2f9dff;
  --brand-strong: #1a8aed;
  --brand-ink:    #06131f;
  --brand-wash:   rgba(47, 157, 255, 0.13);
  --brand-edge:   rgba(47, 157, 255, 0.32);

  /* status — reserved, never used as a series colour */
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --good-wash:    rgba(12, 163, 12, 0.14);
  --warning-wash: rgba(250, 178, 25, 0.14);
  --serious-wash: rgba(236, 131, 90, 0.14);
  --critical-wash:rgba(208, 59, 59, 0.15);

  /* chart */
  --series-1:     #3987e5;
  --series-2:     #d95926;
  --series-3:     #199e70;
  --grid:         #2c2c2a;
  --axis:         #383835;
  --muted-ink:    #898781;

  /* ordinal ramp — one hue, light→dark; nearest-surface step clears 2:1 */
  --ramp-1: #86b6ef;
  --ramp-2: #5598e7;
  --ramp-3: #3987e5;
  --ramp-4: #256abf;
  --ramp-5: #184f95;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.45);

  --sidebar-w: 236px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

:root[data-theme='light'] {
  color-scheme: light;
  --plane:        #f7f8fa;
  --surface-1:    #ffffff;
  --surface-2:    #f4f6f8;
  --surface-3:    #eaedf1;
  --hairline:     rgba(11, 11, 11, 0.11);
  --hairline-2:   rgba(11, 11, 11, 0.06);
  --text-1:       #0f1216;
  --text-2:       #545c68;
  --text-3:       #858d99;
  --brand-ink:    #ffffff;
  --brand-wash:   rgba(47, 157, 255, 0.1);
  --brand-edge:   rgba(47, 157, 255, 0.35);
  --series-1:     #2a78d6;
  --series-2:     #eb6834;
  --series-3:     #1baf7a;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --ramp-1: #86b6ef;
  --ramp-2: #5598e7;
  --ramp-3: #2a78d6;
  --ramp-4: #1c5cab;
  --ramp-5: #104281;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 12px 32px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--plane);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--plane); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- structure */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  padding: 18px 12px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 10px rgba(47, 157, 255, 0.35);
}
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: -2px; }

.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-1); }
.nav-item.is-active {
  background: var(--brand-wash); color: var(--brand); font-weight: 600;
  box-shadow: inset 2.5px 0 0 var(--brand);
}
.nav-item .ico { width: 17px; text-align: center; opacity: 0.9; font-size: 14px; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: 20px;
  padding: 1px 7px;
  font-weight: 600;
}
.nav-item .count.alert { background: var(--critical-wash); color: var(--critical); }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--hairline-2); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--plane) 86%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
}
.topbar h1 { font-size: 17px; font-weight: 680; letter-spacing: -0.02em; margin: 0; }
.topbar .date { font-size: 12.5px; color: var(--text-3); }
.topbar .spacer { flex: 1; }

.page { padding: 22px 26px 64px; max-width: 1440px; width: 100%; }

.section { margin-bottom: 30px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 12px;
}
.section-head h2 { font-size: 13px; font-weight: 640; letter-spacing: -0.005em; margin: 0; }
.section-head .hint { font-size: 12px; color: var(--text-3); }
.section-head .spacer { flex: 1; }

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

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 16px 18px; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline-2);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 13px; font-weight: 640; }
.card-head .spacer { flex: 1; }
.card-head .sub { font-size: 12px; color: var(--text-3); }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ------------------------------------------------------------ stat tiles */

.stat {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 15px 16px 14px;
  position: relative;
  overflow: hidden;
}
.stat .label {
  font-size: 11.5px; color: var(--text-3); font-weight: 550;
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 6px;
}
.stat .value {
  font-size: 32px; font-weight: 680; letter-spacing: -0.04em;
  margin-top: 7px; line-height: 1.02;
  font-variant-numeric: tabular-nums;
}
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.stat.is-critical .value { color: var(--critical); }
.stat.is-warning  .value { color: var(--warning); }
.stat.is-good     .value { color: var(--good); }
.stat .spark { margin-top: 10px; display: block; }

/* --------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.pill.good     { background: var(--good-wash);     color: var(--good); }
.pill.warning  { background: var(--warning-wash);  color: #a9760a; }
.pill.serious  { background: var(--serious-wash);  color: var(--serious); }
.pill.critical { background: var(--critical-wash); color: var(--critical); }
.pill.brand    { background: var(--brand-wash);    color: var(--brand); }
:root[data-theme='light'] .pill.warning { color: #7a5405; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--text-3); }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }
.dot.paused, .dot.unknown { background: var(--text-3); }

.biz-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 560; color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  padding: 1px 8px 1px 6px; border-radius: 20px;
  white-space: nowrap;
}
.biz-chip .swatch { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 auto; }

/* --------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--hairline-2);
  transition: background 0.1s ease;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .title { font-weight: 520; letter-spacing: -0.005em; }
.row .meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.row .body { min-width: 0; flex: 1; }
.row .body .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.row.is-late { background: linear-gradient(90deg, var(--critical-wash), transparent 42%); }
.row.is-done .title { text-decoration: line-through; color: var(--text-3); }

.check {
  width: 18px; height: 18px; flex: 0 0 auto;
  border-radius: 6px;
  border: 1.5px solid var(--text-3);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.12s ease;
  padding: 0;
}
.check:hover { border-color: var(--brand); background: var(--brand-wash); }
.check.is-done { background: var(--brand); border-color: var(--brand); color: #fff; }
.check.is-done::after { content: '✓'; font-size: 11px; font-weight: 700; line-height: 1; }

/* ------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 13px; font-weight: 550;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 8px rgba(47, 157, 255, 0.28);
}
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: var(--critical-wash); border-color: var(--critical); }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px; letter-spacing: 0.01em;
}
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* ---------------------------------------------------------- quick capture */

.capture {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 3px 3px 3px 12px;
  min-width: 340px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.capture:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.capture input {
  flex: 1; background: transparent; border: 0; outline: none; padding: 6px 0;
}
.capture .kbd {
  font-size: 10px; color: var(--text-3); border: 1px solid var(--hairline);
  border-radius: 4px; padding: 1px 5px; font-family: var(--font);
}

/* --------------------------------------------------------------- kanban */

.board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 140px;
}
.col-head {
  padding: 11px 13px;
  display: flex; align-items: center; gap: 7px;
  border-bottom: 1px solid var(--hairline-2);
  font-size: 12px; font-weight: 640;
}
.col-head .n { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; }

.idea-card {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  transition: all 0.12s ease;
}
.idea-card:hover { border-color: var(--brand-edge); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.idea-card .t { font-weight: 540; font-size: 13px; letter-spacing: -0.005em; line-height: 1.35; }
.idea-card .m { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.score {
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--brand); background: var(--brand-wash);
  padding: 1px 6px; border-radius: 5px;
}

/* --------------------------------------------------------------- charts */

.chart-wrap { padding: 16px 18px 12px; }
.chart-title { font-size: 13px; font-weight: 640; margin: 0 0 2px; }
.chart-sub { font-size: 12px; color: var(--text-3); margin: 0 0 14px; }
svg.chart { display: block; width: 100%; overflow: visible; }
svg.chart text { font-family: var(--font); }
.axis-label { font-size: 10.5px; fill: var(--muted-ink); }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.bar { transition: opacity 0.12s ease; }
.bar:hover { opacity: 0.82; }
.value-label { font-size: 10.5px; font-weight: 620; fill: var(--text-2); font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend .swatch { width: 9px; height: 9px; border-radius: 2px; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 100;
  max-width: 240px;
}
.tooltip.on { opacity: 1; }
.tooltip .tt-title { font-weight: 640; margin-bottom: 2px; }
.tooltip .tt-val { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- table */

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 11px; font-weight: 620; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 9px 18px; border-bottom: 1px solid var(--hairline);
}
table.tbl td { padding: 11px 18px; border-bottom: 1px solid var(--hairline-2); }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- misc */

.empty {
  padding: 22px 20px; text-align: center; color: var(--text-3); font-size: 13px;
}
.empty .big { font-size: 20px; margin-bottom: 4px; opacity: 0.5; }

.meter { height: 6px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 20px; background: var(--brand); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(14px);
  background: var(--surface-3); border: 1px solid var(--hairline);
  padding: 9px 16px; border-radius: 20px; box-shadow: var(--shadow-2);
  font-size: 13px; font-weight: 540;
  opacity: 0; pointer-events: none; transition: all 0.18s ease; z-index: 200;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* the developed brief */
.prose { line-height: 1.65; }
.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }
.prose ul { margin: 0; padding-left: 18px; }
.prose li { margin-bottom: 5px; }
.prose code {
  background: var(--surface-3); padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.raw-capture {
  white-space: pre-wrap;
  line-height: 1.6;
  border-left: 2px solid var(--hairline);
  padding-left: 12px;
  color: var(--text-2);
  font-size: 13.5px;
}
.step-n {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; border-radius: 5px;
  background: var(--brand-wash); color: var(--brand);
  font-size: 10.5px; font-weight: 700;
  margin-right: 8px; vertical-align: 1px;
}

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.strong { font-weight: 640; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.hide { display: none !important; }

/* ---------------------------------------------------------------- login */

.login-plane { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 350px; }
.login-card .brand { justify-content: center; padding-bottom: 22px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; overflow-x: auto; align-items: center;
    padding: 10px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--hairline);
  }
  .brand, .nav-label, .sidebar-foot { display: none; }
  .nav-item { padding: 7px 11px; white-space: nowrap; }
  .page { padding: 16px 14px 60px; }
  .topbar { padding: 0 14px; height: 54px; }
  .topbar .date { display: none; }
  .capture { min-width: 0; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(5, 76vw); }

  /* Feed rows stack: title on its own line, metadata underneath, controls
     below that — otherwise the flex row squeezes the title to nothing. */
  .row { flex-wrap: wrap; align-items: flex-start; padding: 12px 14px; row-gap: 8px; }
  .row .body { flex: 1 1 0; min-width: 0; }
  .row .body .title { white-space: normal; overflow: visible; line-height: 1.35; }
  .row .meta {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-top: 3px;
  }
  .row .right {
    margin-left: 30px; width: 100%; justify-content: flex-start; flex-wrap: wrap;
  }
  .check { margin-top: 2px; }

  .card-head { padding: 12px 14px; }
  table.tbl th, table.tbl td { padding: 9px 14px; }
  .stat .value { font-size: 26px; }
  .field-row { flex-wrap: wrap; }
  .field-row > * { flex: 1 1 140px; }
}

/* =========================================================================
   Assistant — the talker
   ========================================================================= */

.chat {
  display: flex; flex-direction: column;
  max-width: 820px; margin: 0 auto;
  min-height: calc(100vh - 170px);
}
.chat-scroll { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 2px 18px; }

.chat-hello { margin: auto; text-align: center; padding: 40px 20px; }
.chat-hello h2 { font-size: 19px; font-weight: 680; letter-spacing: -0.02em; margin: 16px 0 6px; }
.chat-hello p { color: var(--text-3); font-size: 13.5px; max-width: 400px; margin: 0 auto; line-height: 1.6; }

.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg.is-me { justify-content: flex-end; }
.msg-avatar {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  color: #fff; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(47, 157, 255, 0.3);
}
.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  position: relative;
}
.msg.is-hq .msg-bubble {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 5px;
}
.msg.is-me .msg-bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg-body { white-space: pre-wrap; line-height: 1.6; font-size: 13.5px; }
.msg-time {
  display: block; font-size: 10px; margin-top: 4px;
  color: var(--text-3); text-align: right;
  font-variant-numeric: tabular-nums;
}
.msg.is-me .msg-time { color: rgba(255,255,255,0.65); }

.typing { display: flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: typing 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-foot {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--plane) 78%, transparent);
  padding: 14px 0 8px;
}
.chat-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-q {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 20px; padding: 5px 13px;
  font-size: 12px; color: var(--text-2); cursor: pointer;
  transition: all 0.12s ease;
}
.chip-q:hover { border-color: var(--brand-edge); color: var(--brand); background: var(--brand-wash); }

.chat-input {
  display: flex; gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-2);
  transition: border-color 0.12s ease;
}
.chat-input:focus-within { border-color: var(--brand); }
.chat-input input {
  flex: 1; background: transparent; border: 0; outline: none;
  padding: 8px 10px; font-size: 14px;
}
.chat-tools { display: flex; justify-content: center; margin-top: 6px; }
.chat-tools .btn-ghost { font-size: 11px; color: var(--text-3); }

/* =========================================================================
   Task popup — click anywhere, edit by talking
   ========================================================================= */

.tm-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(5, 6, 9, 0.55);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: tm-fade 0.14s ease;
}
@keyframes tm-fade { from { opacity: 0; } }

.tm-card {
  --tm-accent: #5b6472;
  width: 100%; max-width: 560px;
  max-height: min(82vh, 720px);
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--tm-accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  padding: 18px 20px 16px;
  position: relative;
  animation: tm-pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes tm-pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } }

.tm-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  border: 0; background: transparent; color: var(--text-3);
  font-size: 19px; cursor: pointer; line-height: 1;
}
.tm-close:hover { background: var(--surface-2); color: var(--text-1); }

.tm-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding-right: 30px; }
.tm-title {
  font-size: 17px; font-weight: 680; letter-spacing: -0.02em;
  margin: 8px 0 2px; line-height: 1.3; padding-right: 20px;
}
.tm-body { overflow-y: auto; min-height: 0; }
.tm-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.tm-body .next-action { margin-top: 8px; }
.tm-detail {
  margin-top: 10px; font-size: 13px; color: var(--text-2);
  line-height: 1.55; white-space: pre-wrap;
  max-height: 110px; overflow-y: auto;
}

.tm-notes { margin-top: 12px; border-top: 1px solid var(--hairline-2); }
.tm-note { padding: 9px 0; border-bottom: 1px solid var(--hairline-2); }
.tm-note:last-child { border-bottom: 0; }
.tm-note-body { font-size: 12.5px; line-height: 1.5; }
.tm-note-hq { font-size: 12px; color: var(--good); margin-top: 3px; font-weight: 540; }
:root[data-theme='light'] .tm-note-hq { color: #006300; }
.tm-note-hq.is-thinking { color: var(--text-3); font-style: italic; }
.tm-note-hq.is-thinking::after {
  content: ''; display: inline-block; width: 1em; text-align: left;
  animation: tm-dots 1.2s steps(4) infinite;
}
@keyframes tm-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.tm-talk {
  display: flex; gap: 8px; margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px; padding: 5px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  flex: 0 0 auto;
}
.tm-talk:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.tm-input { flex: 1; background: transparent; border: 0; outline: none; padding: 7px 9px; font-size: 13.5px; }

.tm-foot { display: flex; align-items: center; margin-top: 10px; flex: 0 0 auto; }
.tm-full { font-size: 11.5px; color: var(--text-3); }
.tm-full:hover { color: var(--brand); }

/* =========================================================================
   Radar — a clean timeline with a date rail
   ========================================================================= */

.tl { display: flex; flex-direction: column; gap: 8px; max-width: 880px; }
.tl-month {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
  padding: 14px 2px 2px;
}
.tl-day { display: flex; gap: 14px; align-items: stretch; }
.tl-rail {
  flex: 0 0 52px;
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0 0;
}
.tl-dow {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
}
.tl-num {
  font-size: 19px; font-weight: 680; letter-spacing: -0.02em;
  color: var(--text-1); font-variant-numeric: tabular-nums; line-height: 1.15;
}
.tl-rel { font-size: 9.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tl-day.is-today .tl-num {
  background: var(--brand); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
}
.tl-day.is-today .tl-dow { color: var(--brand); }

.tl-items {
  flex: 1 1 0; min-width: 0;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.tl-day.is-late .tl-items { border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.tl-day.is-late .tl-items .tl-item { background: linear-gradient(90deg, var(--critical-wash), transparent 30%); }

.tl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline-2);
  font-size: 13px;
  transition: background 0.1s ease;
}
.tl-item:last-child { border-bottom: 0; }
a.tl-item:hover { background: var(--surface-2); }
.tl-dot { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 auto; }
.tl-title {
  font-weight: 540; letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-kind { color: var(--text-3); font-size: 12px; flex: 0 0 auto; }
.tl-biz { font-size: 11px; color: var(--text-3); flex: 0 0 auto; }
.tl-doit { opacity: 0; transition: opacity 0.1s ease; flex: 0 0 auto; }
.tl-item:hover .tl-doit { opacity: 1; }
@media (max-width: 820px) {
  .tl-doit { opacity: 1; }
  .tl-rail { flex-basis: 44px; }
}

/* decision toasts can be a sentence — let them breathe */
.toast { max-width: min(560px, 90vw); text-align: center; line-height: 1.45; }

/* =========================================================================
   Calendar v3 — blocks ARE the events; one visual system, auto-fit hours
   ========================================================================= */

.cal-bar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.cal-nav { display: flex; align-items: center; gap: 3px; }
.cal-nav .btn-ghost { font-size: 18px; line-height: 1; padding: 4px 10px; color: var(--text-2); }
.cal-month { font-size: 19px; font-weight: 680; letter-spacing: -0.02em; }
.cal-sub { font-size: 12.5px; color: var(--text-3); }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; }
.lg { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-3); }
.lg:hover { color: var(--text-1); }
.lg i { width: 8px; height: 8px; border-radius: 3px; }

/* frame */
.gcal {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.g-headrow, .g-allday, .g-body { display: flex; }
.g-corner { flex: 0 0 56px; }
.g-corner.is-ad {
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 9px;
}
.g-corner.is-ad span {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
}

.g-head {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 10px 0 8px;
  border-left: 1px solid var(--hairline-2);
  transition: background 0.12s ease;
}
.g-head:hover { background: var(--surface-2); }
.gh-dow {
  font-size: 10px; font-weight: 650; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
}
.g-head.is-today .gh-dow { color: var(--brand); }
.gh-num {
  font-size: 17px; font-weight: 640; color: var(--text-2);
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.g-head.is-today .gh-num { background: var(--brand); color: #fff; }
.gh-load { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.g-allday { border-top: 1px solid var(--hairline-2); }
.g-adcell {
  flex: 1 1 0; min-width: 0;
  border-left: 1px solid var(--hairline-2);
  padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.ad-chip {
  --ev: #5b6472;
  display: block;
  background: color-mix(in srgb, var(--ev) 22%, var(--surface-1));
  border-left: 3px solid var(--ev);
  color: var(--text-1);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px; font-weight: 550; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ad-chip:hover { background: color-mix(in srgb, var(--ev) 34%, var(--surface-1)); }
.ad-more { font-size: 10.5px; color: var(--text-3); padding-left: 6px; }

/* time axis */
.g-body { border-top: 1px solid var(--hairline); }
.g-gutter { flex: 0 0 56px; position: relative; }
.g-time {
  position: absolute; right: 9px; transform: translateY(-55%);
  font-size: 10.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
  background: var(--surface-1); padding: 0 2px;
}
.g-col {
  flex: 1 1 0; min-width: 0;
  border-left: 1px solid var(--hairline-2);
  display: flex; flex-direction: column;
}
.g-col.is-today { background: color-mix(in srgb, var(--brand) 4.5%, transparent); }

.g-canvas { position: relative; }
.g-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--hairline-2); }
.g-canvas.is-off {
  background: repeating-linear-gradient(-45deg,
    transparent, transparent 9px, var(--hairline-2) 9px, var(--hairline-2) 10px);
}
.g-off {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 11px; color: var(--text-3); letter-spacing: 0.04em;
  writing-mode: vertical-rl;
}

.g-now {
  position: absolute; left: 0; right: 0; z-index: 6;
  border-top: 2px solid #ea4335; pointer-events: none;
}
.g-now i {
  position: absolute; left: -5px; top: -6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #ea4335; border: 2px solid var(--surface-1);
}

/* ------------------------------------------------- the block event card */

.gblk {
  --bk: #5b6472;
  position: absolute; left: 4px; right: 5px;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--bk) 16%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--bk) 42%, transparent);
  border-left: 3px solid var(--bk);
  border-radius: 9px;
  overflow: hidden;
  z-index: 2;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}
.gblk:hover { box-shadow: var(--shadow-1); }
.gblk.is-over { border-color: color-mix(in srgb, var(--critical) 55%, transparent); }
.gblk.is-ghost {
  background: transparent;
  border: 1px dashed var(--hairline);
  border-left: 1px dashed var(--hairline);
  z-index: 1;
}
.gblk.is-ghost .bk-label { color: var(--text-3); font-weight: 560; }

.bk-head {
  display: flex; align-items: baseline; gap: 7px;
  padding: 4px 8px 2px;
  flex: 0 0 auto;
}
.bk-label {
  font-size: 11px; font-weight: 680; letter-spacing: -0.005em;
  color: color-mix(in srgb, var(--bk) 60%, var(--text-1));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-time {
  margin-left: auto; flex: 0 0 auto;
  font-size: 9.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.bk-body {
  flex: 1 1 auto; min-height: 0; overflow: hidden;
  padding: 1px 5px 5px;
  display: flex; flex-direction: column; gap: 2px;
}

.bk-task {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-1) 78%, transparent);
  min-height: 19px;
}
.bk-task:hover { background: var(--surface-1); }
.bk-task.is-done .bk-title { text-decoration: line-through; color: var(--text-3); }
.bk-title {
  flex: 1 1 0; min-width: 0;
  font-size: 11.5px; font-weight: 540; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bk-min { font-size: 9.5px; color: var(--text-3); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.bk-flag { color: var(--critical); font-weight: 800; font-size: 12px; flex: 0 0 auto; }
.bk-more { font-size: 10px; color: var(--text-3); padding: 1px 5px; }
.bk-check {
  width: 12px; height: 12px; flex: 0 0 auto;
  border: 1.5px solid var(--text-3); border-radius: 4px;
  background: transparent; cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.bk-check:hover { border-color: var(--brand); }
.bk-check.is-done { background: var(--brand); border-color: var(--brand); }
.bk-check.is-done::after { content: '✓'; color: #fff; font-size: 8px; font-weight: 800; line-height: 1; }

/* rituals outside the fitted hours */
.g-pins { padding: 5px 6px; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--hairline-2); }
.g-pin {
  font-size: 10px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- chase */

.chase {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--warning-wash);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: var(--radius); padding: 8px 14px; margin-bottom: 12px;
  font-size: 12.5px;
}
.chase-ico { font-size: 13px; }
.chase-label { font-weight: 680; }
.chase-item { font-weight: 560; }
.chase-item:hover { color: var(--brand); }
.chase-item em { font-style: normal; color: var(--text-3); font-size: 11.5px; margin-left: 3px; }

/* ---------------------------------------------------------------- tray */

.tray {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 12px; padding: 9px 13px;
  background: var(--surface-1); border: 1px dashed var(--hairline);
  border-radius: var(--radius);
}
.tray .ad-chip { max-width: 240px; }
.tray-label {
  font-size: 10.5px; font-weight: 680; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-3); margin-right: 4px;
}

/* ------------------------------------------------------------- day view */

.day-split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 14px; align-items: start;
}
.gcal.is-single .gblk { left: 8px; right: 10px; }
.gcal.is-single .bk-label { font-size: 12px; }
.gcal.is-single .bk-title { font-size: 12.5px; }
.gcal.is-single .bk-task { min-height: 23px; }

.agenda { display: flex; flex-direction: column; gap: 12px; }
.ag {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
}
.ag-head {
  --accent: var(--hairline);
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline-2);
  border-left: 3px solid var(--accent);
  font-size: 13px;
}
.ag-label { font-weight: 660; }
.ag-load { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ag-task {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--hairline-2);
}
.ag-task:last-child { border-bottom: 0; }
.ag-task:hover { background: var(--surface-2); }
.ag-when {
  flex: 0 0 42px; font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; padding-top: 2px; font-weight: 600;
}
.ag-body { flex: 1 1 0; min-width: 0; }
.ag-title { display: block; font-size: 13.5px; font-weight: 540; line-height: 1.35; }
.ag-title.is-done { text-decoration: line-through; color: var(--text-3); }
.ag-next { display: block; font-size: 11.5px; color: var(--brand); margin-top: 2px; }
.ag-right { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.ag-min { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------- task detail */

.next-action {
  display: flex; align-items: baseline; gap: 9px;
  background: var(--brand-wash); border: 1px solid var(--brand-edge);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13.5px; font-weight: 540; line-height: 1.45;
}
.na-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--brand); font-weight: 700; flex: 0 0 auto;
}
.notes { border-top: 1px solid var(--hairline-2); }
.note { padding: 12px 18px; border-bottom: 1px solid var(--hairline-2); }
.note:last-child { border-bottom: 0; }
.note-body { line-height: 1.55; white-space: pre-wrap; }
.note-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 6px; font-size: 11.5px; color: var(--text-3);
}
.note-decision { color: var(--good); font-weight: 540; }
:root[data-theme='light'] .note-decision { color: #006300; }

@media (max-width: 1100px) {
  .day-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .gcal { overflow-x: auto; }
  .g-headrow, .g-allday, .g-body { min-width: 880px; }
  .cal-legend { display: none; }
  .cal-month { font-size: 16px; }
}

/* a tiny block whose single task is the event itself */
.gblk.is-line { justify-content: center; padding: 0 3px; }
.gblk.is-line .bk-task { background: transparent; min-height: 0; }
.gblk.is-line .bk-title { font-weight: 600; }

/* =========================================================================
   Calendar interactions — clickable feel, drag & drop, right-click menu
   ========================================================================= */

.gcal, .mcal { user-select: none; -webkit-user-select: none; }
.bk-task, .ad-chip, .mc-chip, .ag-task { cursor: pointer; }
.bk-task:hover { filter: brightness(1.12); }
.bk-task:active, .ad-chip:active, .mc-chip:active, .ag-task:active {
  transform: scale(0.975);
  transition: transform 0.06s ease;
}
.gblk { transition: box-shadow 0.12s ease; }
.gblk:hover { box-shadow: var(--shadow-2); }

[data-drag-task].is-dragging { opacity: 0.35; }
body.hq-dragging .bk-task:hover { filter: none; }
[data-drop-date].is-drop {
  outline: 2px dashed var(--brand);
  outline-offset: -2px;
  background: var(--brand-wash);
  border-radius: 8px;
}

.ctx {
  position: fixed; z-index: 300;
  min-width: 168px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
  padding: 5px;
  display: flex; flex-direction: column;
  animation: tm-pop 0.12s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.ctx-item {
  border: 0; background: transparent; text-align: left;
  font: inherit; font-size: 13px; color: var(--text-1);
  padding: 8px 11px; border-radius: 8px; cursor: pointer;
}
.ctx-item:hover { background: var(--surface-2); }
.ctx-item.is-danger { color: var(--critical); }
.ctx-item.is-danger:hover { background: rgba(208, 59, 59, 0.12); }
.ctx-item.is-armed { background: var(--critical); color: #fff; font-weight: 650; }
.ctx-item.is-armed:hover { background: var(--critical); }

/* ------------------------------------------------ popup: move + delete */

.tm-move {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 12px; flex: 0 0 auto;
}
.tm-move-label { font-size: 11px; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; margin-right: 2px; }
.chip-btn {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-1);
  font: inherit; font-size: 12px; font-weight: 560;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  transition: background 0.1s ease, transform 0.06s ease;
}
.chip-btn:hover { background: var(--surface-3); border-color: var(--brand); }
.chip-btn:active { transform: scale(0.95); }
.chip-btn.is-ghost { color: var(--text-3); }
.tm-date {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 999px; padding: 4px 9px; font: inherit; font-size: 12px;
  cursor: pointer; width: 118px;
}
.tm-del-btn { color: var(--critical); margin-left: 8px; }
.tm-del-btn.is-armed { background: var(--critical); color: #fff; border-color: var(--critical); }

/* =========================================================================
   Month view — all the days at once
   ========================================================================= */

.mcal {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.mc-head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--hairline);
}
.mc-head span {
  padding: 8px 10px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3);
}
.mc-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--hairline-2);
  min-height: 106px;
}
.mc-row:last-child { border-bottom: 0; }
.mc-cell {
  border-right: 1px solid var(--hairline-2);
  padding: 6px 6px 8px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
  transition: background 0.1s ease;
}
.mc-cell:last-child { border-right: 0; }
.mc-cell.is-out { background: var(--surface-2); opacity: 0.55; }
.mc-cell.is-off { background: repeating-linear-gradient(-45deg, transparent, transparent 7px, var(--surface-2) 7px, var(--surface-2) 8px); }
.mc-cell.is-today { box-shadow: inset 0 0 0 2px var(--brand); border-radius: 2px; }
.mc-day {
  font-size: 12px; font-weight: 650; color: var(--text-2);
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; flex: 0 0 auto;
}
.mc-day:hover { background: var(--surface-3); color: var(--text-1); }
.mc-cell.is-today .mc-day { background: var(--brand); color: #fff; }
.mc-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mc-chip {
  display: block; font-size: 11.5px; font-weight: 560; color: #fff;
  background: var(--ev, #5b6472);
  border-radius: 6px; padding: 2.5px 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: filter 0.1s ease, transform 0.06s ease;
}
.mc-chip:hover { filter: brightness(1.15); }
.mc-chip.is-done { opacity: 0.45; text-decoration: line-through; }
.mc-chip.is-crit { box-shadow: inset 0 0 0 1.5px var(--critical); }
.mc-more { font-size: 11px; color: var(--text-3); padding: 1px 7px; }
.mc-more:hover { color: var(--brand); }

/* =========================================================================
   Discipline — the scoreboard
   ========================================================================= */

.card-title-row {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
}
.card-title-row h3 { font-size: 13.5px; font-weight: 680; letter-spacing: -0.01em; }
.card-title-row .small { margin-left: auto; }
.small.good { color: var(--good); font-weight: 600; }
.small.warn { color: var(--warning); font-weight: 600; }

.stat .delta { font-size: 12.5px; font-weight: 650; vertical-align: 3px; margin-left: 2px; }
.stat .delta.up { color: var(--good); }
.stat .delta.down { color: var(--critical); }

.dp-goal {
  position: relative; height: 14px; border-radius: 999px;
  background: var(--surface-3); overflow: visible; margin-top: 4px;
}
.dp-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #6cc0ff);
  transition: width 0.4s ease;
}
.dp-fill.is-behind { background: linear-gradient(90deg, var(--warning), #ffd35c); }
.dp-marker {
  position: absolute; top: -4px; bottom: -4px; width: 2.5px;
  background: var(--text-1); border-radius: 2px; opacity: 0.8;
}
.dp-goal-legend {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-3); margin-top: 6px;
}

.dp-brand {
  display: grid;
  grid-template-columns: 14px minmax(90px, 170px) 1fr 42px 34px 40px 64px;
  align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--hairline-2);
  font-size: 13px;
}
.dp-brand:last-child { border-bottom: 0; }
.dp-brand .swatch { width: 10px; height: 10px; border-radius: 3px; }
.dp-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dp-bar i { display: block; height: 100%; border-radius: 999px; min-width: 3px; }
.dp-share { text-align: right; font-weight: 650; }
.dp-count { text-align: right; color: var(--text-2); }
.dp-delta { text-align: right; font-size: 12px; font-weight: 650; }
.dp-delta.up { color: var(--good); }
.dp-delta.down { color: var(--critical); }
.dp-open { text-align: right; font-size: 11.5px; color: var(--text-3); }

.dp-goal-form { display: flex; align-items: center; gap: 7px; }
.dp-goal-form label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.dp-goal-form .input { width: 76px; padding: 6px 9px; }

@media (max-width: 760px) {
  .dp-brand { grid-template-columns: 12px 1fr 40px 34px; }
  .dp-bar, .dp-delta, .dp-open { display: none; }
  .mc-row { min-height: 74px; }
  .mc-chip { font-size: 10px; }
}

/* ------------------------------------------------ block popup (readable) */

.gblk[data-block-pop] { cursor: pointer; }
.gblk[data-block-pop] .bk-head:hover .bk-label { text-decoration: underline; text-underline-offset: 2px; }

.bp-card { max-width: 620px; }
.bp-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--hairline-2);
}
.bp-row:last-child { border-bottom: 0; }
.bp-row.is-done { opacity: 0.55; }
.bp-row .check { margin-top: 2px; flex: 0 0 auto; }
.bp-mid { flex: 1; min-width: 0; }
.bp-title {
  display: block; font-size: 14px; font-weight: 620; line-height: 1.4;
  color: var(--text-1); white-space: normal; word-break: break-word;
}
.bp-title:hover { color: var(--brand); }
.bp-title.is-done { text-decoration: line-through; color: var(--text-3); }
.bp-detail {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-top: 3px;
  white-space: normal; word-break: break-word;
}
.bp-right { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; margin-top: 2px; }
.bp-min { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.bp-sum { font-size: 12px; color: var(--text-3); }

/* Task-count badge for blocks too short to show their checklist. */
.bk-count {
  flex: 0 0 auto;
  min-width: 17px; height: 17px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  background: var(--bk); color: #fff; border-radius: 999px;
}

/* All-day strip: its own quiet zone, never a tall ragged stack. */
.g-allday {
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-2);
}
.g-adcell { padding: 5px 5px 6px; }
.ad-more:hover { color: var(--brand); }
