:root {
  --canvas: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f0f3f8;
  --surface-strong: #e9eef7;
  --ink: #19212f;
  --ink-muted: #687386;
  --ink-faint: #9aa5b7;
  --line: #dce2ec;
  --line-strong: #c8d1df;
  --accent: #5969eb;
  --accent-ink: #4050d5;
  --accent-soft: #ebedff;
  --success: #25866f;
  --success-soft: #e4f3ed;
  --warning: #b56d19;
  --warning-soft: #fff1dd;
  --danger: #bf4d5d;
  --danger-soft: #fdebed;
  --shadow-sm: 0 1px 2px rgb(25 33 47 / 0.04), 0 4px 12px rgb(25 33 47 / 0.04);
  --shadow-lg: 0 22px 60px rgb(20 29 44 / 0.18), 0 4px 16px rgb(20 29 44 / 0.09);
  --radius-sm: 10px;
  --radius-md: 15px;
  --radius-lg: 22px;
  --rail-width: 84px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --type-title: 14px;
  --type-content: 12px;
  --type-meta: 10px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Pretendard Variable, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

[data-theme="dark"] {
  --canvas: #121822;
  --surface: #1a2230;
  --surface-muted: #202a3a;
  --surface-strong: #283448;
  --ink: #eef3fb;
  --ink-muted: #aeb9ca;
  --ink-faint: #7f8ca0;
  --line: #303c50;
  --line-strong: #40506a;
  --accent: #909cff;
  --accent-ink: #b1baff;
  --accent-soft: #292f62;
  --success: #55b99d;
  --success-soft: #1b3b37;
  --warning: #e9ad61;
  --warning-soft: #47331b;
  --danger: #ed8492;
  --danger-soft: #48262e;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.24), 0 4px 12px rgb(0 0 0 / 0.16);
  --shadow-lg: 0 22px 60px rgb(0 0 0 / 0.48), 0 4px 16px rgb(0 0 0 / 0.24);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
textarea { resize: vertical; }

::selection { color: #fff; background: var(--accent); }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 9px 12px;
  color: #fff;
  border-radius: 8px;
  background: var(--ink);
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus { transform: translateY(0); }

.app-loading {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  color: var(--ink-muted);
  font-size: 14px;
}

.launch-screen {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 28px;
}

.launch-card {
  width: min(100%, 620px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 96%, var(--accent-soft));
  box-shadow: var(--shadow-lg);
}

.launch-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 20px;
  color: #fff;
  border-radius: 14px;
  background: var(--ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.launch-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.launch-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 3.6vw, 30px);
  letter-spacing: -0.035em;
}

.launch-message {
  max-width: 52ch;
  margin: 13px 0 0;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.7;
}

.launch-steps {
  display: grid;
  gap: 12px;
  margin-top: 27px;
  padding-top: 23px;
  border-top: 1px solid var(--line);
}

.launch-steps p,
.launch-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.65;
}

.launch-command {
  display: block;
  overflow-wrap: anywhere;
  padding: 13px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
}

.launch-link {
  width: fit-content;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.launch-note { margin-top: 2px; }


.app-shell {
  min-height: 100dvh;
}

.app-rail {
  position: fixed;
  z-index: 20;
  display: flex;
  width: var(--rail-width);
  height: 100dvh;
  flex-direction: column;
  align-items: center;
  padding: 18px 10px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(18px);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  border-radius: 14px;
  background: #202835;
  box-shadow: 0 6px 16px rgb(32 40 53 / 0.22);
}

.brand-mark svg { width: 24px; height: 24px; }

.rail-nav {
  display: grid;
  width: 100%;
  gap: 8px;
  margin-top: 34px;
}

.rail-bottom { margin-top: auto; }

.nav-button {
  display: grid;
  width: 100%;
  min-height: 56px;
  place-items: center;
  gap: 3px;
  padding: 6px 2px;
  color: var(--ink-muted);
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.nav-button:hover { color: var(--ink); background: var(--surface-muted); }
.nav-button:active { transform: scale(0.96); }
.nav-button.is-active { color: var(--accent-ink); background: var(--accent-soft); }
.nav-button svg { width: 21px; height: 21px; }
.nav-button span { font-size: 10px; font-weight: 720; letter-spacing: -0.03em; }

.workspace {
  min-width: 0;
  padding: 0;
  padding-left: var(--rail-width);
}

.screen {
  width: min(100%, 1560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 30px clamp(22px, 3.2vw, 56px) 42px;
}

.screen-header {
  display: flex;
  min-height: 68px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.heading-group { min-width: 0; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(24px, 2.2vw, 33px);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 1.14;
  text-wrap: balance;
}
h2 { margin-bottom: 0; color: var(--ink); font-size: 17px; font-weight: 780; letter-spacing: -0.045em; }
h3 { margin-bottom: 0; color: var(--ink); font-size: 14px; font-weight: 760; letter-spacing: -0.035em; }

.header-actions, .inline-actions, .segmented, .field-actions, .date-control, .modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button, .icon-button, .chip-button, .segmented button, .nav-link-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button { padding: 0 13px; }
.button svg, .icon-button svg { width: 17px; height: 17px; }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 24%, transparent); }
.button-primary:hover { background: var(--accent-ink); }
.button-secondary { color: var(--ink); border-color: var(--line); background: var(--surface); }
.button-secondary:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.button-ghost { color: var(--ink-muted); background: transparent; }
.button-ghost:hover { color: var(--ink); background: var(--surface-muted); }
.button-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); background: var(--surface); }
.button-danger:hover { color: #fff; border-color: var(--danger); background: var(--danger); }
.button:active, .icon-button:active, .chip-button:active { transform: translateY(1px); }

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--ink-muted);
  border-color: var(--line);
  background: var(--surface);
}
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-muted); }
.icon-button.is-danger:hover { color: #fff; border-color: var(--danger); background: var(--danger); }
.icon-button.is-accent { color: var(--accent); }
.icon-button.is-accent:hover { color: #fff; border-color: var(--accent); background: var(--accent); }

.date-control {
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.date-label-button {
  min-width: 122px;
  min-height: 32px;
  padding: 0 6px;
  color: var(--ink);
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: -0.03em;
}
.date-label-button:hover { background: var(--surface-muted); }
.date-picker-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.metric-strip { display: flex; flex-wrap: wrap; gap: 7px; }
.metric {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  color: var(--ink-muted);
  border-radius: 8px;
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metric strong { color: var(--ink); font-size: 12px; }
.metric-complete strong { color: var(--success); }

.screen[data-screen="journal"] { --journal-context-height: 62px; }
.journal-title-header { margin-bottom: 14px; }
.screen-eyebrow-line { display: flex; align-items: center; gap: 7px; }
.screen-eyebrow-line .eyebrow { margin-bottom: 5px; }
.screen-version {
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  padding: 0 5px;
  color: var(--ink-faint);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-muted) 72%, transparent);
  font-size: 9px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1;
}
.journal-sticky-context {
  position: sticky;
  z-index: 15;
  top: 0;
  min-height: var(--journal-context-height);
  margin: 0 0 16px;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--canvas) 94%, transparent);
  backdrop-filter: blur(16px);
}
.journal-context-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.journal-context-row .metric-strip { flex: 0 0 auto; }

.day-board {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 17px;
  border-bottom: 1px solid var(--line);
}
.panel-heading p { margin: 3px 0 0; color: var(--ink-muted); font-size: 11px; font-weight: 650; }

.plan-list { padding: 7px; }
.plan-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 68px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
}
.plan-item:hover { border-color: var(--line); background: var(--surface-muted); }
.plan-item [data-plan-drag-source="true"] { cursor: grab; }
.plan-item [data-plan-drag-source="true"]:active { cursor: grabbing; }
.plan-item.is-record-dragging { opacity: 0.42; }
.plan-item.is-complete { opacity: 0.64; }
.plan-item.is-complete .plan-title { text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.plan-check { display: grid; width: 18px; height: 18px; place-items: center; color: #fff; border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.plan-check.is-complete { border-color: var(--success); background: var(--success); }
.plan-check svg { width: 12px; height: 12px; }
.plan-copy { min-width: 0; }
.plan-title { overflow: hidden; margin: 0 0 4px; color: var(--ink); font-size: 13px; font-weight: 760; letter-spacing: -0.035em; text-overflow: ellipsis; white-space: nowrap; }
.plan-meta { display: flex; min-width: 0; gap: 5px; color: var(--ink-muted); font-size: 10px; font-weight: 670; }
.plan-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tomorrow-plan { margin: 10px 7px 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); }
.tomorrow-plan-heading { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; color: var(--ink-muted); font-size: 11px; font-weight: 750; }
.tomorrow-plan-heading svg { width: 14px; height: 14px; }
.tomorrow-plan-list { display: grid; gap: 4px; }
.tomorrow-plan-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 12px; }
.tomorrow-plan-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tomorrow-plan-row .button { padding: 3px 9px; font-size: 11px; min-height: unset; }

.priority-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 99px; background: var(--ink-faint); }
.priority-dot.urgent { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent); }
.priority-dot.high { background: var(--warning); }
.priority-dot.normal { background: var(--accent); }
.priority-dot.low { background: var(--success); }

.ledger { overflow: hidden; }
.ledger .panel-heading { padding-right: 13px; }
.ledger-header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.ledger-order-control { display: inline-flex; }
.ledger-order-control select {
  min-width: 78px;
  min-height: 34px;
  padding: 0 25px 0 9px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 740;
  letter-spacing: -0.02em;
}
.ledger-order-control select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.ledger-display-control { min-height: 34px; padding: 2px; border-radius: 10px; }
.ledger-display-control button { min-width: 43px; min-height: 28px; padding: 0 7px; font-size: 11px; }
.ledger-body { position: relative; padding: 6px 0 8px; }
.ledger-body[data-record-drop-zone] { transition: outline-color 140ms ease, background-color 140ms ease; }
.ledger-body[data-record-drop-zone].is-record-drop-target { outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -5px; background: color-mix(in srgb, var(--accent-soft) 68%, transparent); }
.ledger-row {
  position: relative;
  display: grid;
  grid-template-columns: 73px 14px minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0;
  min-height: 92px;
  padding: 0 15px;
}
.ledger-row + .ledger-row .ledger-evidence::after { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 1px; background: color-mix(in srgb, var(--line) 68%, transparent); }
.ledger-row.is-manual-order, .ledger-row.is-manual-order .ledger-content-button { cursor: grab; }
.ledger-row.is-manual-order:active, .ledger-row.is-manual-order:active .ledger-content-button { cursor: grabbing; }
.ledger-row.is-record-dragging { opacity: 0.42; }
.ledger-row.ledger-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.ledger-row.ledger-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.ledger-row, .ledger-content-button { scroll-margin-top: calc(var(--journal-context-height) + 12px); }
.ledger-time { padding: 16px 12px 0 0; color: var(--ink-faint); font-size: 11px; font-weight: 760; font-variant-numeric: tabular-nums; text-align: right; }
.ledger-evidence { position: relative; display: grid; min-height: 100%; place-items: start center; padding-top: 18px; }
.ledger-evidence::before { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.ledger-evidence > span { position: relative; z-index: 1; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 99px; background: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--line)); }
.ledger-evidence > span.result { background: var(--success); box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 35%, var(--line)); }
.ledger-evidence > span.instruction { background: var(--warning); box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 35%, var(--line)); }
.ledger-content { min-width: 0; padding: 13px 14px 14px; }
.ledger-content-button { display: block; width: 100%; padding: 0; color: inherit; border: 0; background: transparent; text-align: left; }
.ledger-content-button:hover .ledger-title { color: var(--accent-ink); }
.ledger-line { display: flex; min-width: 0; align-items: center; gap: 9px; }
.ledger-title { overflow: hidden; margin: 8px 0 0; color: var(--ink); font-size: var(--type-title); font-weight: 790; letter-spacing: -0.045em; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.ledger-preview { margin: 6px 0 0; color: var(--ink-muted); font-size: var(--type-content); letter-spacing: -0.025em; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ledger-preview.is-compact { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.ledger-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; color: var(--ink-faint); font-size: var(--type-meta); font-weight: 650; }
.ledger-actions { display: flex; align-items: flex-start; padding-top: 13px; }
.ledger-actions .journal-order-step { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 24%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface)); }
.ledger-actions .journal-order-step:hover { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 46%, var(--line)); background: var(--accent-soft); }
.ledger-field-group + .ledger-field-group { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.ledger-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 15px 7px 102px; color: var(--ink-muted); }
.ledger-field-heading > div { display: flex; min-width: 0; align-items: center; gap: 7px; }
.ledger-field-name { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 760; letter-spacing: -0.03em; text-overflow: ellipsis; white-space: nowrap; }
.ledger-field-count { display: inline-grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; color: var(--ink-muted); border-radius: 7px; background: var(--surface-muted); font-size: 10px; font-weight: 760; }

.composer { margin: 0 15px 4px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.composer-target-row { display: flex; gap: 7px; margin-bottom: 7px; }
.composer-select, .composer-new-title, .composer-content, .composer-advanced-input {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
  font-size: 12px;
  letter-spacing: -0.02em;
}
.composer-select:focus, .composer-new-title:focus, .composer-content:focus, .composer-advanced-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.composer-select { flex: 1; min-width: 0; }
.composer-select-wide { width: 100%; }
.composer-new-title { width: 100%; margin-bottom: 7px; }
.composer-content { width: 100%; margin-bottom: 8px; line-height: 1.55; resize: vertical; }
.composer-footer { display: flex; align-items: center; gap: 8px; }
.composer-kinds { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.composer-kind-chip { padding: 5px 10px; color: var(--ink-muted); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 11px; font-weight: 650; white-space: nowrap; }
.composer-kind-chip.is-active { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }
.composer-advanced-toggle { display: flex; align-items: center; gap: 4px; padding: 6px 4px; color: var(--ink-muted); border: 0; background: transparent; font-size: 11px; font-weight: 650; white-space: nowrap; }
.composer-advanced-toggle svg { width: 13px; height: 13px; }
.composer-submit { flex: 0 0 auto; }
.composer-advanced { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.composer-advanced[hidden] { display: none; }

.project-tag, .kind-tag, .status-tag, .field-tag, .search-field-tag {
  display: inline-flex;
  max-width: 100%;
  min-height: 21px;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 740;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
.project-tag { border-left: 3px solid var(--project-color, var(--accent)); }
.project-tag::before { display: none; }
.kind-tag { color: var(--accent-ink); background: var(--accent-soft); }
.status-tag.completed { color: var(--success); background: var(--success-soft); }
.status-tag.hold, .status-tag.waiting { color: var(--warning); background: var(--warning-soft); }
.status-tag.cancelled { color: var(--danger); background: var(--danger-soft); }

.screen-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.82fr) minmax(0, 1.5fr);
  gap: 18px;
  align-items: start;
}

.list-panel { overflow: hidden; }
.list-panel-body { padding: 7px; }
.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  text-align: left;
}
button.list-row { width: 100%; }
.list-row:hover, .list-row.is-selected { border-color: var(--line); background: var(--surface-muted); }
.list-row.is-selected { box-shadow: inset 3px 0 0 var(--accent); }
.list-copy { min-width: 0; }
button.list-copy, .tree-copy { display: block; width: 100%; padding: 0; color: inherit; border: 0; background: transparent; text-align: left; }
.list-title { overflow: hidden; margin: 0; color: var(--ink); font-size: calc(var(--type-title) - 1px); font-weight: 760; letter-spacing: -0.035em; text-overflow: ellipsis; white-space: nowrap; }
.project-list-row.is-selected { border-color: color-mix(in srgb, var(--project-color) 34%, var(--line)); background: color-mix(in srgb, var(--project-color) 8%, var(--surface)); box-shadow: none; }
.project-list-title { display: flex; min-width: 0; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: calc(var(--type-title) - 1px); font-weight: 760; letter-spacing: -0.035em; }
.project-list-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list-swatch { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 3px; background: var(--project-color, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--project-color, var(--accent)) 12%, transparent); }
.list-detail { overflow: hidden; margin: 4px 0 0; color: var(--ink-muted); font-size: var(--type-meta); font-weight: 650; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.work-record-list { padding-top: 5px; }
.list-row.work-record-row { min-height: 0; align-items: start; padding: 11px 10px; }
.work-record-copy { display: block; }
.work-record-meta { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 9px; }
.work-record-meta time { flex: 0 0 auto; color: var(--ink-faint); font-size: var(--type-meta); font-weight: 700; font-variant-numeric: tabular-nums; }
.work-record-preview { display: -webkit-box; overflow: hidden; margin: 6px 0 0; color: var(--ink-muted); font-size: var(--type-content); font-weight: 540; letter-spacing: -0.025em; line-height: 1.52; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.work-record-row > svg { width: 17px; height: 17px; margin-top: 3px; color: var(--ink-faint); }
.list-side { display: flex; align-items: center; gap: 5px; color: var(--ink-faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.work-list-detail { display: flex; min-width: 0; align-items: center; gap: 5px; }
.work-list-detail > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-project-name { color: var(--ink); font-weight: 720; }
.work-meta-separator { flex: 0 0 auto; color: var(--ink-faint); }

.detail-panel { min-height: 390px; }
.detail-panel-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.detail-panel-body { padding: 22px; }
.detail-title { margin: 9px 0 8px; color: var(--ink); font-size: clamp(20px, 1.8vw, 26px); font-weight: 820; letter-spacing: -0.06em; line-height: 1.25; overflow-wrap: anywhere; }
.detail-summary { margin: 0; color: var(--ink-muted); font-size: 13px; letter-spacing: -0.025em; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-divider { height: 1px; margin: 20px 0; background: var(--line); }
.detail-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 22px; }
.fact dt { margin: 0 0 4px; color: var(--ink-faint); font-size: 10px; font-weight: 720; }
.fact dd { margin: 0; color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.detail-fact-stack { display: grid; gap: 12px; }
.detail-fact-group { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.detail-fact-group-title { margin: 0; padding: 9px 12px 8px; color: var(--ink-muted); font-size: calc(var(--type-meta) + 1px); font-weight: 780; letter-spacing: -0.02em; }
.detail-fact-group .detail-facts { gap: 1px; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--line); }
.detail-fact-group.is-management .detail-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.detail-fact-group .fact { min-width: 0; min-height: 62px; padding: 10px 12px; background: var(--surface); }
.detail-fact-group .fact dt { margin-bottom: 6px; color: var(--ink-muted); font-size: calc(var(--type-meta) + 1px); font-weight: 740; }
.detail-fact-group .fact dd { min-height: 25px; color: var(--ink); font-size: calc(var(--type-content) + 1px); font-weight: 760; line-height: 1.35; }
.detail-fact-group .inline-fact-value { width: 100%; min-height: 29px; margin: -3px -5px; padding: 4px 5px; font-size: calc(var(--type-content) + 1px); }
.detail-fact-group .inline-edit-mark { opacity: 0.3; transform: none; }
.detail-fact-group .inline-entry-value:hover .inline-edit-mark, .detail-fact-group .inline-entry-value:focus-visible .inline-edit-mark { opacity: 0.82; }
.entry-panel-form { display: grid; gap: 14px; }
.inline-panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 14px; padding-top: 2px; }
.panel-check-field { min-height: 41px !important; align-self: end; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-muted); }
.inline-panel-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.tree-controls { display: flex; align-items: center; gap: 8px; }
.tree-controls .field-select { min-height: 33px; padding: 0 27px 0 9px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 9px; outline: none; background: var(--surface); font-size: 11px; font-weight: 740; letter-spacing: -0.02em; }
.tree-controls .field-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.tree-list { padding: 10px 7px; }
.tree-row {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
}
.tree-row.is-root { grid-template-columns: 25px minmax(0, 1fr) auto; }
.tree-toggle-spacer { pointer-events: none; visibility: hidden; }
.tree-row:hover { border-color: var(--line); background: var(--surface-muted); }
.tree-row.is-dragging { opacity: 0.42; }
.tree-toggle, .tree-action {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  padding: 0;
  color: var(--ink-muted);
  border: 0;
  border-radius: 7px;
  background: transparent;
}
.tree-toggle.is-expandable { color: var(--accent-ink); border: 1px solid var(--line); background: var(--surface-muted); }
.tree-toggle.is-expandable:hover { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 36%, var(--line)); background: var(--accent-soft); }
.tree-toggle:hover, .tree-action:hover { color: var(--ink); background: var(--surface-strong); }
.tree-toggle svg, .tree-action svg { width: 16px; height: 16px; }
.tree-stem { display: grid; width: 15px; height: 25px; place-items: center; color: var(--accent-ink); font-size: 16px; font-weight: 760; line-height: 1; }
.tree-stem-spacer { color: transparent; }
.tree-copy { min-width: 0; }
.tree-title-line { display: flex; min-width: 0; align-items: center; gap: 7px; }
.tree-title { overflow: hidden; margin: 0; color: var(--ink); font-size: calc(var(--type-title) - 1px); font-weight: 750; letter-spacing: -0.035em; text-overflow: ellipsis; white-space: nowrap; }
.tree-level-tag { display: inline-flex; min-height: 19px; align-items: center; flex: 0 0 auto; padding: 0 6px; color: var(--ink-muted); border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); font-size: 9px; font-weight: 750; letter-spacing: -0.015em; line-height: 1; white-space: nowrap; }
.tree-meta-line { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--ink-faint); font-size: 10px; font-weight: 650; }
.tree-meta-line time { font-variant-numeric: tabular-nums; }
.tree-meta-empty { font-style: italic; }
.tree-meta-people { overflow: hidden; color: var(--accent-ink); text-overflow: ellipsis; white-space: nowrap; }
.tree-meta-preview { overflow: hidden; margin: 3px 0 0; color: var(--ink-muted); font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.tree-row[draggable="true"] { cursor: grab; }
.tree-row[draggable="true"]:active { cursor: grabbing; }
.tree-row-actions { flex: 0 0 auto; gap: 5px; }
.tree-row-actions .icon-button { width: 34px; min-height: 34px; border-radius: 9px; }
.tree-row-actions .icon-button svg { width: 15px; height: 15px; }
.tree-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tree-drop-child { outline: 2px solid color-mix(in srgb, var(--accent) 46%, transparent); outline-offset: -2px; background: var(--accent-soft); }

.priority-list { padding: 6px 7px 8px; }
.priority-section + .priority-section { margin-top: 12px; }
.priority-label { display: flex; align-items: center; gap: 7px; padding: 9px 10px 6px; color: var(--ink-muted); font-size: 11px; font-weight: 760; }
.priority-label strong { color: var(--ink); font-size: 12px; }

.search-bar {
  display: flex;
  min-height: 47px;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.search-bar svg { width: 19px; height: 19px; color: var(--ink-muted); }
.search-bar input { width: 100%; min-width: 0; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 14px; font-weight: 650; letter-spacing: -0.025em; }
.search-bar input::placeholder { color: var(--ink-faint); }
.search-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.search-results { padding: 8px; }
.search-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; width: 100%; padding: 13px; color: inherit; border: 1px solid transparent; border-radius: 14px; background: transparent; text-align: left; }
.search-result:hover { border-color: var(--line); background: var(--surface-muted); }
.search-result-title { margin: 0; color: var(--ink); font-size: 14px; font-weight: 770; letter-spacing: -0.04em; }
.search-result-path { margin: 4px 0 0; color: var(--ink-muted); font-size: 10px; font-weight: 650; }
.search-match { margin: 9px 0 0; color: var(--ink-muted); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
mark { padding: 0 1px; color: inherit; border-radius: 2px; background: #ffe68d; }
[data-theme="dark"] mark { color: #fff4c8; background: #765d18; }

.settings-layout { display: grid; grid-template-columns: minmax(250px, 0.72fr) minmax(0, 1.28fr); gap: 18px; }
.settings-list { padding: 7px; }
.setting-row { display: flex; min-height: 60px; align-items: center; justify-content: space-between; gap: 14px; padding: 10px; border: 1px solid transparent; border-radius: 14px; }
.setting-row + .setting-row { margin-top: 2px; }
.setting-row:hover { background: var(--surface-muted); }
.setting-copy p { margin: 4px 0 0; color: var(--ink-muted); font-size: 11px; line-height: 1.45; }
.setting-row-stack { display: grid; align-items: start; }
.type-size-controls { display: flex; flex-wrap: wrap; gap: 7px; }
.type-size-controls label { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-muted); font-size: 10px; font-weight: 720; }
.type-size-controls input { width: 46px; min-height: 30px; padding: 4px 5px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-size: 11px; text-align: center; }
.toggle { position: relative; display: inline-flex; width: 42px; height: 25px; flex: 0 0 auto; border: 0; border-radius: 99px; background: var(--line-strong); }
.toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 17px; height: 17px; border-radius: 99px; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.22); transition: transform 150ms ease; }
.toggle[aria-pressed="true"] { background: var(--accent); }
.toggle[aria-pressed="true"]::after { transform: translateX(17px); }
.backup-status { display: grid; gap: 11px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-muted); }
.backup-status p { margin: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.55; }
.backup-status strong { color: var(--ink); }

.empty-state { display: grid; min-height: 182px; place-items: center; align-content: center; gap: 8px; padding: 28px 20px; color: var(--ink-muted); text-align: center; }
.empty-state svg { width: 28px; height: 28px; color: var(--ink-faint); }
.empty-state h3 { margin-top: 4px; }
.empty-state p { max-width: 280px; margin: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.55; }

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) 18px max(18px, var(--safe-bottom));
  background: rgb(20 28 41 / 0.44);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
}
.dialog {
  width: min(680px, 100%);
  max-height: calc(100dvh - 36px - var(--safe-bottom));
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}
.dialog.dialog-wide { width: min(850px, 100%); }
.dialog.dialog-compact { width: min(540px, 100%); }
.dialog-header { position: sticky; z-index: 2; top: 0; display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
.dialog-header h2 { font-size: 17px; }
.dialog-body { padding: 20px; }
.dialog-footer { position: sticky; z-index: 2; bottom: 0; display: flex; min-height: 66px; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 14px; }
.field { min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field > label, .fieldset-label { display: block; margin: 0 0 6px; color: var(--ink-muted); font-size: 11px; font-weight: 740; letter-spacing: -0.02em; }
.field input:not([type="checkbox"]), .field textarea, .field select {
  width: 100%;
  min-height: 41px;
  padding: 9px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  font-size: 13px;
  letter-spacing: -0.02em;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}
.field textarea { min-height: 132px; line-height: 1.62; }
.field input:not([type="checkbox"]):focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.check-field { display: inline-flex !important; width: fit-content; min-height: 30px; align-items: center; gap: 9px; margin: 0 !important; color: var(--ink) !important; font-size: 12px !important; font-weight: 720 !important; cursor: pointer; }
.check-field input[type="checkbox"] { position: relative; display: grid; width: 18px; min-width: 18px; height: 18px; min-height: 18px; place-items: center; margin: 0; padding: 0; appearance: none; color: var(--accent); border: 1.5px solid var(--line-strong); border-radius: 5px; outline: none; background: var(--surface); cursor: pointer; }
.check-field input[type="checkbox"]::after { width: 7px; height: 4px; content: ""; border-right: 2px solid #fff; border-bottom: 2px solid #fff; opacity: 0; transform: translateY(-1px) rotate(45deg); }
.check-field input[type="checkbox"]::before { position: absolute; inset: -4px; content: ""; border-radius: 8px; }
.check-field input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
.check-field input[type="checkbox"]:checked::after { opacity: 1; }
.check-field input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field-help { margin: 6px 0 0; color: var(--ink-faint); font-size: 10px; line-height: 1.4; }
.detail-dialog { padding-top: 18px; }
.detail-dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.inline-entry-heading { margin: 3px 0 7px; }
.inline-entry-value {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}
.inline-entry-value > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.inline-entry-title-value { font-size: clamp(20px, 1.8vw, 26px); font-weight: 820; letter-spacing: -0.06em; line-height: 1.25; }
.inline-entry-content-value { min-height: 48px; color: var(--ink-muted); font-size: var(--type-content); font-weight: 500; letter-spacing: -0.025em; line-height: 1.7; white-space: pre-wrap; }
.inline-entry-content-value.is-empty { color: var(--ink-faint); }
.inline-edit-mark { display: grid; width: 18px; height: 18px; flex: 0 0 auto; place-items: center; margin-top: 2px; color: var(--accent-ink); opacity: 0; transform: translateX(-2px); transition: opacity 140ms ease, transform 140ms ease; }
.inline-edit-mark svg { width: 14px; height: 14px; }
.inline-entry-value:hover, .inline-entry-value:focus-visible { border-color: var(--line); background: var(--surface-muted); outline: none; }
.inline-entry-value:hover .inline-edit-mark, .inline-entry-value:focus-visible .inline-edit-mark { opacity: 0.72; transform: translateX(0); }
.inline-title-input, .inline-content-input { width: 100%; color: var(--ink); border: 1px solid transparent; border-radius: 10px; outline: none; background: transparent; transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease; }
.inline-title-input { margin: 3px 0 7px; padding: 4px 6px; font-size: clamp(20px, 1.8vw, 26px); font-weight: 820; letter-spacing: -0.06em; line-height: 1.25; }
.inline-content-input { min-height: 88px; padding: 7px 6px; font-size: var(--type-content); letter-spacing: -0.025em; line-height: 1.7; resize: vertical; }
.inline-title-input:hover, .inline-content-input:hover { border-color: var(--line); background: var(--surface-muted); }
.inline-title-input:focus, .inline-content-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.inline-fact-value { min-height: 27px; padding: 3px 5px; color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.35; }
.inline-fact-value .inline-edit-mark { width: 15px; height: 15px; margin-top: 0; }
.inline-fact-value .inline-edit-mark svg { width: 12px; height: 12px; }
.inline-fact-editor { width: 100%; min-height: 34px; padding: 6px 7px; color: var(--ink); border: 1px solid var(--accent); border-radius: 8px; outline: none; background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); font-size: 12px; font-weight: 700; letter-spacing: -0.025em; }
.record-content-input { min-height: 205px; }
.quick-record-dialog { display: grid; gap: 14px; }
.quick-record-context { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 10px 11px; border-radius: 11px; background: var(--surface-muted); }
.quick-record-context strong { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 760; letter-spacing: -0.03em; text-overflow: ellipsis; white-space: nowrap; }
.quick-fields { display: grid; grid-template-columns: 0.75fr 1.1fr 1.1fr; gap: 10px; margin: 12px 0; }
.quick-fields label { display: grid; gap: 5px; color: var(--ink-muted); font-size: 10px; font-weight: 720; }
.quick-fields select, .quick-fields input { width: 100%; min-height: 37px; padding: 7px 8px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 9px; outline: none; background: var(--surface); font-size: 12px; }
.quick-fields select:focus, .quick-fields input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.detail-section-heading { display: flex; align-items: center; gap: 7px; margin: 0 0 11px; }
.count-badge { display: inline-grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; color: var(--accent-ink); border-radius: 7px; background: var(--accent-soft); font-size: 10px; font-weight: 800; vertical-align: 2px; }
.record-stack, .revision-list { display: grid; gap: 5px; }
.record-line { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: start; gap: 10px; width: 100%; padding: 10px; color: inherit; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); text-align: left; }
.record-line:hover { border-color: var(--line-strong); background: var(--surface-strong); }
.record-line time { padding-top: 4px; color: var(--ink-faint); font-size: var(--type-meta); font-weight: 700; font-variant-numeric: tabular-nums; }
.record-line p { display: -webkit-box; overflow: hidden; margin: 5px 0 0; color: var(--ink-muted); font-size: var(--type-content); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 10; }
.record-line-source { display: block; overflow: visible; margin: 0; color: var(--accent); font-size: var(--type-meta); font-weight: 700; -webkit-line-clamp: 1; }
.record-line svg { width: 17px; height: 17px; margin-top: 4px; color: var(--ink-faint); }
.revision-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); }
.revision-row strong { color: var(--ink); font-size: 12px; font-weight: 760; }
.revision-row p { margin: 4px 0 0; color: var(--ink-faint); font-size: var(--type-meta); font-variant-numeric: tabular-nums; }
.confirm-copy { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.confirm-copy > svg { width: 24px; height: 24px; color: var(--warning); }
.confirm-copy p { margin: 7px 0 0; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
.form-section { grid-column: span 2; padding-top: 2px; }
.form-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 8px; color: var(--ink); font-size: 12px; font-weight: 760; }
.form-section-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch { display: inline-grid; width: 26px; height: 26px; place-items: center; padding: 0; border: 2px solid transparent; border-radius: 9px; background: var(--swatch); }
.color-swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.color-swatch svg { width: 15px; height: 15px; color: #fff; }

.segmented { min-height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.segmented button { min-height: 30px; flex: 1; padding: 0 8px; color: var(--ink-muted); border: 0; border-radius: 8px; background: transparent; white-space: nowrap; }
.segmented button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgb(25 33 47 / 0.1); }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; width: min(360px, calc(100% - 36px)); gap: 8px; padding-bottom: var(--safe-bottom); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 12px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-lg); font-size: 12px; font-weight: 660; line-height: 1.45; pointer-events: auto; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }

.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

:is(button, input, textarea, select, a):focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

@media (max-width: 959px) {
  :root { --bottom-bar-height: 70px; }
  .app-shell { display: block; min-height: 100dvh; }
  .app-rail { display: none; }
  .workspace { padding-left: 0; padding-bottom: calc(var(--bottom-bar-height) + var(--safe-bottom)); }
  .screen { min-height: calc(100dvh - var(--bottom-bar-height)); padding: 22px 18px 26px; }
  .screen-header { min-height: 0; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
  .screen-header .header-actions { margin-left: auto; }
  .journal-context-row { flex-wrap: wrap; gap: 7px; }
  .journal-context-row .header-actions, .journal-context-row .metric-strip { width: 100%; }
  .day-board, .screen-grid, .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .day-board { gap: 14px; }
  .panel { border-radius: 18px; }
  .mobile-nav {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(var(--bottom-bar-height) + var(--safe-bottom));
    padding: 7px 8px calc(7px + var(--safe-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 93%, transparent);
    backdrop-filter: blur(18px);
  }
  .mobile-nav .nav-button { min-height: 51px; }
  .mobile-nav .nav-button span { font-size: 10px; }
  .workspace .screen:last-child { padding-bottom: 0; }
  .ledger-row { grid-template-columns: 52px 13px minmax(0, 1fr) auto; padding: 0 10px; }
  .ledger-time { padding-right: 8px; font-size: 10px; }
  .ledger-content { padding-right: 8px; padding-left: 10px; }
}

@media (min-width: 960px) {
  .mobile-nav { display: none; }
  .day-board > .plan-panel {
    position: sticky;
    top: calc(var(--journal-context-height) + 12px);
    display: flex;
    max-height: calc(100dvh - var(--journal-context-height) - 24px);
    flex-direction: column;
    overflow: hidden;
  }
  .plan-panel .plan-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
}

@media (max-width: 620px) {
  .screen { padding: 18px 13px 24px; }
  h1 { font-size: 25px; }
  .header-actions { gap: 6px; }
  .button { padding: 0 10px; }
  .button-label-mobile-hidden { display: none; }
  .date-control { width: 100%; justify-content: space-between; }
  .date-label-button { flex: 1; }
  .metric-strip { width: 100%; }
  .metric { flex: 1; justify-content: center; }
  .ledger-row { grid-template-columns: 44px 11px minmax(0, 1fr); min-height: 88px; }
  .ledger-actions { display: none; }
  .ledger-title { font-size: 13px; }
  .ledger-preview { font-size: 11px; }
  .ledger .panel-heading { align-items: flex-start; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
  .ledger-header-actions { width: 100%; flex-wrap: wrap; justify-content: space-between; }
  .ledger-order-control { flex: 1 1 86px; }
  .ledger-order-control select { width: 100%; }
  .ledger-display-control { flex: 0 0 auto; }
  .ledger-header-actions .button { flex: 1; }
  .ledger-field-heading { padding-right: 10px; padding-left: 67px; }
  .panel-heading { min-height: 54px; padding: 0 14px; }
  .detail-panel-body { padding: 17px; }
  .detail-facts, .detail-fact-group .detail-facts, .detail-fact-group.is-management .detail-facts, .form-grid, .form-section-body, .inline-panel-grid { grid-template-columns: minmax(0, 1fr); }
  .quick-fields { grid-template-columns: minmax(0, 1fr); }
  .record-line { grid-template-columns: minmax(0, 1fr) auto; }
  .record-line time { grid-column: span 2; padding-top: 0; }
  .field.span-2, .form-section { grid-column: span 1; }
  .form-section-body { padding: 12px; }
  .dialog { width: 100%; max-height: calc(100dvh - 18px - var(--safe-bottom)); border-radius: 20px; }
  .modal-backdrop { align-items: end; padding: 9px 8px var(--safe-bottom); }
  .dialog-body { padding: 17px; }
  .dialog-header { padding: 0 16px; }
  .dialog-footer { padding-right: 16px; padding-left: 16px; }
  .toast-region { right: 10px; bottom: calc(var(--bottom-bar-height) + 9px); width: calc(100% - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* Cloudflare → Oracle sync status. Compact enough to remain visible in phone and DeX headers. */
.screen-title-line { display: flex; min-width: 0; align-items: center; gap: 10px; }
.screen-title-line h1 { min-width: 0; }
.sync-badge { display: inline-flex; min-height: 28px; flex: 0 0 auto; align-items: center; gap: 5px; padding: 3px 9px; color: var(--ink-muted); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 10px; font-weight: 760; line-height: 1; }
.sync-badge svg { width: 13px; height: 13px; }
.sync-badge.is-synced { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--line)); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.sync-badge.is-working { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); background: var(--accent-soft); }
.sync-badge.is-pending, .sync-badge.is-warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 32%, var(--line)); }
.sync-badge.is-conflict { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--line)); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }

.settings-layout > .sync-panel { grid-column: 1 / -1; }
.sync-panel .panel-heading { gap: 18px; }
.sync-overview { display: grid; grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr); gap: 14px; padding: 18px; }
.sync-primary-status { display: flex; min-height: 92px; align-items: center; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-muted); }
.sync-primary-status > svg { width: 28px; height: 28px; flex: 0 0 auto; color: var(--accent); }
.sync-primary-status strong, .sync-primary-status span { display: block; }
.sync-primary-status strong { color: var(--ink); font-size: 14px; }
.sync-primary-status span { margin-top: 5px; color: var(--ink-muted); font-size: 11px; line-height: 1.45; }
.sync-primary-status.is-conflict > svg { color: var(--danger); }
.sync-primary-status.is-pending > svg, .sync-primary-status.is-warning > svg { color: var(--warning); }
.sync-primary-status.is-synced > svg { color: var(--success); }
.sync-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--line); }
.sync-metrics > div { min-width: 0; padding: 13px 15px; background: var(--surface); }
.sync-metrics dt { color: var(--ink-faint); font-size: 10px; font-weight: 720; }
.sync-metrics dd { overflow: hidden; margin: 5px 0 0; color: var(--ink); font-size: 12px; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.sync-boundary-note { margin: 0 18px 18px; padding: 12px 14px; color: var(--ink-muted); border-left: 3px solid var(--accent); background: var(--surface-muted); font-size: 11px; line-height: 1.6; }
.sync-conflict-list { padding: 0 18px 18px; }
.sync-conflict-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.sync-conflict-card + .sync-conflict-card { margin-top: 8px; }
.sync-conflict-kicker { color: var(--danger) !important; font-size: 9px !important; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.sync-conflict-card h3 { margin: 3px 0 0; font-size: 13px; }
.sync-conflict-card p { margin: 5px 0 0; color: var(--ink-muted); font-size: 11px; line-height: 1.45; }
.sync-conflict-copy { min-width: 0; flex: 1; }
.sync-conflict-item { margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.sync-conflict-item summary { cursor: pointer; padding: 9px 11px; color: var(--ink); font-size: 11px; font-weight: 720; }
.sync-value-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 9px 9px; }
.sync-value-grid > div { min-width: 0; padding: 9px; border-radius: 8px; background: var(--surface-muted); }
.sync-value-grid strong { font-size: 10px; }
.sync-value-grid pre { overflow: auto; max-height: 180px; margin: 6px 0 0; color: var(--ink-muted); font: 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.sync-rejected-card code { display: inline-block; margin-top: 8px; padding: 3px 6px; border-radius: 6px; background: var(--surface-muted); color: var(--danger); font-size: 10px; }

@media (max-width: 720px) {
  .sync-overview { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .sync-panel .panel-heading, .sync-conflict-card { align-items: flex-start; flex-direction: column; }
  .sync-panel .panel-heading .inline-actions, .sync-conflict-card .inline-actions { width: 100%; }
  .sync-panel .panel-heading .button, .sync-conflict-card .button { flex: 1; }
  .sync-value-grid { grid-template-columns: minmax(0, 1fr); }
  .sync-boundary-note { margin-right: 14px; margin-left: 14px; }
}

@media (max-width: 420px) {
  .screen-title-line { align-items: flex-end; justify-content: space-between; }
  .sync-badge { min-height: 26px; padding: 3px 7px; }
  .sync-badge span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sync-metrics { grid-template-columns: minmax(0, 1fr); }
}
