@layer components {
  .brand-mark { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; color: white; background: var(--color-primary); border-radius: var(--radius-sm); font-weight: 750; }
  .muted { color: var(--color-text-muted); }

  .button, .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.5rem;
    padding: 0.55rem 0.9rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }
  .button:hover, .icon-button:hover { background: var(--color-surface-muted); }
  .button--primary { color: white; background: var(--color-primary); border-color: var(--color-primary); }
  .button--menu { min-height: 1.9rem; padding: 0.15rem 0.6rem; border-color: transparent; font-size: 0.875rem; color: var(--color-text-muted); background: transparent; }
  .button--menu:hover, .button--menu[aria-expanded="true"] { color: var(--color-text); background: var(--color-surface-muted); }
  .button--mode { color: var(--color-text); border-color: var(--color-border); }

  .menu { position: absolute; z-index: 50; min-width: 14rem; max-height: min(70vh, 32rem); overflow-y: auto; padding: var(--space-1); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
  .menu hr { margin: var(--space-1) 0; border: 0; border-top: 1px solid var(--color-border); }
  .menu__heading { padding: 0.35rem 0.75rem 0.1rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
  .menu__item { display: flex; justify-content: space-between; gap: 1rem; width: 100%; padding: 0.45rem 0.75rem; background: none; border: 0; border-radius: var(--radius-sm); color: var(--color-text); text-align: start; }
  .menu__item:hover, .menu__item:focus-visible { background: var(--color-surface-muted); }
  .menu__item:disabled { opacity: 0.45; }
  .menu__item--danger { color: var(--color-danger); }
  .menu__item--checked { font-weight: 650; color: var(--color-primary); }
  .menu__item[aria-checked="true"] > span:first-child::before { content: "✓ "; }
  .menu__item[aria-checked="false"] > span:first-child::before { content: "\00a0\00a0\00a0"; }
  .menu__shortcut { font-size: 0.78rem; color: var(--color-text-muted); }

  .editor-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
  .editor-shell--dropping::after { content: 'Drop to open'; position: absolute; inset: 0.5rem; z-index: 50; display: grid; place-items: center; border: 2px dashed var(--color-accent, #2563eb); border-radius: 0.75rem; background: color-mix(in srgb, var(--color-accent, #2563eb) 8%, transparent); color: var(--color-accent, #2563eb); font-weight: 600; pointer-events: none; }
  .editor-header { position: relative; z-index: 10; flex: none; background: var(--color-surface); box-shadow: var(--shadow-sm); }
  .editor-header__top { display: flex; align-items: center; gap: var(--space-3); min-height: 4rem; padding: var(--space-2) var(--space-4); }
  .editor-header__title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
  .editor-header__menus { display: flex; flex-wrap: wrap; gap: 0.1rem; }
  .document-title { width: min(100%, 36rem); padding: var(--space-1) var(--space-2); font-size: 1.1rem; font-weight: 650; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: inherit; }
  .document-title:hover, .document-title:focus { border-color: var(--color-border); }
  .save-state { min-width: 6rem; color: var(--color-text-muted); font-size: 0.82rem; text-align: right; }
  .save-state[data-status="error"], .save-state[data-status="offline"] { color: var(--color-danger); }
  .presence { display: inline-flex; }
  .presence__avatar { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; margin-inline-start: -0.4rem; border: 2px solid var(--color-surface); border-radius: 50%; background: var(--peer-color, #8b5cf6); color: #fff; font-size: 0.75rem; font-weight: 700; }
  .presence__avatar:first-child { margin-inline-start: 0; }
  .editor-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  native-docs-editor { display: block; flex: 1; min-height: 0; height: 100%; --nde-min-height: 0; --nde-radius: 0; }
  native-docs-editor::part(editor) { border-left: 0; border-right: 0; border-bottom: 0; }

  @media (max-width: 640px) {
    .editor-header__top { padding-inline: var(--space-2); }
    .save-state { display: none; }
    .brand-mark { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
  }

  @media print {
    .editor-header, .menu, .skip-link { display: none !important; }
    .editor-shell { height: auto; overflow: visible; }
    .editor-stage { display: block; }
    native-docs-editor { height: auto; }
    body { background: white; }
  }
}
