:root {
  color-scheme: light;
  --page-bg: #f6f8fb;
  --ink: #0f172a;
  --ink-soft: #475467;
  --ink-faint: #667085;
  --accent: #0071e3;
  --accent-strong: #0058b0;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(0, 113, 227, 0.32);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.78);
  --surface-muted: rgba(248, 250, 252, 0.92);
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --shadow-panel: 0 28px 80px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-hover: 0 16px 36px rgba(15, 23, 42, 0.13);
  --radius-panel: 28px;
  --radius-card: 22px;
  --radius-control: 15px;
  --sans: "SF Pro Display", "SF Pro Text", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(145deg, #fbfdff 0%, #eef3f8 48%, #f8fafc 100%);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: radial-gradient(rgba(148, 163, 184, 0.22) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

.notes-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
}

.app-shell,
.dialog,
.select-menu,
.toast {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(165deg, var(--surface), var(--surface-soft));
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  color: #0b1220;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.06;
  font-weight: 760;
}

h2 {
  margin-bottom: 5px;
  font-size: 21px;
  line-height: 1.22;
  font-weight: 740;
}

h3 {
  margin-bottom: 0;
  font-size: 21px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-width: 0;
  border-radius: 0;
  box-shadow: none;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 54px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.62);
}

.app-shell.sidebar-collapsed .sidebar {
  overflow: visible;
}

.sidebar-head,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.sidebar-head {
  padding: 12px 12px 10px;
}

.sidebar-head h1 {
  margin: 0;
  font-size: 20px;
}

.sidebar-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-toggle-svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 0.18s ease;
}

.app-shell.sidebar-collapsed .sidebar-head {
  display: block;
  min-height: 52px;
  padding: 0;
}

.app-shell.sidebar-collapsed .sidebar-head-actions {
  display: block;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  left: 9px;
  top: 10px;
  z-index: 60;
  background: linear-gradient(135deg, var(--accent), #3e9aff);
  color: #fff;
  box-shadow: 0 12px 22px rgba(0, 113, 227, 0.28);
}

.app-shell.sidebar-collapsed .sidebar-toggle:hover {
  box-shadow: 0 16px 28px rgba(0, 113, 227, 0.34);
}

.app-shell.sidebar-collapsed .sidebar-toggle-svg {
  transform: rotate(180deg);
}

.app-shell.sidebar-collapsed .sidebar-title,
.app-shell.sidebar-collapsed .sidebar-actions,
.app-shell.sidebar-collapsed .search-box,
.app-shell.sidebar-collapsed .tree,
.app-shell.sidebar-collapsed #refreshButton {
  display: none;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.tree-action,
.select-trigger,
.segmented button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.select-trigger:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #3e9aff);
  color: #fff;
  box-shadow: 0 14px 28px rgba(0, 113, 227, 0.28);
}

.primary-button:hover:not(:disabled) {
  box-shadow: 0 18px 30px rgba(0, 113, 227, 0.34);
}

.secondary-button,
.icon-button,
.select-trigger {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.select-trigger:hover {
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
}

.danger-button {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 12px 24px rgba(220, 38, 38, 0.27);
}

.danger-button:hover:not(:disabled) {
  box-shadow: 0 16px 30px rgba(220, 38, 38, 0.32);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
  transform: none;
  box-shadow: none;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 12px 10px;
  padding: 0 13px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-faint);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.search-box:focus-within {
  border-color: rgba(0, 113, 227, 0.62);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.13);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.tree {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0 10px 12px;
}

.folder {
  margin-bottom: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.folder-row,
.file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  border-radius: 16px;
  color: var(--ink);
}

.folder-row {
  min-height: 44px;
  padding: 6px 7px 6px 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(239, 246, 255, 0.72));
}

.file-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  max-width: calc(100% - 12px);
  margin: 4px 6px;
  padding: 5px 7px 5px 20px;
  background: transparent;
  text-align: left;
}

.folder-row:hover,
.file-row:hover,
.file-row.active {
  background: rgba(0, 113, 227, 0.09);
}

.file-row.active {
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.18);
}

.folder-toggle {
  position: relative;
  display: inline-flex;
  width: 26px;
  min-width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: #64748b;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.folder-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.18s ease;
}

.folder-toggle:hover {
  border-color: rgba(0, 113, 227, 0.28);
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.folder-name,
.file-name {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-name {
  font-weight: 850;
}

.folder-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.folder-icon {
  position: relative;
  width: 22px;
  height: 17px;
  flex: 0 0 22px;
  border-radius: 5px;
  background: linear-gradient(135deg, #62a8ff, #2f8cff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 6px 14px rgba(0, 113, 227, 0.18);
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -4px;
  width: 10px;
  height: 6px;
  border-radius: 4px 4px 0 0;
  background: #8bc1ff;
}

.folder-count {
  color: var(--ink-faint);
  font-size: 12px;
}

.file-date {
  justify-self: end;
  min-width: 0;
  max-width: 48px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #748094;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.68;
  padding: 5px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row:hover .file-date,
.file-row.active .file-date {
  border-color: rgba(0, 113, 227, 0.18);
  background: rgba(255, 255, 255, 0.9);
  color: #4b5c73;
  opacity: 1;
}

.folder-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: 120px;
  overflow: hidden;
}

.folder-files {
  display: grid;
  gap: 1px;
  padding: 2px 0 6px;
}

.folder.collapsed .folder-files {
  display: none;
}

.folder.collapsed .folder-toggle {
  transform: none;
}

.folder.collapsed .folder-toggle::before {
  transform: rotate(-45deg) translate(-1px, 1px);
}

.tree-action {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  box-shadow: none;
}

.tree-action:hover {
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent-strong);
}

.file-icon {
  display: inline-grid;
  width: 28px;
  height: 21px;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.18);
  border-radius: 8px;
  background: #e7f2ff;
  color: #0b63c2;
  font-size: 10px;
  font-weight: 900;
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.44);
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 48px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

.document-meta {
  min-width: 0;
}

.document-meta h2 {
  overflow: hidden;
  max-width: 46vw;
  margin: 0;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#saveState {
  color: var(--ink-faint);
  font-size: 11px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.64);
}

.segmented button {
  min-height: 30px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink-faint);
  box-shadow: none;
}

.segmented button.active {
  background: #fff;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.1);
  color: var(--accent-strong);
}

.custom-select {
  position: relative;
}

.select-trigger {
  min-width: 142px;
  min-height: 34px;
  padding: 0 14px;
  justify-content: space-between;
}

.compact-select .select-trigger {
  min-width: 112px;
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.formatbar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.68);
  overflow-x: auto;
}

.formatbar .custom-select {
  flex: 0 0 auto;
}

.formatbar button {
  display: inline-flex;
  min-width: 34px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #1f2937;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.formatbar button:hover {
  border-color: rgba(0, 113, 227, 0.3);
  background: #fff;
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.formatbar .toggle-button.active {
  border-color: rgba(0, 113, 227, 0.38);
  background: linear-gradient(135deg, var(--accent), #3e9aff);
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 113, 227, 0.22);
}

.format-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

#zoomValue {
  min-width: 44px;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

.select-caret {
  position: relative;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 50%;
  background: rgba(248, 250, 252, 0.86);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.compact-select .select-caret {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
}

.select-caret::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 7px;
  height: 7px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translate(-50%, -50%) rotate(45deg);
}

.compact-select .select-caret::before {
  width: 5px;
  height: 5px;
}

.select-trigger:hover .select-caret,
.select-trigger[aria-expanded="true"] .select-caret {
  border-color: rgba(0, 113, 227, 0.28);
  background: #fff;
}

.select-trigger[aria-expanded="true"] .select-caret {
  transform: rotate(180deg);
}

.select-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  min-width: 178px;
  max-height: min(320px, calc(100vh - 24px));
  overflow: auto;
  padding: 6px;
  border-color: rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.17);
}

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

.select-menu button {
  min-height: 36px;
  border-radius: 11px;
  background: transparent;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.select-menu button:hover,
.select-menu button[aria-selected="true"] {
  background: rgba(0, 113, 227, 0.11);
  color: var(--accent-strong);
}

.select-menu button[aria-selected="true"] {
  font-weight: 800;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.editor-pane,
.preview-pane,
.preview-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.preview-wrap {
  position: relative;
  display: grid;
}

.editor-pane {
  border-right: 1px solid var(--line);
  background: #0f172a;
}

#sourceEditor {
  width: 100%;
  min-height: 100%;
  padding: 18px 22px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: #e5edf7;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  tab-size: 2;
}

#sourceEditor::placeholder {
  color: rgba(226, 232, 240, 0.58);
}

.preview-pane {
  padding: 22px min(4vw, 44px);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

body[data-page="a4"] .preview-pane {
  background: #e9edf3;
}

body[data-page="a4"] .preview-wrap {
  grid-template-columns: minmax(0, 1fr);
  background: #e9edf3;
  overflow: auto;
}

body[data-page="a4"][data-toc="on"] .preview-wrap {
  grid-template-columns: minmax(0, 1fr) 210px;
}

body[data-page="a4"] .markdown-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, calc(210mm * var(--page-scale, 1)));
  align-content: start;
  justify-content: center;
  gap: 18px;
  width: auto;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 24px;
  border: 0;
  background: #e9edf3;
  box-shadow: none;
}

body[data-page="a4"] .app-shell.sidebar-collapsed .markdown-body {
  max-width: none;
}

body[data-page="a4"][data-view="source"] .markdown-body {
  max-width: none;
}

.a4-page {
  width: calc(210mm * var(--page-scale, 1));
  height: calc(297mm * var(--page-scale, 1));
  min-width: calc(210mm * var(--page-scale, 1));
  max-width: none;
  margin: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  break-after: page;
  page-break-after: always;
}

.a4-page-inner {
  transform: scale(var(--page-scale, 1));
  transform-origin: top left;
  width: 210mm;
  height: 297mm;
  overflow: hidden;
  padding: 20mm 18mm;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

.toc-panel {
  position: sticky;
  top: 16px;
  display: none;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 8px;
  border-left: 1px solid #d8dee8;
  background: transparent;
}

.page-zoom-control {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 40;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #cfd7e3;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

body[data-page="a4"] .page-zoom-control {
  display: flex;
}

body[data-page="a4"][data-toc="on"] .page-zoom-control {
  right: 224px;
}

.page-zoom-control button {
  width: 24px;
  height: 22px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #1f2937;
  cursor: pointer;
  font-weight: 800;
}

.page-zoom-control button:hover {
  background: #eef3f9;
}

.page-zoom-control strong {
  min-width: 42px;
  color: #475467;
  font-size: 12px;
  text-align: center;
}

body[data-page="a4"][data-toc="on"] .toc-panel {
  display: grid;
  gap: 2px;
  align-self: start;
}

.toc-panel strong {
  padding: 4px 8px 6px;
  color: #334155;
  font-size: 12px;
}

.toc-item {
  display: block;
  width: 100%;
  min-height: 24px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #475467;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-item:hover {
  background: #eef3f9;
  color: #0b63c2;
}

.toc-h2 { padding-left: 16px; }
.toc-h3 { padding-left: 28px; }
.toc-h4 { padding-left: 40px; }
.toc-h5 { padding-left: 52px; }
.toc-h6 { padding-left: 64px; }
.toc-h7 { padding-left: 76px; }

body[data-page="a4"] .app-shell.sidebar-collapsed .a4-page {
  max-width: calc(100vw - 124px);
}

.preview-pane[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 3px rgba(0, 113, 227, 0.16);
}

body[data-view="preview"] .editor-shell {
  grid-template-columns: 1fr;
}

body[data-view="preview"] .editor-pane,
body[data-view="source"] .preview-wrap {
  display: none;
}

body[data-view="source"] .editor-shell {
  grid-template-columns: 1fr;
}

body[data-view="source"] .editor-pane {
  border-right: 0;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--ink-faint);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 20px;
}

.markdown-body {
  color: #111827;
  font-family: var(--font-zh, var(--serif));
  font-size: calc(15px * var(--doc-scale, 1));
  line-height: 1.56;
}

.latin-font {
  font-family: var(--font-en, inherit);
}

.greek-font {
  font-family: var(--font-greek, inherit);
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6,
.markdown-body h7 {
  display: block;
  margin: 1.35em 0 0.55em;
  color: #0b1220;
  font-family: var(--sans);
  line-height: 1.25;
}

.heading-number {
  display: inline-block;
  margin-right: 0.18em;
  color: inherit;
  user-select: none;
}

.markdown-body h1 {
  padding-bottom: 0.28em;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  font-size: calc(28px * var(--doc-scale, 1));
}

.markdown-body h2 {
  font-size: calc(23px * var(--doc-scale, 1));
}

.markdown-body h3 {
  font-size: calc(19px * var(--doc-scale, 1));
}

.markdown-body h4 {
  font-size: calc(17px * var(--doc-scale, 1));
}

.markdown-body h5 {
  font-size: calc(15px * var(--doc-scale, 1));
}

.markdown-body h6,
.markdown-body h7 {
  font-size: calc(14px * var(--doc-scale, 1));
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
  margin-bottom: 1em;
}

.markdown-body a {
  color: var(--accent-strong);
  text-underline-offset: 3px;
}

.markdown-body blockquote {
  margin-left: 0;
  padding: 13px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 0 14px 14px 0;
  background: rgba(231, 242, 255, 0.72);
  color: #334155;
}

.markdown-body code {
  border-radius: 7px;
  background: rgba(0, 113, 227, 0.1);
  color: #0b63c2;
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 0.14em 0.35em;
}

.markdown-body pre {
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: #0f172a;
  color: #e5edf7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.markdown-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown-body table {
  display: table;
  width: auto;
  max-width: 100%;
  overflow: visible;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #d9e2ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.markdown-body th,
.markdown-body td {
  min-width: 78px;
  padding: 10px 16px;
  border-right: 1px solid #e3e9f2;
  border-bottom: 1px solid #e3e9f2;
  text-align: left;
  vertical-align: top;
}

.markdown-body tr > *:last-child {
  border-right: 0;
}

.markdown-body tr:last-child > * {
  border-bottom: 0;
}

.markdown-body th {
  background: linear-gradient(180deg, #f7fbff, #eef5ff);
  color: #334155;
  font-family: var(--sans);
  font-weight: 800;
}

.markdown-body tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.markdown-body tbody tr:hover td {
  background: #f1f7ff;
}

.markdown-body thead tr:first-child th:first-child {
  border-top-left-radius: 12px;
}

.markdown-body thead tr:first-child th:last-child {
  border-top-right-radius: 12px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 16px;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}

.math-source {
  white-space: pre-wrap;
}

.katex {
  font-size: 1.02em;
}

.katex .katex-mathml {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  border: 0;
  padding: 0;
}

.katex .katex-html {
  display: inline-block;
}

.katex-display > .katex {
  display: block;
  text-align: center;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--ink);
  font-size: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.17);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.26);
  background: linear-gradient(165deg, #fff, var(--danger-soft));
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.dialog {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 22px;
  border-radius: 24px;
}

.dialog h3 {
  margin: 0;
  font-size: 22px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: 0;
  padding: 0 13px;
  font-weight: 600;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input:focus {
  border-color: rgba(0, 113, 227, 0.62);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.13);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#dropdownLayer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

#dropdownLayer .select-menu {
  pointer-events: auto;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: rgba(248, 250, 252, 0.72);
}

body[data-page="a4"] .preview-pane {
  background: #e9edf3;
}

body[data-page="a4"] .a4-page,
body[data-page="a4"] .a4-page h1,
body[data-page="a4"] .a4-page h2,
body[data-page="a4"] .a4-page h3,
body[data-page="a4"] .a4-page h4,
body[data-page="a4"] .a4-page h5,
body[data-page="a4"] .a4-page h6,
body[data-page="a4"] .a4-page h7 {
  color: #111827;
}

@media (max-width: 1100px) {
  .notes-shell {
    width: 100%;
    padding: 0;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .notes-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 760px;
  }

  .sidebar {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .document-meta h2 {
    max-width: 100%;
  }

  .toolbar {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .notes-shell {
    width: 100%;
    gap: 0;
    padding: 0;
  }

  .app-shell {
    border-radius: 0;
  }

  .sidebar-actions,
  .editor-shell {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .segmented,
  .custom-select {
    grid-column: 1 / -1;
  }

  .select-trigger {
    width: 100%;
  }

  body[data-view="split"] .editor-shell {
    grid-template-columns: 1fr;
  }

  body[data-view="split"] .editor-pane {
    min-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-pane {
    padding: 24px 18px;
  }
}

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

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    overflow: visible !important;
    background: #fff !important;
  }

  .bg-noise,
  .sidebar,
  .topbar,
  .formatbar,
  .toc-panel,
  .page-zoom-control,
  .editor-pane,
  .toast-region,
  .modal-backdrop,
  #dropdownLayer {
    display: none !important;
  }

  .notes-shell,
  .app-shell,
  .workspace,
  .editor-shell {
    display: block !important;
    width: 210mm !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .preview-pane,
  .markdown-body {
    display: block !important;
    width: 210mm !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .a4-page {
    width: 210mm !important;
    height: 297mm !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    break-after: page;
    page-break-after: always;
  }

  .a4-page-inner {
    transform: none !important;
    width: 210mm !important;
    height: 297mm !important;
    padding: 20mm 18mm !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .a4-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

/* Word-like flat command surface */
.topbar {
  min-height: 38px;
  padding: 4px 8px;
  background: #fff;
  border-bottom: 1px solid #d8dee8;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.document-meta {
  display: flex;
  min-width: 120px;
  align-items: center;
}

.document-meta .eyebrow,
#saveState {
  display: none;
}

.document-meta h2 {
  max-width: 220px;
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}

.toolbar,
.formatbar {
  gap: 2px;
}

.formatbar {
  min-height: 32px;
  padding: 2px 6px;
  background: #f7f9fc;
  border-bottom: 1px solid #d8dee8;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.tree-action,
.select-trigger,
.segmented button,
.formatbar button {
  min-height: 26px;
  border-radius: 4px;
  box-shadow: none;
  transform: none;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.select-trigger:hover,
.segmented button:hover,
.formatbar button:hover {
  transform: none;
  box-shadow: none;
}

.primary-button,
.toolbar .primary-button {
  border-color: #b9d7ff;
  background: #e7f1ff;
  color: #0b63c2;
}

.secondary-button,
.icon-button,
.select-trigger,
.formatbar button {
  border-color: transparent;
  background: transparent;
  color: #1f2937;
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.select-trigger:hover,
.formatbar button:hover {
  border-color: #cfd7e3;
  background: #eef3f9;
}

.danger-button,
.toolbar .danger-button {
  border-color: transparent;
  background: transparent;
  color: #dc2626;
}

.danger-button:hover:not(:disabled) {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.segmented {
  gap: 0;
  padding: 0;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #f1f4f8;
  overflow: hidden;
}

.segmented button {
  min-height: 28px;
  border-radius: 0;
  padding: 0 10px;
}

.segmented button.active {
  background: #fff;
  color: #0b63c2;
  box-shadow: inset 0 -2px 0 #2f8cff;
}

.select-trigger {
  min-width: 118px;
  justify-content: space-between;
}

.compact-select .select-trigger {
  min-width: 94px;
}

.select-caret,
.compact-select .select-caret {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
  border: 0;
  background: transparent;
}

.select-caret::before,
.compact-select .select-caret::before {
  width: 6px;
  height: 6px;
  border-width: 1.7px;
}

.formatbar button {
  min-width: 28px;
  min-height: 26px;
  padding: 0 7px;
  font-size: 12px;
}

.formatbar .toggle-button.active {
  border-color: #b9d7ff;
  background: #e7f1ff;
  color: #0b63c2;
  box-shadow: none;
}

#zoomValue {
  min-width: 38px;
  font-size: 12px;
}

.sidebar {
  background: #f8fafc;
}

.sidebar-head {
  min-height: 38px;
  padding: 6px 8px;
  border-bottom: 1px solid #e5eaf1;
}

.sidebar-head h1 {
  font-size: 15px;
}

.sidebar-actions {
  gap: 4px;
  padding: 6px 8px;
}

.search-box {
  margin: 6px 8px;
  border-radius: 6px;
  box-shadow: none;
}

.search-box input {
  height: 30px;
}

.tree {
  padding: 4px 6px 8px;
}

.folder {
  margin-bottom: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.folder-row {
  min-height: 32px;
  padding: 3px 4px;
  border-radius: 4px;
  background: transparent;
}

.folder-icon {
  box-shadow: none;
}

.folder-files {
  padding: 0 0 2px;
}

.file-row {
  min-height: 30px;
  margin: 1px 0;
  padding: 3px 4px 3px 22px;
  border-radius: 4px;
}

.file-row.active {
  background: #e7f1ff;
  box-shadow: inset 3px 0 0 #2f8cff;
}

.file-date,
.folder-count {
  display: none;
}

.tree-action {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
}

/* Flatter Word-style ribbon refinement */
.topbar {
  min-height: 32px;
  padding: 2px 8px;
  border-bottom: 0;
  background: #fff;
}

.formatbar {
  min-height: 30px;
  padding: 1px 8px 3px;
  border-top: 1px solid #eef1f5;
  border-bottom: 0;
  background: #f8fafc;
}

.document-meta h2 {
  font-size: 13px;
}

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.formatbar button,
.segmented button {
  min-height: 24px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
}

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button {
  padding: 0 7px;
}

.formatbar button {
  min-width: auto;
  padding: 0 7px;
}

.toolbar .primary-button:hover:not(:disabled),
.toolbar .secondary-button:hover:not(:disabled),
.toolbar .danger-button:hover:not(:disabled),
.formatbar button:hover,
.select-trigger:hover,
.segmented button:hover {
  background: #eef3f9;
  border: 0;
  box-shadow: none;
}

.toolbar .primary-button {
  color: #0b63c2;
  background: transparent;
}

.toolbar .primary-button:hover:not(:disabled) {
  background: #e7f1ff;
}

.toolbar .danger-button {
  color: #dc2626;
}

.toolbar .danger-button:hover:not(:disabled) {
  background: #fff1f2;
}

.segmented {
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.segmented button {
  padding: 0 10px;
  color: #475467;
}

.segmented button.active {
  background: #e7f1ff;
  color: #0b63c2;
  box-shadow: none;
}

.formatbar .toggle-button.active {
  border: 0;
  background: #e7f1ff;
  color: #0b63c2;
  box-shadow: none;
}

.select-trigger,
.compact-select .select-trigger {
  min-height: 24px;
  padding: 0 7px;
  border: 0;
}

.select-menu {
  border: 1px solid #d8dee8;
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

.select-menu button {
  border-radius: 4px;
}

.select-caret,
.compact-select .select-caret {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

#zoomValue {
  min-width: 34px;
}

.preview-pane {
  border-top: 1px solid #eef1f5;
}

/* Flat sidebar refinement */
.sidebar {
  background: #f8fafc;
  border-right: 1px solid #d8dee8;
}

.sidebar-head {
  min-height: 34px;
  padding: 4px 8px;
  border-bottom: 1px solid #eef1f5;
}

.sidebar-head h1 {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  color: #111827;
}

.sidebar-head .icon-button {
  width: 26px;
  min-width: 26px;
  min-height: 26px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
}

.sidebar-head .icon-button:hover {
  background: #eef3f9;
}

.sidebar-actions {
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 4px 8px;
  border-bottom: 1px solid #eef1f5;
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button {
  min-height: 28px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: #1f2937;
  font-size: 13px;
}

.sidebar-actions .primary-button:hover,
.sidebar-actions .secondary-button:hover {
  background: #eef3f9;
}

.sidebar-actions .primary-button {
  color: #0b63c2;
}

.search-box {
  height: 30px;
  margin: 6px 8px;
  padding: 0 8px;
  border: 1px solid #d8dee8;
  border-radius: 3px;
  background: #fff;
  box-shadow: none;
}

.search-box:focus-within {
  border-color: #9cc8ff;
  box-shadow: none;
}

.search-box input {
  height: 28px;
  font-size: 13px;
}

.tree {
  padding: 2px 4px 8px;
}

.folder {
  margin: 0;
  border: 0;
  background: transparent;
}

.folder-row,
.file-row {
  min-height: 28px;
  border-radius: 3px;
}

.folder-row {
  padding: 2px 4px;
  background: transparent;
}

.folder-row:hover,
.file-row:hover {
  background: #eef3f9;
}

.folder-toggle {
  width: 22px;
  min-width: 22px;
  height: 22px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
}

.folder-toggle:hover {
  background: #e5ebf3;
  box-shadow: none;
}

.folder-icon {
  width: 18px;
  height: 14px;
  border-radius: 3px;
  background: #5aa2ff;
  box-shadow: none;
}

.folder-icon::before {
  top: -3px;
  width: 8px;
  height: 5px;
  background: #83bbff;
}

.folder-name,
.file-name {
  font-size: 13px;
  font-weight: 700;
}

.folder-actions {
  gap: 0;
  max-width: 82px;
}

.tree-action {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: 3px;
  font-size: 13px;
}

.tree-action:hover {
  background: #e5ebf3;
}

.folder-files {
  padding: 0 0 2px;
}

.file-row {
  grid-template-columns: auto minmax(0, 1fr);
  max-width: 100%;
  margin: 0;
  padding: 2px 4px 2px 34px;
}

.file-row.active {
  background: #e7f1ff;
  box-shadow: inset 3px 0 0 #2f8cff;
}

.file-icon {
  width: 24px;
  height: 18px;
  border: 1px solid #b9d7ff;
  border-radius: 4px;
  background: #eff6ff;
  color: #0b63c2;
  font-size: 10px;
}

.file-date,
.folder-count {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  left: 13px;
  top: 6px;
  border-radius: 3px;
  background: #e7f1ff;
  color: #0b63c2;
  box-shadow: none;
}

/* Polished flat workspace */
:root {
  --sidebar-width: 340px;
  --ui-bg: #edf1f6;
  --ui-panel: #ffffff;
  --ui-panel-soft: #f8fafc;
  --ui-line: #d6deea;
  --ui-line-soft: #e7ecf3;
  --ui-hover: #edf4ff;
  --ui-active: #dcecff;
  --ui-blue: #1f73d8;
  --ui-blue-strong: #155fb5;
  --ui-text: #111827;
  --ui-muted: #64748b;
  --ui-command: #ffffff;
  --ui-command-hover: #f2f6fb;
  --ui-command-active: #eaf3ff;
}

body {
  background: var(--ui-bg);
}

.bg-noise {
  display: none;
}

.app-shell {
  grid-template-columns: minmax(240px, var(--sidebar-width)) 6px minmax(0, 1fr);
  background: var(--ui-bg);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 54px 0 minmax(0, 1fr);
}

.sidebar-resizer {
  position: relative;
  z-index: 30;
  min-width: 6px;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}

.sidebar-resizer::before {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 2px;
  background: #dfe6f0;
  transition: background 0.12s ease;
}

.sidebar-resizer:hover::before,
body.resizing-sidebar .sidebar-resizer::before {
  background: #b8c7da;
}

.app-shell.sidebar-collapsed .sidebar-resizer {
  width: 0;
  min-width: 0;
  overflow: hidden;
  pointer-events: none;
}

body.resizing-sidebar,
body.resizing-sidebar * {
  cursor: col-resize !important;
  user-select: none;
}

body.resizing-sidebar .preview-pane,
body.resizing-sidebar #sourceEditor {
  pointer-events: none;
}

.sidebar {
  border-right: 0;
  background: #f7f9fc;
  box-shadow: inset -1px 0 0 var(--ui-line);
}

.workspace {
  background: var(--ui-panel);
}

.topbar {
  min-height: 38px;
  padding: 4px 10px;
  border-bottom: 0;
  background: var(--ui-command);
  box-shadow: none;
}

.document-meta h2 {
  max-width: min(360px, 34vw);
  color: var(--ui-text);
  font-size: 14px;
  font-weight: 850;
}

.document-meta + #saveState {
  margin-left: 2px;
  margin-right: 8px;
  flex: 0 0 auto;
}

.toolbar {
  gap: 4px;
}

.formatbar {
  min-height: 34px;
  padding: 3px 10px;
  border-top: 0;
  border-bottom: 1px solid var(--ui-line);
  background: var(--ui-command);
  box-shadow: none;
}

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.formatbar button,
.segmented button,
.select-trigger,
.compact-select .select-trigger {
  min-height: 27px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #253044;
  font-weight: 750;
  box-shadow: none;
}

.toolbar .primary-button {
  border-color: #1769c9;
  background: var(--ui-blue);
  color: #fff;
}

.toolbar .primary-button:hover:not(:disabled) {
  border-color: var(--ui-blue-strong);
  background: var(--ui-blue-strong);
}

.toolbar .danger-button {
  color: #b42318;
}

.toolbar .danger-button:hover:not(:disabled) {
  border-color: #f3c4bf;
  background: #fff1f0;
  color: #9f1f16;
}

.toolbar .secondary-button:hover:not(:disabled),
.toolbar .select-trigger:hover,
.formatbar button:hover,
.select-trigger:hover,
.segmented button:hover {
  border-color: #c7d4e5;
  background: var(--ui-command-hover);
}

.segmented {
  gap: 2px;
  padding: 2px;
  border: 1px solid #ccd6e3;
  border-radius: 6px;
  background: var(--ui-command);
}

.segmented button {
  min-height: 25px;
  padding: 0 10px;
  color: var(--ui-muted);
}

.segmented button.active {
  border-color: #b7d3f6;
  background: #fff;
  color: var(--ui-blue-strong);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.formatbar .toggle-button.active {
  border-color: #aecaee;
  background: var(--ui-command-active);
  color: var(--ui-blue-strong);
}

.select-menu {
  padding: 5px;
  border: 1px solid #cfd8e6;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.select-menu button {
  min-height: 28px;
  border-radius: 5px;
  color: #253044;
  font-weight: 650;
}

.select-menu button:hover,
.select-menu button[aria-selected="true"] {
  background: var(--ui-hover);
  color: var(--ui-blue-strong);
}

.sidebar-head {
  min-height: 42px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #fbfcfe;
}

.sidebar-head h1 {
  font-size: 20px;
  font-weight: 900;
  color: #0f172a;
}

.sidebar-head .icon-button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 5px;
  color: #334155;
}

.sidebar-head .icon-button:hover {
  background: var(--ui-hover);
  color: var(--ui-blue-strong);
}

.sidebar-actions {
  gap: 5px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #f7f9fc;
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button {
  min-height: 30px;
  border: 1px solid #d6deea;
  border-radius: 6px;
  background: #fff;
  color: #253044;
  font-weight: 800;
}

.sidebar-actions .primary-button {
  border-color: #bad4f6;
  color: var(--ui-blue-strong);
}

.sidebar-actions .primary-button:hover,
.sidebar-actions .secondary-button:hover {
  border-color: #adc3dc;
  background: var(--ui-hover);
}

.search-box {
  height: 32px;
  margin: 8px 9px;
  padding: 0 9px;
  border: 1px solid #d3dce8;
  border-radius: 7px;
  background: #fff;
}

.search-box:focus-within {
  border-color: #8fbdf2;
  box-shadow: 0 0 0 2px rgba(31, 115, 216, 0.12);
}

.tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 2px 7px 10px;
}

.sidebar-foot {
  display: grid;
  gap: 5px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--ui-line-soft);
  background: #fbfcfe;
}

.storage-line {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #334155;
  font-size: 12px;
}

.storage-line span,
.storage-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-line strong {
  color: var(--ui-blue-strong);
  font-weight: 850;
}

.storage-hint {
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-storage="local"] .storage-line strong {
  color: #9a6700;
}

body[data-storage="local"] .storage-hint {
  color: #9a6700;
}

.app-shell.sidebar-collapsed .sidebar-foot {
  display: none;
}

.folder {
  margin: 2px 0;
}

.folder-row,
.file-row {
  min-height: 30px;
  border-radius: 6px;
}

.folder-row {
  padding: 3px 5px;
}

.folder-row:hover,
.file-row:hover {
  background: #edf3fb;
}

.folder-toggle {
  border-radius: 5px;
  color: #667085;
}

.folder-toggle:hover {
  background: #e4ebf5;
  color: var(--ui-blue-strong);
}

.folder-icon {
  width: 20px;
  height: 15px;
  border-radius: 4px;
  background: #4f94dd;
}

.folder-icon::before {
  background: #78afe8;
}

.folder-name,
.file-name {
  color: #253044;
  font-size: 13px;
  font-weight: 760;
}

.folder-actions {
  max-width: 88px;
}

.tree-action {
  width: 23px;
  min-width: 23px;
  height: 23px;
  min-height: 23px;
  border-radius: 5px;
  color: #64748b;
}

.tree-action:hover {
  background: #e4ebf5;
  color: #1f2937;
}

.file-row {
  margin: 1px 0;
  padding: 3px 5px 3px 34px;
}

.file-row.active {
  background: var(--ui-active);
  box-shadow: inset 3px 0 0 var(--ui-blue);
}

.file-row.active .file-name {
  color: #0f4f99;
}

.file-icon {
  border-color: #b8d3f5;
  background: #f5f9ff;
  color: var(--ui-blue-strong);
}

.preview-pane {
  border-top: 0;
  background: #fff;
}

body[data-page="fluid"] .preview-pane {
  padding: 24px clamp(24px, 5vw, 64px);
}

.markdown-body {
  color: #111827;
  line-height: 1.52;
}

.markdown-body h1 {
  border-bottom-color: #dbe3ef;
}

.markdown-body blockquote {
  border-left-color: var(--ui-blue);
  border-radius: 0 8px 8px 0;
  background: #f2f7ff;
}

.markdown-body pre {
  border-radius: 8px;
}

.markdown-body table {
  border-color: #d8e2ef;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

.page-zoom-control {
  border-color: #c7d4e5;
  border-radius: 6px;
}

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

  .sidebar-resizer {
    display: none;
  }
}

/* Public share reader */
body.share-reader {
  min-height: 100vh;
  overflow: auto;
  background: #f1f4f8;
}

.share-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
  align-content: start;
  justify-items: center;
}

.share-reader-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  width: min(1120px, 100%);
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 10px;
  border: 1px solid #cfd8e6;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
}

.share-reader-bar strong,
.share-reader-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-reader-bar strong {
  color: #111827;
  font-size: 14px;
}

.share-reader-bar span {
  color: #64748b;
  font-size: 12px;
}

body.share-reader[data-page="fluid"] .share-pages {
  width: min(1120px, 100%);
  min-height: calc(100vh - 88px);
  margin: 0;
  padding: 34px clamp(28px, 5vw, 72px);
  overflow-wrap: anywhere;
  border: 1px solid #d8e1ed;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.09);
}

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

  .share-reader-bar {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  }

  body.share-reader[data-page="fluid"] .share-pages {
    width: 100%;
    min-height: calc(100vh - 48px);
    padding: 24px 18px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Current compact command polish */
#saveState {
  display: inline-flex !important;
  min-height: 24px;
  max-width: 190px;
  align-items: center;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  flex-wrap: wrap;
}

.formatbar {
  align-items: center;
  overflow-x: auto;
  overflow-y: visible;
}

.formatbar::-webkit-scrollbar {
  height: 6px;
}

.format-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.markdown-body img.selected-image {
  outline: 2px solid #1f73d8;
  outline-offset: 3px;
}

.image-size-value {
  display: inline-flex;
  min-width: 64px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.markdown-body table {
  width: 100%;
}

.markdown-body th {
  background: #f3f7fc;
}

.markdown-body tbody tr:hover td {
  background: #f6faff;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  display: inline-flex;
}

/* Unified Word-like ribbon color */
.topbar,
.formatbar {
  background: var(--ui-command) !important;
  box-shadow: none !important;
}

.topbar {
  border-bottom: 0 !important;
}

.formatbar {
  border-bottom: 1px solid #edf1f6 !important;
}

.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.formatbar button,
.segmented,
#saveState {
  background-color: transparent;
}

.segmented {
  border-color: #e2e8f0 !important;
  background: #f8fafc !important;
}

.toolbar .secondary-button:hover:not(:disabled),
.toolbar .danger-button:hover:not(:disabled),
.toolbar .select-trigger:hover,
.formatbar button:hover,
.segmented button:hover {
  background: var(--ui-command-hover) !important;
}

.segmented button.active,
.formatbar .toggle-button.active {
  background: var(--ui-command-active) !important;
}

#saveState {
  border-color: transparent;
  background: transparent !important;
}

.ribbon-tabs {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-left: auto;
  overflow-x: auto;
}

.ribbon-tabs button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.ribbon-tabs button:hover {
  background: var(--ui-command-hover);
  color: #1f2937;
}

.ribbon-tabs button.active {
  background: var(--ui-command-active);
  color: var(--ui-blue-strong);
}

.ribbon-panel {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: visible;
}

.ribbon-panel[hidden] {
  display: none !important;
}

.ribbon-panel .primary-button {
  border-color: var(--ui-blue) !important;
  background: var(--ui-blue) !important;
  color: #fff !important;
}

.ribbon-panel .primary-button:hover:not(:disabled) {
  border-color: var(--ui-blue-strong) !important;
  background: var(--ui-blue-strong) !important;
}

.ribbon-panel .danger-button {
  color: #b42318 !important;
}

.ribbon-panel .danger-button:hover:not(:disabled) {
  background: #fff1f0 !important;
  color: #9f1f16 !important;
}

/* Harmonized left navigation */
.sidebar {
  background: #fff !important;
  box-shadow: inset -1px 0 0 #edf1f6 !important;
}

.sidebar-head,
.sidebar-actions,
.sidebar-foot {
  background: #fff !important;
  border-color: #edf1f6 !important;
}

.sidebar-head {
  min-height: 40px;
  padding: 6px 10px;
}

.sidebar-head h1 {
  color: #111827;
  font-size: 20px;
  font-weight: 900;
}

.sidebar-head .icon-button,
.sidebar-actions .primary-button,
.sidebar-actions .secondary-button,
.tree-action,
.folder-toggle {
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

.sidebar-head .icon-button:hover,
.sidebar-actions .primary-button:hover,
.sidebar-actions .secondary-button:hover,
.tree-action:hover,
.folder-toggle:hover,
.folder-row:hover,
.file-row:hover {
  background: #f2f6fb !important;
}

.sidebar-actions {
  gap: 3px;
  padding: 5px 8px;
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button {
  min-height: 28px;
  color: #334155 !important;
  font-size: 13px;
  font-weight: 800;
}

.sidebar-actions .primary-button {
  color: #155fb5 !important;
}

.search-box {
  height: 30px;
  margin: 7px 8px;
  border-color: #e2e8f0 !important;
  border-radius: 6px;
  background: #f8fafc !important;
}

.search-box:focus-within {
  border-color: #b7d3f6 !important;
  background: #fff !important;
  box-shadow: 0 0 0 2px rgba(31, 115, 216, 0.08) !important;
}

.tree {
  padding: 2px 6px 10px;
}

.folder {
  margin: 1px 0;
}

.folder-row,
.file-row {
  min-height: 29px;
  border-radius: 5px;
}

.folder-row {
  padding: 2px 4px;
}

.folder-icon {
  width: 19px;
  height: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #eef2f7 !important;
  box-shadow: none !important;
}

.folder-icon::before {
  top: -4px;
  left: 2px;
  width: 8px;
  height: 5px;
  border: 1px solid #cbd5e1;
  border-bottom: 0;
  background: #f8fafc !important;
}

.folder-name,
.file-name {
  color: #263244;
  font-weight: 760;
}

.file-row {
  padding-left: 32px;
}

.file-row.active {
  background: #eef6ff !important;
  box-shadow: inset 2px 0 0 var(--ui-blue) !important;
}

.file-icon {
  border-color: #d8e2ef !important;
  background: #fff !important;
  color: #64748b !important;
}

.storage-line strong,
body[data-storage="local"] .storage-line strong {
  color: #155fb5 !important;
}

.storage-hint,
body[data-storage="local"] .storage-hint {
  color: #64748b !important;
}

.sidebar-resizer::before {
  background: #edf1f6 !important;
}

.sidebar-resizer:hover::before,
body.resizing-sidebar .sidebar-resizer::before {
  background: #cbd5e1 !important;
}

.folder-actions {
  max-width: 118px !important;
}

.folder-icon.shared-folder-icon {
  border-color: #b7d3f6 !important;
  background: #eaf3ff !important;
  color: #155fb5 !important;
}

.folder-icon.shared-folder-icon::before {
  border-color: #b7d3f6 !important;
  background: #d9ebff !important;
}

/* Final workspace header layout: commands on the left, note title on the right */
.topbar {
  display: flex !important;
  min-height: 42px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  padding: 5px 10px !important;
}

.ribbon-tabs {
  order: 1;
  flex: 1 1 auto;
  justify-content: flex-start !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}

#saveState {
  order: 2;
  flex: 0 1 auto !important;
  margin-left: auto !important;
  margin-right: 6px !important;
}

.document-meta {
  order: 3;
  display: flex !important;
  min-width: 0;
  flex: 0 1 min(420px, 42vw);
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}

.document-meta h2 {
  max-width: 100% !important;
  text-align: right;
}

.formatbar,
.ribbon-panel {
  justify-content: flex-start !important;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start !important;
    flex-direction: column !important;
  }

  .ribbon-tabs,
  .document-meta,
  #saveState {
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .ribbon-tabs {
    order: 1;
  }

  .document-meta {
    order: 2;
    flex-basis: auto;
    justify-content: flex-end;
  }

  #saveState {
    order: 3;
    justify-content: flex-end;
  }
}

@media print {
  body.share-reader {
    width: 210mm;
    background: #fff !important;
  }

  .share-shell {
    display: block;
    padding: 0;
  }

  .share-reader-bar {
    display: none;
  }

  .share-pages {
    width: 210mm !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }
}

/* ---- Public folder link + access password gate ---- */
body[data-public-folder] #newFolderButton,
body[data-public-folder] [data-ribbon-tab="storage"],
body[data-public-folder] [data-ribbon-panel="storage"],
body[data-public-folder] #shareButton,
body[data-public-folder] #renameButton,
body[data-public-folder] #deleteButton,
body[data-public-folder] #historyButton,
body[data-public-folder] #importJsonButton,
body[data-public-folder] #exportJsonButton {
  display: none !important;
}

.pf-gate {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.pf-gate[hidden] {
  display: none;
}

.pf-gate-card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: var(--radius-card, 20px);
  background: var(--ui-panel, #fff);
  box-shadow: var(--shadow-panel, 0 28px 80px rgba(15, 23, 42, 0.2));
}

.pf-gate-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 850;
  color: var(--ink, #0f172a);
}

.pf-gate-sub {
  margin: 0;
  color: var(--ink-soft, #475467);
  font-size: 13px;
  line-height: 1.5;
}

.pf-gate-card input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--ui-line, #d6deea);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: var(--ink, #0f172a);
  outline: 0;
}

.pf-gate-card input:focus {
  border-color: var(--accent, #0071e3);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(0, 113, 227, 0.12));
}

.pf-gate-card .primary-button {
  justify-content: center;
}

.pf-gate-error {
  margin: 0;
  color: var(--danger, #dc2626);
  font-size: 13px;
}

.pf-gate-error[hidden] {
  display: none;
}

.folder-link-desc {
  margin: 0;
  color: var(--ink-soft, #475467);
  font-size: 13px;
  line-height: 1.5;
}

.folder-link-clear {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft, #475467);
  font-size: 13px;
  font-weight: 700;
}

.folder-link-clear[hidden] {
  display: none;
}

.folder-link-actions {
  flex-wrap: wrap;
  gap: 8px;
}

#folderLinkUrl {
  font-family: var(--mono, monospace);
  font-size: 12px;
}

.tree-share-menu {
  gap: 2px;
}

.tree-share-option {
  display: grid !important;
  gap: 2px;
  padding: 8px 11px !important;
  min-height: 0 !important;
}

.tree-share-option strong {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.tree-share-option span {
  color: var(--ink-faint, #667085);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.tree-share-option:hover span {
  color: inherit;
}

/* ---- 2026 admin-workspace theme pass ---- */
:root {
  --ui-bg: #eef2f7;
  --ui-bg-deep: #e4eaf2;
  --ui-panel: #ffffff;
  --ui-panel-soft: #f8fafc;
  --ui-line: #d8e1ed;
  --ui-line-soft: #edf1f6;
  --ui-text: #101828;
  --ui-muted: #667085;
  --ui-blue: #2563eb;
  --ui-blue-strong: #1d4ed8;
  --ui-blue-soft: #eff6ff;
  --ui-green: #15803d;
  --ui-rose: #be123c;
  --shadow-panel: 0 18px 42px rgba(15, 23, 42, 0.09);
  --shadow-float: 0 16px 34px rgba(15, 23, 42, 0.14);
}

body {
  background:
    linear-gradient(180deg, #f8fafc 0%, var(--ui-bg) 42%, var(--ui-bg-deep) 100%);
  color: var(--ui-text);
}

.app-shell {
  background: var(--ui-bg);
}

.sidebar {
  background: linear-gradient(180deg, #fbfcfe 0%, #f5f8fc 100%);
  box-shadow: inset -1px 0 0 var(--ui-line), 8px 0 28px rgba(15, 23, 42, 0.04);
}

.sidebar-head {
  min-height: 48px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-line-soft);
  background: rgba(255, 255, 255, 0.78);
}

.sidebar-head h1 {
  font-size: 19px;
  font-weight: 920;
  color: var(--ui-text);
}

.sidebar-head .icon-button,
.tree-action,
.page-zoom-control button {
  border-radius: 7px;
}

.sidebar-actions {
  gap: 8px;
  padding: 10px 12px;
  background: rgba(248, 250, 252, 0.82);
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button {
  min-height: 34px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  color: #27364a;
}

.sidebar-actions .primary-button {
  border-color: #bed7ff;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-strong);
}

.sidebar-actions .primary-button:hover,
.sidebar-actions .secondary-button:hover,
.sidebar-head .icon-button:hover,
.tree-action:hover {
  border-color: #b8c7da;
  background: #edf4ff;
  color: var(--ui-blue-strong);
}

.search-box {
  height: 36px;
  margin: 10px 12px;
  padding: 0 11px;
  border: 1px solid var(--ui-line);
  border-radius: 9px;
  background: #fff;
}

.search-box:focus-within {
  border-color: #8bbcff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tree {
  padding: 2px 10px 12px;
}

.folder {
  margin: 4px 0;
}

.folder-row,
.file-row {
  min-height: 34px;
  border-radius: 8px;
}

.folder-row {
  padding: 5px 6px;
}

.file-row {
  margin: 2px 0;
  padding: 5px 6px 5px 36px;
}

.folder-row:hover,
.file-row:hover {
  background: #edf4ff;
}

.file-row.active {
  background: #dfeeff;
  box-shadow: inset 3px 0 0 var(--ui-blue);
}

.folder-icon {
  background: linear-gradient(135deg, #4f94dd, #2563eb);
}

.folder-icon::before {
  background: #8abfff;
}

.folder-name,
.file-name {
  font-size: 13px;
  font-weight: 780;
}

.sidebar-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--ui-line-soft);
  background: rgba(255, 255, 255, 0.76);
}

.storage-line {
  font-size: 12px;
}

.workspace {
  background: var(--ui-panel);
}

.topbar {
  min-height: 46px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--ui-line-soft) !important;
  background: #fff !important;
}

.document-meta {
  min-width: 190px;
}

.document-meta h2 {
  color: var(--ui-text);
  font-size: 14px;
  font-weight: 880;
}

#saveState {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--ui-line-soft);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--ui-muted);
}

.ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.ribbon-tabs button {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #475467;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  padding: 0 11px;
}

.ribbon-tabs button:hover {
  background: #f1f5fb;
  color: var(--ui-blue-strong);
}

.ribbon-tabs button.active {
  border-color: #c7dcff;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-strong);
}

.formatbar {
  min-height: 40px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--ui-line-soft) !important;
  background: #fbfcfe !important;
}

.ribbon-panel {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

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

.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.formatbar button,
.segmented button,
.select-trigger,
.compact-select .select-trigger {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 820;
}

.formatbar button,
.toolbar .secondary-button,
.toolbar .danger-button,
.select-trigger {
  background: #fff;
  border-color: #dce3ee;
  color: #27364a;
}

.formatbar button:hover,
.toolbar .secondary-button:hover:not(:disabled),
.toolbar .danger-button:hover:not(:disabled),
.select-trigger:hover,
.segmented button:hover {
  border-color: #b8c7da;
  background: #f1f6fd;
  color: var(--ui-blue-strong);
}

.toolbar .primary-button,
.formatbar .toggle-button.active,
.segmented button.active {
  border-color: #bcd7ff;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-strong);
}

.toolbar .primary-button:hover:not(:disabled) {
  border-color: var(--ui-blue-strong);
  background: var(--ui-blue);
  color: #fff;
}

.toolbar .danger-button,
.danger-button {
  color: var(--ui-rose);
}

.toolbar .danger-button:hover:not(:disabled),
.danger-button:hover:not(:disabled) {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #9f1239;
}

.segmented {
  gap: 3px;
  padding: 3px;
  border: 1px solid #dce3ee !important;
  border-radius: 9px;
  background: #fff !important;
}

.select-menu {
  border-radius: 10px;
  box-shadow: var(--shadow-float);
}

.editor-shell {
  background: #f3f6fa;
}

.editor-pane {
  border-right: 1px solid #d4deeb;
  background: #111827;
}

#sourceEditor {
  padding: 24px 26px;
  color: #e5edf7;
  font-size: 14px;
  line-height: 1.62;
}

.preview-wrap {
  background: #f3f6fa;
}

.preview-pane {
  background: #fff;
}

body[data-page="fluid"] .preview-pane {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 34px clamp(28px, 5vw, 72px);
}

body[data-view="split"][data-page="fluid"] .preview-pane {
  width: 100%;
}

.empty-state {
  min-height: 320px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.markdown-body {
  color: #111827;
  line-height: 1.66;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6,
.markdown-body h7 {
  color: #0f172a;
}

.markdown-body h1 {
  border-bottom-color: #dbe3ef;
}

.markdown-body blockquote {
  border-left-color: var(--ui-blue);
  border-radius: 0 10px 10px 0;
  background: #f0f6ff;
}

.markdown-body pre,
.markdown-body table,
.markdown-body img {
  border-radius: 10px;
}

.markdown-body table {
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

.dialog,
.toast,
.pf-gate-card {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-float);
}

.field input,
.pf-gate-card input {
  border-radius: 10px;
}

.page-zoom-control {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-float);
}

@media (max-width: 980px) {
  .topbar {
    gap: 8px;
  }

  .document-meta {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

  .document-meta h2 {
    text-align: left;
  }

  #saveState {
    width: auto;
    justify-content: flex-start;
  }

  .ribbon-tabs {
    width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 700px) {
  body[data-page="fluid"] .preview-pane {
    padding: 24px 18px;
  }

  .formatbar {
    padding: 6px 8px;
  }

  .ribbon-panel {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
}

/* Keep the final theme above older compact overrides that used !important. */
.topbar {
  min-height: 46px !important;
  padding: 7px 12px !important;
  border-bottom: 1px solid var(--ui-line-soft) !important;
  background: #fff !important;
}

.sidebar {
  background: linear-gradient(180deg, #fbfcfe 0%, #f5f8fc 100%) !important;
  box-shadow: inset -1px 0 0 var(--ui-line), 8px 0 28px rgba(15, 23, 42, 0.04) !important;
}

.sidebar-head,
.sidebar-actions,
.sidebar-foot {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: var(--ui-line-soft) !important;
}

.search-box {
  height: 36px !important;
  margin: 10px 12px !important;
  border-color: var(--ui-line) !important;
  border-radius: 9px !important;
  background: #fff !important;
}

.sidebar-head .icon-button,
.sidebar-actions .primary-button,
.sidebar-actions .secondary-button,
.tree-action,
.folder-toggle {
  border-color: transparent !important;
  box-shadow: none !important;
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button {
  min-height: 34px !important;
  border-color: var(--ui-line) !important;
  border-radius: 8px !important;
  background: #fff !important;
}

.sidebar-actions .primary-button {
  border-color: #bed7ff !important;
  background: var(--ui-blue-soft) !important;
  color: var(--ui-blue-strong) !important;
}

.folder-row:hover,
.file-row:hover,
.sidebar-head .icon-button:hover,
.sidebar-actions .primary-button:hover,
.sidebar-actions .secondary-button:hover,
.tree-action:hover,
.folder-toggle:hover {
  background: #edf4ff !important;
}

.file-row.active {
  background: #dfeeff !important;
  box-shadow: inset 3px 0 0 var(--ui-blue) !important;
}

.folder-icon {
  border-color: transparent !important;
  background: linear-gradient(135deg, #4f94dd, #2563eb) !important;
}

.folder-icon::before {
  border-color: transparent !important;
  background: #8abfff !important;
}

.ribbon-tabs {
  gap: 4px !important;
}

.ribbon-tabs button {
  min-height: 30px !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
}

.ribbon-tabs button.active {
  border-color: #c7dcff !important;
  background: var(--ui-blue-soft) !important;
  color: var(--ui-blue-strong) !important;
}

#saveState {
  border-color: var(--ui-line-soft) !important;
  border-radius: 999px !important;
  background: #f8fafc !important;
}

.formatbar {
  min-height: 40px !important;
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--ui-line-soft) !important;
  background: #fbfcfe !important;
}

.formatbar button,
.toolbar .secondary-button,
.toolbar .danger-button,
.select-trigger {
  border-color: #dce3ee !important;
  border-radius: 7px !important;
  background: #fff !important;
}

.formatbar button:hover,
.toolbar .secondary-button:hover:not(:disabled),
.toolbar .danger-button:hover:not(:disabled),
.select-trigger:hover,
.segmented button:hover {
  border-color: #b8c7da !important;
  background: #f1f6fd !important;
}

.segmented {
  border-color: #dce3ee !important;
  border-radius: 9px !important;
  background: #fff !important;
}

.segmented button.active,
.formatbar .toggle-button.active {
  border-color: #bcd7ff !important;
  background: var(--ui-blue-soft) !important;
  color: var(--ui-blue-strong) !important;
}

/* Borderless controls for the note workspace. */
.sidebar-head .icon-button,
.sidebar-actions .primary-button,
.sidebar-actions .secondary-button,
.tree-action,
.folder-toggle,
.ribbon-tabs button,
.formatbar button,
.toolbar .primary-button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.segmented button,
.page-zoom-control button {
  border: 0 !important;
  box-shadow: none !important;
}

.segmented {
  border: 0 !important;
  box-shadow: none !important;
}

.sidebar-actions .primary-button,
.sidebar-actions .secondary-button,
.formatbar button,
.toolbar .secondary-button,
.toolbar .danger-button,
.toolbar .select-trigger,
.page-zoom-control button {
  background: transparent !important;
}

.folder-row:hover,
.file-row:hover,
.sidebar-head .icon-button:hover,
.sidebar-actions .primary-button:hover:not(:disabled),
.sidebar-actions .secondary-button:hover:not(:disabled),
.tree-action:hover,
.folder-toggle:hover,
.ribbon-tabs button:hover,
.formatbar button:hover,
.toolbar .secondary-button:hover:not(:disabled),
.toolbar .select-trigger:hover,
.segmented button:hover,
.page-zoom-control button:hover {
  border: 0 !important;
  background: #edf4ff !important;
  box-shadow: none !important;
}

.toolbar .primary-button,
.sidebar-actions .primary-button,
.ribbon-tabs button.active,
.segmented button.active,
.formatbar .toggle-button.active {
  border: 0 !important;
  background: var(--ui-blue-soft) !important;
  color: var(--ui-blue-strong) !important;
  box-shadow: none !important;
}

.toolbar .primary-button:hover:not(:disabled),
.sidebar-actions .primary-button:hover:not(:disabled) {
  border: 0 !important;
  background: #dbeafe !important;
  color: var(--ui-blue-strong) !important;
  box-shadow: none !important;
}

.toolbar .danger-button:hover:not(:disabled) {
  border: 0 !important;
  background: #fff1f2 !important;
  color: #9f1239 !important;
  box-shadow: none !important;
}

/* Keep the folder disclosure arrow centered in both states. */
.folder-toggle {
  display: grid !important;
  padding: 0 !important;
  place-items: center !important;
  line-height: 1 !important;
}

.folder-toggle::before {
  margin: 0 !important;
  transform: rotate(45deg) !important;
  transform-origin: center !important;
}

.folder.collapsed .folder-toggle::before {
  transform: rotate(-45deg) !important;
}

/* Mobile workspace: off-canvas files, compact commands, full-height editor. */
.mobile-sidebar-button,
.sidebar-scrim {
  display: none;
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    overflow: hidden !important;
  }

  .notes-shell {
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding: 0 !important;
  }

  .app-shell,
  .app-shell.sidebar-collapsed {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    height: 100%;
    min-height: 0 !important;
    overflow: hidden;
  }

  .sidebar {
    position: absolute !important;
    inset: 0 auto 0 0;
    z-index: 100;
    width: min(88vw, 340px);
    max-height: none !important;
    overflow: hidden !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    transform: translateX(calc(-100% - 16px));
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s ease, visibility 0.22s ease;
    box-shadow: 12px 0 36px rgba(15, 23, 42, 0.18) !important;
  }

  .app-shell.mobile-sidebar-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .sidebar-resizer {
    display: none !important;
  }

  .sidebar-scrim {
    position: absolute;
    inset: 0;
    z-index: 90;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .app-shell.mobile-sidebar-open .sidebar-scrim {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .topbar {
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-areas:
      "sidebar document"
      "tabs tabs";
    gap: 4px 8px !important;
    min-height: 76px !important;
    padding: 6px 10px !important;
    align-items: center !important;
  }

  .mobile-sidebar-button {
    grid-area: sidebar;
    display: inline-grid;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #475467;
    cursor: pointer;
  }

  .mobile-sidebar-button:hover,
  .mobile-sidebar-button:focus-visible {
    background: var(--ui-blue-soft);
    color: var(--ui-blue-strong);
    outline: none;
  }

  .mobile-sidebar-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  .document-meta {
    grid-area: document;
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    flex-basis: auto !important;
    text-align: left !important;
  }

  .document-meta .eyebrow,
  #saveState {
    display: none !important;
  }

  .document-meta h2 {
    width: 100%;
    max-width: 100% !important;
    overflow: hidden;
    margin: 0;
    color: var(--ui-text);
    font-size: 14px;
    line-height: 34px;
    text-align: left !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ribbon-tabs {
    grid-area: tabs;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100% !important;
    overflow: visible !important;
    gap: 2px !important;
  }

  .ribbon-tabs button {
    min-width: 0;
    min-height: 30px !important;
    padding: 0 3px !important;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .formatbar {
    display: block;
    min-height: 42px !important;
    padding: 5px 8px !important;
    overflow: hidden !important;
  }

  .ribbon-panel {
    width: 100%;
    min-height: 32px;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .ribbon-panel::-webkit-scrollbar {
    display: none;
  }

  .ribbon-panel[hidden] {
    display: none !important;
  }

  .formatbar button,
  .formatbar .select-trigger {
    min-height: 32px !important;
  }

  [data-ribbon-panel="style"] [data-format="h4"],
  [data-ribbon-panel="style"] [data-format="h5"],
  [data-ribbon-panel="style"] [data-format="h6"],
  [data-ribbon-panel="style"] [data-format="h7"],
  #imageSizeDown,
  #imageSizeValue,
  #imageSizeUp,
  [data-view-mode="split"],
  #tocToggle,
  [data-ribbon-panel="page"] [data-zoom],
  #zoomValue,
  .page-zoom-control,
  .toc-panel {
    display: none !important;
  }

  #viewModeSwitch {
    grid-template-columns: repeat(2, minmax(64px, 1fr));
    flex: 0 0 auto;
  }

  .editor-shell {
    min-height: 0 !important;
    flex: 1 1 auto;
  }

  body[data-view="split"] .editor-shell {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-view="split"] .editor-pane {
    display: none !important;
  }

  #sourceEditor {
    padding: 18px 16px;
    font-size: 14px;
  }

  body[data-page="fluid"] .preview-pane,
  .preview-pane {
    padding: 22px 16px !important;
  }

  .markdown-body {
    font-size: 15px;
    line-height: 1.68;
  }

  .markdown-body h1 {
    font-size: 28px;
    line-height: 1.24;
  }

  .markdown-body h2 {
    font-size: 23px;
  }

  .markdown-body h3 {
    font-size: 19px;
  }

  .dialog,
  .history-dialog,
  .folder-link-dialog {
    width: calc(100% - 24px) !important;
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }

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

  .toast {
    width: 100%;
  }
}

/* Toolbar hierarchy and command grouping. */
.topbar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 52px !important;
  align-items: center !important;
  gap: 16px !important;
  padding: 7px 12px !important;
}

.document-meta {
  order: initial !important;
  display: block !important;
  min-width: 0 !important;
  text-align: left !important;
}

.document-meta .eyebrow {
  display: block !important;
  margin: 0 0 2px;
  color: #7b8798;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.1;
  text-transform: none;
}

.document-meta h2 {
  max-width: min(620px, 48vw) !important;
  color: #172033;
  font-size: 15px;
  line-height: 1.25;
  text-align: left !important;
}

.document-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#saveState.save-state {
  position: relative;
  order: initial;
  display: inline-flex !important;
  min-height: 30px;
  max-width: 230px;
  align-items: center;
  margin: 0 !important;
  padding: 0 10px 0 25px !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  color: #64748b;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

#saveState.save-state::before {
  position: absolute;
  left: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  content: "";
}

#saveState[data-state="saving"]::before {
  background: #f59e0b;
  box-shadow: 0 0 0 3px #fef3c7;
}

#saveState[data-state="saved"]::before {
  background: #10b981;
}

#saveState[data-state="error"] {
  color: #b42318;
}

#saveState[data-state="error"]::before {
  background: #ef4444;
}

.storage-select .select-trigger {
  min-width: 116px;
  min-height: 32px !important;
  padding: 0 7px 0 10px;
  border: 0 !important;
  border-radius: 8px !important;
  background: #f3f6fa !important;
  box-shadow: none !important;
  color: #475467;
}

.storage-select .select-trigger:hover {
  background: #eaf2ff !important;
  color: var(--ui-blue-strong);
}

.storage-select .select-caret,
.heading-select .select-caret {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  border: 0;
  background: transparent;
}

.public-mode-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 7px;
  background: #ecfdf3;
  color: #047857;
  font-size: 11px;
  font-weight: 800;
}

.top-save-button {
  min-width: 66px;
  min-height: 32px !important;
  padding: 0 14px;
  border: 0 !important;
  border-radius: 8px !important;
  background: var(--ui-blue) !important;
  box-shadow: none !important;
  color: #fff !important;
  font-size: 12px;
}

.top-save-button:hover:not(:disabled) {
  background: var(--ui-blue-strong) !important;
  box-shadow: none !important;
  transform: none !important;
}

.top-save-button:disabled {
  background: #e8edf4 !important;
  color: #98a2b3 !important;
  opacity: 1;
}

.ribbon-nav {
  position: relative;
  z-index: 19;
  display: flex;
  min-height: 35px;
  align-items: end;
  gap: 12px;
  padding: 3px 12px 0;
  border-bottom: 1px solid var(--ui-line-soft);
  background: #fff;
}

.ribbon-tabs {
  order: initial;
  display: inline-flex;
  width: auto;
  flex: 0 0 auto;
  justify-content: flex-start !important;
  gap: 2px !important;
  margin: 0 !important;
  overflow: visible;
}

.ribbon-tabs button {
  position: relative;
  min-width: 58px;
  min-height: 31px !important;
  padding: 0 12px !important;
  border: 0 !important;
  border-radius: 7px 7px 0 0 !important;
  background: transparent !important;
  color: #667085;
}

.ribbon-tabs button:hover {
  background: #f5f8fc !important;
  color: #175cd3;
}

.ribbon-tabs button.active {
  background: #eef5ff !important;
  color: #175cd3 !important;
}

.ribbon-tabs button.active::after {
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--ui-blue);
  content: "";
}

.ribbon-tabs button:focus-visible {
  outline: 2px solid rgba(0, 113, 227, 0.34);
  outline-offset: -2px;
}

.formatbar {
  display: flex;
  min-height: 46px !important;
  align-items: center;
  padding: 6px 12px !important;
  overflow: visible;
  border-bottom-color: var(--ui-line-soft) !important;
  background: #f8fafc !important;
}

.ribbon-panel {
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start !important;
  gap: 8px;
  flex-wrap: nowrap;
}

.command-group {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.command-divider {
  width: 1px;
  height: 24px;
  flex: 0 0 1px;
  margin: 0 2px;
  background: #dfe5ed;
}

.command-hint {
  color: #7b8798;
  font-size: 11px;
  white-space: nowrap;
}

.heading-select .select-trigger {
  min-width: 108px;
  min-height: 32px !important;
  padding: 0 6px 0 10px;
  border: 0 !important;
  border-radius: 7px !important;
  background: #fff !important;
  box-shadow: inset 0 0 0 1px #e2e8f0 !important;
}

.heading-select .select-trigger:hover:not(:disabled) {
  background: #edf4ff !important;
  box-shadow: inset 0 0 0 1px #c7dcff !important;
}

.formatbar button,
.toolbar .secondary-button,
.toolbar .danger-button {
  min-height: 32px !important;
  padding: 0 9px;
}

.formatbar button:disabled,
.formatbar .select-trigger:disabled {
  color: #a9b2c0 !important;
  opacity: 1;
}

.image-command-group .image-size-value {
  min-width: 42px;
  color: #475467;
  font-size: 11px;
  text-align: center;
}

.history-dialog {
  width: min(520px, calc(100vw - 32px));
}

.history-list {
  display: grid;
  max-height: min(430px, 56vh);
  gap: 6px;
  overflow: auto;
  margin: 16px 0;
}

.history-item {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 8px 8px 12px;
  border: 1px solid #e5eaf1;
  border-radius: 10px;
  background: #f8fafc;
}

.history-item-meta {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.history-item-meta strong {
  color: #27364a;
  font-size: 12px;
}

.history-item-meta span,
.history-empty {
  color: #7b8798;
  font-size: 11px;
}

.history-empty {
  padding: 28px 16px;
  border: 1px dashed #d5dce7;
  border-radius: 10px;
  background: #f8fafc;
  text-align: center;
}

@media (max-width: 1100px) {
  .button-label {
    display: none;
  }

  #saveState.save-state {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 820px) {
  .topbar {
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas: "sidebar document actions";
    min-height: 50px !important;
    gap: 8px !important;
    padding: 6px 10px !important;
  }

  .document-meta {
    grid-area: document;
  }

  .document-meta .eyebrow,
  #saveState.save-state,
  .storage-select,
  .public-mode-badge {
    display: none !important;
  }

  .document-meta h2 {
    max-width: 100% !important;
    line-height: 34px;
  }

  .document-actions {
    grid-area: actions;
  }

  .top-save-button {
    min-width: 56px;
  }

  .ribbon-nav {
    min-height: 36px;
    padding: 3px 8px 0;
    overflow: hidden;
  }

  .ribbon-tabs {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ribbon-tabs button {
    min-width: 0;
    padding: 0 4px !important;
  }

  .formatbar {
    min-height: 44px !important;
    padding: 5px 8px !important;
    overflow: hidden !important;
  }

  .ribbon-panel {
    gap: 6px;
  }

  .command-divider {
    margin: 0;
  }

  [data-ribbon-panel="view"] [data-zoom],
  [data-ribbon-panel="view"] #zoomValue,
  .image-command-group {
    display: none !important;
  }
}
