@font-face {
  font-family: "TeX Gyre Heros";
  src: url("/static/assets/fonts/texgyreheros-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Heros";
  src: url("/static/assets/fonts/texgyreheros-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Heros";
  src: url("/static/assets/fonts/texgyreheros-italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Heros";
  src: url("/static/assets/fonts/texgyreheros-bolditalic.otf") format("opentype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --color-primary: #000000;
  --color-primary-active: #111111;
  --color-on-primary: #ffffff;
  --color-canvas: #ffffff;
  --color-canvas-soft: #f7f7f5;
  --color-surface: #ffffff;
  --color-surface-soft: #f4f4f2;
  --color-surface-muted: #e9e9e6;
  --color-surface-elevated: #ffffff;
  --color-ink: #000000;
  --color-ink-secondary: #2c2c2c;
  --color-ink-muted: #666666;
  --color-ink-faint: #9a9a9a;
  --color-hairline: #e2e2df;
  --color-hairline-strong: #cfcfcc;
  --color-code-bg: #0b0b0b;
  --color-code-ink: #f8f8f8;
  --color-code-muted: #a8a8a8;
  --color-selection: rgb(0 0 0 / 8%);
  --color-focus-ring: rgb(0 0 0 / 28%);
  --icon-filter: brightness(0);
  --dark-color-primary: #f4f4f2;
  --dark-color-primary-active: #ffffff;
  --dark-color-on-primary: #0f1115;
  --dark-color-canvas: #101114;
  --dark-color-canvas-soft: #17191d;
  --dark-color-surface: #1d2025;
  --dark-color-surface-soft: #262a30;
  --dark-color-surface-muted: #30343b;
  --dark-color-surface-elevated: #22262b;
  --dark-color-ink: #f4f4f2;
  --dark-color-ink-secondary: #d7d9dc;
  --dark-color-ink-muted: #a2a7ae;
  --dark-color-ink-faint: #707780;
  --dark-color-hairline: #32363d;
  --dark-color-hairline-strong: #464b54;
  --dark-color-code-bg: #050607;
  --dark-color-code-ink: #f8f8f8;
  --dark-color-code-muted: #a8a8a8;
  --dark-color-selection: rgb(255 255 255 / 12%);
  --dark-color-focus-ring: rgb(255 255 255 / 36%);
  --dark-icon-filter: brightness(0) invert(1);
  --font-main: "TeX Gyre Heros", Arial, Helvetica, sans-serif;
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-xxl: 24px;
  --radius-full: 9999px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-xxl: 32px;
  --content-width: 760px;
  font-family: var(--font-main);
  color: var(--color-ink);
  background: var(--color-canvas);
}

:root.dark-mode {
  color-scheme: dark;
  --color-primary: var(--dark-color-primary);
  --color-primary-active: var(--dark-color-primary-active);
  --color-on-primary: var(--dark-color-on-primary);
  --color-canvas: var(--dark-color-canvas);
  --color-canvas-soft: var(--dark-color-canvas-soft);
  --color-surface: var(--dark-color-surface);
  --color-surface-soft: var(--dark-color-surface-soft);
  --color-surface-muted: var(--dark-color-surface-muted);
  --color-surface-elevated: var(--dark-color-surface-elevated);
  --color-ink: var(--dark-color-ink);
  --color-ink-secondary: var(--dark-color-ink-secondary);
  --color-ink-muted: var(--dark-color-ink-muted);
  --color-ink-faint: var(--dark-color-ink-faint);
  --color-hairline: var(--dark-color-hairline);
  --color-hairline-strong: var(--dark-color-hairline-strong);
  --color-code-bg: var(--dark-color-code-bg);
  --color-code-ink: var(--dark-color-code-ink);
  --color-code-muted: var(--dark-color-code-muted);
  --color-selection: var(--dark-color-selection);
  --color-focus-ring: var(--dark-color-focus-ring);
  --icon-filter: var(--dark-icon-filter);
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

::selection {
  background: var(--color-selection);
}

html {
  min-width: 320px;
  background: var(--color-canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-ink);
  background: var(--color-canvas);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.72;
  letter-spacing: 0;
}

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

button {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-full);
  padding: 9px 16px;
  color: var(--color-on-primary);
  background: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

/* button:hover {
  background: var(--color-primary-active);
} */

button:disabled {
  color: var(--color-ink-faint);
  background: var(--color-surface-muted);
  cursor: default;
}

a,
.link-button {
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.44;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

p {
  color: var(--color-ink-muted);
}

label,
legend {
  display: block;
  margin: 0 0 var(--space-sm);
  color: var(--color-ink-secondary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--color-ink);
  background: var(--color-surface);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-hairline-strong);
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 0;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--color-canvas);
}

.workspace {
  height: 100vh;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  border: 0;
  background: var(--color-canvas);
  overflow: hidden;
}

.editor-toolbar,
.editor-layout {
  width: 100%;
}

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 920;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--color-hairline);
  background: color-mix(in srgb, var(--color-canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.editor-toolbar > div:first-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pages-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.brand-block {
  min-width: 0;
}

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

.pages-toggle-button {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  margin: 0;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  padding: 8px 12px;
  color: var(--color-ink);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.pages-toggle-button:hover {
  background: var(--color-surface-soft);
}

.pages-toggle-button img {
  width: 17px;
  height: 17px;
  display: block;
}

.editor-toolbar h1,
.auth-intro h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.editor-toolbar p {
  margin-top: 2px;
  color: var(--color-ink-muted);
  font-size: 11px;
  line-height: 1.45;
}

.user-menu {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  flex-direction: row;
  flex-wrap: nowrap;
  min-width: max-content;
  min-height: 36px;
  padding: 3px 4px;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  background: var(--color-surface);
}

.user-menu[hidden] {
  display: none;
}

.user-menu .language-select {
  margin: 0;
  text-align: right;
}

.user-menu .language-select select {
  text-align: right;
}

.user-menu .language-select,
.user-menu .secondary-button,
.user-menu .pdf-export-button {
  min-height: 28px;
  border: 0;
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.user-menu .language-select:hover,
.user-menu .secondary-button:hover,
.user-menu .pdf-export-button:hover {
  background: var(--color-surface);
}

.user-menu .pdf-export-button,
.user-menu .theme-toggle-button,
.user-menu #logout-button {
  border-left: 1px solid var(--color-hairline);
  border-radius: 0;
}

.user-menu .language-select span,
.user-menu .language-select select,
.user-menu .secondary-button,
.user-menu .pdf-export-button span {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.user-menu .current-user,
.user-menu .billing-summary,
.user-menu .pdf-export-status {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1.35;
}

.user-menu .current-user:empty,
.user-menu .billing-summary:empty,
.user-menu .pdf-export-status:empty {
  display: none;
}

.theme-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.theme-toggle-button span {
  display: none;
}

.theme-toggle-button img {
  width: 14px;
  height: 14px;
  display: block;
}

.toolbar-options {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  position: relative;
}

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  color: var(--color-ink);
  background: var(--color-surface);
}

.icon-button:hover {
  background: var(--color-surface-soft);
}

.icon-button img {
  width: 17px;
  height: 17px;
  display: block;
}

.more-options-button {
  display: grid;
}

.toolbar-options .user-menu {
  display: none;
  position: absolute;
  z-index: 700;
  top: 50%;
  right: calc(100% + var(--space-sm));
  transform: translateY(-50%);
}

.toolbar-options.is-open .user-menu {
  display: flex;
}

img[src^="/static/assets/icons/"],
img[src^="./assets/icons/"],
img[src^="assets/icons/"] {
  filter: var(--icon-filter);
}

.secondary-button,
.pdf-export-button,
.language-select,
.chat-source-add {
  border: 1px solid var(--color-hairline-strong);
  color: var(--color-ink);
  background: #ffffff00;
  
}

.secondary-button:hover,
.pdf-export-button:hover,
.language-select:hover,
.chat-source-add:hover {
  background: #ffffff00;
}

.current-user,
.billing-summary,
.pdf-export-status {
  color: var(--color-ink-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;

}

@media (max-width: 720px) {
  .toolbar-options .user-menu {
    min-width: min(260px, calc(100vw - 32px));
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    padding: var(--space-xs);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: 0 18px 42px rgb(0 0 0 / 10%);
    top: calc(100% + var(--space-sm));
    right: 0;
    transform: none;
  }

  .user-menu .language-select {
    text-align: left;
  }

  .user-menu .language-select select {
    text-align: left;
  }

  .user-menu .language-select,
  .user-menu .secondary-button,
  .user-menu .pdf-export-button {
    width: 100%;
    min-height: 38px;
    border: 0;
    border-radius: var(--radius-md);
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.25;
    text-align: left;
  }

  .user-menu .language-select:hover,
  .user-menu .secondary-button:hover,
  .user-menu .pdf-export-button:hover {
    background: var(--color-surface-soft);
  }

  .user-menu > * + * {
    border-top: 1px solid var(--color-hairline);
  }

  .user-menu .pdf-export-button,
  .user-menu .theme-toggle-button,
  .user-menu #logout-button {
    border-left: 0;
  }

  .user-menu .language-select span,
  .user-menu .language-select select,
  .user-menu .secondary-button,
  .user-menu .pdf-export-button span {
    font-size: 13px;
    line-height: 1.25;
  }

  .user-menu .current-user,
  .user-menu .billing-summary,
  .user-menu .pdf-export-status {
    display: block;
    padding: 8px 10px;
  }

  .theme-toggle-button {
    justify-content: flex-start;
  }

  .theme-toggle-button span {
    display: inline;
  }
}

.billing-summary {
  max-width: 380px;
  overflow-wrap: anywhere;
}

.pdf-export-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.pdf-export-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor-layout {
  flex: 1;
  display: grid;
  grid-template-columns:
    minmax(220px, 260px)
    minmax(0, 1fr)
    minmax(340px, 420px);
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.tree-panel,
.chat-panel {
  min-height: 0;
  background: var(--color-canvas-soft);
}

.tree-panel {
  padding: var(--space-lg) var(--space-md);
  border-right: 1px solid var(--color-hairline);
  overflow-x: hidden;
  overflow-y: auto;
}

.tree-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
  padding: 0 0 0 var(--space-sm);
}

.tree-panel-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tree-panel h2 {
  margin: 0;
  padding: 0;
  color: var(--color-ink);
  font-size: 13px;
  line-height: 1.55;
}

.tree-add-page-button,
.tree-search-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 0;
  background: transparent;
}

.page-search-input {
  display: block;
  width: 100%;
  margin: 0 0 var(--space-md);
  padding: 8px 10px;
  font-size: 13px;
}

.editor-panel {
  min-width: 0;
  min-height: 0;
  padding: 38px clamp(24px, 6vw, 72px) 56px;
  background: var(--color-canvas);
  overflow-y: auto;
}

.editor-panel > label {
  width: min(100%, var(--content-width));
  margin: 0 auto var(--space-sm);
  color: var(--color-ink-faint);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

.title-input {
  display: block;
  width: min(100%, var(--content-width));
  margin: 0 auto;
  border: 0;
  border-bottom: 1px solid var(--color-hairline);
  border-radius: 0;
  padding: 0 0 var(--space-md);
  color: var(--color-ink);
  background: transparent;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
}

.title-input:focus {
  border-color: var(--color-ink);
  outline: 0;
}

#editorjs {
  min-height: 560px;
  margin-top: 22px;
}

.codex-editor {
  color: var(--color-ink);
  font-family: var(--font-main);
}

.ce-header {
  color: var(--color-ink);
  font-family: var(--font-main);
}

.ce-paragraph,
.cdx-block {
  color: var(--color-ink-secondary);
  font-family: var(--font-main);
}

.ce-toolbar__plus,
.ce-toolbar__settings-btn,
.cdx-settings-button {
  border-radius: var(--radius-full) !important;
  color: var(--color-ink-muted) !important;
}

.ce-toolbar__plus:hover,
.ce-toolbar__settings-btn:hover,
.cdx-settings-button:hover {
  background: var(--color-surface-muted) !important;
  color: var(--color-ink) !important;
}

.ce-popover,
.tc-popover,
.ce-inline-toolbar {
  --color-background: var(--color-surface);
  --color-border: var(--color-hairline);
  --color-text-primary: var(--color-ink);
  --color-text-secondary: var(--color-ink-muted);
  --color-background-item-hover: var(--color-surface-soft);
  --color-shadow: rgb(0 0 0 / 10%);
  font-family: var(--font-main);
}

.ce-popover__container,
.tc-popover {
  border: 1px solid var(--color-hairline) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 18px 42px rgb(0 0 0 / 10%) !important;
}

.ce-popover-item:hover,
.tc-popover__item:hover {
  background: var(--color-surface-soft) !important;
}

.cdx-search-field,
.cdx-input {
  border: 1px solid var(--color-hairline) !important;
  border-radius: var(--radius-md) !important;
  background: var(--color-surface-soft) !important;
  box-shadow: none !important;
}

.tc-wrap {
  --color-background: var(--color-canvas-soft);
  --color-text-secondary: var(--color-ink-muted);
  --color-border: var(--color-hairline);
}

.tc-table {
  border-color: var(--color-hairline) !important;
  font-family: var(--font-main);
}

.page-tree,
.tree-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
}

.tree-row {
  width: 100%;
  min-height: 30px;
  display: grid;
  grid-template-columns: 28px 14px minmax(0, 1fr) 28px;
  align-items: center;
  padding-left: calc(var(--depth) * 18px);
  border-radius: var(--radius-md);
  color: var(--color-ink-secondary);
}

.tree-row:hover,
.tree-row:focus-within {
  background: var(--color-surface-soft);
}

.tree-row.active {
  background: var(--color-surface-muted);
  color: var(--color-ink);
}

.tree-row[draggable="true"] {
  cursor: grab;
}

.tree-row.dragging {
  opacity: 0.48;
}

.tree-row.drop-child-target {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
  background: var(--color-surface-muted);
}

.tree-title {
  min-width: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 8px;
  color: inherit;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  overflow: hidden;
}

.tree-title:hover {
  background: transparent;
}

.tree-title span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row.active .tree-title {
  font-weight: 700;
}

.tree-handle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  justify-self: center;
  opacity: 1;
  color: var(--color-ink-muted);
}

.tree-handle img,
.tree-action img {
  width: 15px;
  height: 15px;
  display: block;
  object-fit: contain;
}

.tree-action,
.tree-subpage-action {
  width: 28px;
  height: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  justify-self: center;
  padding: 0;
  border-radius: var(--radius-full);
  color: var(--color-ink-muted);
  background: transparent;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  opacity: 1;
  position: relative;
}

.tree-subpage-action {
  position: absolute;
  top: 30px;
  left: calc(var(--depth) * 18px + 46px);
  z-index: 3;
  background: rgb(255 255 255 / 64%);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
}

.tree-row:hover .tree-action,
.tree-row:hover .tree-handle,
.tree-row:focus-within .tree-action,
.tree-row:focus-within .tree-handle,
.tree-node > .tree-row:hover + .tree-subpage-action,
.tree-node > .tree-row:focus-within + .tree-subpage-action,
.tree-subpage-action:hover,
.tree-subpage-action:focus-visible {
  opacity: 1;
}

.tree-node > .tree-row:hover + .tree-subpage-action,
.tree-node > .tree-row:focus-within + .tree-subpage-action,
.tree-subpage-action:hover,
.tree-subpage-action:focus-visible {
  pointer-events: auto;
}

.tree-action:hover,
.tree-subpage-action:hover {
  color: var(--color-ink);
  background: var(--color-surface-muted);
}

.tree-action.add-sibling,
.tree-action.delete-page {
  width: 28px;
  height: 28px;
  min-height: 28px;
  font-size: 0;
}

.tree-drop-zone {
  height: 5px;
  margin-left: calc(var(--depth) * 18px + 46px);
  border-radius: var(--radius-full);
  background: transparent;
  transition: height 80ms ease, background-color 80ms ease;
}

.page-tree.is-dragging .tree-drop-zone {
  height: 12px;
}

.page-tree.is-searching .tree-drop-zone {
  display: none;
}

.tree-drop-zone.drop-target {
  background: var(--color-ink);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-hairline);
  overflow: hidden;
}

.chat-collapse-button {
  display: none;
}

.chat-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-hairline);
  background: var(--color-canvas-soft);
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
}

.chat-kicker,
.chat-model-label {
  color: var(--color-ink-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

.chat-kicker {
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
}

.chat-model-label {
  margin-top: var(--space-xs);
}

.chat-status,
.chat-action-summary,
.chat-source-count {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  color: var(--color-ink);
  background: var(--color-surface);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.chat-status {
  flex: 0 0 auto;
  padding: 5px 10px;
}

.chat-status::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--color-ink);
}

.chat-log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg);
  overflow-y: auto;
  background: var(--color-canvas);
}

.chat-message {
  width: 100%;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.assistant-message,
.user-message {
  width: fit-content;
  max-width: 88%;
  padding: 11px 14px;
  border: 1px solid var(--color-hairline-strong);
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

.assistant-message {
  align-self: flex-start;
  border-radius: var(--radius-xxl) var(--radius-xxl) var(--radius-xxl) var(--radius-sm);
  background: var(--color-surface);
}

.user-message {
  align-self: flex-end;
  border-radius: var(--radius-xxl) var(--radius-xxl) var(--radius-sm) var(--radius-xxl);
}

.chat-message h3 {
  display: none;
}

.chat-message p {
  margin-bottom: var(--space-md);
  color: var(--color-ink-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.chat-message p:last-child {
  margin-bottom: 0;
}

.chat-message.user-message p {
  color: inherit;
}

p.chat-action-summary::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("/static/assets/icons/text.page.svg") center / contain no-repeat;
  mask: url("/static/assets/icons/text.page.svg") center / contain no-repeat;
}

.thinking-message {
  color: var(--color-ink-muted);
}

.thinking-text {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 0;
  font-weight: 700;
  animation: thinkingColor 1.35s ease-in-out infinite;
}

.thinking-word-count {
  margin-top: var(--space-xs);
  margin-bottom: 0;
  color: var(--color-ink-muted);
  font-size: 11px;
  font-weight: 400;
}

.thinking-dots {
  display: inline-flex;
  gap: var(--space-xs);
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: thinkingDot 1.1s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes thinkingColor {
  0%,
  100% {
    color: var(--color-ink-muted);
  }

  50% {
    color: var(--color-ink);
  }
}

@keyframes thinkingDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-message code,
.otp-setup code {
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  color: var(--color-ink);
  background: var(--color-surface-soft);
  font-family: var(--font-main);
  font-size: 12px;
}

p.chat-action-summary,
.chat-source-toggle {
  min-height: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  color: var(--color-ink);
  background: var(--color-surface);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.assistant-message:has(.chat-action-row) {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  min-width: 0;
}

.assistant-message:has(.chat-action-row) > p:not(.chat-action-summary) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

.chat-action-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 0;
}

.chat-source-details {
  width: 100%;
  min-width: 0;
  margin-top: 6px;
}

.chat-source-toggle {
  list-style: none;
  cursor: pointer;
}

.chat-source-toggle::-webkit-details-marker {
  display: none;
}

.chat-source-toggle:hover,
.chat-source-toggle:focus-visible {
  background: var(--color-surface-soft);
}

.chat-source-toggle svg,
.chat-source-add svg,
.chat-icon-button svg,
.chat-send svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-source-toggle svg {
  width: 12px;
  height: 12px;
}

.chat-source-count {
  min-width: 20px;
  height: 16px;
  justify-content: center;
  padding: 0 5px;
  background: var(--color-surface-muted);
  font-size: 10px;
}

.chat-source-panel {
  width: 100%;
  min-width: 0;
  margin-top: 6px;
}

.chat-source-panel[hidden] {
  display: none;
}

.chat-sources {
  display: grid;
  gap: var(--space-sm);
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--color-ink-muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chat-sources a {
  color: var(--color-ink);
  font-weight: 400;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-source-actions {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  margin-top: 10px;
}

.chat-source-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
}

.chat-source-add svg {
  width: 14px;
  height: 14px;
}

.chat-code-card {
  margin: 14px 0 18px;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-code-bg);
  overflow: hidden;
}

.chat-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 12px 14px;
  border-bottom: 1px solid rgb(255 255 255 / 14%);
  color: var(--color-code-ink);
}

.chat-code-language {
  color: var(--color-code-muted);
  font-size: 12px;
  font-weight: 700;
}

.chat-code-card pre {
  margin: 0;
  padding: var(--space-lg);
  overflow-x: auto;
  color: var(--color-code-ink);
  font-size: 12px;
  line-height: 1.5;
}

.chat-code-card code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.chat-composer {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: end;
  gap: var(--space-sm);
  margin: var(--space-lg);
  padding: var(--space-md) 14px;
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-xxl);
  background: var(--color-surface);
}

.chat-composer:focus-within {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 0;
}

.chat-composer textarea {
  width: 100%;
  min-height: 34px;
  max-height: 150px;
  resize: none;
  border: 0;
  padding: 7px 4px;
  color: var(--color-ink);
  background: transparent;
  line-height: 1.45;
  outline: none;
}

.chat-composer textarea::placeholder {
  color: var(--color-ink-faint);
}

.chat-icon-button,
.chat-send,
.empty-create {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border-radius: var(--radius-full);
}

.chat-icon-button {
  color: var(--color-ink-muted);
  background: transparent;
}

.chat-icon-button:hover,
.chat-icon-button:focus-visible,
.chat-icon-button.is-active,
.chat-icon-button[aria-pressed="true"] {
  color: var(--color-ink);
  background: var(--color-surface-muted);
}

.chat-icon-button svg,
.chat-send svg {
  width: 20px;
  height: 20px;
}

.chat-send {
  color: var(--color-on-primary);
  background: var(--color-primary);
}

.chat-send:hover,
.chat-send:focus-visible {
  background: var(--color-primary-active);
}

.auth-panel {
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-xl);
  background:
    linear-gradient(var(--color-hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-hairline) 1px, transparent 1px),
    var(--color-canvas-soft);
  background-size: 56px 56px;
}

.auth-card {
  width: min(100%, 440px);
  padding: var(--space-xl);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: 0 24px 60px rgb(0 0 0 / 8%);
}

.auth-intro {
  display: grid;
  gap: 10px;
  margin-bottom: var(--space-xl);
}

.auth-intro p,
.auth-switch {
  color: var(--color-ink-muted);
  font-size: 13px;
  line-height: 1.55;
}

.language-select {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  width: fit-content;
  min-height: 36px;
  margin: 0;
  padding: 0 12px;
  border-radius: var(--radius-full);
  color: var(--color-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.language-select span {
  color: var(--color-ink-muted);
}

.language-select select {
  min-height: auto;
  border: 0;
  border-radius: 0;
  padding: 0 18px 0 0;
  color: var(--color-ink);
  background: transparent;
  appearance: none;
  line-height: 1;
  cursor: pointer;
}

.language-select.compact {
  font-size: 12px;
}

.auth-view,
.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-view {
  gap: var(--space-lg);
}

.auth-form {
  gap: 10px;
}

.auth-form h2 {
  margin-bottom: var(--space-xs);
}

.auth-form button {
  margin-top: var(--space-sm);
}

.auth-switch {
  text-align: center;
}

.link-button {
  display: inline;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  color: var(--color-ink);
  background: transparent;
  font: inherit;
  font-weight: 700;
}

.link-button:hover,
.link-button:focus-visible {
  background: transparent;
}

.otp-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-canvas-soft);
  text-align: center;
}

.otp-setup p {
  color: var(--color-ink-secondary);
  font-size: 13px;
  font-weight: 700;
}

.otp-qr {
  width: min(100%, 220px);
  height: auto;
  display: block;
  padding: 10px;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.otp-setup code {
  display: block;
  overflow-wrap: anywhere;
}

.plan-options {
  display: grid;
  gap: var(--space-sm);
  margin: var(--space-xs) 0 0;
  padding: 0;
  border: 0;
}

.plan-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
}

.plan-option:hover {
  background: var(--color-surface-soft);
}

.plan-option input {
  margin-top: 3px;
}

.plan-option span {
  min-width: 0;
}

.plan-option strong,
.plan-option small {
  display: block;
}

.plan-option small {
  margin-top: 2px;
  color: var(--color-ink-muted);
  font-size: 11px;
  line-height: 1.45;
}

.plan-option.is-disabled {
  color: var(--color-ink-faint);
  cursor: not-allowed;
  opacity: 0.66;
}

.alert-overlay,
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 46%);
}

.alert-overlay {
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: var(--space-xl);
}

.alert-dialog,
.tour-popover {
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface-elevated);
  box-shadow: 0 24px 60px rgb(0 0 0 / 18%);
}

.alert-dialog {
  width: min(100%, 420px);
  padding: var(--space-xl);
}

.alert-dialog h2 {
  margin: 0 0 10px;
}

.alert-dialog p {
  margin-bottom: 18px;
  color: var(--color-ink-secondary);
  line-height: 1.55;
}

.alert-dialog button {
  width: 100%;
}

.tour-overlay {
  z-index: 1050;
  pointer-events: none;
}

.tour-highlight {
  position: relative;
  z-index: 1060;
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 6px;
}

.tour-popover {
  position: fixed;
  z-index: 1070;
  width: min(320px, calc(100vw - 32px));
  padding: 18px;
  pointer-events: auto;
}

.tour-arrow {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--color-hairline);
  background: var(--color-surface);
  transform: rotate(45deg);
}

.tour-popover[data-placement="right"] .tour-arrow {
  left: -8px;
  top: var(--tour-arrow-y, 24px);
  border-right: 0;
  border-top: 0;
}

.tour-popover[data-placement="left"] .tour-arrow {
  right: -8px;
  top: var(--tour-arrow-y, 24px);
  border-left: 0;
  border-bottom: 0;
}

.tour-popover[data-placement="bottom"] .tour-arrow {
  left: var(--tour-arrow-x, 24px);
  top: -8px;
  border-right: 0;
  border-bottom: 0;
}

.tour-popover[data-placement="top"] .tour-arrow {
  left: var(--tour-arrow-x, 24px);
  bottom: -8px;
  border-left: 0;
  border-top: 0;
}

.tour-step {
  margin-bottom: var(--space-sm);
  color: var(--color-ink-muted);
  font-size: 11px;
  line-height: 1.45;
  text-transform: uppercase;
}

.tour-popover h2 {
  margin: 0 0 var(--space-sm);
}

.tour-popover p:not(.tour-step) {
  color: var(--color-ink-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 12px);
  transform: translateY(-4px);
  width: max-content;
  max-width: min(180px, calc(100vw - 48px));
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--color-code-ink);
  background: var(--color-code-bg);
  box-shadow: 0 14px 28px rgb(0 0 0 / 18%);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms ease, transform 80ms ease;
}

[data-tooltip]::before {
  content: "";
  position: absolute;
  z-index: 20;
  left: 12px;
  top: calc(100% + 3px);
  transform: none;
  border: 9px solid transparent;
  border-bottom-color: var(--color-code-bg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
  opacity: 1;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  transform: translateY(0);
}

.tree-panel [data-tooltip]::after {
  max-width: calc(20vw - 32px);
  white-space: normal;
}

.tree-panel .delete-page[data-tooltip]::after {
  right: 0;
  left: auto;
}

.tree-panel .delete-page[data-tooltip]::before {
  right: 12px;
  left: auto;
}

.muted {
  color: var(--color-ink-muted);
  font-size: 13px;
  line-height: 1.55;
}

.success-message {
  color: var(--color-ink);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    height: auto;
    overflow: visible;
  }

  .editor-layout {
    grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr);
    overflow: visible;
  }

  .chat-panel {
    grid-column: 1 / -1;
    min-height: 560px;
    border-top: 1px solid var(--color-hairline);
    border-left: 0;
  }
}

@media (max-width: 900px) {
  .shell {
    padding: 0;
  }

  .workspace {
    min-height: auto;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    padding-bottom: 86px;
  }

  .pages-toggle-button {
    display: inline-flex;
    width: 36px;
    min-height: 36px;
    border: 0;
    padding: 0;
    background: transparent;
  }

  .pages-toggle-button span {
    display: none;
  }

  .pages-toggle-button:hover {
    background: transparent;
  }

  .editor-toolbar p {
    margin-left: 44px;
  }

  .tree-panel {
    position: fixed;
    z-index: 850;
    top: 69px;
    left: 0;
    right: auto;
    width: min(82vw, 360px);
    min-width: min(280px, calc(100vw - 32px));
    max-width: calc(100vw - 24px);
    display: none;
    max-height: min(520px, calc(100dvh - 128px));
    border-right: 0;
    border-bottom: 1px solid var(--color-hairline);
    box-shadow: 0 18px 32px rgb(0 0 0 / 10%);
  }

  .pages-toggle:checked ~ .editor-layout .tree-panel {
    display: block;
  }

  .tree-panel [data-tooltip]::after {
    max-width: calc(100vw - 64px);
  }

  .editor-panel {
    min-height: 560px;
    padding: var(--space-xl);
  }

  .chat-panel {
    position: fixed;
    z-index: 900;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 0;
    height: auto;
    border: 0;
    background: transparent;
    pointer-events: none;
  }

  .chat-panel .chat-header,
  .chat-panel .chat-log {
    display: none;
  }

  .chat-panel .chat-composer {
    pointer-events: auto;
  }

  .chat-panel:focus-within {
    top: auto;
    height: 33.333dvh;
    display: flex;
    flex-direction: column;
    padding-top: var(--space-md);
    background: color-mix(in srgb, var(--color-canvas) 94%, transparent);
    pointer-events: auto;
  }

  .chat-panel:focus-within .chat-collapse-button {
    width: 44px;
    height: 28px;
    min-height: 28px;
    display: grid;
    place-items: center;
    align-self: center;
    margin: 0 0 var(--space-sm);
    padding: 0;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-full);
    color: var(--color-ink);
    background: var(--color-surface);
    box-shadow: 0 8px 20px rgb(0 0 0 / 12%);
  }

  .chat-panel:focus-within .chat-collapse-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.3;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .chat-panel.is-expanded {
    top: 0;
    height: 100dvh;
  }

  .chat-panel:focus-within .chat-header {
    display: flex;
    margin: 0 var(--space-md);
    border: 1px solid var(--color-hairline);
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .chat-panel:focus-within .chat-log {
    flex: 1;
    min-height: 0;
    display: flex;
    margin: 0 var(--space-md);
    border: 1px solid var(--color-hairline);
    border-top: 0;
    overflow-y: auto;
  }

  .chat-panel:focus-within .chat-composer {
    flex: 0 0 auto;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 0;
  }

  .workspace {
    border-width: 0;
  }

  .auth-panel {
    min-height: 100vh;
    padding: var(--space-lg);
  }

  .auth-card {
    padding: var(--space-lg);
  }

  .editor-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .brand-row {
    justify-content: flex-start;
  }

  .user-menu {
    align-items: stretch;
    flex-direction: column;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .user-menu .pdf-export-button,
  .user-menu .theme-toggle-button,
  .user-menu #logout-button {
    border-top: 1px solid var(--color-hairline);
    border-left: 0;
  }

  .toolbar-options {
    align-items: flex-start;
    flex-direction: row;
    justify-self: end;
  }

  .user-menu button,
  .user-menu label,
  .language-select select {
    width: 100%;
  }

  .title-input {
    font-size: 22px;
  }

  .chat-composer {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    margin: var(--space-md);
  }

  .chat-composer .chat-icon-button:not(.composer-add) {
    display: none;
  }
}
