@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700&family=Source+Serif+4:opsz,wght@8..60,400;500;600&display=swap");

:root {
  color-scheme: light;
  --reading-progress: 0%;
  --bg: #f1efeb;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-soft: rgba(246, 245, 241, 0.97);
  --panel-ink: #ffffff;
  --line: rgba(36, 37, 42, 0.08);
  --line-strong: rgba(36, 37, 42, 0.14);
  --text: #1f1f21;
  --text-soft: #72727b;
  --accent: #17191e;
  --accent-deep: #0f1013;
  --accent-soft: rgba(23, 25, 30, 0.1);
  --mint-soft: rgba(23, 25, 30, 0.05);
  --brand-warm: #bea070;
  --brand-warm-soft: rgba(190, 160, 112, 0.16);
  --brand-ink-soft: rgba(23, 25, 30, 0.08);
  --danger: #d84f4f;
  --shadow: 0 22px 56px rgba(33, 33, 36, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-ui: "Manrope", "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", sans-serif;
  --font-reading: "Source Serif 4", "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
  --editor-gutter: clamp(18px, 4vw, 48px);
  --document-width: 860px;
  --sidebar-width: 320px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: none;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at top left, rgba(190, 160, 112, 0.08), transparent 22%),
    radial-gradient(circle at right 18%, rgba(23, 25, 30, 0.05), transparent 26%),
    linear-gradient(180deg, #f8f7f4 0%, var(--bg) 100%);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-image-viewer="open"] {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

.format-glyph,
.format-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
}

.format-glyph {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.format-glyph-italic {
  font-style: italic;
}

.format-glyph-underline {
  text-decoration: underline;
  text-decoration-thickness: 1.4px;
  text-underline-offset: 0.16em;
}

.format-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.page {
  width: min(1520px, calc(100vw - 28px));
  margin: 14px auto 16px;
  min-height: calc(100vh - 28px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px 12px;
  position: sticky;
  top: 0;
  z-index: 30;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(249, 249, 246, 0.94), rgba(249, 249, 246, 0.8));
  box-shadow: 0 12px 28px rgba(33, 33, 36, 0.04);
  backdrop-filter: blur(16px);
}

.topbar-main,
.topbar-actions,
.topbar-meta,
.action-group {
  display: flex;
  align-items: center;
}

.topbar-main,
.topbar-actions {
  gap: 8px;
}

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

.topbar-meta,
.action-group {
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 74% 34%, rgba(255, 255, 255, 0.24), transparent 18%),
    linear-gradient(145deg, #272a31 0%, var(--accent-deep) 100%);
  box-shadow:
    0 10px 24px rgba(16, 17, 22, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-warm);
  box-shadow: 0 0 0 5px rgba(190, 160, 112, 0.12);
}

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

.brand-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-sub {
  color: var(--text-soft);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-soft);
  font-size: 0.72rem;
  gap: 6px;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.72;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #6e675e;
  font-size: 0.72rem;
  font-weight: 600;
  gap: 6px;
  box-shadow: 0 8px 20px rgba(33, 33, 36, 0.04);
}

button.sync-chip {
  appearance: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

button.sync-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(33, 33, 36, 0.08);
}

.sync-chip[hidden] {
  display: none !important;
}

.sync-chip .ui-icon {
  width: 15px;
  height: 15px;
}

.sync-chip[data-state="saved"] {
  color: #6f695f;
}

.sync-chip[data-state="pending"] {
  color: var(--accent-deep);
  background: var(--brand-warm-soft);
}

.sync-chip[data-state="offline"] {
  color: #7d6b4d;
  background: rgba(190, 160, 112, 0.12);
}

.sync-chip[data-state="syncing"] {
  color: var(--accent);
  background: var(--brand-warm-soft);
}

.encrypt-chip {
  color: #4e525d;
  background: rgba(240, 240, 237, 0.9);
}

@keyframes syncChipSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.sync-chip[data-state="syncing"] .ui-icon {
  animation: syncChipSpin 1.05s linear infinite;
}

body[data-online="online"] .status-pill {
  background: var(--brand-warm-soft);
  color: var(--accent);
}

body[data-online="offline"] .status-pill {
  color: var(--text);
}

.lang-toggle-btn {
  min-height: 28px;
  padding: 0 10px;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.7);
}

.lang-toggle-btn .ui-icon {
  width: 15px;
  height: 15px;
}

.lang-toggle-text {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.btn,
.icon-btn,
.dock-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.btn:hover,
.icon-btn:hover,
.dock-btn:hover {
  transform: translateY(-1px);
}

.btn {
  min-height: 30px;
  padding: 0 10px;
  font-weight: 600;
  font-size: 0.8rem;
}

.btn.primary {
  background: linear-gradient(180deg, #23262d 0%, var(--accent-deep) 100%);
  color: #faf7f1;
  box-shadow: 0 12px 22px rgba(16, 17, 22, 0.18);
}

.btn.ghost,
.btn.subtle,
.icon-btn,
.dock-btn {
  background: transparent;
  color: var(--text);
}

.btn.subtle {
  color: #6d675f;
}

.icon-action-btn,
.icon-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-cluster {
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(33, 33, 36, 0.04);
}

.action-cluster .btn.subtle {
  min-height: 28px;
  padding: 0 12px;
}

.action-cluster .btn.primary {
  min-height: 28px;
  padding: 0 13px;
}

.action-cluster .btn.icon-action-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.btn.subtle-danger {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(216, 79, 79, 0.12);
  border-radius: 999px;
  background: rgba(216, 79, 79, 0.06);
  color: var(--danger);
  flex-shrink: 0;
  white-space: nowrap;
  opacity: 0.9;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease,
    transform 0.16s ease;
}

.btn.subtle-danger:hover {
  background: rgba(216, 79, 79, 0.1);
  border-color: rgba(216, 79, 79, 0.18);
  opacity: 1;
}

.btn.subtle-danger.confirming {
  background: rgba(216, 79, 79, 0.14);
  border-color: rgba(216, 79, 79, 0.28);
  color: #b43737;
}

.btn.subtle-danger.icon-action-btn {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.btn.subtle-danger:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 17, 22, 0.34);
  backdrop-filter: blur(14px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: rgba(249, 248, 244, 0.96);
  box-shadow: 0 28px 60px rgba(20, 21, 24, 0.16);
  display: grid;
  gap: 14px;
}

.modal-copy {
  display: grid;
  gap: 6px;
}

.modal-eyebrow {
  color: #7a746b;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-title {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.03em;
}

.modal-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.6;
}

.modal-hint {
  color: #7d766c;
  font-size: 0.76rem;
  line-height: 1.5;
}

.modal-error {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(216, 79, 79, 0.08);
  color: #a33f3f;
  font-size: 0.78rem;
  line-height: 1.5;
}

.field-group {
  display: grid;
  gap: 7px;
}

.field-group[hidden] {
  display: none !important;
}

.field-label {
  color: #5f5c56;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.field-input {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(36, 37, 42, 0.08);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field-input:focus {
  border-color: rgba(23, 25, 30, 0.12);
  box-shadow: 0 0 0 4px rgba(23, 25, 30, 0.06);
  background: #fff;
}

.field-input[readonly] {
  color: #78746e;
  background: rgba(248, 245, 239, 0.9);
  cursor: default;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 10px;
  min-height: calc(100vh - 112px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  transition: grid-template-columns 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.sidebar,
.editor {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  inset: 16px auto 16px 16px;
  width: min(320px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 10px 0 0;
  transform: translateX(-110%);
  transition: transform 0.22s ease;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(249, 249, 246, 0.99), rgba(243, 243, 239, 0.96)),
    var(--panel-soft);
  box-shadow: 0 24px 60px rgba(33, 33, 36, 0.1);
  backdrop-filter: blur(18px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 12px 18px 14px;
  background: linear-gradient(180deg, rgba(252, 252, 249, 0.98), rgba(252, 252, 249, 0.94));
  border-bottom: 1px solid rgba(36, 37, 42, 0.04);
}

.sidebar-head-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-hint {
  color: #8d877d;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-meta {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #686a72;
  font-size: 0.7rem;
}

.search {
  position: sticky;
  top: 46px;
  z-index: 2;
  padding: 12px 12px 12px;
  background: linear-gradient(180deg, rgba(252, 252, 249, 0.98), rgba(252, 252, 249, 0.94));
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: #8f9198;
  pointer-events: none;
}

.search-icon .ui-icon {
  width: 15px;
  height: 15px;
  stroke-width: 1.85;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border: 1px solid rgba(36, 37, 42, 0.04);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  outline: none;
  color: var(--text);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.search input:focus,
#titleInput:focus,
#contentInput:focus {
  background: #fff;
}

.search input:focus {
  border-color: rgba(23, 25, 30, 0.12);
  box-shadow: 0 0 0 4px rgba(23, 25, 30, 0.06);
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0;
  overflow: auto;
  padding: 4px 12px 18px;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.note-list::-webkit-scrollbar {
  display: none;
}

.note-group-label {
  margin: 14px 6px 4px;
  padding: 0 4px;
  color: #8a8a92;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.note-list > .note-group-label:first-child {
  margin-top: 2px;
}

.note-card {
  position: relative;
  margin: 0;
  padding: 12px 14px 12px 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease,
    opacity 0.16s ease;
  outline: none;
}

.note-card.state-synced {
  background: transparent;
}

.note-card.state-local {
  background: rgba(23, 25, 30, 0.04);
}

.note-card.state-dirty {
  background: rgba(23, 25, 30, 0.055);
}

.note-card.state-conflict {
  background: rgba(216, 79, 79, 0.06);
}

.note-card:hover {
  background: rgba(255, 255, 255, 0.74);
  border-color: rgba(36, 37, 42, 0.04);
}

.note-card.active {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(36, 37, 42, 0.05);
  box-shadow: 0 10px 24px rgba(33, 33, 36, 0.05);
  transform: translateX(2px);
}

.note-card.active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 5px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2b2f37 0%, var(--accent-deep) 100%);
  transform: translateY(-50%);
}

.note-card.active::after {
  display: none;
}

.note-card:focus-visible {
  border-color: rgba(23, 25, 30, 0.14);
  box-shadow: 0 0 0 3px rgba(23, 25, 30, 0.08);
}

.note-card.empty-state {
  cursor: default;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 184px;
  color: var(--text-soft);
  padding: 28px 20px;
  text-align: center;
  background:
    radial-gradient(circle at top, rgba(190, 160, 112, 0.1), transparent 42%),
    rgba(255, 255, 255, 0.86);
}

.note-card.fresh {
  animation: noteFreshIn 560ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.note-card.empty-state:hover {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(60, 60, 67, 0.05);
}

.empty-illustration {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 72% 28%, rgba(190, 160, 112, 0.18), transparent 22%),
    linear-gradient(145deg, rgba(31, 33, 39, 0.96), rgba(15, 16, 19, 1));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 12px 28px rgba(18, 19, 24, 0.14);
  position: relative;
}

.empty-illustration::before,
.empty-illustration::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.empty-illustration::before {
  left: 8px;
  top: 18px;
  width: 22px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.empty-illustration::after {
  right: 7px;
  top: 14px;
  width: 10px;
  height: 10px;
  background: var(--brand-warm);
  box-shadow: 0 0 0 6px rgba(190, 160, 112, 0.12);
}

.empty-title {
  color: #4d483f;
  font-size: 0.84rem;
  font-weight: 600;
}

.empty-hint {
  max-width: 180px;
  line-height: 1.45;
  font-size: 0.74rem;
}

.note-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.note-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.34;
  letter-spacing: -0.01em;
}

.note-card:hover .note-title-text,
.note-card.active .note-title-text {
  color: #22252c;
}

.note-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(36, 37, 42, 0.05);
  color: var(--text-soft);
  font-size: 0.68rem;
}

.state-local .note-tag {
  background: rgba(23, 25, 30, 0.08);
  color: #4f535d;
}

.state-dirty .note-tag {
  background: var(--brand-warm-soft);
  color: var(--accent-deep);
}

.state-conflict .note-tag {
  background: rgba(216, 79, 79, 0.14);
  color: #b14545;
}

.note-time,
.note-preview {
  color: var(--text-soft);
}

.note-time {
  font-size: 0.67rem;
  white-space: nowrap;
  padding-top: 2px;
  letter-spacing: 0.02em;
}

.note-card.active .note-time {
  color: #4f5560;
}

.note-preview {
  margin-top: 6px;
  line-height: 1.42;
  font-size: 0.74rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.88;
}

.note-card.active .note-preview {
  color: #555a64;
  opacity: 0.96;
}

.editor {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: transparent;
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px var(--editor-gutter) 8px;
  border-bottom: 0;
  background: transparent;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.delete-notice {
  position: sticky;
  top: 74px;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(100%, var(--document-width));
  margin: 0 auto 10px;
  padding: 12px 14px;
  border: 1px solid rgba(216, 79, 79, 0.09);
  border-radius: 18px;
  background: rgba(255, 248, 248, 0.96);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 32px rgba(216, 79, 79, 0.08);
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.delete-notice[hidden] {
  display: none !important;
}

.delete-notice-copy {
  min-width: 0;
}

.delete-notice-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #7d2828;
}

.delete-notice-text {
  margin-top: 4px;
  color: #7f6363;
  font-size: 0.74rem;
  line-height: 1.45;
}

.delete-notice-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.delete-confirm-btn {
  min-width: 84px;
}

.editor-toolbar-inner,
.editor-footer-inner {
  width: min(100%, var(--document-width));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-toolbar-inner {
  justify-content: space-between;
}

.editor-footer-inner {
  justify-content: flex-start;
  align-items: center;
}

.editor-toolbar-copy,
.editor-toolbar-actions,
.editor-meta-row,
.doc-stats,
.quick-insert-bar {
  display: flex;
  align-items: center;
}

.editor-toolbar-copy {
  min-width: 0;
  flex: 1;
  gap: 12px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.editor-toolbar-actions {
  gap: 8px;
}

.editor-toolbar-actions .btn.icon-action-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
}

.icon-action-btn.is-active {
  background: rgba(23, 25, 30, 0.08);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(23, 25, 30, 0.08);
}

.editor-state-sub {
  color: var(--text-soft);
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  width: min(100%, var(--document-width));
  margin: 0 auto;
  padding: 42px var(--editor-gutter) 16px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.editor-header-top,
.editor-meta-row {
  justify-content: space-between;
  gap: 14px;
}

.editor-header-top {
  display: flex;
  align-items: flex-start;
}

.editor-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 4px;
}

.editor-stage-badge,
.stat-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(36, 37, 42, 0.06);
  background: rgba(248, 248, 245, 0.92);
  color: #6a6a73;
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
}

.editor-stage-badge {
  box-shadow: none;
}

body[data-mode="empty"] .editor-stage-badge,
body[data-mode="empty"] .doc-stats,
body[data-mode="empty"] .focus-exit-btn {
  display: none !important;
}

.editor-stage-badge[data-state="synced"] {
  color: #4f535d;
  background: rgba(244, 244, 241, 0.98);
}

.editor-stage-badge[data-state="dirty"] {
  color: var(--accent);
  background: rgba(243, 241, 237, 0.98);
}

.editor-stage-badge[data-state="local"] {
  color: var(--accent);
  background: rgba(243, 241, 237, 0.98);
}

.editor-stage-badge[data-state="conflict"] {
  color: #b14545;
  background: rgba(255, 236, 236, 0.94);
}

.doc-stats {
  gap: 8px;
  flex-wrap: wrap;
}

.doc-stats .stat-chip {
  background: rgba(247, 247, 244, 0.96);
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y pinch-zoom;
  scroll-padding-top: 18px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: none;
}

.editor-scroll::-webkit-scrollbar {
  display: none;
}

.editor-scroll,
.editor-document {
  cursor: text;
}

.editor-document {
  width: min(100%, calc(var(--document-width) + (var(--editor-gutter) * 2)));
  min-height: 100%;
  margin: 0 auto;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(251, 251, 249, 0.98)),
    var(--panel-ink);
  box-shadow: 0 18px 44px rgba(33, 33, 36, 0.06);
  overflow: hidden;
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.editor-document::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0) 14%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0) 56%);
  pointer-events: none;
}

.editor-document::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--reading-progress);
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(23, 25, 30, 0.72), rgba(190, 160, 112, 0.96));
  opacity: 0;
  pointer-events: none;
  transition: width 0.12s linear, opacity 0.18s ease;
}

@keyframes noteFreshIn {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
    box-shadow: 0 12px 24px rgba(190, 137, 33, 0.12);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#titleInput {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-reading);
  font-size: clamp(2.1rem, 4vw, 2.85rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  outline: none;
  line-height: 1.12;
}

body[data-lang="zh"] #titleInput {
  font-family: "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-weight: 700;
  letter-spacing: -0.035em;
}

#titleInput:disabled {
  color: #a09c93;
  cursor: default;
}

.meta {
  color: var(--text-soft);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.editor-body {
  display: block;
  margin-top: 2px;
  min-height: 100%;
}

.editor-body::before {
  content: "";
  display: block;
  width: min(100%, var(--document-width));
  margin: 0 auto;
  border-top: 1px solid rgba(36, 37, 42, 0.05);
}

.rich-toolbar-shell {
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 12px var(--editor-gutter) 0;
  background: linear-gradient(180deg, rgba(252, 252, 249, 0.94), rgba(252, 252, 249, 0.72) 72%, transparent);
  backdrop-filter: blur(10px);
  transition: background 0.18s ease, backdrop-filter 0.18s ease, box-shadow 0.18s ease;
}

.command-surface {
  width: min(100%, var(--document-width));
  margin: 0 auto;
  padding: 0 0 10px;
  border-bottom: 1px solid rgba(36, 37, 42, 0.05);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: fit-content;
  margin: 0;
  padding: 4px;
  border: 1px solid rgba(36, 37, 42, 0.05);
  border-radius: 999px;
  background: rgba(245, 245, 242, 0.94);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.command-tray {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: fit-content;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid rgba(36, 37, 42, 0.05);
  border-radius: 18px;
  background: rgba(247, 247, 244, 0.96);
  box-shadow: 0 12px 24px rgba(33, 33, 36, 0.06);
}

#moreToolsBtn,
.command-tray,
.bubble-menu,
.floating-menu {
  display: none !important;
}

.bubble-menu[hidden],
.floating-menu[hidden] {
  display: none !important;
}

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

.tray-btn {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #3a3a40;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.tray-btn:hover {
  background: rgba(36, 37, 42, 0.06);
  transform: translateY(-1px);
}

.tray-btn.is-active {
  background: rgba(200, 138, 43, 0.12);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(200, 138, 43, 0.12);
}

.tray-btn:disabled {
  opacity: 0.46;
  cursor: default;
  transform: none;
}

.tool-btn {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #3a3a40;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tool-btn:hover {
  transform: translateY(-1px);
  background: rgba(36, 37, 42, 0.06);
  box-shadow: none;
}

.tool-btn.is-active {
  background: rgba(23, 25, 30, 0.08);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(23, 25, 30, 0.08);
}

.tool-btn:disabled {
  opacity: 0.46;
  cursor: default;
  transform: none;
}

.tool-btn-accent {
  background: rgba(23, 25, 30, 0.08);
  color: var(--accent);
}

.tool-divider {
  width: 1px;
  height: 22px;
  background: rgba(60, 60, 67, 0.1);
}

.editor-tip {
  display: none;
  width: 100%;
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.45;
  opacity: 0.82;
  padding-left: 2px;
}

body[data-note-body="empty"][data-mode="editing"] .editor-tip,
body[data-note-body="empty"][data-mode="focus"] .editor-tip {
  display: block;
}

.bubble-menu,
.floating-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: max-content;
  max-width: min(92vw, 520px);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: rgba(252, 252, 249, 0.94);
  backdrop-filter: blur(18px);
  box-shadow:
    0 20px 40px rgba(43, 40, 31, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.slash-menu {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 25;
  width: min(320px, calc(100% - 24px));
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: rgba(252, 250, 246, 0.94);
  backdrop-filter: blur(22px);
  box-shadow:
    0 26px 48px rgba(43, 40, 31, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.slash-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.slash-item:hover,
.slash-item.is-active {
  background: rgba(47, 111, 95, 0.1);
  transform: translateY(-1px);
}

.slash-item-copy {
  display: grid;
  gap: 3px;
}

.slash-item-icon {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 12px;
  background: rgba(36, 37, 42, 0.05);
  color: #4d4d56;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slash-item-icon .ui-icon {
  width: 16px;
  height: 16px;
}

.slash-item-icon-text {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.slash-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #223046;
}

.slash-item-desc {
  color: var(--text-soft);
  font-size: 0.73rem;
  line-height: 1.45;
}

.slash-empty {
  padding: 12px;
}

.slash-empty-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #223046;
}

.slash-empty-copy {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 0.73rem;
  line-height: 1.45;
}

.menu-chip {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 17, 34, 0.05);
  color: #253246;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.menu-chip:hover {
  transform: translateY(-1px);
  background: rgba(36, 37, 42, 0.06);
}

.menu-chip.is-active {
  background: rgba(23, 25, 30, 0.08);
  color: var(--accent);
}

.menu-chip-accent {
  background: rgba(23, 25, 30, 0.08);
  color: var(--accent);
}

.rich-editor-shell {
  position: relative;
  padding: 22px var(--editor-gutter) 42px;
}

.editor-empty-state {
  display: none;
  place-items: center;
  gap: 12px;
  width: min(100%, var(--document-width));
  min-height: 360px;
  margin: 0 auto;
  padding: 32px;
  border: 1px solid rgba(36, 37, 42, 0.05);
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(190, 160, 112, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 248, 245, 0.9));
  text-align: center;
  box-shadow:
    0 24px 48px rgba(33, 33, 36, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.empty-doc-mark {
  width: 56px;
  height: 56px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 74% 30%, rgba(190, 160, 112, 0.24), transparent 20%),
    linear-gradient(145deg, #272a31 0%, var(--accent-deep) 100%);
  box-shadow:
    0 16px 34px rgba(16, 17, 22, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}

.empty-doc-mark::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  width: 24px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.empty-doc-mark::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand-warm);
  box-shadow: 0 0 0 8px rgba(190, 160, 112, 0.12);
}

.empty-doc-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-doc-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(23, 25, 30, 0.06);
  color: #5a5f69;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.empty-doc-copy {
  max-width: 440px;
  color: var(--text-soft);
  line-height: 1.6;
  font-size: 0.9rem;
}

body[data-mode="empty"] .editor-empty-state {
  display: grid;
}

body[data-mode="empty"] .rich-editor-shell #contentInput {
  display: none;
}

body[data-mode="empty"] .rich-editor-shell .bubble-menu,
body[data-mode="empty"] .rich-editor-shell .floating-menu,
body[data-mode="empty"] .rich-editor-shell .slash-menu {
  display: none !important;
}

#contentInput {
  width: min(100%, var(--document-width));
  margin: 0 auto;
  min-height: calc(100vh - 360px);
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.86;
  font-size: 1.04rem;
  outline: none;
  box-shadow: none;
  scrollbar-width: none;
}

#contentInput::-webkit-scrollbar {
  display: none;
}

#titleInput::placeholder,
.search input::placeholder {
  color: #9a9aa2;
}

.rich-editor .ProseMirror {
  min-height: calc(100vh - 360px);
  padding: 8px 0 84px;
  font-family: var(--font-reading);
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.rich-editor .ProseMirror > * {
  max-width: 660px;
  margin-left: auto;
  margin-right: auto;
}

body[data-lang="zh"] .rich-editor .ProseMirror {
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  font-size: 1.03rem;
  line-height: 1.94;
  letter-spacing: 0.01em;
}

body[data-lang="zh"] .rich-editor .ProseMirror p + p {
  margin-top: 0.18em;
}

body[data-lang="en"] .rich-editor .ProseMirror {
  line-height: 1.82;
}

.rich-editor .ProseMirror > *:first-child {
  margin-top: 0;
}

.rich-editor .ProseMirror > * + * {
  margin-top: 0.8em;
}

.rich-editor .ProseMirror p,
.rich-editor .ProseMirror li,
.rich-editor .ProseMirror blockquote,
.rich-editor .ProseMirror pre {
  font-size: 1rem;
}

.rich-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: #9a9aa2;
  pointer-events: none;
  float: left;
  height: 0;
}

.rich-editor .ProseMirror h2 {
  margin: 1.35em 0 0.5em;
  font-size: 1.52rem;
  line-height: 1.3;
}

.rich-editor .ProseMirror h3 {
  margin: 1.1em 0 0.42em;
  font-size: 1.18rem;
  line-height: 1.36;
}

.rich-editor .ProseMirror ul,
.rich-editor .ProseMirror ol {
  padding-left: 1.4em;
}

.rich-editor .ProseMirror blockquote {
  margin-left: 0;
  padding: 0.26em 1em;
  border-left: 3px solid rgba(23, 25, 30, 0.18);
  color: #575760;
  background: rgba(23, 25, 30, 0.04);
  border-radius: 0 14px 14px 0;
}

.rich-editor .ProseMirror mark {
  padding: 0.12em 0.22em;
  border-radius: 0.32em;
  background: rgba(190, 160, 112, 0.24);
}

.rich-editor .ProseMirror pre {
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 16px;
  background: #211b12;
  color: #f8f2df;
  line-height: 1.6;
}

.rich-editor .ProseMirror code {
  padding: 0.15em 0.38em;
  border-radius: 8px;
  background: rgba(60, 60, 67, 0.08);
  font-size: 0.92em;
}

.rich-editor .ProseMirror pre code {
  padding: 0;
  background: transparent;
}

.rich-editor .ProseMirror hr {
  margin: 1.35em 0;
  border: 0;
  border-top: 1px solid rgba(60, 60, 67, 0.12);
}

.rich-editor .ProseMirror a {
  color: var(--accent);
  text-decoration-color: rgba(23, 25, 30, 0.18);
  text-underline-offset: 0.18em;
}

.rich-editor .ProseMirror ul[data-type="taskList"] {
  padding-left: 0;
  list-style: none;
}

.rich-editor .ProseMirror ul[data-type="taskList"] li {
  display: flex;
  gap: 10px;
  margin: 0.5em 0;
}

.rich-editor .ProseMirror ul[data-type="taskList"] li > label {
  padding-top: 0.22em;
}

.rich-editor .ProseMirror ul[data-type="taskList"] li > div {
  flex: 1;
  min-width: 0;
}

.rich-editor .ProseMirror img {
  display: block;
  max-width: min(100%, 760px);
  width: auto;
  height: auto;
  margin: 26px auto;
  border-radius: 18px;
  border: 1px solid rgba(23, 25, 30, 0.06);
  box-shadow: 0 20px 40px rgba(33, 33, 36, 0.08);
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}

.rich-editor .ProseMirror img:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 52px rgba(33, 33, 36, 0.12);
}

.rich-editor .ProseMirror img.ProseMirror-selectednode {
  border-color: rgba(23, 25, 30, 0.16);
  box-shadow:
    0 26px 56px rgba(33, 33, 36, 0.14),
    0 0 0 4px rgba(23, 25, 30, 0.08);
  filter: saturate(1.02);
}

.editor-footer {
  padding: 10px var(--editor-gutter) 14px;
  border-top: 0;
  background: linear-gradient(180deg, rgba(249, 249, 246, 0), rgba(249, 249, 246, 0.76));
  transition: opacity 0.18s ease;
}

.status {
  color: var(--text-soft);
  font-size: 0.71rem;
  opacity: 0.84;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.02em;
}

#statusText {
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(36, 37, 42, 0.05);
  box-shadow: 0 8px 18px rgba(33, 33, 36, 0.03);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.status-meta {
  margin-left: auto;
  text-align: right;
}

#statusText::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.7;
}

#statusText[data-tone="success"] {
  color: #2d6a46;
  background: rgba(235, 247, 238, 0.92);
  border-color: rgba(45, 106, 70, 0.08);
}

#statusText[data-tone="success"]::before {
  background: #2d6a46;
}

#statusText[data-tone="warning"] {
  color: #80653a;
  background: rgba(249, 242, 229, 0.94);
  border-color: rgba(128, 101, 58, 0.08);
}

#statusText[data-tone="warning"]::before {
  background: #b28b48;
}

#statusText[data-tone="danger"] {
  color: #a33f3f;
  background: rgba(253, 241, 241, 0.96);
  border-color: rgba(163, 63, 63, 0.08);
}

#statusText[data-tone="danger"]::before {
  background: #d84f4f;
}

#statusText[data-tone="progress"] {
  color: var(--accent-deep);
  background: rgba(243, 241, 237, 0.94);
  border-color: rgba(23, 25, 30, 0.06);
}

@keyframes savingPulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.94);
  }

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

body[data-saving="true"] #statusText {
  color: var(--accent-deep);
}

body[data-saving="true"] #statusText::before {
  animation: savingPulse 1.1s ease-in-out infinite;
}

body[data-editor-active="true"] .editor-document {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 28px 70px rgba(33, 33, 36, 0.1);
  transform: translateY(-1px);
}

body[data-switching="true"] .editor-document {
  transform: translateY(-3px) scale(0.998);
  box-shadow: 0 34px 82px rgba(33, 33, 36, 0.12);
}

body[data-editor-active="true"] .editor-state-sub {
  color: #5f6068;
}

body[data-scrollable="true"] .editor-document::after {
  opacity: 0.88;
}

body[data-editor-active="true"][data-scrolled="true"] .editor-header {
  opacity: 0.92;
  transform: translateY(-2px);
}

body[data-editor-active="true"][data-scrolled="true"] .editor-meta-row,
body[data-editor-active="true"][data-scrolled="true"] .editor-stage-badge,
body[data-editor-active="true"][data-scrolled="true"] .doc-stats {
  opacity: 0.78;
}

body[data-scrolled="true"] .topbar {
  padding-top: 8px;
  padding-bottom: 9px;
}

body[data-editor-active="true"][data-scrolled="true"] .sidebar {
  opacity: 0.94;
}

body[data-editor-active="true"][data-scrolled="true"] .editor-toolbar-copy {
  opacity: 0.52;
  transform: translateY(-1px);
}

body[data-editor-active="true"][data-scrolled="true"] .editor-footer {
  opacity: 0.76;
}

body[data-scrolled="true"] .rich-toolbar-shell {
  background: linear-gradient(180deg, rgba(252, 252, 249, 0.98), rgba(252, 252, 249, 0.88) 72%, transparent);
}

body[data-scrolled="true"] .rich-toolbar {
  box-shadow:
    0 10px 22px rgba(33, 33, 36, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.tray-open .rich-toolbar {
  box-shadow:
    0 10px 22px rgba(33, 33, 36, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

body[data-mode="focus"] {
  --document-width: 720px;
}

body[data-mode="focus"] .workspace {
  grid-template-columns: 1fr;
}

body[data-mode="focus"] .sidebar {
  display: none;
}

body[data-mode="focus"] .editor {
  background: transparent;
}

body[data-mode="focus"] .editor-document::after {
  opacity: 0;
}

body[data-mode="focus"] .topbar,
body[data-mode="focus"] .editor-toolbar,
body[data-mode="focus"] .delete-notice,
body[data-mode="focus"] .rich-toolbar-shell,
body[data-mode="focus"] .editor-footer {
  opacity: 0;
  pointer-events: none;
}

body[data-mode="focus"] .editor-header {
  padding-top: 18px;
}

body[data-mode="focus"] .mobile-dock {
  display: none;
}

body[data-mode="focus"] .focus-exit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-dock {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: none;
  gap: 6px;
  width: min(282px, calc(100vw - 22px));
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 15px;
  background: rgba(248, 251, 255, 0.86);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
  box-shadow: 0 8px 20px rgba(19, 25, 33, 0.05);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.dock-btn {
  flex: 1;
  min-height: 32px;
  padding: 0;
  font-weight: 600;
  font-size: 0.73rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dock-btn-primary {
  background: var(--accent);
  color: #f7fbff;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 15, 18, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.focus-exit-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  display: none;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: rgba(252, 252, 249, 0.92);
  color: var(--text);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 30px rgba(33, 33, 36, 0.1);
  cursor: pointer;
}

.focus-exit-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.98);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.image-viewer[hidden] {
  display: none !important;
}

.image-viewer.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.image-viewer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(14, 15, 18, 0.68);
  backdrop-filter: blur(18px);
}

.image-viewer-stage {
  position: relative;
  z-index: 1;
  width: min(100%, 1120px);
  max-height: calc(100vh - 56px);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.image-viewer-img {
  display: block;
  max-width: min(100%, 1120px);
  max-height: calc(100vh - 128px);
  width: auto;
  height: auto;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.34);
}

.image-viewer-caption {
  min-height: 20px;
  max-width: min(100%, 720px);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.image-viewer-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.image-viewer-close:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
}

body[data-keyboard="true"] .mobile-dock {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

body[data-list="open"] .sidebar {
  transform: translateX(0);
}

body[data-list="open"] .backdrop {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1080px) {
  .page {
    width: min(1540px, calc(100vw - 36px));
  }

  .workspace {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
    min-height: calc(100vh - 118px);
  }

  .sidebar {
    position: sticky;
    inset: auto;
    top: 92px;
    width: 100%;
    min-height: calc(100vh - 136px);
    transform: none;
    z-index: 1;
    border-radius: 30px;
  }

  .editor {
    min-width: 0;
  }

  .editor-toolbar {
    padding-top: 4px;
    padding-bottom: 10px;
  }

  .editor-toolbar-inner,
  .editor-footer-inner {
    width: min(100%, calc(var(--document-width) + (var(--editor-gutter) * 2)));
  }

  .editor-document {
    margin-bottom: 6px;
  }

  #toggleListBtn,
  .backdrop,
  .mobile-dock {
    display: none !important;
  }

  body[data-list="open"] .sidebar {
    transform: none;
  }
}

@media (max-width: 760px) {
  .page {
    width: 100vw;
    margin: 0;
    margin-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 8px 12px 6px;
    flex-wrap: wrap;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: linear-gradient(180deg, rgba(250, 248, 243, 0.94), rgba(250, 248, 243, 0.82));
    backdrop-filter: blur(12px);
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 22px;
    height: 14px;
    border-radius: 999px;
  }

  .brand-mark::before {
    left: 3px;
    top: 3px;
    width: 8px;
    height: 8px;
  }

  .brand-mark::after {
    right: -3px;
    top: 3px;
    width: 7px;
    height: 7px;
  }

  .topbar-main,
  .topbar-actions {
    justify-content: space-between;
  }

  .topbar-main,
  .topbar-actions {
    width: 100%;
  }

  .topbar-meta {
    flex-wrap: wrap;
  }

  .topbar-actions {
    gap: 8px;
  }

  .lang-toggle-btn {
    min-height: 26px;
    padding: 0 9px;
  }

  .action-group {
    display: flex;
  }

  .status-pill {
    min-height: 22px;
    padding: 0 8px;
    font-size: 0.69rem;
  }

  .sync-chip {
    min-height: 22px;
    padding: 0 8px;
    font-size: 0.68rem;
    max-width: min(42vw, 160px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-pill::before {
    width: 5px;
    height: 5px;
  }

  .brand-title {
    font-size: 0.96rem;
  }

  .brand-sub {
    display: none;
  }

  .workspace {
    margin-top: 6px;
    min-height: calc(100vh - 64px);
    border-radius: 0;
  }

  .editor {
    min-height: calc(100vh - 154px);
    padding: 0;
  }

  .editor-toolbar {
    padding: 8px 14px 6px;
  }

  .delete-notice {
    top: 68px;
    width: calc(100% - 28px);
    margin-bottom: 8px;
    padding: 11px 12px;
    border-radius: 16px;
  }

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

  .editor-footer-inner {
    width: 100%;
  }

  .editor-toolbar-copy {
    gap: 8px;
  }

  .rich-toolbar-shell,
  .rich-editor-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .command-surface {
    padding: 10px;
    border-radius: 18px;
  }

  .rich-toolbar {
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    width: 100%;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .rich-toolbar::-webkit-scrollbar {
    display: none;
  }

  .tool-btn {
    flex: 0 0 auto;
    width: 34px;
    min-width: 34px;
    min-height: 30px;
    padding: 0;
    font-size: 0.74rem;
    scroll-snap-align: start;
  }

  .bubble-menu,
  .floating-menu {
    max-width: calc(100vw - 30px);
    padding: 7px;
    border-radius: 16px;
  }

  .slash-menu {
    width: min(300px, calc(100% - 12px));
    padding: 7px;
    border-radius: 18px;
  }

  .menu-chip {
    width: 32px;
    min-width: 32px;
    min-height: 30px;
    padding: 0;
    font-size: 0.73rem;
  }

  .slash-item {
    padding: 10px 11px;
    border-radius: 14px;
  }

  .slash-item-title,
  .slash-empty-title {
    font-size: 0.78rem;
  }

  .slash-item-desc,
  .slash-empty-copy {
    font-size: 0.71rem;
  }

  .editor-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 18px 14px 8px;
  }

  .editor-header-top,
  .editor-meta-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .editor-stage-badge {
    align-self: flex-start;
  }

  .doc-stats {
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .doc-stats::-webkit-scrollbar {
    display: none;
  }

  .stat-chip {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  #titleInput {
    font-size: 1.22rem;
  }

  #contentInput {
    min-height: 42vh;
    font-size: 0.92rem;
  }

  .rich-editor .ProseMirror {
    min-height: 42vh;
    padding: 6px 0 54px;
  }

  .rich-editor .ProseMirror > * {
    max-width: none;
  }

  .editor-empty-state {
    min-height: 54vh;
    padding: 24px 18px;
    border-radius: 22px;
  }

  .empty-doc-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .empty-doc-title {
    font-size: 0.98rem;
  }

  .empty-doc-copy {
    font-size: 0.82rem;
  }

  .editor-footer {
    padding: 10px 14px calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .modal-shell {
    padding: 14px;
  }

  .modal-card {
    width: 100%;
    padding: 18px;
    border-radius: 20px;
  }

  .image-viewer {
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .image-viewer-stage {
    gap: 10px;
  }

  .image-viewer-img {
    max-height: calc(100vh - 120px);
    border-radius: 18px;
  }

  .editor-footer-inner {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  #statusText {
    min-height: 26px;
    padding: 0 10px;
  }

  .status-meta {
    text-align: left;
  }

  .sidebar {
    inset: 10px auto 10px 10px;
    width: min(320px, calc(100vw - 44px));
    min-height: calc(100vh - 20px);
    border-radius: 22px;
  }

  .note-card {
    padding: 10px 12px 10px 14px;
  }

  .note-title {
    font-size: 0.84rem;
  }

  .note-preview {
    -webkit-line-clamp: 1;
    font-size: 0.75rem;
  }

  .note-card.empty-state {
    min-height: 156px;
    padding: 24px 18px;
  }

  .empty-illustration {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .empty-title {
    font-size: 0.8rem;
  }

  .empty-hint {
    font-size: 0.72rem;
  }

  .search input {
    height: 34px;
    font-size: 0.84rem;
  }

  .meta,
  .editor-state-sub,
  .status {
    font-size: 0.75rem;
  }

  .status-meta {
    margin-left: 0;
  }

  .btn.subtle-danger {
    min-height: 34px;
    padding: 0;
    border-radius: 999px;
    border-color: rgba(216, 79, 79, 0.14);
    background: #fff1f1;
  }

  .btn.subtle-danger.confirming {
    background: #ffe4e4;
    border-color: rgba(216, 79, 79, 0.24);
  }

  .mobile-dock {
    display: none;
  }
}

@media (max-width: 560px) {
  .status-pill {
    min-height: 20px;
    padding: 0 7px;
    font-size: 0.66rem;
  }

  .sync-chip {
    min-height: 20px;
    padding: 0 7px;
    font-size: 0.64rem;
    max-width: 112px;
  }

  .editor-state-sub {
    display: none;
  }

  .editor-toolbar {
    padding-top: 6px;
  }

  .editor-toolbar-inner {
    gap: 8px;
  }

  .topbar-meta {
    gap: 4px;
  }

  .editor-toolbar-actions {
    margin-left: auto;
  }

  .delete-notice {
    top: 60px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .delete-notice-actions {
    width: 100%;
    justify-content: flex-end;
  }

  #toggleListBtn,
  .topbar-actions .action-group {
    display: none;
  }

  .editor-tip {
    display: none;
  }

  .editor-header {
    padding-top: 14px;
  }

  #contentInput {
    min-height: 38vh;
  }

  .rich-editor .ProseMirror {
    min-height: 38vh;
    padding-top: 2px;
  }

  .editor-stage-badge,
  .stat-chip {
    min-height: 26px;
    padding: 0 9px;
    font-size: 0.68rem;
  }

  .sidebar {
    inset: 8px auto 8px 8px;
    width: calc(100vw - 16px);
    min-height: calc(100vh - 16px);
  }

  .editor-footer {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-dock {
    display: flex;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: min(270px, calc(100vw - 22px));
  }

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

  .image-viewer-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .image-viewer-caption {
    font-size: 0.76rem;
  }
}

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

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px);
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-gate-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(200, 138, 43, 0.12), transparent 40%),
    rgba(244, 241, 236, 0.82);
  backdrop-filter: blur(18px);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  border-radius: 28px;
  padding: 28px;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(17, 17, 17, 0.06);
  box-shadow: 0 28px 90px rgba(17, 17, 17, 0.14);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand-copy {
  display: grid;
  gap: 3px;
}

.auth-brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.auth-brand-sub {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.auth-copy {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.auth-eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-title {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  line-height: 1.08;
}

.auth-text {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.auth-mode-switch {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(17, 17, 17, 0.04);
}

.auth-mode-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.auth-mode-btn.is-active {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-strong);
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.08);
}

.auth-actions {
  margin-top: 22px;
}

.auth-primary-btn {
  width: 100%;
  justify-content: center;
}

.account-chip {
  max-width: 220px;
}

.account-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card {
  width: min(100%, 500px);
}

body[data-auth="booting"] .page,
body[data-auth="guest"] .page {
  pointer-events: none;
  user-select: none;
}

body[data-auth="booting"] .page {
  filter: blur(10px);
}

body[data-auth="guest"] .page {
  filter: blur(6px);
}

body[data-auth="ready"] .auth-gate {
  display: none !important;
  pointer-events: none;
  opacity: 0;
}

@media (max-width: 720px) {
  .auth-card {
    padding: 22px;
    border-radius: 24px;
  }

  .account-chip {
    display: none;
  }
}

