/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  color-scheme: light;
  --topbar-height: 62px;
  --left-panel-width: 282px;
  --right-panel-width: 326px;
  --workbar-height: 47px;
  --statusbar-height: 38px;

  --font-ui: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --font-reading: "Iowan Old Style", "Songti SC", "STSong", "Noto Serif CJK SC",
    Georgia, serif;
  --font-hand: "KaiTi", "STKaiti", "Kaiti SC", "FangSong", cursive;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;

  --bg-shell: #f3f1eb;
  --bg-sidebar: #f8f6f1;
  --bg-sidebar-strong: #f1eee7;
  --bg-workspace: #e8e5dd;
  --bg-elevated: #fffdf8;
  --bg-input: #fffdfa;
  --bg-subtle: #efede7;
  --bg-hover: rgba(75, 63, 49, 0.065);
  --bg-active: #f2e5d7;
  --bg-scrim: rgba(31, 27, 23, 0.34);

  --text-strong: #2c2925;
  --text-primary: #4a463f;
  --text-muted: #7d776d;
  --text-faint: #a29b90;
  --text-on-accent: #fffaf4;

  --border: #ded9cf;
  --border-strong: #cbc4b8;
  --border-soft: rgba(63, 55, 45, 0.09);
  --accent: #b76a2c;
  --accent-hover: #9d5620;
  --accent-pressed: #854718;
  --accent-soft: #f3e4d4;
  --accent-border: #d7b18b;
  --success: #2f7d5e;
  --success-soft: #e3f1e9;
  --danger: #b44a3f;
  --danger-soft: #f8e7e4;
  --blue: #3d6f9d;
  --grid-line: rgba(71, 63, 52, 0.115);

  --shadow-sm: 0 1px 1px rgba(45, 38, 30, 0.04), 0 4px 12px rgba(45, 38, 30, 0.035);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.56) inset, 0 10px 30px rgba(57, 47, 35, 0.04);
  --shadow-popover: 0 18px 50px rgba(38, 31, 23, 0.17), 0 2px 8px rgba(38, 31, 23, 0.08);
  --shadow-paper: 0 2px 4px rgba(42, 35, 26, 0.09), 0 24px 70px rgba(42, 35, 26, 0.18),
    0 60px 120px rgba(42, 35, 26, 0.08);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 11px;
  --radius-lg: 15px;
  --radius-xl: 20px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-color-scheme="dark"] {
  color-scheme: dark;
  --bg-shell: #161715;
  --bg-sidebar: #1c1d1a;
  --bg-sidebar-strong: #22231f;
  --bg-workspace: #101210;
  --bg-elevated: #24251f;
  --bg-input: #252620;
  --bg-subtle: #292a24;
  --bg-hover: rgba(255, 244, 225, 0.06);
  --bg-active: rgba(209, 138, 76, 0.14);
  --bg-scrim: rgba(0, 0, 0, 0.56);

  --text-strong: #f2eee5;
  --text-primary: #d5d0c6;
  --text-muted: #9e988d;
  --text-faint: #716c63;
  --text-on-accent: #fff9f0;

  --border: #34352f;
  --border-strong: #46473f;
  --border-soft: rgba(255, 246, 231, 0.07);
  --accent: #d08a4b;
  --accent-hover: #df9a5c;
  --accent-pressed: #b97438;
  --accent-soft: rgba(208, 138, 75, 0.13);
  --accent-border: rgba(208, 138, 75, 0.42);
  --success: #70b896;
  --success-soft: rgba(76, 155, 117, 0.14);
  --danger: #e17b70;
  --danger-soft: rgba(188, 82, 69, 0.14);
  --blue: #8fb9df;
  --grid-line: rgba(240, 231, 215, 0.07);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.22);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.028) inset;
  --shadow-popover: 0 20px 55px rgba(0, 0, 0, 0.46), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-paper: 0 2px 4px rgba(0, 0, 0, 0.32), 0 28px 80px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  height: 100%;
  background: var(--bg-shell);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  width: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg-shell);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
}

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

button,
summary,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
}

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

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

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white 10%);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--small {
  width: 13px;
  height: 13px;
  stroke-width: 1.9;
}

/* Scrollbars */

* {
  scrollbar-color: color-mix(in srgb, var(--text-faint) 52%, transparent) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-faint) 48%, transparent);
  background-clip: padding-box;
}

/* ==========================================================================
   Shared controls
   ========================================================================== */

.button {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

.button:hover {
  background: var(--bg-hover);
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  border-color: color-mix(in srgb, var(--accent-pressed) 32%, transparent);
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.button--primary:hover {
  background: var(--accent-hover);
}

.button--soft {
  border-color: var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.button--soft:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.button--ghost {
  border-color: transparent;
  color: var(--text-primary);
}

.button--full {
  width: 100%;
}

.button.is-disabled,
.button:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background-color 150ms ease,
    opacity 150ms ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-strong);
}

.icon-button:disabled {
  opacity: 0.32;
}

.icon-button--tiny {
  width: 27px;
  height: 27px;
  border-radius: var(--radius-xs);
}

.icon-button--tiny .icon {
  width: 15px;
  height: 15px;
}

.icon-button--square {
  width: 36px;
  height: 36px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.text-button {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.text-button:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.theme-icon--sun {
  display: none;
}

html[data-color-scheme="dark"] .theme-icon--moon {
  display: none;
}

html[data-color-scheme="dark"] .theme-icon--sun {
  display: block;
}

/* ==========================================================================
   Top bar
   ========================================================================== */

.app {
  height: 100%;
  min-height: 0;
}

.topbar {
  position: relative;
  z-index: 70;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 16px 0 19px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-sidebar) 94%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.36) inset;
  backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
}

.topbar-left {
  gap: 11px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  overflow: visible;
}

.brand-sheet,
.brand-fold {
  fill: none;
  stroke: var(--text-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.25;
}

.brand-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-width: 2.1;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  color: var(--text-strong);
  font-family: var(--font-reading);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.brand-copy span {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.1;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 5px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--success-soft) 62%, transparent);
  color: color-mix(in srgb, var(--success) 88%, var(--text-primary));
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent);
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 1px;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--border);
}

.open-file-button {
  min-height: 34px;
}

.mobile-panel-toggle,
.mobile-close {
  display: none;
}

/* Export popover */

.export-menu {
  position: relative;
}

.export-menu > summary {
  list-style: none;
  cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

.export-menu[open] > summary {
  background: var(--accent-hover);
}

.menu-popover {
  position: absolute;
  z-index: 100;
  top: calc(100% + 9px);
  right: 0;
  width: 228px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-popover);
  animation: popover-in 150ms var(--ease-out);
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.menu-popover button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  text-align: left;
}

.menu-popover button:hover {
  background: var(--bg-hover);
  color: var(--text-strong);
}

.menu-popover button span {
  font-size: 12px;
  font-weight: 580;
}

.menu-popover button small {
  color: var(--text-faint);
  font-size: 9.5px;
  white-space: nowrap;
}

.menu-divider {
  display: block;
  height: 1px;
  margin: 5px 5px;
  background: var(--border-soft);
}

/* ==========================================================================
   Main layout and sidebars
   ========================================================================== */

.main-layout {
  display: grid;
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  grid-template-columns: var(--left-panel-width) minmax(320px, 1fr) var(--right-panel-width);
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--bg-sidebar);
}

.sidebar--left {
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.38) inset;
}

.sidebar--right {
  border-left: 1px solid var(--border);
  box-shadow: -1px 0 0 rgba(255, 255, 255, 0.28) inset;
}

html[data-color-scheme="dark"] .sidebar--left {
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.018) inset;
}

html[data-color-scheme="dark"] .sidebar--right {
  box-shadow: -1px 0 0 rgba(255, 255, 255, 0.018) inset;
}

.sidebar-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 19px 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-header--compact {
  padding-bottom: 13px;
}

.sidebar-header h1,
.sidebar-header h2 {
  color: var(--text-strong);
  font-family: var(--font-reading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.025em;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.15em;
  line-height: 1;
}

.sidebar-content {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-content--left {
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 14px 14px 22px;
}

.sidebar-content--right {
  padding-bottom: 28px;
}

/* ==========================================================================
   Left panel: upload, lists, layers
   ========================================================================== */

.upload-zone {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent-soft) 55%, transparent), transparent 62%),
    color-mix(in srgb, var(--bg-elevated) 52%, transparent);
  color: var(--text-muted);
  text-align: center;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--accent);
  background-color: var(--bg-active);
  transform: translateY(-1px);
}

.upload-zone strong {
  margin-top: 6px;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.upload-zone > span:not(.upload-icon):not(.upload-link) {
  color: var(--text-faint);
  font-size: 10px;
}

.upload-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.upload-icon .icon {
  width: 18px;
  height: 18px;
}

.upload-link {
  margin-top: 5px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  text-underline-offset: 3px;
}

.quick-actions {
  display: grid;
  gap: 6px;
}

.quick-actions .button {
  min-height: 34px;
  justify-content: flex-start;
  padding-inline: 11px;
  font-size: 11.5px;
}

.quick-actions .icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.panel-section {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.panel-section + .panel-section {
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.panel-section--layers {
  flex: 1 0 auto;
}

.section-heading {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 3px;
}

.section-heading h2 {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 680;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.count-badge {
  display: inline-grid;
  min-width: 20px;
  height: 18px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
}

.list-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.list-placeholder {
  padding: 12px 4px;
  color: var(--text-faint);
  font-size: 10.5px;
  text-align: center;
}

.document-item,
.frame-item {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.document-item {
  grid-template-columns: 29px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px 8px;
}

.document-item:hover,
.frame-item:hover {
  background: var(--bg-hover);
}

.document-item.is-active,
.frame-item.is-active {
  border-color: color-mix(in srgb, var(--accent-border) 66%, transparent);
  background: var(--bg-active);
}

.document-item.is-active::before,
.frame-item.is-active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -1px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  content: "";
}

.document-icon,
.frame-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--bg-elevated) 74%, transparent);
  color: var(--text-muted);
}

.document-icon .icon,
.frame-icon .icon {
  width: 14px;
  height: 14px;
}

.document-item.is-active .document-icon,
.frame-item.is-active .frame-icon {
  border-color: var(--accent-border);
  color: var(--accent);
}

.document-copy,
.frame-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.document-copy strong,
.frame-copy strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 580;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-copy span,
.frame-copy span {
  overflow: hidden;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-state {
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.document-state.is-queued {
  background: var(--bg-subtle);
  color: var(--text-faint);
}

.frame-item {
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 7px 8px;
}

.frame-sheet {
  padding: 2px 5px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.layer-list {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.layer-item {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: 18px 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 6px 5px;
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  text-align: left;
  transition:
    background-color 130ms ease,
    opacity 130ms ease;
}

.layer-item:hover {
  background: var(--bg-hover);
}

.layer-item.is-hidden {
  opacity: 0.48;
}

.layer-eye {
  display: grid;
  place-items: center;
  color: var(--text-faint);
}

.layer-eye .icon {
  width: 14px;
  height: 14px;
}

.layer-swatch {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: var(--layer-color, var(--text-muted));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--layer-color, currentColor) 13%, transparent);
}

.layer-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0;
}

.layer-name {
  overflow: hidden;
  font-size: 10.5px;
  font-weight: 540;
  line-height: 1.32;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-copy small {
  overflow: hidden;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-count {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8px;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: auto;
  padding: 12px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
  color: var(--text-faint);
}

.privacy-note .icon {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  color: var(--success);
}

.privacy-note p {
  font-size: 9px;
  line-height: 1.55;
}

.privacy-note strong {
  display: block;
  margin-bottom: 1px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 650;
}

/* ==========================================================================
   Workspace
   ========================================================================== */

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: var(--workbar-height) minmax(0, 1fr) var(--statusbar-height);
  overflow: hidden;
  background: var(--bg-workspace);
}

.workspace-topbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-sidebar) 86%, var(--bg-workspace));
}

.breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.breadcrumb-document {
  overflow: hidden;
  max-width: 230px;
  color: var(--text-primary);
  font-weight: 600;
  text-overflow: ellipsis;
}

.breadcrumb-separator {
  color: var(--border-strong);
}

.breadcrumb-frame {
  overflow: hidden;
  max-width: 170px;
  color: var(--text-faint);
  text-overflow: ellipsis;
}

.page-navigator,
.zoom-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 1px;
}

.page-navigator {
  padding: 1px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-elevated) 48%, transparent);
}

.page-navigator > span {
  min-width: 48px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: center;
}

.zoom-controls {
  padding: 1px 2px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-elevated) 48%, transparent);
}

.zoom-readout {
  width: 47px;
  height: 27px;
  border-radius: 5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 560;
  text-align: center;
}

.zoom-readout:hover {
  background: var(--bg-hover);
  color: var(--text-strong);
}

.viewport {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  outline: none;
  background-color: var(--bg-workspace);
  background-image:
    radial-gradient(circle at 50% 44%, color-mix(in srgb, white 38%, transparent), transparent 48%),
    radial-gradient(circle at 1px 1px, var(--grid-line) 1px, transparent 0);
  background-position: center, 0 0;
  background-size: auto, 22px 22px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

html[data-color-scheme="dark"] .viewport {
  background-image:
    radial-gradient(circle at 50% 44%, color-mix(in srgb, white 2%, transparent), transparent 48%),
    radial-gradient(circle at 1px 1px, var(--grid-line) 1px, transparent 0);
}

.viewport::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 100px rgba(53, 44, 32, 0.045);
  content: "";
  pointer-events: none;
}

.viewport.is-panning {
  cursor: grabbing;
}

.viewport.is-placement,
.viewport.is-box-selecting {
  cursor: crosshair;
}

.paper-stage {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 28px 36px;
  transform-origin: 50% 50%;
  will-change: transform;
  pointer-events: none;
}

.paper {
  --paper-ratio: 1.46341;
  position: relative;
  display: block;
  width: min(1120px, calc(100% - 12px), calc((100dvh - 196px) * var(--paper-ratio)));
  aspect-ratio: var(--paper-ratio);
  overflow: hidden;
  border-radius: 1px;
  background: #fbfaf6;
  outline: 1px solid rgba(64, 54, 42, 0.08);
  outline-offset: -1px;
  pointer-events: auto;
  transition:
    box-shadow 240ms ease,
    transform 320ms var(--ease-out);
  transform-style: preserve-3d;
}

.paper.has-shadow {
  box-shadow: var(--shadow-paper);
}

.paper--blueprint {
  background: #173b5a;
  outline-color: rgba(255, 255, 255, 0.07);
}

.paper--kraft {
  background: #d0b486;
  outline-color: rgba(78, 57, 36, 0.12);
}

.paper--grid {
  background: #fbfaf4;
}

.paper svg {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.paper-text,
.paper svg text {
  font-family: var(--font-hand);
}

.canvas-hint {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-sidebar) 78%, transparent);
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.canvas-hint span + span::before {
  margin-right: 10px;
  color: var(--border-strong);
  content: "·";
}

.empty-state {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  display: flex;
  width: min(440px, calc(100% - 40px));
  align-items: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.empty-mark {
  display: grid;
  width: 112px;
  height: 84px;
  place-items: center;
  margin-bottom: 4px;
  color: var(--text-faint);
}

.empty-mark svg {
  width: 104px;
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 0.9;
  opacity: 0.68;
}

.empty-state h2 {
  color: var(--text-strong);
  font-family: var(--font-reading);
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: 0.015em;
}

.empty-state p {
  max-width: 390px;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
}

.busy-overlay {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: flex;
  width: 230px;
  align-items: center;
  flex-direction: column;
  gap: 7px;
  padding: 23px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  box-shadow: var(--shadow-popover);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(14px);
}

.busy-overlay strong {
  color: var(--text-strong);
  font-size: 12px;
}

.busy-overlay > span:last-child {
  color: var(--text-faint);
  font-size: 9.5px;
}

.spinner {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.workspace-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-sidebar) 83%, var(--bg-workspace));
  color: var(--text-faint);
  font-size: 9px;
}

.document-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.document-stats span {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
}

.document-stats b {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
}

.phase-badge {
  overflow: hidden;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 19%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 88%, var(--text-primary));
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-security {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ==========================================================================
   Right controls
   ========================================================================== */

.control-group {
  border-bottom: 1px solid var(--border-soft);
}

.control-group summary {
  display: flex;
  min-height: 47px;
  align-items: center;
  gap: 9px;
  padding: 0 17px;
  color: var(--text-strong);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.control-group summary::-webkit-details-marker {
  display: none;
}

.control-group summary > span:first-child {
  font-size: 11.5px;
  font-weight: 670;
  letter-spacing: 0.02em;
}

.summary-value {
  overflow: hidden;
  margin-left: auto;
  color: var(--text-faint);
  font-size: 8.5px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-group summary::after {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  margin-left: 1px;
  border-right: 1.4px solid var(--text-faint);
  border-bottom: 1.4px solid var(--text-faint);
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.control-group[open] summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.control-group summary:hover {
  background: var(--bg-hover);
}

.control-body {
  display: grid;
  gap: 15px;
  padding: 2px 17px 19px;
}

.control-field,
.select-field,
.range-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.control-label,
.select-field > span {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 570;
  letter-spacing: 0.015em;
}

.control-label output {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 450;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.select-field select {
  width: 100%;
  height: 35px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  background-color: var(--bg-input);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 15px,
    calc(100% - 9px) 15px;
  background-repeat: no-repeat;
  background-size: 4px 4px, 4px 4px;
  color: var(--text-primary);
  font-size: 10.5px;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.select-field select:hover {
  border-color: var(--border-strong);
}

.select-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Theme selector */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.theme-option {
  display: flex;
  min-height: 45px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 540;
  text-align: left;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}

.theme-option:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.theme-option.is-active {
  border-color: var(--accent-border);
  background: var(--bg-active);
  color: var(--text-strong);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent) inset;
}

.theme-swatch {
  position: relative;
  width: 31px;
  height: 25px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(64, 54, 42, 0.14);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(54, 44, 32, 0.08);
}

.theme-swatch::after {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  height: 1px;
  background: currentColor;
  box-shadow: 0 3px 0 color-mix(in srgb, currentColor 62%, transparent);
  content: "";
  opacity: 0.74;
  transform: rotate(-4deg);
}

.theme-swatch--white {
  background: #fbfaf6;
  color: #4e4942;
}

.theme-swatch--blueprint {
  background: #173b5a;
  color: #e4f1fa;
}

.theme-swatch--kraft {
  background: #d0b486;
  color: #4e3c2b;
}

.theme-swatch--grid {
  background-color: #fbfaf4;
  background-image:
    linear-gradient(rgba(86, 124, 131, 0.17) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 124, 131, 0.17) 1px, transparent 1px);
  background-size: 6px 6px;
  color: #35464a;
}

/* Range */

.range-field output {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 450;
}

input[type="range"] {
  width: 100%;
  height: 17px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--accent) 46%, var(--border)) 0%,
    var(--border) 100%
  );
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  appearance: none;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(55, 39, 23, 0.24);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(55, 39, 23, 0.24);
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb {
  transform: scale(1.13);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

input[type="range"]:focus-visible {
  outline: none;
}

/* Switch */

.switch-field {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.switch-field > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.switch-field strong {
  color: var(--text-primary);
  font-size: 10.5px;
  font-weight: 570;
  line-height: 1.4;
}

.switch-field small {
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.4;
}

.switch-control {
  position: relative;
  display: inline-flex;
  width: 32px;
  height: 19px;
  flex: 0 0 auto;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-subtle);
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 1px 2px rgba(44, 35, 25, 0.2);
  content: "";
  transition:
    transform 170ms var(--ease-out),
    background-color 150ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--border));
  background: color-mix(in srgb, var(--accent) 76%, var(--bg-elevated));
}

.switch-control input:checked + .switch-track::after {
  background: var(--text-on-accent);
  transform: translateX(13px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 2px solid color-mix(in srgb, var(--accent) 54%, transparent);
  outline-offset: 2px;
}

/* Seed input */

.seed-field {
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-subtle) 52%, transparent);
}

.seed-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.seed-input-row input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  outline: none;
}

.seed-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.seed-field small {
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.55;
}

/* 字体载入状态与手写批注 */

.font-loader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-subtle) 52%, transparent);
}

.font-loader-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.font-loader-copy strong {
  color: var(--text-primary);
  font-size: 10.5px;
  font-weight: 620;
}

.font-loader-copy span {
  overflow: hidden;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-loader .button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 9.5px;
}

.annotation-field {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 570;
}

.annotation-field textarea {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-hand);
  font-size: 12px;
  line-height: 1.55;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.annotation-field textarea::placeholder {
  color: var(--text-faint);
  font-family: var(--font-ui);
  font-size: 9.5px;
}

.annotation-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.future-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-subtle) 48%, transparent);
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.6;
}

.future-note .icon {
  width: 13px;
  height: 13px;
  margin-top: 1px;
  color: var(--accent);
}

.is-disabled {
  opacity: 0.48;
}

.control-field.is-disabled,
.range-field.is-disabled {
  pointer-events: none;
}

.annotation-colors {
  display: flex;
  gap: 6px;
}

.color-chip {
  height: 30px;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  font-size: 9px;
}

.color-chip--red {
  color: #b6463d;
}

.color-chip--blue {
  color: #3d6f9d;
}

.color-chip--green {
  color: #2f7d5e;
}

.color-chip.is-active {
  border-color: currentColor;
  background: color-mix(in srgb, currentColor 8%, var(--bg-input));
}

.sidebar-footer {
  display: grid;
  gap: 9px;
  padding: 18px 17px 8px;
}

.sidebar-footer p {
  color: var(--text-faint);
  font-size: 8px;
  line-height: 1.6;
  text-align: center;
}

/* ==========================================================================
   Overlays and notifications
   ========================================================================== */

.panel-scrim {
  position: fixed;
  z-index: 45;
  inset: var(--topbar-height) 0 0;
  display: none;
  background: var(--bg-scrim);
  backdrop-filter: blur(2px);
}

.drop-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: color-mix(in srgb, var(--bg-scrim) 72%, transparent);
  backdrop-filter: blur(9px);
  animation: overlay-in 140ms ease;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.drop-overlay-card {
  display: flex;
  width: min(430px, 100%);
  align-items: center;
  flex-direction: column;
  gap: 8px;
  padding: 40px 30px;
  border: 1.5px dashed var(--accent-border);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  box-shadow: var(--shadow-popover);
  color: var(--text-muted);
  text-align: center;
}

.drop-overlay-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 4px;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.drop-overlay-icon .icon {
  width: 23px;
  height: 23px;
}

.drop-overlay-card strong {
  color: var(--text-strong);
  font-family: var(--font-reading);
  font-size: 20px;
  letter-spacing: 0.02em;
}

.drop-overlay-card > span:last-child {
  font-size: 10px;
}

.toast-region {
  position: fixed;
  z-index: 300;
  bottom: 23px;
  left: 50%;
  display: flex;
  width: min(480px, calc(100vw - 32px));
  align-items: center;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  max-width: 100%;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 13px 9px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-elevated) 95%, transparent);
  box-shadow: var(--shadow-popover);
  color: var(--text-primary);
  font-size: 10.5px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 220ms var(--ease-out);
  backdrop-filter: blur(12px);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-mark {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

.toast--success .toast-mark {
  background: var(--success-soft);
  color: var(--success);
}

.toast--error .toast-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   Responsive layout
   ========================================================================== */

@media (max-width: 1280px) {
  :root {
    --left-panel-width: 258px;
    --right-panel-width: 306px;
  }

  .breadcrumb-frame,
  .breadcrumb-separator {
    display: none;
  }

  .canvas-hint {
    display: none;
  }
}

@media (max-width: 1080px) {
  :root {
    --left-panel-width: 250px;
    --right-panel-width: 296px;
  }

  .main-layout {
    grid-template-columns: var(--left-panel-width) minmax(300px, 1fr) var(--right-panel-width);
  }

  .button-label {
    display: none;
  }

  .open-file-button,
  .export-menu > summary {
    width: 36px;
    padding-inline: 0;
  }

  .export-menu > summary .icon--small {
    display: none;
  }
}

@media (max-width: 940px) {
  .mobile-panel-toggle,
  .mobile-close {
    display: inline-grid;
  }

  .main-layout {
    display: block;
    position: relative;
  }

  .panel-scrim {
    display: block;
  }

  .workspace {
    width: 100%;
    height: 100%;
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    top: var(--topbar-height);
    bottom: 0;
    width: min(354px, calc(100vw - 48px));
    box-shadow: var(--shadow-popover);
    transition: transform 260ms var(--ease-out);
  }

  .sidebar--left {
    left: 0;
    transform: translateX(-103%);
  }

  .sidebar--right {
    right: 0;
    transform: translateX(103%);
  }

  body.left-panel-open .sidebar--left,
  body.right-panel-open .sidebar--right {
    transform: translateX(0);
  }

  .local-badge {
    display: none;
  }

  .paper {
    width: min(1120px, calc(100% - 6px), calc((100dvh - 190px) * var(--paper-ratio)));
  }

  .topbar {
    padding-inline: 12px;
  }

  .topbar-left,
  .topbar-actions {
    gap: 3px;
  }

  .topbar-divider {
    margin-inline: 2px;
  }
}

@media (max-width: 680px) {
  :root {
    --topbar-height: 56px;
    --workbar-height: 43px;
    --statusbar-height: 34px;
  }

  .brand-copy span {
    display: none;
  }

  .brand-copy strong {
    font-size: 14.5px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .brand-mark svg {
    width: 26px;
    height: 26px;
  }

  .history-controls,
  .topbar-divider {
    display: none;
  }

  .topbar-actions {
    gap: 1px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .workspace-topbar {
    padding-inline: 9px;
  }

  .breadcrumb-document {
    max-width: 132px;
    font-size: 9px;
  }

  .page-navigator > span {
    min-width: 42px;
  }

  .paper-stage {
    padding: 15px 12px;
  }

  .paper {
    width: min(100%, calc((100dvh - 170px) * var(--paper-ratio)));
  }

  .document-stats span:nth-child(2),
  .document-stats span:nth-child(3) {
    display: none;
  }

  .workspace-footer {
    padding-inline: 9px;
  }

  .phase-badge {
    display: none;
  }

  .sidebar {
    width: min(348px, calc(100vw - 26px));
  }

  .toast-region {
    bottom: 12px;
  }
}

@media (max-width: 470px) {
  .topbar {
    gap: 5px;
  }

  .brand {
    gap: 7px;
  }

  .brand-copy strong {
    font-size: 13px;
    letter-spacing: 0.01em;
  }

  .open-file-button,
  .export-menu > summary {
    width: 32px;
  }

  .workspace-topbar {
    gap: 6px;
  }

  .breadcrumb {
    display: none;
  }

  .page-navigator {
    margin-right: auto;
  }

  .zoom-controls {
    margin-left: auto;
  }

  .zoom-readout {
    width: 41px;
  }

  .paper-stage {
    padding: 9px 7px;
  }

  .paper {
    width: min(100%, calc((100dvh - 148px) * var(--paper-ratio)));
  }

  .document-stats {
    gap: 7px;
  }

  .footer-security {
    font-size: 8px;
  }

  .empty-state h2 {
    font-size: 23px;
  }
}

@media (max-height: 620px) {
  .paper-stage {
    padding-block: 12px;
  }

  .paper {
    width: min(100%, calc((100dvh - 156px) * var(--paper-ratio)));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Print
   ========================================================================== */

@page {
  size: auto;
  margin: 0;
}

@media print {
  html,
  body {
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: white;
  }

  .topbar,
  .sidebar,
  .workspace-topbar,
  .workspace-footer,
  .canvas-hint,
  .empty-state,
  .toast-region,
  .panel-scrim,
  .drop-overlay,
  .busy-overlay {
    display: none !important;
  }

  .main-layout,
  .workspace,
  .viewport {
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: white;
  }

  .viewport::after {
    display: none;
  }

  .paper-stage {
    display: block;
    width: 100%;
    height: auto;
    padding: 0;
    transform: none !important;
  }

  .paper {
    width: 100% !important;
    max-width: none;
    height: auto;
    aspect-ratio: auto;
    border-radius: 0;
    outline: none;
    box-shadow: none !important;
    transform: none !important;
  }

  .paper svg {
    width: 100%;
    height: auto;
  }
}
