:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f24;
  --muted: #647084;
  --border: #dfe3ea;
  --border-strong: #b9c0cc;
  --accent: #2456d6;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --bubble-neutral: #e3e7ee;
  --shadow: 0 6px 24px rgba(20, 28, 40, 0.18);
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #20252d;
    --text: #e8ebf0;
    --muted: #8d97a8;
    --border: #2a303a;
    --border-strong: #3d4552;
    --accent: #6b95f2;
    --accent-text: #0c1220;
    --danger: #ef7466;
    --bubble-neutral: #2c333e;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 18px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 8px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.topbar, .toolbar, .filters, #main, .banner {
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 16px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; padding-block: 14px 8px; }
.topbar-actions { display: flex; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-block: 6px 10px; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
#main { padding-block: 4px 40px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: 12px; min-width: 20px; padding: 0 6px; text-align: center; }

/* segmented controls (buttons or radio labels) */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg > button, .seg > label > span {
  font: inherit; display: block; min-height: 38px; line-height: 38px; padding: 0 14px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; white-space: nowrap;
}
.seg > button + button, .seg > label + label { border-left: 1px solid var(--border-strong); }
.seg > button[aria-pressed='true'], .seg > label:has(input:checked) > span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg > label { display: block; flex: 1; text-align: center; }
.field .seg { display: flex; }
.seg > label > input { position: absolute; opacity: 0; pointer-events: none; }
.seg > label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: calc(1040px - 32px); padding: 14px 16px; margin-bottom: 12px;
}
.filters .field { margin: 0; }
.filters .btn { min-height: 36px; }
.filters label.field { font-size: 13px; color: var(--muted); }
.filters select, .filters input { font-size: 14px; }
.filters .range input { width: 84px; }
.filters .range input[type='date'] { width: 142px; }
.filters .quadrants { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.filters .quadrants legend { width: 100%; }
.filters .quadrants label { color: var(--text); font-size: 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .label { padding: 0; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.range { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 0 6px; }
.range legend { grid-column: 1 / -1; }
.range input { width: 84px; }
.range input[type='date'] { width: 138px; }
.quadrants { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.quadrants legend { width: 100%; }
.quadrants label { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- form controls ---------- */
input[type='text'], input[type='number'], input[type='date'], select, textarea {
  font-family: inherit; font-size: 15px; line-height: 1.4; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%;
}
input.narrow { width: 72px; }
textarea { resize: vertical; }
input[type='range'] { width: 100%; accent-color: var(--accent); }
input[type='color'] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); vertical-align: middle; }
.field { display: grid; gap: 4px; margin: 0 0 14px; }
label.field { font-size: 13px; color: var(--muted); }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 200px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.error { color: var(--danger); font-size: 13px; min-height: 0; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.score-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.score-row input[type='number'] { width: 72px; text-align: center; }
.calc { margin: 8px 0 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }

/* ---------- matrix ---------- */
.matrix {
  display: grid;
  grid-template-columns: 22px 24px minmax(0, 1fr);
  grid-template-rows: auto 22px 20px;
}
.axis-title { color: var(--muted); font-size: 13px; text-align: center; }
.axis-title.y { grid-column: 1; grid-row: 1; writing-mode: vertical-rl; transform: rotate(180deg); align-self: center; }
.axis-title.x { grid-column: 3; grid-row: 3; }
.y-ticks { grid-column: 2; grid-row: 1; position: relative; }
.x-ticks { grid-column: 3; grid-row: 2; position: relative; }
.y-ticks span, .x-ticks span { position: absolute; font-size: 12px; color: var(--muted); }
.y-ticks span { right: 4px; transform: translateY(-50%); }
.x-ticks span { top: 4px; transform: translateX(-50%); }

.matrix-plot {
  grid-column: 3; grid-row: 1;
  position: relative; overflow: hidden;
  width: 100%; aspect-ratio: 16 / 11; max-height: 74vh; min-height: 300px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  --r: 22px;
}
.quad { position: absolute; }
.q1 { background: color-mix(in srgb, var(--q1, #d9483b) 11%, transparent); }
.q2 { background: color-mix(in srgb, var(--q2, #3a86c8) 11%, transparent); }
.q3 { background: color-mix(in srgb, var(--q3, #f2b134) 11%, transparent); }
.q4 { background: color-mix(in srgb, var(--q4, #8a94a6) 11%, transparent); }
.quad-label { position: absolute; font-size: 12px; color: var(--muted); pointer-events: none; white-space: nowrap; }
.quad-label b { font-weight: 700; }
.quad-label i { font-style: normal; }
.q1 .quad-label { top: 8px; right: 10px; }
.q2 .quad-label { top: 8px; left: 10px; }
.q3 .quad-label { bottom: 8px; right: 10px; }
.q4 .quad-label { bottom: 8px; left: 10px; }
.threshold { position: absolute; background: var(--border-strong); opacity: 0.8; pointer-events: none; }
.threshold.vertical { top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--border-strong); background: none; }
.threshold.horizontal { left: 0; right: 0; height: 0; border-top: 1px dashed var(--border-strong); background: none; }
.bubble-layer { position: absolute; inset: 0; }
.matrix-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; color: var(--muted); pointer-events: none; }

.bubble {
  position: absolute; left: 0; top: 0;
  width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.75);
  background: var(--bubble-neutral); color: var(--text);
  font: 700 12px/1 system-ui, sans-serif; letter-spacing: 0.01em;
  box-shadow: 0 1px 4px rgba(20, 28, 40, 0.3);
  cursor: pointer; touch-action: manipulation;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.15s, opacity 0.15s;
}
.bubble[data-len='s'] { font-size: 13px; }
.bubble[data-len='m'] { font-size: 11px; }
.bubble[data-len='l'] { font-size: 9.5px; }
.bubble:hover { box-shadow: 0 2px 10px rgba(20, 28, 40, 0.45); z-index: 2; }
.bubble.is-selected { outline: 3px solid var(--accent); outline-offset: 2px; z-index: 3; }
.bubble.is-completed { opacity: 0.55; border-style: dashed; }
@media (prefers-reduced-motion: reduce) { .bubble { transition: none; } }

/* ---------- list ---------- */
.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; background: var(--surface-2); }
.list td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--surface-2); }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list tr.is-completed .name { text-decoration: line-through; color: var(--muted); }
.list input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent); }
.list-empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.chip {
  display: inline-grid; place-items: center; min-width: 40px; height: 28px; padding: 0 8px;
  border-radius: 999px; background: var(--bubble-neutral); color: var(--text); font-weight: 700; font-size: 12px;
}
.sub { color: var(--muted); font-size: 13px; }
.show-sm { display: none; }
.name { font-weight: 600; }
.auto-dot { color: var(--muted); font-size: 12px; }

/* ---------- details popover / sheet ---------- */
#detail-backdrop { position: fixed; inset: 0; z-index: 40; }
#detail-backdrop.clear { pointer-events: none; }
#detail-backdrop.dim { background: rgba(10, 14, 20, 0.45); }
.detail {
  position: fixed; z-index: 50; width: min(320px, calc(100vw - 16px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 16px;
}
.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.detail-head .chip { height: 40px; min-width: 48px; font-size: 14px; flex: none; }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 12px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }
.detail-desc { margin: 0 0 12px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; white-space: pre-wrap; max-height: 140px; overflow: auto; }
.detail-actions { display: flex; gap: 8px; }
.detail-actions .btn { flex: 1; }

/* ---------- dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--border-strong); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 14, 20, 0.5); }
dialog form { padding: 20px; }
dialog h2 { margin-bottom: 16px; }
.dialog-actions {
  display: flex; gap: 8px; align-items: center; position: sticky; bottom: 0;
  margin: 8px -20px -20px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.spacer { flex: 1; }
.mapping { display: grid; gap: 6px; margin: 6px 0; }
.mapping-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mapping-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.colors { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.gradient-preview { height: 12px; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- misc ---------- */
.banner { display: block; background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; max-width: calc(1040px - 32px); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 24px);
  background: #1f2630; color: #f2f4f8; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
}
.toast.is-error { background: var(--danger); color: #fff; }
.toast-action { font: inherit; font-weight: 700; color: #9db8ff; background: none; border: 0; cursor: pointer; padding: 4px; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .list th, .list td { padding: 10px 8px; }
}

@media (max-width: 640px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar, .toolbar, #main, .banner { padding-inline: 12px; }
  .toolbar { gap: 8px; }
  .toolbar > .seg { width: 100%; }
  .toolbar > .seg > button { flex: 1; padding: 0 6px; }
  .toolbar-right { width: 100%; }
  #btn-filters { flex: 1; }

  /* Matrix / List switch becomes a bottom bar. */
  #view-seg {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; border-radius: 0; border-width: 1px 0 0;
    padding-bottom: env(safe-area-inset-bottom); background: var(--surface);
  }
  #view-seg > button { flex: 1; min-height: 56px; line-height: 56px; }

  .matrix { grid-template-columns: 18px 20px minmax(0, 1fr); }
  .matrix-plot { aspect-ratio: auto; height: clamp(340px, calc(100dvh - 330px), 640px); min-height: 0; max-height: none; }
  input[type='text'], input[type='number'], input[type='date'], select, textarea,
  .filters select, .filters input { font-size: 16px; } /* 16px stops iOS from zooming into fields */
  .quad-label i { display: none; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }

  .detail.sheet {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 75dvh; overflow: auto;
    border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  dialog { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; max-height: 94dvh; }
  .filters { margin-inline: 12px; padding: 12px; }
  .filters .range input { width: 72px; }
  .filters .range input[type='date'] { width: 128px; }
}

/* ---- v0.2 additions ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.matrix-plot { user-select: none; -webkit-user-select: none; touch-action: manipulation; cursor: cell; }
.bubble { cursor: pointer; }

.sim-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.sim-bar.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.sim-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 4px; }
.sim-head label { font-weight: 600; font-size: 14px; }
.sim-head output { flex: 1; min-width: 160px; color: var(--muted); font-size: 14px; }
.sim-bar.is-active .sim-head output { color: var(--text); font-weight: 600; }
.sim-bar input[type='range'] { width: 100%; height: 32px; accent-color: var(--accent); margin: 0; }
.sim-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-size: 14px; font-weight: 600; }
.sim-chip[hidden], .sim-bar[hidden], .summary[hidden] { display: none; }

.summary { padding: 10px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); }
.summary strong { color: var(--text); font-size: 18px; }

.th-sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.th-sort .arrow { font-size: 9px; min-width: 9px; }
.btn.mini { min-height: 30px; padding: 0 10px; font-size: 13px; }
.total-row { text-align: right; padding: 12px; background: var(--surface-2); border-top: 2px solid var(--border-strong) !important; }
.is-overdue { color: var(--danger); }
.auto-dot { color: var(--muted); }

.field.group, fieldset.field.group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 10px; }
.field.group > legend { font-weight: 600; padding: 0 6px; }
.origin { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-radius: 8px; padding: 6px 10px; }
.origin[hidden] { display: none; }

/* Timeline */
#timeline-view { display: grid; gap: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.card.warn { border-color: var(--danger); }
.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.card-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; }
.card.warn .card-value { color: var(--danger); }
.card-note { font-size: 13px; color: var(--muted); }
.tl-h { font-size: 15px; margin: 6px 0 0; }
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; overflow: hidden; }
.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis, .chart .tick-line { stroke: var(--border-strong); }
.chart text { fill: var(--muted); font: 11px system-ui, sans-serif; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: none; }
.chart .today { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .today-label { fill: var(--text); font-weight: 600; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .dot.overdue { stroke: var(--danger); }
.chart .event-label { fill: var(--text); font-weight: 600; font-size: 10.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.tl-table .sub { margin-top: 2px; }
.tl-table caption { text-align: left; }
.abbr-tag { display: inline-block; min-width: 2.2em; text-align: center; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 700; }
.unscheduled { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.unscheduled li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }

@media (max-width: 640px) {
  #mode-seg > button { font-size: 13px; padding: 0 4px; }
  #view-seg > button { font-size: 14px; }
  .sim-bar { padding: 8px 12px; }
  #main { padding-bottom: 80px; }
  .card-value { font-size: 18px; }
}

/* Settings tabs */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 0 -20px 14px; padding: 0 20px; scrollbar-width: none; }
.tabs [role='tab'] { flex: none; min-height: 40px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.tabs [role='tab']:hover { color: var(--text); }
.tabs [role='tab'][aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs [role='tab']:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.tab-panel[hidden] { display: none; }
.tab-panel { min-height: 260px; display: grid; gap: 12px; align-content: start; }
.tab-panel h3 { margin: 6px 0 0; }

/* ---- v0.3 additions ---- */
.quick-add { max-width: 1040px; margin: 0 auto 8px; padding: 0 16px; }
.qa-row { display: flex; gap: 8px; }
.qa-row input { flex: 1; min-width: 0; }
.qa-preview { margin-top: 4px; min-height: 18px; overflow-wrap: anywhere; }
.qa-preview.is-error { color: var(--danger); }
.quick-add .btn[hidden] { display: none; }

.focus { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.focus[hidden] { display: none; }
.focus > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style-position: inside; }
.focus > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.focus-list { list-style: none; margin: 0; padding: 0 6px 6px; max-height: 40vh; overflow: auto; }
.focus-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.focus-item:hover { background: var(--surface-2); }
.focus-text { flex: 1; min-width: 0; }
.focus-text .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pills:empty { display: none; }
.tag-pills.small { margin-top: 3px; gap: 4px; }
.tag-pill { font: inherit; font-size: 13px; line-height: 1; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.tag-pill:hover { background: var(--surface-2); }
.tag-pill[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.tag-pill.static { cursor: default; font-size: 11px; padding: 3px 7px; background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.tag-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-filter { grid-column: 1 / -1; }
.tag-filter[hidden] { display: none; }
.tag-rows { display: grid; gap: 4px; }
.tag-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.tag-row input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent); }
.tag-row input[type='color'] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--border-strong); border-radius: 6px; background: none; }
.tag-row input[type='color']:disabled { opacity: 0.35; }
.tag-name { font-size: 14px; }

.bubble { touch-action: none; cursor: grab; }
.bubble.has-tag { border-width: 3px; }
.bubble.is-dragging { z-index: 6; cursor: grabbing; box-shadow: 0 6px 18px rgba(20, 28, 40, 0.5); transition: none; }
.drag-hint { position: absolute; transform: translateX(-50%); z-index: 7; padding: 4px 10px; border-radius: 999px; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.drag-hint.is-cancel { background: var(--danger); color: #fff; }
.drag-hint[hidden] { display: none; }

#imp-result ul { margin: 6px 0 0; padding-left: 18px; }
#imp-result.error { color: var(--danger); }
@media (max-width: 640px) {
  .quick-add { padding: 0 12px; }
  .qa-row .btn { padding: 0 10px; }
}

/* ---- v0.4: six quadrants, smooth background, dimmed low-urgency bubbles ---- */
/* Smooth background: bottom layer blends Q4 -> Q3 left to right, the top layer Q2 -> Q1 and fades out
   towards the bottom, so colours change continuously with urgency (x) and importance (y). The 50 % point
   of each blend sits on the configured threshold (--gx / --gy). */
.bg-wrap { display: none; position: absolute; top: 0; bottom: 0; right: 0; left: var(--xl, 0%); opacity: var(--bg-strength, 0.26); pointer-events: none; }
.matrix-plot.smooth .bg-wrap { display: block; }
.bg-layer { position: absolute; inset: 0; filter: saturate(1.25); }
.bg-layer.bottom { background: linear-gradient(to right, var(--q4), color-mix(in srgb, var(--q4), var(--q3)) var(--gx, 50%), var(--q3)); }
.bg-layer.top {
  background: linear-gradient(to right, var(--q2), color-mix(in srgb, var(--q2), var(--q1)) var(--gx, 50%), var(--q1));
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.5) var(--gy, 50%), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.5) var(--gy, 50%), transparent 100%);
}
.matrix-plot.smooth .quad { background: none; }
@media (prefers-color-scheme: dark) { .matrix-plot { --bg-strength: 0.40; } }

.zone-low { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--dimmed, #9aa3b2) 15%, transparent); pointer-events: none; }
.zone-low[hidden], .quad[hidden], .threshold[hidden] { display: none; }
.threshold.vertical.low { border-left-style: dotted; opacity: 0.6; }
.q5 .quad-label { top: 8px; left: 10px; }
.q6 .quad-label { bottom: 8px; left: 10px; }
.q5 .quad-label, .q6 .quad-label { white-space: normal; max-width: calc(100% - 16px); }
.q5 .quad-label b, .q6 .quad-label b, .q5 .quad-label i, .q6 .quad-label i { opacity: 0.8; }

.bubble.is-dim {
  background: color-mix(in srgb, var(--dim-bg, #9aa3b2) calc(var(--dim-alpha, 0.55) * 100%), transparent);
  color: color-mix(in srgb, var(--dim-fg, #1b1f24) calc(var(--dim-alpha, 0.55) * 100%), transparent);
  border-color: rgba(255, 255, 255, calc(var(--dim-alpha, 0.55) * 0.8)); box-shadow: none;
}
.bubble.is-dim[data-len] { font-size: 9px; }
.bubble.is-dim:hover, .bubble.is-dim.is-selected, .bubble.is-dim.is-dragging { --dim-alpha: 1 !important; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type='range'] { flex: 1; accent-color: var(--accent); }
.range-row output { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.is-off { opacity: 0.5; }
.six-only[hidden] { display: none; }
@media (max-width: 640px) { .q5 .quad-label i, .q6 .quad-label i { display: none; } }

/* Marks on bubbles: ! overdue (top-right), amber dot due soon (top-right), ↻ repeats (top-left), € amount (bottom-right).
   In the low-urgency area ↻ and € turn grey; ! and the amber dot stay colored. */
.bubble-mark {
  position: absolute; display: grid; place-items: center; border-radius: 50%; color: #fff;
  border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(20, 28, 40, 0.4); pointer-events: none;
  font: 800 11px/1 system-ui, sans-serif;
}
.bubble-mark.flag { top: -5px; right: -5px; width: 16px; height: 16px; background: #d92d20; }
.bubble-mark.soon { top: -3px; right: -3px; width: 11px; height: 11px; background: #f59f00; }
.bubble-mark.repeat { top: -4px; left: -4px; width: 15px; height: 15px; background: #475467; font-size: 11px; font-weight: 700; padding-bottom: 1px; }
.bubble-mark.value { bottom: -4px; right: -4px; background: #0b7285; font-weight: 700; }
.bubble.is-dim .bubble-mark.repeat, .bubble.is-dim .bubble-mark.value { background: #7b8494; } /* ! and the amber dot keep their color */
.bubble.is-dim .bubble-mark.repeat { width: 12px; height: 12px; font-size: 9px; }

/* the same marks as samples next to the settings checkboxes */
.mark-sample { display: inline-grid; place-items: center; vertical-align: middle; width: 16px; height: 16px; border-radius: 50%; color: #fff; font: 800 10px/1 system-ui, sans-serif; margin: 0 4px 0 2px; }
.mark-sample.flag { background: #d92d20; }
.mark-sample.soon { background: #f59f00; width: 11px; height: 11px; margin: 0 7px 0 5px; }
.mark-sample.repeat { background: #475467; }
.mark-sample.value { background: #0b7285; }
