:root {
  color-scheme: light dark;
  --canvas: #f4f1e9;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17312f;
  --muted: #66736f;
  --line: #d7ddd8;
  --primary: #165f5a;
  --primary-strong: #0d4b47;
  --primary-soft: #dcece8;
  --danger: #a33b36;
  --shadow: 0 12px 34px rgb(30 52 49 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, rgb(120 188 173 / 13%), transparent 25rem),
    var(--canvas);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--primary); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.45rem; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.02; letter-spacing: -0.045em; }
h1:focus { outline: none; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 3vw, 1.8rem); letter-spacing: -0.025em; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0.75rem max(1rem, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid rgb(23 49 47 / 10%);
  background: rgb(244 241 233 / 88%);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 0.75rem; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { margin-top: 0.2rem; color: var(--muted); font-size: 0.74rem; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; color: white; background: var(--primary); font-weight: 750; }
.environment-badge { padding: 0.22rem 0.48rem; border: 1px solid #d29b42; border-radius: 999px; background: #fff2d6; color: #6d542d; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.account-menu { display: flex; align-items: center; gap: 0.75rem; }
.account-name { display: flex; min-width: 0; max-width: min(40vw, 320px); flex-direction: column; align-items: flex-end; line-height: 1.15; }
.account-name small { margin-bottom: 0.2rem; color: var(--muted); font-size: 0.68rem; }
.account-name strong { overflow: hidden; max-width: 100%; font-size: 0.86rem; text-overflow: ellipsis; white-space: nowrap; }
.account-action { min-height: 42px; padding: 0.62rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 650; text-decoration: none; white-space: nowrap; }
.identity-loading { color: var(--muted); font-size: 0.82rem; }
.app-shell { width: min(1160px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 6rem; }

.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; }
.intro { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.eyebrow { margin-bottom: 0.45rem; color: var(--primary); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.sync-panel { display: grid; grid-template-columns: auto auto; align-items: center; gap: 0.35rem 0.55rem; min-width: 230px; padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.sync-panel > span:nth-of-type(2) { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; }
.sync-panel .button { grid-column: 1 / -1; margin-top: 0.35rem; }
.sync-choice { display: flex; grid-column: 1 / -1; align-items: center; gap: 0.45rem; margin-top: 0.25rem; color: var(--ink); cursor: pointer; font-size: 0.78rem; font-weight: 700; }
.sync-choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #a36c2f; box-shadow: 0 0 0 4px rgb(163 108 47 / 12%); }
.status-dot.online { background: #278167; box-shadow: 0 0 0 4px rgb(39 129 103 / 13%); }
.message { margin-bottom: 1.5rem; padding: 0.9rem 1rem; border: 1px solid #acd2c7; border-radius: 13px; background: #e8f5f1; }
.message.error, .form-error { border-color: #e3b0ab; background: #fcedeb; color: var(--danger); }
.mobile-only { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.help-panel { margin: -0.65rem 0 2rem; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgb(255 253 248 / 55%); }
.help-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem; list-style: none; }
.help-panel > summary::-webkit-details-marker { display: none; }
.help-panel > summary::after { content: "+"; flex: 0 0 auto; color: var(--muted); font-size: 1.25rem; font-weight: 500; line-height: 1; }
.help-panel[open] > summary::after { content: "−"; }
.help-panel > summary span { font-weight: 750; }
.help-panel > summary small { margin-left: auto; color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.help-content { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 1rem; border-top: 1px solid var(--line); }
.help-content section { min-width: 0; }
.help-content h3 { margin: 0 0 0.45rem; font-size: 0.95rem; }
.help-content p { margin: 0 0 0.65rem; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.help-content p:last-child { margin-bottom: 0; }
.help-content strong { color: var(--ink); }
.help-links { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin: 0; padding: 0 1rem 1rem; font-size: 0.78rem; }

.section-title { display: flex; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.quick-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.8rem; }
.quick-card { display: flex; min-height: 145px; flex-direction: column; align-items: flex-start; gap: 0.38rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: 0 3px 12px rgb(30 52 49 / 4%); cursor: pointer; text-align: left; transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease; }
.quick-card:hover { transform: translateY(-2px); border-color: #9cb8b0; box-shadow: var(--shadow); }
.quick-card:active { transform: translateY(0); }
.quick-card strong { margin-top: auto; font-size: 0.96rem; }
.quick-card small { color: var(--muted); line-height: 1.3; }

.event-icon { display: inline-grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 14px; background: #e1e8e5; color: #35524e; font-weight: 800; }
.event-icon.drink { background: #dceefa; color: #246286; }
.event-icon.urge { background: #f4e1ee; color: #8c3d71; }
.event-icon.release { background: #e3e5f7; color: #4c5692; }
.event-icon.measure, .event-icon.outputmeasurement { background: #dceee8; color: #246f5d; }
.event-icon.stool { background: #eee3d6; color: #7a5635; }
.event-icon.sleep { background: #e7e2f3; color: #62518a; }
.event-icon.context, .event-icon.contextnote { background: #eee9d1; color: #71632c; }

.active-strip { margin: 0 0 2rem; padding: 0.8rem; border: 1px solid #a8c9bd; border-radius: 18px; background: #e9f4f0; }
.active-strip > div { display: flex; align-items: center; gap: 0.8rem; }
.active-strip .button { margin-left: auto; }

.insights-section { margin-top: 3.75rem; }
.insight-title { align-items: center; }
.range-field { display: flex; align-items: center; gap: 0.55rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.range-field select { min-height: 42px; padding: 0.5rem 2rem 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.insights-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.8rem; }
.insight-card { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 3px 12px rgb(30 52 49 / 4%); }
.insight-card-heading { display: flex; min-height: 48px; align-items: flex-start; justify-content: space-between; gap: 0.45rem; }
.insight-label { color: var(--muted); font-size: 0.75rem; font-weight: 750; line-height: 1.3; text-transform: uppercase; letter-spacing: 0.045em; }
.insight-card .badge { flex: 0 0 auto; }
.insight-value { display: block; overflow-wrap: anywhere; margin: 0.3rem 0 0.6rem; font-size: clamp(1.3rem, 2.2vw, 1.85rem); line-height: 1.1; letter-spacing: -0.025em; }
.insight-detail, .insight-provenance { margin: 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.insight-provenance { margin-top: 0.45rem; font-size: 0.7rem; }
.insight-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; margin: 0.3rem 0 0.7rem; }
.insight-breakdown span { display: flex; min-width: 0; flex-direction: column; padding: 0.45rem; border-radius: 10px; background: var(--primary-soft); text-align: center; }
.insight-breakdown strong { font-size: 1.2rem; }
.insight-breakdown small { overflow: hidden; color: var(--muted); font-size: 0.65rem; text-overflow: ellipsis; }
.insight-note { max-width: 940px; margin: 0.8rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.5; }
.insight-note strong { color: var(--ink); }

.timeline-section { margin-top: 3.75rem; }
.timeline-title { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.timeline-heading { display: flex; align-items: center; gap: 0.65rem; }
.timeline-toggle { display: inline-flex; min-height: 36px; align-items: center; gap: 0.35rem; padding: 0.35rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--primary); cursor: pointer; font-size: 0.75rem; font-weight: 750; }
.timeline-toggle:hover { border-color: #9cb8b0; background: var(--primary-soft); }
.timeline-toggle span { font-size: 1rem; line-height: 0.75; }
.export-actions { display: flex; gap: 0.5rem; }
.timeline-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; max-width: 860px; margin: -0.35rem 0 0.25rem; }
.day-navigator { display: flex; align-items: center; gap: 0.4rem; }
.day-button { display: grid; width: 40px; min-height: 40px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 750; }
.day-button:hover { border-color: #9cb8b0; background: var(--primary-soft); }
.date-picker input { min-height: 40px; padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.compact-text { min-height: 40px; padding: 0.4rem 0.55rem; }
.timeline-date-label { max-width: 860px; margin: 0 0 0.65rem; color: var(--muted); font-size: 0.76rem; font-weight: 650; }
.text-button, .icon-button, .close-button { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-weight: 700; }
.text-button { min-height: 42px; padding: 0.55rem 0.7rem; }
.icon-button { min-height: 38px; padding: 0.35rem 0.55rem; border-radius: 9px; }
.icon-button:hover { background: var(--primary-soft); }
.timeline { max-width: 860px; }
.timeline-item { display: grid; grid-template-columns: 62px 1fr; }
.timeline-rail { position: relative; display: flex; justify-content: flex-start; padding-top: 1rem; }
.timeline-rail::after { position: absolute; z-index: -1; top: 0; bottom: 0; left: 21px; width: 1px; background: var(--line); content: ""; }
.timeline-card { margin: 0.65rem 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.timeline-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.timeline-card-heading > div { display: flex; flex-direction: column; gap: 0.18rem; }
.timeline-card p { margin: 0.65rem 0; color: var(--muted); line-height: 1.5; }
.event-time { color: var(--muted); font-size: 0.8rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0.18rem 0.5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.7rem; font-weight: 700; }
.badge.measured { border-color: #a6cdc1; background: #e6f3ef; color: #246957; }
.badge.estimated { border-color: #ddc894; background: #fff4d9; color: #725c26; }
.badge.imported { border-color: #b8c4db; background: #edf1f8; color: #4f6385; }
.badge.imputed { border-color: #d6b7d0; background: #f5eaf2; color: #77516e; }
.badge.mixed { border-color: #c2b9da; background: #eeeaf7; color: #645a82; }
.badge.insufficient { border-color: #c6cdca; background: #f1f3f2; color: #67736f; }
.badge.pending { border-color: #b6c3ce; background: #edf2f5; color: #536674; }
.empty-state { padding: 2.5rem; border: 1px dashed #b9c4bd; border-radius: 18px; color: var(--muted); text-align: center; }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; overflow-y: auto; place-items: center; padding: 1rem; background: rgb(12 33 31 / 60%); backdrop-filter: blur(4px); }
.editor { width: min(680px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.4rem; border: 1px solid var(--line); border-radius: 24px; background: var(--surface-strong); box-shadow: 0 30px 70px rgb(7 28 26 / 35%); }
.editor-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.3rem; }
.close-button { width: 44px; height: 44px; border-radius: 50%; color: var(--muted); font-size: 1.7rem; }
.close-button:hover { background: var(--primary-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid.nested { margin-top: 0.9rem; }
.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.42rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 0.72rem 0.8rem; border: 1px solid #bac6c0; border-radius: 11px; outline: none; background: var(--surface); color: var(--ink); font-weight: 500; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(22 95 90 / 12%); }
.check-field { display: flex; min-height: 48px; align-items: center; gap: 0.65rem; padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.check-field input { width: 20px; height: 20px; accent-color: var(--primary); }
details { padding: 0.8rem; border: 1px solid var(--line); border-radius: 12px; }
summary { color: var(--primary); cursor: pointer; font-weight: 700; }
.severity { margin: 0; padding: 0.9rem; border: 1px solid var(--line); border-radius: 12px; }
.severity input { width: 100%; accent-color: var(--primary); }
.severity div { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.72rem; }
.calculation { margin: 0; padding: 0.8rem; border-radius: 11px; background: var(--primary-soft); }
.form-error { margin: 1rem 0 0; padding: 0.8rem; border: 1px solid; border-radius: 10px; }
.editor-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }
.button { min-height: 46px; padding: 0.68rem 1rem; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 750; }
.button:disabled { cursor: not-allowed; opacity: 0.5; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.danger { background: var(--danger); color: white; }
.button.compact { min-height: 38px; padding: 0.45rem 0.8rem; font-size: 0.82rem; }
.danger-text { color: var(--danger); }
.loading-card { width: min(420px, calc(100% - 2rem)); margin: 20vh auto; padding: 2rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); text-align: center; }
#blazor-error-ui { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: none; max-width: 500px; padding: 1rem; border-radius: 12px; background: #fcedeb; color: #5f2824; box-shadow: var(--shadow); }
#blazor-error-ui .dismiss { float: right; border: 0; background: transparent; }

@media (max-width: 980px) {
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subjective-card { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.3rem; }
  .app-header { min-height: 58px; padding: 0.45rem 0.6rem; }
  .app-shell { width: min(100% - 1.2rem, 1160px); padding: 1rem 0 3.5rem; }
  .brand { gap: 0.5rem; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .brand > span:last-child { display: none; }
  .account-menu { gap: 0.4rem; }
  .account-name { max-width: 38vw; }
  .account-name small { display: none; }
  .account-name strong { font-size: 0.76rem; }
  .account-action { min-height: 38px; padding: 0.5rem 0.7rem; font-size: 0.78rem; }
  .dashboard-heading { align-items: stretch; flex-direction: column; gap: 0.75rem; }
  .dashboard-heading .eyebrow { margin-bottom: 0.25rem; }
  .intro { display: none; }
  .sync-panel { display: flex; min-width: 0; flex-wrap: wrap; gap: 0.35rem 0.5rem; padding: 0.65rem 0.75rem; border-radius: 12px; box-shadow: none; }
  .sync-panel > span:nth-of-type(2) { flex-basis: 100%; font-size: 0.75rem; }
  .sync-choice { flex-basis: 100%; margin-top: 0; font-size: 0.73rem; }
  .help-panel { margin: 0 0 1.35rem; }
  .help-panel > summary { position: relative; align-items: flex-start; flex-direction: column; gap: 0.15rem; padding: 0.65rem 0.75rem; }
  .help-panel > summary small { margin-left: 0; padding-right: 1.5rem; font-size: 0.7rem; }
  .help-panel > summary::after { position: absolute; align-self: flex-end; }
  .help-content { grid-template-columns: 1fr; gap: 1rem; padding: 0.8rem; }
  .help-links { padding: 0 0.8rem 0.8rem; }
  .quick-section .section-title { align-items: end; margin-bottom: 0.65rem; }
  .mobile-only { display: inline; }
  .quick-hint { color: var(--muted); font-size: 0.72rem; }
  .quick-grid { display: flex; padding: 0 0 0.45rem; overflow-x: auto; gap: 0.55rem; scroll-padding-inline: 0.6rem; scroll-snap-type: x proximity; scrollbar-width: none; }
  .quick-grid::-webkit-scrollbar { display: none; }
  .quick-card { min-width: 116px; min-height: 76px; flex: 0 0 116px; flex-direction: row; align-items: center; gap: 0.55rem; padding: 0.65rem; border-radius: 14px; scroll-snap-align: start; }
  .quick-card .event-icon { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; font-size: 0.78rem; }
  .quick-card strong { margin-top: 0; font-size: 0.82rem; line-height: 1.15; }
  .quick-card small { display: none; }
  .insights-section { margin-top: 1.7rem; }
  .insight-title { align-items: flex-end; gap: 0.6rem; margin-bottom: 0.35rem; }
  .insight-title .eyebrow { display: none; }
  .range-field { align-items: flex-end; flex-direction: column; gap: 0.15rem; font-size: 0.67rem; }
  .range-field select { min-height: 36px; max-width: 128px; padding-block: 0.3rem; font-size: 0.75rem; }
  .insights-section > .quick-hint { display: block; margin-bottom: 0.45rem; }
  .insights-grid { display: flex; padding: 0 0 0.45rem; overflow-x: auto; gap: 0.55rem; scroll-padding-inline: 0.6rem; scroll-snap-type: x proximity; scrollbar-width: none; }
  .insights-grid::-webkit-scrollbar { display: none; }
  .insight-card, .subjective-card { min-width: 245px; flex: 0 0 245px; padding: 0.75rem; border-radius: 14px; scroll-snap-align: start; }
  .insight-card-heading { min-height: 38px; }
  .insight-label { font-size: 0.67rem; }
  .insight-value { margin: 0.15rem 0 0.4rem; font-size: 1.35rem; }
  .insight-detail { font-size: 0.7rem; }
  .insight-provenance { font-size: 0.65rem; }
  .insight-note { margin-top: 0.5rem; font-size: 0.68rem; line-height: 1.4; }
  .timeline-section { margin-top: 1.7rem; }
  .timeline-title { align-items: center; gap: 0.4rem; margin-bottom: 0.45rem; padding-bottom: 0.55rem; }
  .timeline-title .eyebrow { display: none; }
  .timeline-heading { gap: 0.35rem; }
  .timeline-toggle { min-height: 32px; padding: 0.25rem 0.45rem; font-size: 0.68rem; }
  .export-actions { gap: 0; }
  .export-actions .text-button { min-height: 36px; padding: 0.35rem 0.45rem; font-size: 0.74rem; }
  .timeline-toolbar { align-items: stretch; gap: 0.3rem; margin: 0 0 0.15rem; }
  .day-navigator { min-width: 0; gap: 0.25rem; }
  .day-button { width: 34px; min-height: 36px; flex: 0 0 34px; }
  .date-picker { min-width: 0; }
  .date-picker input { width: 132px; min-height: 36px; padding: 0.35rem 0.4rem; font-size: 0.72rem; }
  .compact-text { min-height: 36px; padding: 0.25rem 0.35rem; font-size: 0.7rem; }
  .timeline-date-label { margin-bottom: 0.35rem; font-size: 0.68rem; }
  .timeline-item { grid-template-columns: 38px minmax(0, 1fr); }
  .timeline-rail { padding-top: 0.65rem; }
  .timeline-rail::after { display: none; }
  .timeline-rail .event-icon { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; font-size: 0.75rem; }
  .timeline-card { margin: 0.3rem 0; padding: 0.7rem 0.75rem; border-radius: 13px; }
  .timeline-card-heading { gap: 0.5rem; }
  .timeline-card-heading > div { gap: 0.08rem; }
  .timeline-card-heading strong { font-size: 0.9rem; }
  .timeline-card p { margin: 0.35rem 0; font-size: 0.82rem; line-height: 1.35; }
  .event-time { font-size: 0.7rem; }
  .icon-button { min-height: 34px; padding: 0.25rem 0.4rem; font-size: 0.75rem; }
  .badges { gap: 0.25rem; }
  .badge { min-height: 21px; padding: 0.12rem 0.4rem; font-size: 0.62rem; }
  .empty-state { padding: 1.5rem 1rem; font-size: 0.85rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid.nested { gap: 0.75rem; }
  .full { grid-column: auto; }
  .editor { max-height: calc(100vh - 0.5rem); padding: 1rem; border-radius: 18px; }
  .modal-backdrop { align-items: end; padding: 0.25rem; }
  .editor-actions { position: sticky; bottom: -1rem; flex-wrap: wrap; margin-inline: -1rem; padding: 0.8rem 1rem 1rem; background: var(--surface-strong); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #12201f;
    --surface: #192a28;
    --surface-strong: #203330;
    --ink: #e9f2ef;
    --muted: #a9bab5;
    --line: #3b4e4a;
    --primary: #75c7ba;
    --primary-strong: #5fb3a6;
    --primary-soft: #294842;
    --shadow: 0 12px 34px rgb(0 0 0 / 25%);
  }
  .app-header { background: rgb(18 32 31 / 88%); }
  .brand-mark, .button.primary { background: #3b8f83; }
  .button.primary:hover { background: #347d73; }
  .message { background: #193b34; }
  .message.error, .form-error { background: #412824; }
  .help-panel { background: rgb(25 42 40 / 65%); }
}
