/* Shared interaction geometry; page-specific accents remain intact. */
:root {
  --radius-control: 999px;
  --radius-card: 16px;
  --radius-dialog: 20px;
  --mobile-nav-height: 64px;
  --focus-ring: 0 0 0 3px var(--accent-soft);
}
button, input, textarea, select { font-family: inherit; }
/* Toast foreground and background must change together across themes. */
:root .toast {
  color: #ffffff;
  background: #252529;
  border: 1px solid #ffffff26;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-weight: 500;
  line-height: 1.6;
  text-shadow: none;
}
html[data-theme="dark"] .toast {
  color: #202024;
  background: #f2f2f7;
  border-color: #ffffff80;
}
:where(button, a, input, textarea, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:where(.app-shell, .header-center, .input-textarea, .asset-info) { min-width: 0; }
:where(.segmented-control, .filter-capsules-group, .filter-bar, .routine-tag-bar) {
  border-radius: var(--radius-control);
  max-width: 100%;
}
:where(.segmented-control .seg-btn) { border-radius: var(--radius-control); }
:where(.asset-name, .tweet-body, .ai-bubble) { overflow-wrap: anywhere; }
:where(dialog) { overscroll-behavior: contain; }
.data-notice, .profile-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--backdrop);
  padding: 12px 14px;
  font-size: .8rem;
  line-height: 1.65;
  color: var(--muted);
}
.data-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.data-notice p { flex: 1 1 230px; }
.data-notice button {
  border: 1px solid var(--line); border-radius: var(--radius-control);
  color: var(--ink); background: var(--surface-card); padding: 8px 14px; cursor: pointer;
}
.profile-summary { margin-bottom: 14px; }
.profile-summary:empty { display: none; }
.profile-summary strong { color: var(--ink); font-weight: 600; }
.profile-summary span { display: inline-block; margin-right: 16px; }
.sample-badge { font-size: .66rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; white-space: nowrap; }
@media (max-width: 640px) {
  html { scroll-padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  body > aside.left-rail {
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    display: flex; gap: 0; justify-content: space-around;
  }
  body > aside.left-rail .rail-tab { flex: 1 1 0; min-width: 0; max-width: 72px; width: auto; height: 56px; }
  body > .app-shell {
    margin: 0; width: 100%; max-width: 100%; border: 0; border-radius: 0;
    padding-inline: max(12px, env(safe-area-inset-left));
  }
  :where(.segmented-control, .filter-capsules-group, .filter-bar, .routine-tag-bar, .inventory-tag-bar) {
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  :where(.seg-btn, .filter-button, .filter-capsule-btn, .routine-tag-btn, .meal-tab-btn) {
    min-height: 36px; flex-shrink: 0;
  }
  :where(.btn-icon, .theme-toggle-btn, .date-btn, .action-btn-sm, .btn-attach, .btn-send) { min-width: 36px; min-height: 36px; }
  :where(input:not([type=checkbox]):not([type=radio]), textarea, select) { font-size: 16px; }
  dialog#composer, dialog#reviewComposer, dialog#anniversaryModal {
    width: calc(100% - 24px); max-width: 560px; margin: auto;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto; border-radius: var(--radius-dialog);
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .modal-overlay { padding: 16px 12px; }
  .modal-overlay .modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
  .toast { max-width: calc(100vw - 32px); white-space: normal; text-align: center; bottom: calc(var(--mobile-nav-height) + 14px + env(safe-area-inset-bottom)); }
  .floating-add-btn {
    bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom)) !important;
    right: 20px !important;
  }
  .assets-subtabs .seg-btn { flex: 1 0 auto; padding-inline: 10px; }
  .health-header { flex-wrap: wrap; }
  .health-header .date-controller { order: 3; margin-inline: auto; }
  .health-header .header-right { margin-left: auto; }
  .asset-card { gap: 10px; flex-wrap: wrap; }
  .asset-card-left { flex: 1 1 180px; min-width: 0; }
  .asset-card-right { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
body.has-overlay-dialog { overflow: hidden; }
.quiet-settings { color: var(--muted); font-size: .76rem; line-height: 1.7; margin-block: 8px; }
.quiet-settings > summary { cursor: pointer; width: fit-content; padding: 4px 0; }
.quiet-settings[open] { border-top: 1px solid var(--line); padding-top: 8px; }
.quiet-settings .profile-summary { margin-top: 8px; }
.digital-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.digital-filter-controls { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
:root body .account-picker-trigger {
  display: flex; align-items: center; gap: 12px; max-width: 230px; min-width: 100px;
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); background: var(--surface-solid); cursor: pointer; flex: 0 1 auto;
}
#digitalAccountLabel { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.digital-catalog-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .74rem; }
.digital-catalog-summary button { border: none; background: transparent; color: var(--muted); font-size: inherit; cursor: pointer; min-height: 32px; }
#digitalEmpty[hidden], #clearDigitalFilters[hidden] { display: none; }
#openDigitalCosts { margin-left: auto; color: var(--accent); text-align: right; }
.account-picker-list { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.account-picker-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 13px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.account-picker-row span:first-child { overflow-wrap: anywhere; min-width: 0; }
.account-picker-row span:last-child { white-space: nowrap; color: var(--muted); font-size: .74rem; }
.account-picker-row[aria-pressed="true"], .account-picker-row:hover { background: var(--accent-soft); }
.digital-cost-group { padding-block: 12px; border-bottom: 1px solid var(--line); }
.digital-cost-group h4 { font-size: .76rem; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.digital-cost-group p { font-size: 1.05rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.digital-cost-explanation { color: var(--muted); font-size: .76rem; line-height: 1.7; margin-top: 14px; }
.digital-sample-toggle { display: flex; align-items: center; gap: 6px; margin-block: 8px; }
.digital-account-fields, .digital-billing-fields { color: var(--muted); font-size: .8rem; margin-block: 14px; }
.digital-account-fields summary, .digital-billing-fields summary { cursor: pointer; margin-bottom: 12px; }
:root body :is(#digitalAccountModal, #digitalCostsModal) .modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; }
@media (max-width: 900px) {
  .digital-filter-controls { flex-wrap: wrap; gap: 10px; }
  :root body #digitalCategories { max-width: 100%; width: 100%; }
  .digital-toolbar { align-items: flex-start; }
  :root body .account-picker-trigger { max-width: min(250px, 100%); }
}
:root body #digitalCategories { min-width: 0; flex-shrink: 1; }
.digital-streams { display: grid; gap: 16px; }
.digital-streams > [hidden] { display: none !important; }
.digital-streams h2 { font-size: .8rem; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
:root body .digital-compact-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; }
.digital-compact-card .asset-info { flex: 1 1 auto; min-width: 0; }
.digital-card-status, .digital-daily-cost { font-size: .74rem; color: var(--muted); }
.digital-daily-cost { color: var(--accent); }
.digital-card-actions { display: flex; align-items: flex-end; flex-direction: column; gap: 6px; flex: 0 0 auto; }
:root body .digital-card-actions .asset-amount { font-size: .85rem; white-space: nowrap; }
.digital-details-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .75rem; min-height: 32px; padding: 2px 8px; border-radius: 999px; }
.digital-details-btn:hover { color: var(--accent); background: var(--accent-soft); }
.digital-detail-fields { display: grid; grid-template-columns: 1fr; gap: 4px; font-size: .86rem; }
.digital-detail-fields dt { color: var(--muted); margin-top: 10px; font-size: .74rem; }
.digital-detail-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.digital-purchase-fields { margin-block: 14px; color: var(--muted); font-size: .8rem; }
.digital-purchase-fields summary { cursor: pointer; margin-bottom: 12px; }
.asset-note-details summary { cursor: pointer; color: var(--muted); }
.asset-note-details p { margin-top: 6px; overflow-wrap: anywhere; white-space: pre-wrap; }
:root body :is(#digitalModal, #digitalDetailModal) .modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; }
:root body #digitalModal textarea.modal-input { height: auto; min-height: 80px; resize: vertical; }
#localAssetsBackup { width: 100%; min-height: 180px; margin-top: 12px; color: var(--ink); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
@media (max-width: 400px) {
  :root body #digitalCategories .seg-btn { padding-inline: 9px; }
  :root body .digital-compact-card { padding: 12px; }
}

/* C066: navigation families own their accent; child views stay in that family. */
:root[data-app="home"] { --app-accent: #9953c8; }
:root[data-app="tasks"] { --app-accent: #2878ba; }
:root[data-app="life"] { --app-accent: #25836b; }
:root[data-app="clipboard"] { --app-accent: #168894; }
:root[data-app="learning"] { --app-accent: #c45f58; }
:root[data-app="more"] { --app-accent: #797294; }
:root[data-theme="dark"][data-app="home"] { --app-accent: #c68be8; }
:root[data-theme="dark"][data-app="tasks"] { --app-accent: #78b4e5; }
:root[data-theme="dark"][data-app="life"] { --app-accent: #70c9ad; }
:root[data-theme="dark"][data-app="clipboard"] { --app-accent: #6bc7cf; }
:root[data-theme="dark"][data-app="learning"] { --app-accent: #efa39a; }
:root[data-theme="dark"][data-app="more"] { --app-accent: #b3a8d1; }
:root[data-app] {
  --accent: var(--app-accent);
  --accent-soft: color-mix(in srgb, var(--app-accent) 13%, transparent);
  --soft: var(--accent-soft);
  --action-accent: var(--app-accent);
}
/* Creation follows the task module accent in both themes. */
:root[data-app="tasks"] { --add-action-accent: var(--app-accent); }

:root[data-asset-tab="finance"] { --action-accent: #298878; }
:root[data-asset-tab="digital"] { --action-accent: #37856a; }
:root[data-theme="dark"][data-asset-tab="finance"] { --action-accent: #78c9bb; }
:root[data-theme="dark"][data-asset-tab="digital"] { --action-accent: #8acbb0; }
:root[data-diary-tab] { --action-accent: var(--app-accent); }
:root body .rail-tab.active .rail-tab-icon { color: var(--app-accent); }
:root body :is(#themeBtn, #themeToggle).global-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; min-width: 30px; min-height: 30px; flex: 0 0 30px;
  padding: 0; border: 0; border-radius: 0;
  color: var(--ink); background: transparent;
  box-shadow: none; cursor: pointer; transition: color .16s ease, background .16s ease;
}
:root body :is(#themeBtn, #themeToggle).global-theme-toggle:hover {
  color: var(--app-accent) !important;
  background: transparent !important;
}
.global-theme-toggle svg { width: 18px; height: 18px; }
:root body .header-control-capsule :is(.compact-search-toggle, .header-action-icon, .capsule-icon-btn, .btn-icon, .date-btn):hover,
:root body .header-control-capsule :is(.compact-search-toggle, .header-action-icon, .capsule-icon-btn, .btn-icon, .date-btn)[aria-expanded="true"] {
  color: var(--app-accent) !important;
  background: transparent !important;
  border-color: transparent !important;
}
/* Toolbar actions stay flat: only the add action keeps a circle glow. */
:root body .header-control-capsule :is(.compact-search-toggle, .header-action-icon, .capsule-icon-btn, .btn-icon, .date-btn) {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
:root body .header-control-capsule :is(.compact-search-toggle, .header-action-icon, .capsule-icon-btn, .btn-icon, .date-btn):hover {
  background: color-mix(in srgb, var(--app-accent) 8%, transparent) !important;
  box-shadow: none !important;
}
:root body .header-control-capsule :is(.compact-search-toggle, .header-action-icon, .capsule-icon-btn, .btn-icon, .date-btn):is([aria-pressed="true"], .active) {
  color: var(--app-accent) !important;
  background: var(--accent-soft) !important;
  box-shadow: none !important;
}
:root body .header-right { display: flex; align-items: center; gap: 8px; }
:root body .header-control-capsule :is(.header-action-add, .header-add-action) {
  display: inline-grid;
  place-items: center;
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  flex: 0 0 28px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  color: var(--add-action-accent, var(--action-accent, var(--app-accent))) !important;
  background: color-mix(in srgb, var(--add-action-accent, var(--action-accent, var(--app-accent))) 12%, transparent) !important;
  box-shadow: 0 0 12px color-mix(in srgb, var(--add-action-accent, var(--action-accent, var(--app-accent))) 16%, transparent) !important;
  cursor: pointer;
  transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}
:root body .header-control-capsule > :is(.header-action-add, .header-add-action) { order: -100; }
:root body .header-control-capsule > .compact-search { order: -90; }
:root body .header-control-capsule > .todo-top-toolbar { order: -100; }
:root body .header-control-capsule .chat-action-capsule > #newChatBtn { order: -100; }
:root body .header-control-capsule .chat-action-capsule > #searchChatBtn { order: -90; }
:root body .header-control-capsule .chat-action-capsule > #sessionsToggleBtn { order: -80; }
:root body .header-control-capsule > #clearBoughtInventoryBtn { order: -80; }
:root body .header-control-capsule :is(.header-action-add, .header-add-action):hover {
  background: color-mix(in srgb, var(--add-action-accent, var(--action-accent, var(--app-accent))) 18%, transparent) !important;
  box-shadow: 0 0 15px color-mix(in srgb, var(--add-action-accent, var(--action-accent, var(--app-accent))) 22%, transparent) !important;
}
:root body .header-control-capsule .compact-search-toggle {
  width: 30px; height: 30px; min-width: 30px;
  border: 0; border-radius: 0; background: transparent; color: var(--ink);
}
:root body .header-control-capsule .todo-top-toolbar .header-action-add {
  display: grid !important;
  place-items: center;
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  flex: 0 0 28px !important;
  color: var(--add-action-accent, var(--app-accent)) !important;
  background: color-mix(in srgb, var(--add-action-accent, var(--app-accent)) 12%, transparent) !important;
  background-image: none !important;
  box-shadow: 0 0 12px color-mix(in srgb, var(--add-action-accent, var(--app-accent)) 16%, transparent) !important;
}
:root body .header-control-capsule .todo-top-toolbar .header-action-add[hidden] {
  display: none !important;
}
:root body .header-control-capsule .todo-top-toolbar .header-action-add > svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
}
:root body .header-control-capsule .todo-top-toolbar .header-action-add:hover {
  background: color-mix(in srgb, var(--add-action-accent, var(--app-accent)) 18%, transparent) !important;
  box-shadow: 0 0 13px color-mix(in srgb, var(--add-action-accent, var(--app-accent)) 22%, transparent) !important;
}
:root body .round-add {
  /* Existing entry points have inline sizes/colours; the common control owns them. */
  width: 38px !important; height: 38px !important; min-width: 38px !important;
  max-width: 38px; min-height: 38px; padding: 0 !important;
  border-radius: 50% !important; flex: 0 0 38px;
  border: 1px solid color-mix(in srgb, var(--action-accent) 28%, transparent) !important;
  background-color: color-mix(in srgb, var(--action-accent) 12%, var(--surface-solid)) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: 18px 18px !important;
  color: var(--action-accent) !important;
  box-shadow: 0 0 15px color-mix(in srgb, var(--action-accent) 17%, transparent) !important;
  font-size: 0 !important; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; gap: 0;
}
:root[data-theme="dark"] body .round-add {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f2f2f7' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E") !important;
}
:root body .round-add > * { display: none !important; }
:root body .round-add::before,
:root body .round-add::after {
  content: none !important;
  display: none !important;
}
:root body .chat-action-capsule .capsule-icon-btn {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  flex: 0 0 28px !important;
  border-radius: 50% !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 0 !important;
}
:root body .header-control-capsule .chat-action-capsule #newChatBtn {
  color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 16%, transparent) !important;
}
:root body .chat-action-capsule .capsule-icon-btn > * {
  display: block !important;
  margin: auto !important;
}
:root body .chat-action-capsule .capsule-icon-btn::before,
:root body .chat-action-capsule .capsule-icon-btn::after {
  content: none !important;
  display: none !important;
}
:root body .round-add:hover {
  background: color-mix(in srgb, var(--action-accent) 20%, var(--surface-solid)) !important;
  box-shadow: 0 0 20px color-mix(in srgb, var(--action-accent) 25%, transparent) !important;
}
:root body .round-add.floating-add-btn {
  position: fixed !important;
  width: 48px !important;
  height: 48px !important;
  max-width: 48px;
  right: 32px !important;
  bottom: 28px !important;
  z-index: 99 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08) !important;
}
:root body #openAddInventoryBtn { --action-accent: #466fbe; }
:root body #openAddRoutineBtn { --action-accent: #3287a7; }
:root body #openAddHabitDialogBtn { --action-accent: #527cb9; }
:root body .health-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px; align-items: center; margin-bottom: 16px;
}
:root body .health-header .assets-top-toolbar { min-width: 0; margin: 0; }
:root body .health-header .header-right { margin-left: 0; grid-column: 3; grid-row: 1; }
@media (max-width: 760px) {
  :root body .health-header { grid-template-columns: minmax(0, 1fr) 36px; gap: 10px 8px; }
  :root body .health-header .header-right { grid-column: 2; }
  :root body .health-header .date-controller { grid-column: 1 / -1; grid-row: 2; margin-inline: auto; }
  :root body .health-header .assets-subtabs { width: 100%; }
  :root body .health-header .assets-subtabs .seg-btn { flex: 1 0 auto; padding-inline: 7px; gap: 4px; font-size: .75rem; }
}
@media (max-width: 400px) {
  :root body .health-header .assets-subtabs .seg-btn svg { display: none; }
}

/* Compact search occupies the header actions; the original input stays intact. */
:root body .app-header.has-compact-search {
  position: relative;
  display: flex;
  justify-content: space-between;
}
:root body .has-compact-search .header-center[hidden] { display: none; }
:root body .has-compact-search .header-left { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; gap: 6px; }
:root body .has-compact-search .header-right { margin-left: auto; flex: 0 0 auto; }
:root body .has-compact-search { flex-shrink: 0; }
:root body .app-shell > .filter-bar { flex-shrink: 0; }
.compact-search { display: flex; align-items: center; }
:root body .compact-search-toggle, :root body .compact-search-clear {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 36px; height: 36px; min-width: 36px;
  padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface-solid); color: var(--muted); cursor: pointer;
}
.compact-search-toggle svg { width: 16px; height: 16px; }
:root body .compact-search-toggle:hover, :root body .compact-search-toggle[aria-expanded="true"] { color: var(--ink); background: var(--backdrop); }
.compact-search-toggle.has-query { position: relative; }
.compact-search-toggle.has-query::after {
  content: ''; position: absolute; width: 6px; height: 6px; top: 4px; right: 4px;
  border-radius: 50%; background: var(--accent);
}
:root body .compact-search-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  display: flex; align-items: center; gap: 4px;
  width: min(300px, 100%); padding: 4px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-solid); box-shadow: 0 5px 20px rgba(0, 0, 0, .12);
}
:root body .compact-search-panel[hidden], :root body .compact-search-clear[hidden] { display: none; }
:root body .compact-search-panel .search-box {
  display: flex; flex: 1 1 auto; width: auto; min-width: 0; height: 36px;
  padding: 0 10px; margin: 0; border: 0; background: transparent; box-shadow: none;
}
:root body .compact-search-panel .search-box input {
  flex: 1 1 auto; width: 100%; min-width: 0; font-size: 16px;
}
:root body .compact-search-clear { width: 30px; height: 30px; min-width: 30px; font-size: 20px; border: 0; }

/* C060: one nested-capsule language for navigation, tabs and category switches.
   Keep existing DOM/IDs and state classes so business interactions stay intact. */
:root {
  --capsule-tray: var(--backdrop);
  --capsule-selected: var(--surface-solid, var(--surface-card));
  --capsule-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
:root[data-theme="dark"] {
  --capsule-selected: #303036;
  --capsule-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}
:root body :is(.segmented-control, .filter-bar, .routine-tag-bar, .meal-tabs-row, .anniversary-filter-capsules) {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  margin-inline: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--capsule-tray);
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 4px;
}
:root body :is(.segmented-control, .filter-bar, .routine-tag-bar, .meal-tabs-row, .anniversary-filter-capsules)::-webkit-scrollbar { display: none; }
:root body :is(.seg-btn, .filter-button, .routine-tag-btn, .meal-tab-btn, .anni-pill) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 32px;
  height: auto;
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  white-space: nowrap;
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
:root body :is(.seg-btn, .filter-button, .routine-tag-btn, .meal-tab-btn, .anni-pill):hover { color: var(--ink); }
:root[data-theme] body :is(.segmented-control, .filter-bar, .routine-tag-bar, .meal-tabs-row, .anniversary-filter-capsules) :is(.seg-btn, .filter-button, .routine-tag-btn, .meal-tab-btn, .anni-pill).active {
  background: var(--capsule-selected);
  color: var(--ink);
  box-shadow: var(--capsule-shadow);
  font-weight: 600;
}
:root body aside.left-rail {
  top: 22px;
  bottom: auto;
  left: 4px;
  right: auto;
  width: 50px;
  height: auto;
  padding: 4px;
  gap: 4px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--capsule-tray);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
:root body aside.left-rail .rail-tab {
  flex: 0 0 auto;
  width: 40px;
  max-width: none;
  min-width: 0;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
:root body aside.left-rail .rail-tab:hover { color: var(--ink); background: var(--capsule-tray); }
:root body aside.left-rail .rail-tab.active {
  color: var(--ink);
  background: var(--capsule-selected);
  box-shadow: var(--capsule-shadow);
}
@media (max-width: 640px) {
  :root body aside.left-rail {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    width: auto;
    height: 60px;
    padding: 4px;
    flex-direction: row;
    justify-content: space-between;
    gap: 2px;
  }
  :root body aside.left-rail .rail-tab { flex: 1 1 0; width: auto; height: 50px; }
  :root body :is(.seg-btn, .filter-button, .routine-tag-btn, .meal-tab-btn, .anni-pill) { min-height: 36px; }
  :root body .assets-subtabs { display: flex; width: 100%; }
  :root body .assets-subtabs .seg-btn { flex: 1 0 auto; padding-inline: 10px; }
}

:root body .check-button {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  max-width: 22px;
  max-height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}


/* Shared in-place capsule search; keep the original input and its listeners. */
:root body .capsule-search-active { width: var(--capsule-search-width) !important; max-width: 100%; overflow: hidden !important; }
:root body .capsule-search-active > :not(.capsule-inline-search) { display: none !important; }
:root body .capsule-search-active > .capsule-inline-search { position: static !important; inset: auto !important; transform: none !important; display: flex !important; align-items: center; gap: 4px; flex: 1 1 0 !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; height: var(--ui-control-height) !important; padding: 0 4px !important; margin: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; border-radius: 0; overflow: hidden; }
:root body .capsule-inline-search[hidden] { display: none !important; }
:root body .capsule-inline-search .search-box { display: flex; flex: 1 1 0 !important; width: 0 !important; min-width: 0 !important; padding-inline: 4px; }
:root body .header-control-capsule .capsule-inline-search .search-box,
:root body .header-control-capsule .capsule-inline-search .search-box:hover,
:root body .header-control-capsule .capsule-inline-search .search-box:focus-within {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}
:root body .capsule-inline-search input { flex: 1 1 0; width: 0 !important; min-width: 0 !important; height: var(--ui-control-height); padding: 0 4px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 13px; outline: none; }
.compact-search-panel:has(.compact-search-clear) input[type="search"]::-webkit-search-cancel-button {
  display: none;
}
:root body .capsule-inline-search :is(.capsule-search-back, .compact-search-clear, .search-close-btn, .search-nav-btn) { display: grid; place-items: center; flex: 0 0 28px; width: 28px; min-width: 0; height: 30px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
:root body .capsule-inline-search .search-count { flex: 0 0 auto; font-size: 10px; color: var(--muted); }
:root body .capsule-inline-search > .search-bar-icon { display: none; }
:root body .capsule-inline-search button:hover { color: var(--ink); background: var(--backdrop); }
@media (max-width: 640px) {
  :root body .capsule-inline-search input { font-size: 12px; }
  :root body .capsule-inline-search .search-nav-btn { flex-basis: 22px; width: 22px; }
}

:root body .header-control-capsule.capsule-search-active{margin-left:auto;min-width:0;box-sizing:border-box;flex-shrink:0!important}
:root body .capsule-search-active>.capsule-inline-search{box-sizing:border-box;flex-basis:auto!important;animation:none!important}
:root body .capsule-inline-search input{display:block!important;flex:1 1 80px!important;min-width:60px!important}

/* The transparent corner button remains a hover target and keyboard control. */
.ac-card-remove { opacity: 1 !important; visibility: visible !important; }
@media (min-width: 641px) and (hover: hover) and (pointer: fine) {
  .ac-card-remove:not(:hover):not(:focus-visible) { opacity: 0 !important; }
}

/* Final theme glyphs exist from the first paint; no runtime icon replacement. */
:root body .global-theme-toggle .theme-glyph-sun { display:none; }
:root body .global-theme-toggle .theme-glyph-moon { display:block; }
:root[data-theme="dark"] body .global-theme-toggle .theme-glyph-sun { display:block; }
:root[data-theme="dark"] body .global-theme-toggle .theme-glyph-moon { display:none; }
