:root {
  color-scheme: dark;
  --bg: #111315;
  --sidebar-bg: #17191c;
  --surface: #1b1e21;
  --surface-soft: rgba(255, 255, 255, 0.03);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #7dd3fc;
  --accent-soft: rgba(125, 211, 252, 0.12);
  --content-width: 1240px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1eb;
  --sidebar-bg: #ece8e0;
  --surface: #f8f5ef;
  --surface-soft: rgba(36, 31, 26, 0.04);
  --text: #1a1815;
  --text-muted: #4f4941;
  --line: rgba(36, 31, 26, 0.1);
  --line-strong: rgba(36, 31, 26, 0.18);
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.1);
}

[data-theme="light"] .ai-summary-card--accent::before,
[data-theme="light"] .suggestion-card--ai::before {
  background:
    linear-gradient(
      120deg,
      rgba(139, 92, 246, 0.22),
      rgba(168, 85, 247, 0.72),
      rgba(139, 92, 246, 0.22)
    );
}

[data-theme="light"] .ai-summary-card,
[data-theme="light"] .suggestion-card--ai {
  background: color-mix(in srgb, rgba(139, 92, 246, 0.09) 58%, var(--surface));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", sans-serif;
  overflow: hidden;
  transition:
    background-color 240ms ease,
    color 240ms ease;
}

body.body--nav-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0.85rem 1.2rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  overflow-y: auto;
  transition:
    background-color 240ms ease,
    border-color 240ms ease;
}

.sidebar__brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar__brand {
  padding: 0 0.4rem;
}

.sidebar__eyebrow {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.brand-logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
}

.brand-logo::before {
  content: "";
  position: absolute;
  inset: -0.18rem -0.35rem;
  border-radius: 12px;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(187, 134, 252, 0.14) 38%,
    rgba(125, 211, 252, 0.12) 62%,
    transparent 100%
  );
  opacity: 0.7;
  filter: blur(10px);
  pointer-events: none;
  animation: brand-halo 4200ms ease-in-out infinite;
}

.brand-logo__text,
.brand-logo__chip {
  position: relative;
  z-index: 1;
}

.brand-logo__text {
  background: linear-gradient(135deg, var(--text) 0%, rgba(187, 134, 252, 0.92) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-logo__chip {
  position: relative;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: inset 0 0 0 1px rgba(187, 134, 252, 0.22);
  color: var(--text);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
}

.brand-logo__chip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 45%,
    transparent 75%
  );
  transform: translateX(-135%);
  animation: brand-scan 3600ms ease-in-out infinite;
}

.hero-brand {
  margin: 0 0 0.9rem;
  line-height: 1;
}

.brand-logo--hero {
  gap: 0.72rem;
  font-size: clamp(2.8rem, 7vw, 5.4rem);
}

.brand-logo--hero::before {
  inset: -0.45rem -0.75rem;
  border-radius: 24px;
  opacity: 0.86;
  filter: blur(18px);
}

.brand-logo--hero .brand-logo__chip {
  padding: 0.34rem 0.8rem;
  font-size: 0.34em;
  box-shadow: inset 0 0 0 1px rgba(187, 134, 252, 0.28);
}

.sidebar__close,
.workspace-menu {
  display: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.sidebar__close {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  color: var(--text-muted);
}

.sidebar__close span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
}

.sidebar__close span:first-child {
  transform: translate(-50%, -50%) rotate(45deg);
}

.sidebar__close span:last-child {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.sidebar__brand-link,
.sidebar-item,
.sidebar-group__action,
.page-link,
.button {
  border: 0;
  background: transparent;
  color: inherit;
}

.sidebar__brand-link {
  width: 100%;
  padding: 0 0.4rem;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease;
}

.sidebar__brand-link:hover,
.sidebar__brand-link:focus-visible,
.sidebar-item:hover,
.sidebar-item--button:hover,
.sidebar__close:hover,
.workspace-menu:hover {
  background: var(--surface-soft);
}

.sidebar__nav,
.sidebar__footer {
  display: grid;
  gap: 1rem;
}

.sidebar__footer-shell {
  margin-top: auto;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.sidebar-group {
  display: grid;
  gap: 0.35rem;
}

.sidebar-group + .sidebar-group {
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.sidebar-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.4rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-group__action {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.sidebar-group__action:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar-group__items {
  display: grid;
  gap: 0.1rem;
}

.sidebar-item {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.52rem 0.7rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.sidebar-item.is-draggable {
  cursor: grab;
}

.sidebar-item.is-dragging {
  opacity: 0.45;
}

.sidebar-item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(187, 134, 252, 0.14);
}

.sidebar-item.is-active::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 10px;
  background: radial-gradient(circle at center, rgba(187, 134, 252, 0.18), transparent 72%);
  opacity: 0.65;
  z-index: -2;
}

.sidebar-item.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background:
    linear-gradient(
      120deg,
      rgba(187, 134, 252, 0.12),
      rgba(187, 134, 252, 0.52),
      rgba(187, 134, 252, 0.12)
    );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: ai-border-pulse 2400ms ease-in-out infinite;
}

.sidebar-item--button {
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.sidebar-item--muted {
  color: var(--text-muted);
  cursor: default;
}

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.workspace__header {
  display: none;
}

.workspace-bar {
  display: none;
  align-items: flex-start;
  gap: 0.9rem;
  width: 100%;
  min-width: 0;
}

.workspace-heading {
  flex: 1;
  min-width: 0;
}

.workspace-menu {
  position: relative;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  color: var(--text-muted);
}

.workspace-menu span {
  position: absolute;
  left: 50%;
  width: 16px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
}

.workspace-menu span:nth-child(1) {
  top: 12px;
}

.workspace-menu span:nth-child(2) {
  top: 18px;
}

.workspace-menu span:nth-child(3) {
  top: 24px;
}

.page-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0 0 0.6rem;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.theme-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.theme-toggle--sidebar {
  display: inline-flex;
  margin: 0.2rem 0 0;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.theme-toggle__track {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition:
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease;
}

.theme-toggle:hover .theme-toggle__track,
.theme-toggle:focus-visible .theme-toggle__track {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.theme-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff;
  color: #f5c94a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transition:
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
    color 220ms ease,
    background 220ms ease,
    box-shadow 220ms ease;
}

.theme-toggle.is-dark .theme-toggle__track {
  background: #3a3f46;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 8px 18px rgba(0, 0, 0, 0.16);
}

.theme-toggle.is-dark .theme-toggle__thumb {
  transform: translateX(28px);
  background: #1c1f23;
  color: #ffffff;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.theme-toggle.is-light .theme-toggle__track {
  background: #f7f5f1;
}

.theme-toggle.is-light .theme-toggle__track,
.theme-toggle.is-dark .theme-toggle__track {
  animation: theme-toggle-flash 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar__theme {
  padding: 0 0.4rem;
}

.banner-stack {
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem 1.5rem 0;
}

.workspace__header,
.ai-summary-card,
.suggestion-card,
.page-footer-band,
.sidebar-item,
.sidebar__footer-shell {
  transition:
    background-color 240ms ease,
    border-color 240ms ease,
    box-shadow 240ms ease,
    color 240ms ease;
}

.banner-line {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.workspace__content {
  width: 100%;
  max-width: var(--content-width);
  padding: 1.75rem 1.5rem 3rem;
}

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2.5rem;
  align-items: start;
}

.project-layout__main {
  min-width: 0;
}

.project-layout__rail {
  position: relative;
}

.project-rail-top {
  position: relative;
  z-index: 2;
}

.page-intro,
.page-block {
  margin-bottom: 2rem;
}

.document-title {
  margin: 0 0 0.7rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.document-title--brand {
  background: linear-gradient(135deg, var(--text) 0%, rgba(187, 134, 252, 0.9) 62%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.page-copy {
  max-width: 68ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.page-summary {
  width: 100%;
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.page-summary p,
.page-summary ul,
.page-summary ol,
.page-summary blockquote,
.page-summary h2,
.page-summary h3,
.document-body p,
.document-body ul,
.document-body ol,
.document-body blockquote,
.document-body h2,
.document-body h3,
.page-editor__summary p,
.page-editor__summary ul,
.page-editor__summary ol,
.page-editor__summary blockquote,
.page-editor__summary h2,
.page-editor__summary h3,
.page-editor__body p,
.page-editor__body ul,
.page-editor__body ol,
.page-editor__body blockquote,
.page-editor__body h2,
.page-editor__body h3 {
  margin: 0 0 0.9rem;
}

.document-body ul,
.document-body ol,
.page-editor__body ul,
.page-editor__body ol,
.page-summary ul,
.page-summary ol,
.page-editor__summary ul,
.page-editor__summary ol {
  padding-left: 1.35rem;
}

.document-body blockquote,
.page-editor__body blockquote,
.page-summary blockquote,
.page-editor__summary blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line-strong);
  color: var(--text-muted);
}

.document-body h2,
.page-editor__body h2 {
  font-size: 1.45rem;
}

.document-body h3,
.page-editor__body h3 {
  font-size: 1.18rem;
}

.page-divider {
  width: 100%;
  height: 1px;
  background: var(--line);
  margin: 1rem 0 1.4rem;
}

.page-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.page-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.block-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.page-link {
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
}

.page-link:hover {
  color: var(--text);
}

.page-link--danger {
  color: #f87171;
}

.page-link--danger:hover {
  color: #ef4444;
}

.document-body,
.living-document {
  width: 100%;
  font-size: 1rem;
  line-height: 1.85;
}

.document-body--page {
  margin-top: 1.5rem;
}

.document-body p,
.living-document p {
  margin: 0 0 1rem;
}

.update-list {
  display: grid;
  gap: 0.75rem;
}

.update-item {
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}

.update-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.update-item__title {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.update-item__content {
  max-width: 66ch;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 72ch;
}

.editor-field {
  display: grid;
  gap: 0.45rem;
}

.editor-field--wide {
  grid-column: 1 / -1;
}

.editor-field span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.editor-field input,
.editor-field select,
.editor-field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.editor-field textarea {
  min-height: 130px;
  resize: vertical;
}

.editor-field__large {
  min-height: 260px !important;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.65;
}

.editor-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.editor-actions--comments {
  grid-column: auto;
}

.editor-button {
  padding: 0.7rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}

.editor-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.noscript {
  padding: 1rem;
}

.page-editor {
  display: grid;
  gap: 0.85rem;
  width: 100%;
}

.page-editor [contenteditable="true"] {
  outline: none;
}

.page-editor [contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.page-editor__title,
.page-editor__summary,
.page-editor__body {
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  white-space: pre-wrap;
}

.page-editor__title {
  min-height: 2.6rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.15rem 0 0.25rem;
}

.rich-toolbar__button {
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.rich-toolbar__button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rich-toolbar__button--dictation,
.selection-comment-composer__dictation {
  position: relative;
  padding-left: 0.95rem;
}

.rich-toolbar__button--dictation::before,
.selection-comment-composer__dictation::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.46;
  margin-right: 0.45rem;
  display: inline-block;
  vertical-align: middle;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.rich-toolbar__button.is-dictating,
.selection-comment-composer__dictation.is-dictating {
  border-color: rgba(187, 134, 252, 0.45);
  background: rgba(187, 134, 252, 0.1);
  color: var(--text);
}

.rich-toolbar__button.is-dictating::before,
.selection-comment-composer__dictation.is-dictating::before {
  opacity: 1;
  transform: scale(1.15);
  box-shadow: 0 0 0 6px rgba(187, 134, 252, 0.14);
  animation: dictation-pulse 1250ms ease-in-out infinite;
}

.rich-toolbar__button.is-disabled,
.selection-comment-composer__dictation.is-disabled {
  opacity: 0.58;
}

.page-editor__summary {
  min-height: 3.25rem;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.page-editor__body {
  min-height: 45vh;
  font-size: 1rem;
  line-height: 1.85;
}

.document-body img,
.page-editor__body img {
  display: block;
  width: min(100%, 100%);
  max-width: 100%;
  height: auto;
  margin: 1.15rem 0;
  border-radius: 16px;
}

.document-body img[data-display-width="33"],
.page-editor__body img[data-display-width="33"] {
  width: min(33%, 220px);
}

.document-body img[data-display-width="50"],
.page-editor__body img[data-display-width="50"] {
  width: min(50%, 420px);
}

.document-body img[data-display-width="72"],
.page-editor__body img[data-display-width="72"] {
  width: min(72%, 760px);
}

.document-body img[data-display-width="100"],
.page-editor__body img[data-display-width="100"] {
  width: min(100%, 100%);
}

.page-editor__body img.editor-image {
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 180ms ease,
    outline-color 180ms ease;
}

.page-editor__body img.editor-image:hover {
  transform: translateY(-1px);
}

.page-editor__body img.editor-image.is-selected {
  outline: 2px solid rgba(187, 134, 252, 0.7);
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(187, 134, 252, 0.1);
}

.page-editor__status {
  color: var(--text-muted);
  font-size: 0.84rem;
  min-height: 1rem;
}

.page-footer-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.page-footer-band__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.page-footer-band__label {
  color: var(--text);
  font-weight: 600;
}

.page-footer-band__dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
}

.page-footer-band__text {
  color: var(--text-muted);
}

.page-footer-band__action {
  flex: 0 0 auto;
}

.comment-form {
  display: grid;
  gap: 0.85rem;
  width: 100%;
  margin-bottom: 1.5rem;
}

.comment-form__options {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.comment-form textarea {
  min-height: 120px;
}

.comment-list {
  display: grid;
  gap: 1.15rem;
  width: 100%;
}

.comment-item {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.comment-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.comment-item__author {
  color: var(--text);
  font-weight: 600;
}

.comment-item__content {
  margin-top: 0.55rem;
  color: var(--text-muted);
}

.comment-item__content p {
  margin: 0 0 0.8rem;
}

.suggestions-panel {
  display: grid;
  gap: 0.9rem;
}

.selection-comments-layer {
  position: relative;
  min-height: 7rem;
}

.selection-comments-layer--empty {
  min-height: auto;
}

.selection-comments-empty {
  padding-top: 0.2rem;
}

.ai-summary-card {
  position: relative;
  display: grid;
  gap: 0.85rem;
  padding: 1rem 1rem 1.05rem;
  margin-bottom: 1.1rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-soft) 70%, transparent);
  overflow: hidden;
}

.ai-summary-card--accent::before,
.suggestion-card--ai::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background:
    linear-gradient(
      120deg,
      rgba(187, 134, 252, 0.08),
      rgba(187, 134, 252, 0.5),
      rgba(187, 134, 252, 0.08)
    );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: ai-border-pulse 2400ms ease-in-out infinite;
}

.ai-summary-card__body {
  display: grid;
  gap: 0.7rem;
}

.ai-summary-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.ai-summary-card__action {
  flex: 0 0 auto;
}

.ai-summary-card__point {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.suggestions-panel__eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.suggestions-panel__list {
  display: grid;
  gap: 0.9rem;
}

.suggestion-card {
  position: relative;
  display: grid;
  gap: 0.55rem;
  padding: 0.9rem 0.9rem 1rem;
  border-top: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-soft) 44%, transparent);
  cursor: pointer;
}

.suggestion-card--anchored {
  position: absolute;
  left: 0;
  right: 0;
}

.suggestion-card.is-hovered,
.suggestion-card.is-active {
  background: color-mix(in srgb, rgba(187, 134, 252, 0.08) 60%, var(--surface-soft));
  box-shadow: 0 0 0 1px rgba(187, 134, 252, 0.14);
}

.suggestion-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.suggestion-card__content,
.suggestion-card__suggested-text {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.suggestion-card__selection {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.55;
}

.suggestion-card__suggested-text {
  color: var(--text);
}

.suggestion-card__action {
  width: fit-content;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.suggestion-card__action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.suggestion-card__action--danger {
  color: #f87171;
}

.suggestion-card__menu {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.2rem;
}

.suggestion-card.is-active .suggestion-card__menu {
  display: flex;
}

.selection-anchor {
  border-radius: 0.35rem;
  background: rgba(187, 134, 252, 0.14);
  box-shadow: inset 0 0 0 1px rgba(187, 134, 252, 0.28);
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.selection-anchor.is-comment-highlighted {
  background: rgba(187, 134, 252, 0.26);
  box-shadow:
    inset 0 0 0 1px rgba(187, 134, 252, 0.48),
    0 0 0 6px rgba(187, 134, 252, 0.12);
}

[data-page-field].is-comment-highlighted {
  border-radius: 14px;
  background: rgba(187, 134, 252, 0.08);
  box-shadow: 0 0 0 1px rgba(187, 134, 252, 0.14);
}

.selection-comment-action {
  position: fixed;
  z-index: 40;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(187, 134, 252, 0.4);
  border-radius: 999px;
  background: color-mix(in srgb, var(--sidebar-bg) 92%, transparent);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    box-shadow 180ms ease;
}

.selection-comment-action.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.selection-comment-action:hover {
  box-shadow: 0 0 0 4px rgba(187, 134, 252, 0.12);
}

.selection-comment-composer {
  position: fixed;
  z-index: 41;
  display: grid;
  gap: 0.7rem;
  width: min(360px, calc(100vw - 24px));
  padding: 0.85rem;
  border: 1px solid rgba(187, 134, 252, 0.28);
  border-radius: 18px;
  background: color-mix(in srgb, var(--sidebar-bg) 95%, transparent);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 240ms ease;
}

.selection-comment-composer.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.selection-comment-composer__label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.selection-comment-composer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.selection-comment-composer__dictation {
  min-width: 6.3rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.selection-comment-composer__input {
  width: 100%;
  min-height: 110px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  resize: vertical;
  outline: none;
}

.selection-comment-composer__input:focus {
  border-color: rgba(187, 134, 252, 0.45);
  box-shadow: 0 0 0 4px rgba(187, 134, 252, 0.1);
}

.selection-comment-composer__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.image-resize-bar {
  position: fixed;
  z-index: 41;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--sidebar-bg) 94%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.image-resize-bar.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.image-resize-bar__button {
  min-width: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.image-resize-bar__button--danger {
  color: #f87171;
}

@keyframes ai-border-pulse {
  0%,
  100% {
    opacity: 0.45;
    filter: saturate(0.95);
  }

  50% {
    opacity: 0.95;
    filter: saturate(1.15);
  }
}

@keyframes brand-halo {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.98);
  }

  50% {
    opacity: 0.92;
    transform: scale(1.02);
  }
}

@keyframes brand-scan {
  0%,
  18% {
    transform: translateX(-135%);
  }

  34%,
  100% {
    transform: translateX(135%);
  }
}

@keyframes theme-toggle-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(187, 134, 252, 0);
  }

  55% {
    box-shadow: 0 0 0 6px rgba(187, 134, 252, 0.12);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(187, 134, 252, 0);
  }
}

@keyframes dictation-pulse {
  0%,
  100% {
    opacity: 0.72;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .app-shell.is-sidebar-open .sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: min(85vw, 320px);
    max-width: 320px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .app-shell.is-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__close,
  .workspace-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .workspace {
    min-height: 100vh;
  }

  .workspace__header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
    padding: 0.8rem 5rem 0.8rem 1rem;
  }

  .workspace-bar {
    display: flex;
  }

  .workspace__content {
    width: 100%;
    max-width: none;
    padding-top: 1.35rem;
  }

  .project-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .project-layout__rail {
    position: static;
    order: 2;
  }

  .selection-comments-layer {
    min-height: auto !important;
  }

  .suggestion-card--anchored {
    position: relative;
    left: auto;
    right: auto;
    top: auto !important;
    margin-bottom: 0.9rem;
  }

  .document-body img[data-display-width],
  .page-editor__body img[data-display-width] {
    width: min(100%, 100%);
  }

  .selection-comment-composer {
    width: min(420px, calc(100vw - 24px));
  }
}

@media (max-width: 640px) {
  .workspace__header,
  .workspace__content,
  .banner-stack {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .editor-form {
    grid-template-columns: 1fr;
  }

  .comment-form__options {
    grid-template-columns: 1fr;
  }

  .editor-field--wide,
  .editor-actions {
    grid-column: auto;
  }

  .document-title {
    font-size: clamp(1.8rem, 10vw, 2.6rem);
    line-height: 1.02;
  }

  .page-copy,
  .page-summary,
  .document-body,
  .living-document,
  .page-editor__summary,
  .page-editor__body {
    font-size: 0.97rem;
    line-height: 1.75;
  }

  .page-editor__title {
    font-size: clamp(1.8rem, 10vw, 2.6rem);
  }

  .rich-toolbar {
    gap: 0.35rem;
  }

  .rich-toolbar__button {
    padding: 0.4rem 0.65rem;
  }

  .block-head {
    align-items: flex-start;
  }

  .update-item {
    padding: 0.8rem 0;
  }

  .update-item__meta {
    gap: 0.5rem;
    font-size: 0.78rem;
  }

  .editor-field input,
  .editor-field select,
  .editor-field textarea,
  .editor-button,
  .sidebar__brand-link,
  .sidebar-item {
    min-height: 44px;
  }

  .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-footer-band {
    flex-direction: column;
    align-items: flex-start;
  }

  .editor-button,
  .page-link {
    width: 100%;
    text-align: center;
  }

  .selection-comment-composer {
    width: calc(100vw - 24px);
    padding: 0.8rem;
  }

  .selection-comment-composer__actions {
    justify-content: stretch;
  }

  .selection-comment-composer__actions .image-resize-bar__button {
    flex: 1 1 0;
  }
}
