@layer interface {
  @media screen {
    .today-rhythm-strip { display: grid; gap: .25rem; min-width: 0; padding: .35rem .5rem; }
    html[data-theme] .shell-message > p[hidden],
    .topbar-offline-chip[hidden] { display: none; }
    .topbar-offline-chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 10px;
      border-radius: 999px;
      border: 1px solid rgba(245, 158, 11, .45);
      background: #342515;
      color: #ffd78b;
      font-size: .76rem;
      font-weight: 600;
      line-height: 1.2;
      white-space: nowrap;
      cursor: default;
    }
    html[data-theme="light"] .topbar-offline-chip { background: #fff0c7; color: #713d00; }
    .topbar-offline-chip::before {
      content: '';
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #f59e0b;
      flex: 0 0 auto;
    }
    html[data-theme] .button.secondary {
      min-height: 40px;
      padding: 7px 13px;
      border: 1px solid var(--control-border, var(--line));
      border-radius: 8px;
      transition: background-color 140ms ease, border-color 140ms ease;
    }
    html[data-theme] .button.secondary:hover:not(:disabled) {
      border-color: var(--accent, var(--forest-light));
    }
    .today-rhythm-metrics, .today-rhythm-ribbon, .refusal-totem, .totem-kept {
      display: flex; align-items: center; gap: .5rem;
    }
    .today-rhythm-metrics { justify-content: space-between; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
    .today-rhythm-ribbon { font-size: .85rem; }
    .today-rhythm-ribbon > span, .totem-kept { white-space: nowrap; }
    .kintsugi-days {
      display: grid; flex: 1; grid-template-columns: repeat(14, minmax(0, 1fr));
      gap: 2px; list-style: none; margin: 0; padding: 0; max-width: 28rem;
    }
    .kintsugi-days li { position: relative; text-align: center; line-height: 1.2; }
    .kintsugi-days [data-outcome="none"] { color: var(--muted); }
    .kintsugi-days [data-outcome="held"] { color: var(--accent, var(--forest-light)); }
    .kintsugi-days [data-outcome="failed"] { color: var(--error, var(--coral)); }
    .kintsugi-days [data-outcome="return"] { color: var(--amber, currentColor); }
    .deload-badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      margin-top: 4px;
      padding: 2px 8px;
      border-radius: 999px;
      border: 1px solid var(--control-border, var(--line));
      background: var(--soft);
      color: var(--muted);
      font-size: .74rem;
      font-weight: 550;
      letter-spacing: .01em;
      white-space: nowrap;
      width: fit-content;
    }
    .refusal-totem { min-width: 0; justify-content: space-between; border-block-start: 1px solid var(--line); }
    html[data-theme] .refusal-totem > button {
      display: flex; flex: 1; align-items: center; gap: .5rem; justify-content: flex-start; min-width: 0;
      padding-inline: .5rem; white-space: nowrap;
    }
    .totem-boundary { overflow: hidden; text-overflow: ellipsis; }
    .totem-kept { min-height: 40px; padding-inline-end: .5rem; cursor: pointer; }
    .totem-kept input { margin: 0; }
    .living-vibes {
      display: inline-flex;
      align-items: stretch;
      gap: 2px;
      max-width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 2px;
    }
    html[data-theme] .living-vibes .button {
      min-width: 0;
      min-height: 40px;
      border: 0;
      padding: .25em .75em;
      border-radius: 7px;
    }
    html[data-theme] .living-vibes [aria-pressed="true"] {
      background: var(--ink);
      color: var(--paper);
      font-weight: 700;
    }
    html[data-theme] .living-fog-card {
      display: grid;
      justify-items: start;
      gap: .75rem;
      width: min(100%, 42rem);
      margin-inline: auto;
      overflow-wrap: anywhere;
    }
    .living-fog-card :is(h2, p) { margin: 0; }
    .living-fog-card p { max-width: 48ch; }
    .living-fog-clock, .living-load-figures { font-variant-numeric: tabular-nums; }
    html[data-theme] .living-load {
      display: flex;
      align-items: center;
      gap: .5rem;
      min-height: 52px;
      min-width: 0;
      padding-inline: .5rem;
      flex: 1 0 100%;
      border-block: 1px solid var(--line);
    }
    .living-load svg { width: 76px; height: 48px; flex: 0 0 76px; }
    .living-sphere { fill: var(--accent, var(--forest)); }
    .living-load-figures {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      column-gap: .85rem;
      row-gap: .125rem;
      min-width: 0;
      font: .8125rem/1.15 var(--mono, monospace);
    }
    .living-load-figures > * { white-space: nowrap; }
    .living-load-metric.is-overload {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 2px 8px;
      border-radius: 999px;
      border: 1px solid rgba(245, 158, 11, .45);
      background: rgba(245, 158, 11, .12);
      color: #d97706;
      font-weight: 700;
    }
    .living-load-metric.is-overload::before {
      content: '';
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #f59e0b;
      flex: 0 0 auto;
    }
    .living-switch-tax { color: var(--muted); }
    .living-fuel-choice:empty { display: none; }
    .living-fuel-choice { min-width: 0; overflow-wrap: anywhere; }
    .morph-reasons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; }
    html[data-theme] .morph-reasons .button { min-width: 0; white-space: normal; overflow-wrap: anywhere; padding-inline: .25rem; }
    .morph-reasons [aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: -2px; }
    .living-laser-list { min-width: 0; }
    .living-laser-list :is(.task-title-line, .living-laser-step) { overflow-wrap: anywhere; }
    .task-row[data-entropy="fading"] :is(.task-title, .task-title-line strong) { opacity: .68; }
    .task-row[data-entropy="dissolving"] :is(.task-title, .task-title-line strong) { opacity: .46; }

    .today-quick-controls {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px;
      margin-top: 6px;
    }
    .shutdown-closed-card {
      display: grid;
      gap: 8px;
      padding: 18px;
      border: 1px solid var(--line);
    }
    .shutdown-closed-head {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .shutdown-closed-head h2 { margin: 0; font-size: 1.15rem; }
    .shutdown-ritual, .auto-schedule-preview, .sunday-review-modal, .e2ee-sync-body {
      display: grid;
      gap: 12px;
      min-width: 0;
    }
    .shutdown-loops-list, .auto-schedule-list, .sunday-chapters-list {
      display: grid;
      gap: 8px;
      list-style: none;
      margin: 0;
      padding: 0;
    }
    .shutdown-loop-row, .auto-schedule-item, .sunday-chapters-list li {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      min-width: 0;
    }
    .shutdown-loop-info { display: grid; gap: 2px; min-width: 0; flex: 1 1 12rem; }
    .shutdown-loop-actions { display: flex; flex-wrap: wrap; gap: 4px; }
    .shutdown-summary-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
    .focus-audio-bar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--line);
    }
    .focus-audio-bar select { min-height: 40px; min-width: 10rem; flex: 0 1 auto; }
    .focus-audio-volume { flex: 1 1 7rem; max-width: 12rem; min-height: 40px; accent-color: var(--accent, var(--forest-light)); }
    .fog-intention-line {
      margin: 0;
      padding-top: 8px;
      border-top: 1px solid var(--line);
      font-size: .84rem;
      max-width: 48ch;
      overflow-wrap: anywhere;
    }
    .calibration-strip {
      display: grid;
      gap: 6px;
      margin: 8px 0;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
    }
    .calibration-headline { margin: 0; font-size: .86rem; font-weight: 550; }
    .calibration-chips { display: flex; flex-wrap: wrap; gap: 6px; }
    .calibrated-load-hint { margin: 4px 0 0; font-size: .78rem; }
    .sunday-review-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
      gap: 8px;
    }
    .sunday-chapters-list .is-lagging { border-color: var(--amber, var(--coral)); }
    .sunday-review-highlight { border-color: var(--accent, var(--forest-light)); }

    html[data-theme] .calendar-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(170px, 1fr));
      gap: 10px;
      overflow-x: auto;
      overscroll-behavior-x: contain;
      padding-inline-end: 12px;
      padding-block-end: 8px;
    }
    html[data-theme] .week-block :is(.badge, .comparison-tag, .interval-clock),
    html[data-theme] .day-column .deload-badge {
      white-space: nowrap;
      width: fit-content;
      max-width: 100%;
    }
    .week-from-field {
      display: grid;
      gap: 4px;
      margin: 0;
    }
    .week-date-picker {
      position: relative;
      display: inline-flex;
      align-items: center;
    }
    html[data-theme] .week-date-picker .week-date-trigger {
      min-height: 40px;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }
    html[data-theme] .week-date-picker .week-native-date {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      pointer-events: none;
      border: 0;
      padding: 0;
    }

    .guide-workspace { display: grid; gap: 1rem; }
    .guide-quick-jumps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .35rem; }
    .guide-progress-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: .65rem 1rem;
      margin: .5rem 0 .85rem;
      padding: .65rem .85rem;
      border: 1px solid var(--line);
      border-radius: 10px;
    }
    .guide-progress-label { font-weight: 700; font-variant-numeric: tabular-nums; }
    .guide-progress-bar {
      flex: 1 1 10rem;
      max-width: 18rem;
      height: 8px;
      accent-color: var(--accent, var(--forest-light));
    }
    .guide-onboarding-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: .75rem;
    }
    .guide-step-card {
      display: grid;
      gap: .55rem;
      padding: .9rem 1rem;
      border: 1px solid var(--line);
      border-radius: 12px;
      min-width: 0;
    }
    .guide-step-card[data-done="true"] {
      opacity: .84;
      border-color: var(--accent, var(--forest-light));
    }
    .guide-step-card[data-done="true"] .guide-step-title { text-decoration: line-through; }
    .guide-step-check {
      display: flex;
      align-items: center;
      gap: .6rem;
      cursor: pointer;
      min-height: 40px;
    }
    .guide-step-check input[type="checkbox"] {
      width: 1.15rem;
      height: 1.15rem;
      margin: 0;
      flex: 0 0 auto;
      accent-color: var(--accent, var(--forest-light));
    }
    .guide-formula { display: grid; gap: .45rem; min-width: 0; }
    .guide-formula-line { margin: 0; max-width: 72ch; }
    .guide-outcome { color: var(--muted); }
    .guide-card-actions { margin-top: .25rem; }
    .guide-filter-chips {
      display: flex;
      flex-wrap: wrap;
      gap: .4rem;
      margin: .5rem 0 .85rem;
    }
    html[data-theme] .guide-filter-chip {
      min-height: 40px;
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: .35rem .85rem;
    }
    html[data-theme] .guide-filter-chip[aria-pressed="true"] {
      background: var(--ink);
      color: var(--paper);
      border-color: var(--ink);
      font-weight: 700;
    }
    .guide-chip-hint {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: .6rem;
      margin-bottom: .85rem;
      padding: .65rem .85rem;
      border: 1px dashed var(--line);
      border-radius: 10px;
    }
    .guide-map-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
      gap: .85rem;
    }
    .guide-map-card {
      display: grid;
      align-content: start;
      gap: .55rem;
      padding: .95rem 1rem;
      border: 1px solid var(--line);
      border-radius: 12px;
      min-width: 0;
    }
    .guide-map-card-head {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      justify-content: space-between;
      gap: .5rem;
    }
    .guide-map-card-head h3 { margin: 0; font-size: 1rem; flex: 1 1 13rem; }
    .guide-highlights {
      margin: 0;
      padding-inline-start: 1.2rem;
      display: grid;
      gap: .25rem;
      font-size: .9rem;
    }
    .guide-prompt-set + .guide-prompt-set {
      margin-top: 1.25rem;
      padding-top: 1rem;
      border-top: 1px solid var(--line);
    }
    .guide-prompt-set-title { margin: 0 0 .35rem; font-size: 1.05rem; }
    .guide-prompt-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
      gap: .85rem;
    }
    .guide-prompt-card {
      display: grid;
      align-content: start;
      gap: .55rem;
      padding: .95rem 1rem;
      border: 1px solid var(--line);
      border-radius: 12px;
      min-width: 0;
    }
    .guide-prompt-title { margin: 0; font-size: 1rem; }
    .guide-prompt-where { margin: 0; font-size: .86rem; }
    .guide-prompt-code {
      margin: 0;
      padding: .75rem .85rem;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--soft);
      font: .84rem/1.45 var(--mono, monospace);
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      max-width: 100%;
      overflow-x: auto;
      user-select: all;
    }
    .guide-prompt-code code { font: inherit; background: transparent; padding: 0; }
    .guide-prompt-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .15rem; }
    .guide-step-card,
    .guide-map-card,
    .guide-prompt-card,
    .guide-section:not([open]),
    .route-zone,
    .archive-row:not([open]) {
      content-visibility: auto;
      contain-intrinsic-size: auto 220px;
    }

    html[data-theme="oled"]:not([data-appearance="light"]) {
      & [data-vibe="fog"] .living-fog-card { background: #11100f; border-color: #41382f; }
      & [data-vibe="laser"] :is(.living-laser-list, .living-load) { border: 1px solid #44444a; }
      & .living-load[data-overload="true"] .living-bowl { color: #f59e0b; }
      & .living-load-metric.is-overload {
        color: #f59e0b;
        border-color: rgba(245, 158, 11, .45);
        background: rgba(245, 158, 11, .14);
      }
      & .quick-add-mins-box { background: #0c0c0f; border-color: #27272a; }
      & .deload-badge { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .14); color: #cbd5e1; }
      & .shutdown-closed-card { background: #0a0a0c; border-color: #27272a; }
      & .calibration-strip,
      & .shutdown-loop-row,
      & .auto-schedule-item,
      & .sunday-chapters-list li { background: #0d0d10; border-color: #27272a; }
      & .sunday-chapters-list .is-lagging { border-color: #d97706; }
      & .sunday-review-highlight { border-color: var(--accent); background: rgba(16, 185, 129, .08); }
      & .guide-progress-row,
      & .guide-step-card,
      & .guide-map-card,
      & .guide-prompt-card { background: #0c0c0f; border-color: #27272a; }
      & .guide-step-card[data-done="true"] { border-color: var(--accent, #10b981); background: rgba(16, 185, 129, .06); }
      & .guide-prompt-code { background: #050507; border-color: #27272a; color: #e4e4e7; }
      & .guide-chip-hint { background: #0d0d10; border-color: #3f3f46; }
      & .guide-filter-chip[aria-pressed="true"] { background: #f4f4f5; color: #09090b; border-color: #f4f4f5; }
    }
  }
  @media screen and (max-width: 600px) {
    html[data-theme] .topbar:has(.focus-topbar-pill:not([hidden])) { flex-wrap: wrap; }
    html[data-theme] .topbar:has(.focus-topbar-pill:not([hidden])) .topbar-actions {
      max-width: 100%;
      flex: 0 1 auto;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
  }
  @media screen and (prefers-reduced-motion: no-preference) {
    .task-row[data-entropy] :is(.task-title, .task-title-line strong) { transition: opacity 160ms ease; }
    .living-bowl { transition: transform 200ms ease; }
    @starting-style { .living-bowl { transform: rotate(0deg); } }
  }
  @media screen and (forced-colors: active) {
    html[data-theme] .living-vibes [aria-pressed="true"],
    html[data-theme] .guide-filter-chip[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -3px; }
    .task-row[data-entropy] :is(.task-title, .task-title-line strong) { opacity: 1; }
  }
}
