.sheet-wrapper {
  max-width: 72rem;
  margin-inline: auto;
  padding: var(--space-md) var(--space-md) 0;
  min-height: calc(100vh - var(--navbar-footprint) - var(--space-md));
  display: flex;
  flex-direction: column;

  @media (min-width: 768px) {
    padding: var(--space-xl) var(--space-xl) 0;
  }
}

.sheet-wrapper__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

@media (max-width: 1023px) {
  .workspace__pane .sheet {
    margin-inline: calc(-1 * var(--page-gutter));
    border-top: 1px solid var(--color-spring-wood-300);
  }
}

.sheet__notice {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-armadillo-800);
}

.sheet__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-block: var(--space-lg);
  padding-inline: var(--space-md);

  @media (min-width: 768px) {
    padding-inline: max(var(--space-lg), calc((100% - 48rem) / 2));
  }
}

/* The document's meta row — the Edit/Preview toggle (a property of this draft) sits
   with the document at the prose measure, hard-left; the passive status/date strip
   is pushed hard-right. A far-apart adjacency, never a grouped cluster. */
.sheet__meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  row-gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.sheet__meta-row .info-strip {
  margin-left: auto;
  margin-bottom: 0;
}

/* The bar sits inside the sheet, at its top edge — the segmented control and
   actions are part of the document card, not floating chrome above it. */
.sheet__top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-spring-wood-300);
}

.sheet__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.sheet__actions__group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sheet__meta {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--color-armadillo-500);
}

.sheet__content {
  flex: 1;
  padding: var(--space-xl) var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;

  @media (min-width: 768px) {
    padding: var(--space-2xl) var(--space-xl);
  }
}

.sheet__content > * {
  width: 100%;
  max-width: 48rem;
}

.sheet__header + .sheet__content {
  padding-top: 0;
}

.sheet__title {
  display: block;
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  color: var(--color-armadillo-900);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.sheet__title-text {
  overflow-wrap: anywhere;
  hyphens: auto;
}

.sheet__description {
  margin: 0;
  font-size: 1.125rem;
  color: var(--color-armadillo-600);
  line-height: 1.5;
}

.sheet__body {
  line-height: 1.7;
  color: var(--color-armadillo-800);
}

.sheet__title-input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  appearance: none;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  color: var(--color-armadillo-900);
  background: transparent;
  padding: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-family: var(--font-sans);
  resize: none;
  field-sizing: content;
}

.sheet__title-input::placeholder {
  color: var(--color-armadillo-300);
}

.sheet__description-input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  appearance: none;
  font-size: 1.125rem;
  color: var(--color-armadillo-600);
  background: transparent;
  padding: 0;
  line-height: 1.5;
  font-family: var(--font-sans);
  resize: none;
  field-sizing: content;
}

.sheet__description-input::placeholder {
  color: var(--color-armadillo-300);
  font-style: italic;
}

/* Back link in the editor's top-bar band — the lone item on the band's left, with
   the actions pushed right (the same two-zone shape as the collection bands). */
.sheet__top-bar-back {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

/* Icon-only on mobile, where the collection name would crowd the band's actions. */
@media (max-width: 1023px) {
  .sheet__top-bar-back .page__back-link__text {
    display: none;
  }
}

/* Mobile-only back link that surfaces above the topbar when the TOC sidebar is
   hidden. On desktop the back link lives in the top-bar band instead. */
.sheet__mobile-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-armadillo-600);
  text-decoration: none;
  padding-bottom: var(--space-sm);
  transition: color var(--transition-fast);
}

.sheet__mobile-back:hover { color: var(--color-armadillo-900); }

@media (min-width: 1024px) {
  .sheet__mobile-back { display: none; }
}

.sheet__editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sheet__editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sheet__editor-body lexxy-editor {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
}

.sheet__editor-body lexxy-toolbar {
  position: sticky;
  top: var(--navbar-height);
  z-index: 10;
  background: var(--color-white);
  border-top: 1px solid var(--color-spring-wood-300);
  border-bottom: 1px solid var(--color-spring-wood-300);
  padding-block: var(--space-xs);
  padding-inline: var(--space-md);
  border-radius: 0;

  @media (min-width: 768px) {
    padding-inline: max(var(--space-lg), calc((100% - 48rem) / 2));
  }
}


.sheet__editor-body .lexxy-editor__content {
  box-sizing: content-box;
  max-width: 48rem;
  margin-inline: auto;
  padding: var(--space-xl) var(--space-md);
  line-height: 1.7;
  color: var(--color-armadillo-800);

  @media (min-width: 768px) {
    padding: var(--space-2xl) var(--space-xl);
  }
}

.sheet__body-field {
  flex: 1;
  color: var(--color-armadillo-800);
}
