#main:has(.page--section, .page--picture) {
  display: grid;
}

#main:has(.page--picture:not(.picture-form)) {
  inline-size: 100%;
  padding: 0;

  figcaption {
    inline-size: 67ch;
    margin-inline: auto;
    max-inline-size: 100dvw;
    padding-inline: clamp(var(--inline-space), 5%, calc(var(--inline-space) * 3));
  }
}

:has(#section_theme[value=dark]:checked),
:not(:has(#section_theme[value=dark])):has(.page--section.theme--dark) {
  --lch-black: 100% 0 0;
  --lch-white: 0% 0 0;
  --lch-gray-light: 25.2% 0 0;
  --lch-gray: 30.12% 0 0;
  --lch-gray-dark: 44.95% 0 0;
  --lch-blue: 72.25% 0.16 248;
  --lch-blue-light: 28.11% 0.053 248;
  --lch-blue-dark: 42.25% 0.07 248;
  --lch-red: 73.8% 0.184 29.18;
  --lch-green: 75% 0.21 141.89;
  --lch-green-light: 28.11% 0.02 142.49;
  --lch-yellow: 40.9% 0.06 88.9;

  @media (prefers-color-scheme: dark) {
    --lch-black: 0% 0 0;
    --lch-white: 100% 0 0;
    --lch-gray-light: 96% 0.005 96;
    --lch-gray: 92% 0.005 96;
    --lch-gray-dark: 75% 0.005 96;
    --lch-blue: 54% 0.15 255;
    --lch-blue-light: 95% 0.03 255;
    --lch-blue-dark: 80% 0.08 255;
    --lch-orange: 70% 0.2 44;
    --lch-red: 51% 0.2 31;
    --lch-green: 65.59% 0.234 142.49;
    --lch-green-light: 95% 0.03 142.49;
    --lch-always-black: 0% 0 0;
    --lch-always-white: 100% 0 0;
    --lch-yellow: 92.62% 0.1 91.5;
  }

  img,
  .btn img {
    filter: invert(1);

    @media (prefers-color-scheme: dark) {
      filter: invert(0);
    }
  }

  .btn:has(input:checked),
  .btn:is(.btn--positive, .btn--negative, .btn--reversed) {
    & img {
      filter: invert(0);
    }

    @media (prefers-color-scheme: dark) {
      & img {
        filter: invert(1);
      }
    }
  }
}


.leaf-sub-navbar {
  border-block-start: 1px solid #E7E7E7;
  display: block;
  inline-size: 100%;
  padding: 0;
}

.leaf-sub-navbar__inner {
  align-items: center;
  display: flex;
  gap: 1ch;
  margin-inline: auto;
  max-inline-size: 1280px;
  padding-block: 12px;
  padding-inline: 24px;

  .breadcrumbs {
    margin-inline: 0;
    margin-inline-start: var(--inline-space);
    min-inline-size: 0;
  }

  .leaf-sub-navbar__search {
    flex-shrink: 0;
    inline-size: min(320px, 30vw);
    margin-inline-start: auto;
  }

  .btn {
    flex-shrink: 0;
  }
}

/* The editor's one line, in place of the navbar and the sub-navbar. Fixed height: the tree's top
   follows it (book_tree.css). */
.leaf-edit-bar {
  align-items: center;
  block-size: 56px;
  border-block-end: 1px solid #E7E7E7;
  box-sizing: border-box;
  display: flex;
  gap: 1.25em;
  inline-size: 100%;
  justify-content: flex-start;
  padding-block: 0;
  padding-inline: 20px; /* the tree's */

  @media (prefers-color-scheme: dark) {
    border-block-end: 0; /* #header draws its own */
  }

  .btn {
    flex-shrink: 0;
  }

  .breadcrumbs {
    margin-inline: 0;
  }
}

.leaf-edit-bar__book {
  max-inline-size: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaf-edit-bar__mode {
  flex-shrink: 0;
  font-weight: 600;
}

.leaf-edit-bar__leaf {
  color: var(--color-subtle-dark);
}

.leaf-edit-bar__save {
  flex-shrink: 0;
  margin-inline-start: auto;

  .btn {
    border-radius: 2em; /* as the ← beside the book's name */
    font-weight: 600;
  }

  .page-toolbar__save-icon {
    block-size: 1.1em;
    inline-size: 1.1em;
  }
}

/* Reading view: keep the article column narrow even when the page opts
   into the `book` layout to render the shared navbar. */
#main.book:has(.leaf--chapter, .leaf--section) {
  inline-size: min(67ch, 75vw);
  max-inline-size: 100vw;
  padding-block-end: clamp(var(--block-space), 5%, calc(var(--block-space) * 3));
  padding-inline: clamp(var(--inline-space), 5%, calc(var(--inline-space) * 3));
}

.page-toolbar {
  --padding-block: 0.5em;
  --padding-inline: 1.1em;

  border-radius: 5em;
  display: inline-flex;
  margin: var(--block-space-half) auto 0;
  min-width: 0;
  padding: var(--padding-block) var(--padding-inline);
  transition: background-color 300ms ease;

  .separator {
    block-size: 100%;
    border-color: var(--color-bg);
    border-width: 3px;
    margin-block: calc(-1 * var(--padding-block));
  }

  .btn {
    --btn-border-color: transparent;

    flex-shrink: 0;
  }
}

:is(.page__body, .page--page) {
  text-align: start;
}

:is(.page--section, .page--picture) {
  place-self: center;
}

/* Save button — orange accent by default; briefly shows an outline "saved"
   affordance after a successful save, then the autosave controller drops the
   clean class to revert back. */
.page-toolbar__save-icon {
  filter: invert(1);
}

/* Stack both labels in the same grid cell so the button width is fixed to
   the widest label ("저장됨") and doesn't jitter between states. */
.page-toolbar__save-labels {
  display: inline-grid;
  justify-items: center;
}
.page-toolbar__save-label--default,
.page-toolbar__save-label--saved {
  grid-area: 1 / 1;
  transition: opacity 200ms ease;
}
.page-toolbar__save-label--saved {
  opacity: 0;
}

body:has(#leafable-editor.clean) {
  .page-toolbar__save {
    --btn-background: transparent;
    --btn-border-color: var(--color-ink);
    --btn-color: var(--color-ink);
  }

  /* Keep the phosphor SVG black (no orange tint) to match the ink accent. */
  .page-toolbar__save-icon {
    filter: none;
  }

  .page-toolbar__save:hover {
    --btn-background: var(--color-ink);
    --btn-border-color: var(--color-ink);
    --btn-color: var(--color-ink-reversed);
  }

  .page-toolbar__save:hover .page-toolbar__save-icon {
    filter: invert(1);
  }

  .page-toolbar__save-label--default {
    opacity: 0;
  }
  .page-toolbar__save-label--saved {
    opacity: 1;
  }
}

  body:has(#leafable-editor.saving) .page-toolbar__save {
    position: relative;

    > * {
      visibility: hidden;
    }

    &::after {
      --mask: no-repeat radial-gradient(#000 68%,#0000 71%);
      --size: 1.25em;

      -webkit-mask: var(--mask), var(--mask), var(--mask);
      -webkit-mask-size: 28% 45%;
      animation: submitting 1s infinite linear;
      aspect-ratio: 8/5;
      background: currentColor;
      content: "";
      inline-size: var(--size);
      inset: 50%;
      margin-block: calc((var(--size) / 3) * -1);
      margin-inline: calc((var(--size) / 2) * -1);
      position: absolute;
    }
  }

body.edit-mode .hide_from_edit_mode {
  display: none;
}

body:not(.edit-mode) .hide_from_reading_mode {
  display: none;
}

.being-edited-by {
  animation: fade-out 300ms ease-out 20s;
  background-color: var(--color-ink);
  border-radius: 2em;
  color: var(--color-ink-reversed);
  padding: 0.5em 1em;
}

.page-edit__current {
  @media (max-width: 70ch) {
    display: none;
  }
}

/* Lexxy content overrides — left-align headings/paragraphs in both
   the editor and the rendered Action Text content view. Lexxy's
   default lexxy-content.css uses text-align: start on a few elements
   but our app's wrapper containers center text by default. */
.lexxy-content,
.lexxy-content :is(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote) {
  text-align: start;
}

/* Lexxy toolbar — Lexxy sizes its buttons in `lh`/`em` of the inherited
   font, which makes the toolbar oversized inside our reading-sized body
   font. Pin the toolbar to a fixed compact size and shrink the icon. */
lexxy-editor lexxy-toolbar {
  --lexxy-toolbar-button-size: 2.6rem;
  --lexxy-toolbar-icon-size: 1.4rem;
  font-size: 1rem;
}

/* Leaf editor — lift the #main 1280px cap and turn #main into a flex
   column so the layout below can fill the remaining viewport height. */
#main.book:has(.leaf-edit-layout) {
  display: flex;
  flex-direction: column;
  max-inline-size: none;
  padding-block: 0;
}

/* Image layout side panel — grid column to the right of the editor.
   `3fr 1fr` keeps the editor and the image panel growing together as the
   viewport widens beyond the 1280px minimum. `min-block-size: calc(100dvh ...)`
   explicitly fills the height under the editor's one line (.leaf-edit-bar).
   `flex: 1` is kept as a fallback for when #main has a definite block size via
   the body grid. */
.leaf-edit-layout {
  display: grid;
  flex: 1;
  gap: 1rem;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr;
  min-block-size: calc(100dvh - 56px);
  align-items: start; /* the panel sticks beside a taller main column */
  padding-block: 24px;
  position: relative;
}
.leaf-edit-layout__main {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
  min-width: 0;
}
.leaf-edit-layout__main > form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-block-size: 0;
}
.leaf-edit-layout__main > form > div:last-child {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-block-size: 0;
}
lexxy-editor {
  display: flex;
  flex-direction: column;
  block-size: 1025px;
  border: 1px solid #ddd;
}
lexxy-editor .lexxy-editor__content {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.45;
  min-block-size: 0;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  --lexxy-content-margin: 0.5rem;
}
lexxy-editor .lexxy-editor__content :is(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote) {
  margin-block: 0 0.25rem;
}
.leaf-edit-layout__panel {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  /* As tall as the editor, never taller than the screen under the one line; sticky, and scrolled
     on its own once it stacks the pages above the image layout (a scroll that ends here doesn't
     scroll the page). */
  block-size: 1025px;
  inset-block-start: calc(56px + 16px);
  max-block-size: calc(100dvh - 56px - 32px);
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: 0;
  padding-inline: 0;
  position: sticky;
}
.leaf-edit-layout__panel:not(:has(.leaf-pages)) {
  overflow: hidden;
}

/* With a body to edit, the editor and the panel fill the window under the one line and a long
   document scrolls inside them, not the page. (Without one, a picture chapter's list runs on and
   the page scrolls, with the panel stuck beside it, as above.) 664px: the body's 720px minimum. */
.leaf-edit-layout:has(lexxy-editor) {
  align-items: stretch;
  block-size: max(664px, 100dvh - 56px);
  grid-template-rows: minmax(0, 1fr);

  .leaf-edit-layout__panel {
    block-size: auto;
    max-block-size: none;
    min-block-size: 0;
  }

  lexxy-editor {
    block-size: auto;
    flex: 1;
    min-block-size: 0;
  }
}
.image-panel__header,
.image-panel__editors,
.image-panel__empty {
  padding-inline: 1rem;
}
.image-panel__editors,
.image-panel__empty {
  padding-block: 1rem;
}
.image-panel__editors {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.image-panel__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  block-size: 1025px;
  color: var(--color-subtle-dark);
}
.leaf-pages ~ .image-panel .image-panel__empty {
  block-size: auto;
  padding-block: 2rem;
}
.image-panel__header {
  border-block-end: 1px solid var(--color-subtle);
}
.leaf-pages ~ .image-panel .image-panel__header {
  border-block-start: 1px solid var(--color-subtle);
}

/* The leaf's laid-out pages (pdf-pages) as spreads, stacked down the panel: a left (even) page and a
   right (odd) one meeting at the spine, the first page alone on the right when it is odd; each page
   labelled with its number, on its outer edge; dimmed while the next layout is being drawn. */
.leaf-pages .layout-pages {
  display: grid;
  gap: 0.75rem 0;
  grid-auto-flow: row;
  grid-template-columns: 1fr 1fr;
  padding: 1rem;

  .pdf-sheet {
    border: 1px solid var(--color-subtle);
    display: block;
    overflow: hidden;
    transition: opacity 0.2s;
    width: 100%;
  }

  .pdf-sheet--left {
    border-inline-end-color: var(--color-subtle-dark); /* the spine */
    grid-column: 1;
  }

  .pdf-sheet--right {
    grid-column: 2;
  }

  .pdf-sheet--left + .pdf-sheet--right {
    border-inline-start: none; /* the left page's edge is the spine */
  }

  /* Linked to 교정/교열: a page under the pointer (or focused) outlines its spread. */
  &.layout-pages--linked .pdf-sheet {
    cursor: pointer;
  }

  &.layout-pages--linked :is(.pdf-sheet:hover, .pdf-sheet:focus-visible,
                             .pdf-sheet--left:has(+ .pdf-sheet--right:is(:hover, :focus-visible)),
                             .pdf-sheet--left:is(:hover, :focus-visible) + .pdf-sheet--right) {
    outline: 2px solid var(--color-link, #2563eb);
    outline-offset: -1px;
  }

  .pdf-sheet--left .pdf-sheet__label {
    inset-inline-end: auto;
    inset-inline-start: 0.25rem;
  }

  .pdf-sheet .textLayer {
    display: none; /* drawn in page points; the sheets are scaled by width */
  }

  &.is-dimmed .pdf-sheet {
    opacity: 0.45;
  }
}
.leaf-pages .pdf-sheet__label {
  background: rgb(255 255 255 / 0.85);
  border-radius: 3px;
  color: var(--color-subtle-dark);
  font-size: 0.7rem;
  inset-block-start: 0.25rem;
  inset-inline-end: 0.25rem;
  padding: 0 0.3rem;
  position: absolute;
  z-index: 1;

  &:empty {
    display: none;
  }
}
.image-panel__header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  padding-block: calc((var(--nav-block-size, 80px) - var(--btn-size)) / 2);
}
.image-editor {
  position: relative;
  padding: 0.4rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--block-space);
}

.image-editor__preview { display: block; }

/* Six numbers, each one or two digits, in a side panel. At the app's large
   input size every field was over a hundred pixels tall and the set of them
   ran past the screen, which is not a size a single digit needs. */
.image-layout-form .input {
  --input-padding: 0.35em 0.55em;
  font-size: 0.95rem;
}
.image-layout-form .form-field { gap: 0.15rem; }

/* The page is far taller than it is wide, so a preview sized to the panel's
   width pushes every control below it off the screen. Capped against the
   viewport instead: the picker stays visible together with the fields it sets.
   overflow stays visible because the bleed guides are drawn outside the page. */
.image-editor__preview .image-preview {
  display: block;
  margin: 0 auto;
  overflow: visible;
  width: 40%;
  min-width: 7rem;
  height: auto;
  max-height: 38vh;
}

/* Suppress base.css's global `:is(a, button, ...):hover` box-shadow ring
   on the Lexxy attachment delete button so only its own red hover
   background shows. */
lexxy-editor .lexxy-node-delete {
  --hover-size: 0;
}

/* Editor image picker — hover affordance + selected outline. */
lexxy-editor figure.attachment[data-content-type^="image"],
lexxy-editor figure.attachment.attachment--preview {
  cursor: pointer;
}

lexxy-editor figure.attachment[data-content-type^="image"]:not(.is-editor-selected):hover,
lexxy-editor figure.attachment.attachment--preview:not(.is-editor-selected):hover {
  outline: 2px solid color-mix(in srgb, #2B3E58 50%, transparent);
  outline-offset: 2px;
  border-radius: 2px;
}

lexxy-editor figure.attachment.is-editor-selected {
  outline: 2px solid #2B3E58;
  outline-offset: 2px;
  border-radius: 2px;
}
.image-layout-form {
  display: grid;
  gap: var(--block-space);
}
.image-layout-form .image-layout-row {
  display: grid;
  gap: var(--block-space);
  grid-template-columns: 1fr 1fr;
}
.image-layout-form .image-layout-tab {
  display: grid;
  gap: var(--block-space);
}
.image-layout-form .tabs__nav { margin-block-end: var(--block-space); }

/* The two ways to place an image, each a button: the one not in use reads as clickable,
   not as greyed out. */
.image-layout-form {
  .tabs__nav {
    border: 0;
    flex-wrap: nowrap;
    gap: 0.4em;
  }

  .tabs__tab {
    background: var(--color-bg);
    border: 1px solid var(--color-subtle-dark);
    border-radius: 0.5em;
    color: var(--color-ink);
    flex: 1;
    margin: 0;
    padding: 0.45em 0.6em;

    &:hover { background: var(--color-subtle-light); }
  }

  .tabs__tab[aria-selected="true"] {
    background: var(--color-selected);
    border-color: var(--color-ink);
    box-shadow: inset 0 0 0 1px var(--color-ink);
  }
}
.image-layout-sides {
  display: flex;
  font-size: var(--text-small, 0.875em);
  gap: var(--block-space);
  justify-content: center;
}
.image-layout-sides label {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.3em;
}
.image-layout-form .input--actor .input {
  block-size: 1.2em;
}
.image-layout-checks label { color: #555; }

.image-layout-checks__label {
  align-items: center;
  block-size: 2.55rem;
  cursor: pointer;
  display: flex;
  inline-size: 3rem;
  justify-content: center;
}

.image-layout-checks__checkbox {
  /* Native checkbox so the ✓ always renders — Safari/Firefox don't draw
     ::after on <input>, so a custom appearance:none mark stayed invisible. */
  accent-color: var(--color-ink);
  block-size: 1.25rem;
  cursor: pointer;
  inline-size: 1.25rem;
  margin: 0;
}

.image-layout-checks__checkbox:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-link) 40%, transparent);
  outline-offset: 2px;
}

/* 교정/교열's way back: ← 글쓰기, first in its bar and filled, so it's found at a glance. */
.mode-switch {
  border-radius: 2em;
}

.mode-switch--back {
  flex-shrink: 0;
  font-weight: 600;
}

.mode-switch__icon {
  block-size: 1.1em;
  filter: invert(1); /* white on the filled (ink) button */
  inline-size: 1.1em;

  @media (prefers-color-scheme: dark) {
    filter: none; /* the button is light in dark mode */
  }
}

/* The spread view (지면): the spread fills the window under one slim bar */
body:has(.spread-view) :is(#header, #toolbar, #sidebar, #footer) {
  display: none;
}

.spread-view {
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  inset: 0;
  outline: 0; /* focused only to take the keys from the embed (spread#takeFocus) */
  position: fixed;
  z-index: 10;
}

.spread-view__toolbar {
  align-items: center;
  border-block-end: 1px solid var(--color-subtle-light);
  display: flex;
  font-size: 0.8rem;
  gap: 1.25em;
  padding: 0.3em 0.75em;

  .btn {
    --btn-size: 1.9em;
    font-size: inherit;
    padding-inline: 0.8em;
  }
}

.spread-view__pager {
  align-items: center;
  display: inline-flex;
  gap: 0.25em;
}

.spread-view__counter {
  font-variant-numeric: tabular-nums;
  min-inline-size: 3.5em;
  text-align: center;
}

/* As small as the bar's buttons: it says where you are without drawing the eye from the page. */
.spread-view__title {
  font-size: inherit;
  font-weight: 600;
  margin: 0;
  max-inline-size: 22em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spread-view__leaf {
  color: var(--color-subtle-dark);
  font-weight: 400;
  margin-inline-start: 0.4em;
}

.spread-view__status {
  color: var(--color-subtle-dark);
  margin-inline-start: auto;
}

.spread-view__message {
  font-size: 0.8rem;
  margin: 0;
  padding: 0.3em 0.75em;
}

/* The embed, and the fonts overlay over it while the page fetches its fonts. */
.spread-view__stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-block-size: 0;
  position: relative;
}

.spread-view__frame {
  border: 0;
  display: block;
  flex: 1;
  inline-size: 100%;
}

/* Over DesignCraft's embed (교정/교열, 디자인수정) while the page fetches its fonts
   (shared/_embed_fonts): a spinner and which font of how many, or the failure with 다시 시도.
   Until then (no embed-fonts--active) it's out of sight, as .for-screen-reader, but not hidden:
   its live region stays in the page, so the first text put in it is announced. */
.embed-fonts {
  align-items: center;
  background-color: color-mix(in srgb, var(--color-bg) 88%, transparent);
  color: var(--color-ink);
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.75em;
  inset: 0;
  justify-content: center;
  padding-inline: 1em;
  position: absolute;
  text-align: center;
  z-index: 1;

  [hidden] {
    display: none;
  }

  .btn {
    font-size: inherit;
  }

  &:not(.embed-fonts--active) {
    block-size: 1px;
    clip-path: inset(50%);
    inline-size: 1px;
    inset: auto;
    overflow: hidden;
    padding: 0;
    pointer-events: none;
    white-space: nowrap;

    .embed-fonts__spinner {
      display: none;
    }
  }
}

.embed-fonts__text {
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.embed-fonts__spinner {
  animation: embed-fonts-spin 0.9s linear infinite;
  block-size: 1.75em;
  border: 0.2em solid color-mix(in srgb, currentColor 25%, transparent);
  border-block-start-color: currentColor;
  border-radius: 50%;
  inline-size: 1.75em;

  @media (prefers-reduced-motion: reduce) {
    animation-duration: 3s;
  }

  .embed-fonts--failed & {
    display: none;
  }
}

@keyframes embed-fonts-spin {
  to { transform: rotate(1turn); }
}

/* Where the math panel opens: an invisible box over the formula clicked in the page. */
.spread-view__formula-anchor {
  pointer-events: none;
  position: fixed;
  visibility: hidden;
}

/* math_input's panel in book_write's colours, so it follows dark mode. Set on the panel itself
   rather than :root: math_input.css's :root defaults are linked by stylesheet_link_tag :all
   too, and the panel's own declarations win whatever the order. */
.math-panel {
  --math-input-surface: var(--color-bg);
  --math-input-line: var(--color-subtle);
  --math-input-muted: var(--color-subtle-dark);
  --math-input-ink: var(--color-ink);
  --math-input-accent: var(--color-link);
  --math-input-accent-tint: var(--color-selected);
  --math-input-danger: var(--color-negative);
  --math-input-mono: var(--font-mono);
}

/* 디자인수정: the whole book in DesignCraft's studio fills the window under one slim bar */
body:has(.studio-view) :is(#header, #toolbar, #sidebar, #footer) {
  display: none;
}

.studio-view {
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  inset: 0;
  position: fixed;
  z-index: 10;
}

.studio-view__toolbar {
  align-items: center;
  border-block-end: 1px solid var(--color-subtle-light);
  display: flex;
  font-size: 0.8rem;
  gap: 1.25em;
  padding: 0.3em 0.75em;

  .btn {
    --btn-size: 1.9em;
    font-size: inherit;
    padding-inline: 0.8em;
  }
}

.studio-view__title {
  font-weight: 600;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-view__pager {
  align-items: center;
  display: inline-flex;
  gap: 0.25em;
}

.studio-view__counter {
  font-variant-numeric: tabular-nums;
  min-inline-size: 3.5em;
  text-align: center;
}

.studio-view__status {
  color: var(--color-subtle-dark);
  margin-inline-start: auto;
  white-space: nowrap;
}

.studio-view__message {
  font-size: 0.8rem;
  padding: 0.3em 0.75em;

  p {
    margin: 0;
  }

  .btn {
    font-size: inherit;
    margin-block-start: 0.3em;
  }
}

.studio-view__preparing {
  color: var(--color-subtle-dark);
  display: none;
  margin: auto;
  padding-inline: calc(var(--inline-space) * 2);
  text-align: center;

  p {
    margin: 0;
  }
}

.studio-view__preparing-title {
  font-variant-numeric: tabular-nums;
}

.studio-view__preparing .studio-view__preparing-note {
  font-size: 0.85em;
  margin-block-start: 0.5em;
}

.studio-view--preparing {
  .studio-view__preparing {
    display: block;
  }

  .studio-view__frame {
    display: none;
  }
}

/* Three columns: the book's tree, the entry's pages (or the preparing note while it builds) and
   the entry's settings. The tree and the settings keep their place while an entry builds. */
.studio-view__body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr) 22rem;
  min-block-size: 0;
}

.studio-view__tree {
  border-inline-end: 1px solid var(--color-subtle-light);
  min-block-size: 0;
  overflow-y: auto;

  .book-tree { padding: 12px 14px 32px; }

  /* The entries are buttons; they look like the book tree's links. */
  button.book-tree__link {
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    padding-inline: 0;
    text-align: start;
  }
}

.studio-tree__book { padding-block-end: 8px; }

.studio-view__middle {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
  min-inline-size: 0;
  position: relative; /* the fonts overlay covers it */
}

.studio-view__frame {
  border: 0;
  display: block;
  flex: 1;
  inline-size: 100%;
  min-inline-size: 0;
}

/* Narrow windows: the tree sits above, a short scrolling strip, and the settings below the pages. */
@media (max-width: 70ch) {
  .studio-view__body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  }

  .studio-view__tree {
    border-block-end: 1px solid var(--color-subtle-light);
    border-inline-end: 0;
    max-block-size: 30dvh;
  }

  .studio-view__body .studio-view__settings {
    border-block-start: 1px solid var(--color-subtle-light);
    border-inline-start: 0;
  }
}

/* The settings column: the entry's header, then each section group a card that folds. */
.studio-view__settings {
  border-inline-start: 1px solid var(--color-subtle-light);
  font-size: 0.8rem;
  min-block-size: 0;
  min-inline-size: 0;
  overflow-y: auto;
  padding: 0.75em;
  text-align: start;
}

/* 디자인수정 reads as one DesignCraft window: the tree and the settings wear its Medium Dark panel grey
   (designcraft theme.rs: panel #535353, panel_darker #424242), the pages sit on its pasteboard (#5e5e5e).
   The app's colour tokens are redefined here, so cards, borders, buttons and text follow; color-scheme
   dark gives the native inputs and selects dark faces. */
.studio-view__toolbar,
.studio-view__tree,
.studio-view__settings,
.studio-view__middle {
  --color-bg: #4a4a4a;
  --color-ink: #e8e8e8;
  --color-ink-reversed: #2a2a2a;
  --color-subtle-light: #424242;
  --color-subtle: #8c8c8c;
  --color-subtle-dark: #bdbdbd;
  --color-link: #9cc2ff;
  background-color: #535353;
  color: var(--color-ink);
  color-scheme: dark;
}

.studio-view__middle {
  background-color: #5e5e5e;
}

.studio-view__toolbar {
  background-color: #424242;
}

.studio-view__tree .book-tree__section {
  border-block-start-color: #424242;
}

.studio-settings__header {
  margin-block-end: 0.75em;
}

.studio-settings__title {
  font-size: 1.1em;
  margin: 0;
}

.studio-settings__reach {
  color: var(--color-subtle-dark);
  margin: 0.2em 0 0;
}

.studio-settings__follows .btn {
  font-size: inherit;
}

.studio-settings__section {
  background-color: var(--color-bg);
  border: 1px solid var(--color-subtle-light);
  border-radius: 0.4em;
  margin-block-end: 0.6em;
  padding: 0.4em 0.75em;

  &[open] > .studio-settings__summary {
    margin-block-end: 0.3em;
  }

  /* Its first section needs no rule above it: the summary heads it. */
  .studio-layout > .studio-layout__section:first-of-type {
    border-block-start: 0;
  }
}

.studio-settings__summary {
  cursor: pointer;
  font-weight: 600;
  padding-block: 0.2em;
}

/* The summary's heading reads as the summary itself, beside its marker. */
.studio-settings__summary-title {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  margin: 0;
}

/* While the column waits for another entry's settings, it's dimmed and nothing in it can be changed. */
.studio-view__settings[aria-busy="true"] {
  opacity: 0.6;
}

.studio-layout__title {
  font-size: 1em;
  margin: 0 0 0.5em;
}

.studio-layout__section {
  border-block-start: 1px solid var(--color-subtle-light);
  padding-block: 0.6em;
}

.studio-layout__heading {
  font-size: 0.95em;
  margin: 0 0 0.4em;
}

/* 표's opening line: whose tables a document type's are (D spec §6.3). */
.studio-tables__reach {
  font-weight: 600;
  margin: 0 0 0.3em;
}

.studio-layout__picker,
.studio-layout__field {
  align-items: center;
  column-gap: 0.5em;
  display: grid;
  grid-template-columns: 1fr 7em;
  margin-block-end: 0.4em;

  select,
  input {
    font-size: inherit;
    inline-size: 100%;
  }
}

.studio-layout__picker {
  grid-template-columns: auto 1fr;
}

.studio-layout__field--text {
  grid-template-columns: 1fr;
}

.studio-layout__inserts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  margin-block: 0.2em 0.4em;
}

.studio-layout__form .studio-layout__insert {
  margin-block-start: 0;
  padding: 0.15em 0.5em;
}

/* A section's fields, all disabled together while their values are about to be replaced. */
.studio-layout__controls {
  border: 0;
  margin: 0;
  min-inline-size: 0;
  padding: 0;
}

.studio-layout__switches {
  border: 0;
  margin: 0 0 0.4em;
  padding: 0;

  legend {
    font-weight: 600;
    margin-block-end: 0.3em;
    padding: 0;
  }
}

.studio-layout__switch {
  align-items: center;
  display: flex;
  gap: 0.4em;
  margin-block-end: 0.3em;

  &[hidden] {
    display: none;
  }
}

.studio-layout__error,
.studio-layout__field .studio-layout__note {
  grid-column: 1 / -1;
}

.studio-layout__error {
  color: var(--color-negative);
  margin: 0.2em 0 0;
}

.studio-layout__note {
  color: var(--color-subtle-dark);
  font-size: 0.9em;
  margin: 0.2em 0 0.4em;
}

.studio-layout__refusal,
.studio-layout__saved {
  margin-block-end: 0.5em;

  p {
    margin: 0;
  }

  .btn {
    font-size: inherit;
    margin-block-start: 0.3em;
  }
}

.studio-layout__refusal {
  color: var(--color-negative);
}

.studio-layout__form .btn {
  font-size: inherit;
  margin-block-start: 0.3em;
}

/* 장 시작 (C3d1): the heading's positions in a row; a field's own switch (본문과 같음) under it. */
.studio-layout__radios {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1em;
}

/* 표지 (C3f2): a 3 × 3 anchor picker, in reading order. */
.studio-cover__grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0.2em 0.8em;
}

.studio-layout__field .studio-layout__switch {
  grid-column: 1 / -1;
}
