.editor {
  overflow-wrap: anywhere;
}
.editor label {
  display: grid;
  gap: 8px;
  font-size: 0.875rem;
}
.editor input {
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: inherit;
  font: inherit;
  line-height: 1.7;
}
.editor [data-testid="editor-text"] {
  min-height: 340px;
  font-size: 1rem;
}
.editor-preview-heading {
  margin: 24px 0 12px;
  font-family: var(--font-serif);
  font-size: 1.3rem;
}
.editor-blocks {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
  min-width: 0;
}
.editor-blocks hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.editor select {
  max-width: 100%;
  min-width: 0;
}
.editor a {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.editor-breadcrumb,
.editor-unsaved {
  margin: 16px 0;
}
.editor-save {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  margin: 20px 0;
}
.editor-save-head,
.editor-save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.editor-save-head h2,
.editor-leave-dialog h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
}
.editor-save-head a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.editor-save-actions {
  justify-content: flex-start;
  margin-top: 12px;
}
.editor-offline {
  display: inline-flex !important;
  align-items: center;
  grid-auto-flow: column;
  min-height: 44px;
}
.editor-offline input {
  width: 22px;
  min-height: 44px;
  height: 44px;
}
.editor-save [data-state="failed"],
.editor-save [role="alert"] {
  color: #a52b20;
}
.dark .editor-save [data-state="failed"],
.dark .editor-save [role="alert"] {
  color: #ffaaa0;
}
.editor-leave-dialog {
  width: min(90vw, 460px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.7;
}
.editor-leave-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}
.editor-leave-dialog button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: inherit;
}
.editor-unsaved {
  padding: 14px;
  border-left: 3px solid var(--primary);
  background: var(--muted);
  font-size: 0.875rem;
  line-height: 1.8;
}
.editor-surface {
  min-height: 340px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  line-height: 1.9;
  outline: none;
  font-family: var(--font-ink);
  white-space: pre-wrap;
}
.notebook-app .editor-surface:focus-visible {
  outline: none;
}
.editor-surface > p,
.editor-surface > h2,
.editor-surface > blockquote,
.editor-surface > ul {
  margin: 12px 0;
}
.editor-surface h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
}
.editor-surface blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 16px;
}
.editor-surface ul {
  list-style: disc;
  padding-left: 28px;
}
.editor-surface .editor-image-stage {
  white-space: normal;
  margin: 18px 0;
}

.editor-image-stage {
  scroll-margin-top: 80px;
  position: relative;
  width: 100%;
  padding: 0;
}
.editor-image-stage img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 140px;
  object-fit: cover;
}
.editor-image-stage:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
.editor-image-actions {
  display: none;
  position: absolute;
  right: 12px;
  top: 12px;
  left: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.editor-image-actions button {
  min-height: 44px;
  padding: 6px 9px;
  font-size: 0.78rem;
  white-space: nowrap;
}
.editor-image-comment-preview {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgb(0 0 0 / 75%);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  max-height: 5.5em;
  overflow: auto;
}
.editor-image-stage[data-placeholder="true"] .editor-image-comment-preview {
  display: none;
}
.editor-image-comment-dialog textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 100px;
  margin-top: 8px;
}
.editor-image-comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.editor-image-comment-actions button {
  min-height: 44px;
}
.editor-context-menu {
  position: fixed;
  z-index: 100;
  width: min(230px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.editor-context-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: inherit;
}
.editor-context-menu button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--muted);
}
.editor-surface > * {
  scroll-margin-top: 140px;
}
.editor-edit-dialog {
  width: min(90vw, 480px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.7;
}
.editor-edit-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}
.editor-edit-dialog h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
}
.editor-edit-dialog label {
  display: block;
  margin-top: 16px;
}
.editor-edit-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--background);
  color: inherit;
}
.editor-edit-dialog button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: inherit;
}
.editor-edit-dialog [role="alert"] {
  color: #a52b20;
}
.dark .editor-edit-dialog [role="alert"] {
  color: #ffaaa0;
}
.editor-photo-credit {
  max-width: 72rem;
  padding: 20px;
  margin: auto;
  font-size: 0.75rem;
}
.editor-photo-credit a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: underline;
}
.editor-surface a {
  cursor: text;
}
html[data-editor-input="desktop"] .editor-image-actions {
  display: flex;
}
html[data-editor-input="desktop"]
  .editor-image-stage:hover
  .editor-image-actions,
html[data-editor-input="desktop"]
  .editor-image-stage:focus-within
  .editor-image-actions {
  opacity: 1;
  pointer-events: auto;
}
html[data-editor-input="touch"] .editor-image-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  top: 6px;
  right: 6px;
  left: 6px;
  gap: 4px;
}
html[data-editor-input="touch"] .editor-image-actions button {
  min-width: 0;
  padding: 6px 2px;
  font-size: 0.72rem;
  white-space: normal;
  line-height: 1.15;
}
html[data-editor-input="touch"] .editor-image-stage[data-selected="true"] {
  outline: 3px solid #fff;
  outline-offset: -3px;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 70%);
}
html[data-editor-input="touch"]
  .editor-image-stage[data-selected="true"]
  .editor-image-actions {
  opacity: 1;
  pointer-events: auto;
}

.editor-body-region {
  min-width: 0;
}
.editor-history-controls {
  position: fixed;
  z-index: 40;
  top: clamp(
    calc(var(--editor-appbar-height, 56px) + 12px),
    45dvh,
    calc(100dvh - 104px)
  );
  right: max(8px, env(safe-area-inset-right));
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
  box-shadow: 0 4px 18px rgb(0 0 0 / 15%);
}
.editor-history-controls button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  cursor: pointer;
}
.editor-history-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}
.editor-history-controls button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.editor-history-controls svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.editor-help {
  list-style: disc;
  padding-left: 20px;
  margin: 16px 0;
  line-height: 1.7;
}

/* The editor is a full-page workspace; shared Studio rules remain scoped away. */
body.editor-app {
  min-width: 0;
  background: var(--background);
}
.editor-appbar {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 2px 12px rgb(0 0 0 / 5%);
}
.editor-appbar-primary,
.editor-appbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.editor-brand {
  flex: none;
  font-family: var(--font-serif);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.editor-appbar-divider,
.editor-appbar-context {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  white-space: nowrap;
}
.editor-appbar-context {
  overflow: hidden;
  text-overflow: ellipsis;
}
.editor-appbar button,
.editor-appbar-link,
.editor-tabbar button,
.editor-tabbar a,
.editor-nav-heading button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.editor-statusbar .editor-primary-action {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground, #fff);
  font-weight: 600;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 5px;
}
.editor-appbar-link {
  border-color: var(--border);
}
.editor-save-state {
  max-width: 250px;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-save-state[data-state="failed"] {
  color: #a52b20;
}
.editor-demo-label {
  display: none;
}
.dark .editor-save-state[data-state="failed"] {
  color: #ffaaa0;
}
.editor-appbar .editor-nav-toggle {
  display: none;
}
.editor-app-layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: calc(100dvh - 56px);
}
.editor-app-layout[data-sidebar-collapsed="true"] {
  grid-template-columns: 56px minmax(0, 1fr);
}
.editor-app-nav {
  min-width: 0;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  background: var(--background);
}
.editor-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding-left: 10px;
  color: var(--muted-foreground);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.editor-app-nav nav {
  display: grid;
  gap: 2px;
}
.editor-app-nav nav a,
.editor-app-nav nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--foreground);
  font-size: 0.84rem;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.editor-app-nav nav a:hover,
.editor-app-nav nav button:hover,
.editor-app-nav nav a[aria-current] {
  background: var(--muted);
}
.editor-app-nav nav a[aria-current] {
  font-weight: 650;
}
.editor-nav-separator {
  height: 1px;
  margin: 8px 4px;
  background: var(--border);
}
.editor-app-layout[data-sidebar-collapsed="true"] .editor-app-nav nav a span,
.editor-app-layout[data-sidebar-collapsed="true"]
  .editor-app-nav
  nav
  button
  span,
.editor-app-layout[data-sidebar-collapsed="true"] .editor-nav-heading span,
.editor-app-layout[data-sidebar-collapsed="true"] .editor-nav-separator {
  display: none;
}
.editor-app-layout[data-sidebar-collapsed="true"] .editor-app-nav nav a,
.editor-app-layout[data-sidebar-collapsed="true"] .editor-app-nav nav button {
  justify-content: center;
  padding: 9px 2px;
}
.editor-app-layout[data-sidebar-collapsed="true"] .editor-nav-heading {
  padding: 0;
}
.editor-workbench.studio-shell {
  display: flex;
  flex-direction: column;
  max-width: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
}
.editor-tabbar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 49px;
  padding: 2px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}
.editor-active-tab {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 2px solid var(--primary);
  font-size: 0.84rem;
  font-weight: 600;
  max-width: min(44vw, 320px);
}
.editor-active-tab [data-testid="editor-tab-name"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-active-tab .editor-tab-dot {
  color: var(--primary);
  font-size: 0.55rem;
}
.editor-tab-spacer {
  flex: 1;
}
.editor-workbench-content {
  flex: 1;
  padding: 20px clamp(10px, 3vw, 48px) 36px;
}
.editor-document-context {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-width: 900px;
  margin: 0 auto 12px;
  font-size: 0.76rem;
}
.editor-document-context > span:first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.editor-document-sheet {
  max-width: 768px;
  min-height: 70vh;
  margin: 0 auto;
  padding: 40px 20px;
  border: 0;
  border-radius: 0;
  background: var(--background);
  box-shadow: none;
}
.editor .editor-title-label {
  color: var(--muted-foreground);
  font-size: 0.75rem;
}
.notebook-app.editor-app .editor .editor-title-label input {
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 650;
  text-align: center;
}
.editor-utility {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}
.editor-utility button {
  border-color: transparent;
  background: var(--muted);
  font-size: 0.78rem;
}
.editor-preview-heading {
  margin: 14px 0 6px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted-foreground);
}
.editor .editor-surface {
  min-height: 48vh;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  line-height: 2;
}
.editor-surface > p {
  margin-block: 1.5em;
}
.editor-outline-panel,
.editor-markers {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.editor-outline-panel h2,
.editor-markers h2 {
  font-size: 0.9rem;
}
.editor-outline-panel ol {
  padding-left: 20px;
}
.editor-outline-panel button {
  border: 0;
  background: transparent;
  text-align: left;
}
.editor-statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 44px;
  padding: 4px 16px;
  border-top: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 0.75rem;
}
.editor-statusbar .editor-offline {
  display: inline-flex !important;
  gap: 5px;
  font-size: 0.75rem;
}
.editor-statusbar [data-testid="editor-save-error"] {
  color: #a52b20;
}
.editor-statusbar button {
  min-height: 44px;
}
.editor-help-panel {
  padding: 20px clamp(14px, 3vw, 48px);
  border-top: 1px solid var(--border);
  background: var(--background);
  font-size: 0.82rem;
}
.editor-help-panel .editor-unsaved {
  max-width: 850px;
}
.editor-help-panel .editor-photo-credit {
  max-width: none;
  margin: 0;
  padding: 12px 0;
}
@media (max-width: 767px) {
  .editor-appbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: 44px auto;
    align-items: center;
    gap: 0;
    padding: 2px 8px;
  }
  .editor-appbar-primary,
  .editor-appbar-actions {
    display: contents;
  }
  .editor-appbar [data-theme-toggle] {
    grid-column: 1;
    grid-row: 1;
  }
  .editor-appbar .editor-brand {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
  }
  .editor-appbar .editor-nav-toggle {
    grid-column: 3;
    grid-row: 1;
  }
  .editor-demo-label {
    display: block;
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 0;
    padding: 2px 0 4px;
    color: var(--muted-foreground);
    font-size: 0.7rem;
    line-height: 1.2;
    text-align: center;
  }
  .editor-appbar .editor-nav-toggle {
    display: inline-flex;
    padding: 0;
  }
  .editor-appbar-divider,
  .editor-appbar-context {
    display: none;
  }
  .editor-save-state {
    max-width: min(100%, 240px);
  }
  .editor-app-layout,
  .editor-app-layout[data-sidebar-collapsed="true"] {
    display: block;
  }
  .editor-app-nav {
    position: fixed;
    z-index: 60;
    top: var(--editor-appbar-height, 112px);
    bottom: 0;
    left: 0;
    width: min(280px, 88vw);
    overflow-y: auto;
    visibility: hidden;
    transform: translateX(-100%);
    transition:
      transform 0.15s ease,
      visibility 0.15s ease;
    box-shadow: 8px 0 24px rgb(0 0 0 / 15%);
  }
  .editor-app-nav[data-open="true"] {
    visibility: visible;
    transform: translateX(0);
  }
  .editor-nav-backdrop:not([hidden]) {
    position: fixed;
    z-index: 55;
    inset: var(--editor-appbar-height, 112px) 0 0;
    display: block;
    background: rgb(0 0 0 / 35%);
  }
  .editor-nav-heading button {
    display: none;
  }
  .editor-workbench-content {
    padding: 8px 0 20px;
  }
  .editor-document-context {
    margin: 0;
    padding: 6px 12px;
  }
  .editor-document-context [data-testid="editor-context"] {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .editor-document-sheet {
    min-height: 0;
    padding: 24px 20px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .editor-utility {
    margin: 8px 0;
  }
  .editor-utility button {
    padding: 5px 8px;
  }
  .editor-tabbar {
    padding: 2px 6px;
  }
  .editor-tabbar button {
    font-size: 0.73rem;
  }
  .editor .editor-surface {
    min-height: 55vh;
  }
}

/* Shared setting-link picker for the three rich editors. */
.setting-picker {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 20px;
  color: var(--foreground);
  background: var(--background);
}
.setting-picker h2 {
  margin: 0 0 8px;
}
.setting-picker label {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.setting-picker input,
.setting-picker select {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
}
.setting-picker-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-block: 12px;
}
.setting-picker-results {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  max-height: 220px;
  overflow-y: auto;
  border-block: 1px solid var(--border);
}
.setting-picker-results button {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.setting-picker-results button[aria-pressed="true"] {
  background: var(--muted);
  outline: 2px solid var(--foreground);
  outline-offset: -2px;
}
.setting-picker-results span,
.setting-picker-results small,
.setting-picker-hint {
  font-size: 0.78rem;
  color: var(--muted-foreground);
}
.setting-picker-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.setting-picker-actions button {
  min-width: 44px;
  min-height: 44px;
}
.setting-picker [role="alert"] {
  color: var(--foreground);
}
.setting-picker::backdrop {
  background: #0006;
}
@media (max-width: 400px) {
  .setting-picker {
    padding: 12px;
  }
  .setting-picker-filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .setting-picker-results {
    max-height: 170px;
  }
}
