:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --surface: #fffef9;
  --sidebar: #eeece4;
  --ink: #242820;
  --muted: #777b70;
  --line: #deddd5;
  --accent: #526852;
  --accent-dark: #3f523f;
  --accent-soft: #dce5d8;
  --danger: #a64d46;
  --shadow: 0 18px 54px rgb(37 41 34 / 12%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

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

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  z-index: 20;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: max(22px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand-row,
.topbar,
.notes-heading,
.sidebar-footer {
  display: flex;
  align-items: center;
}

.account-sync-button {
  display: none;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  order: -1;
  border: 1px solid #cbd5c8;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.account-sync-button:hover,
.account-sync-button:focus-visible {
  border-color: #aebaaa;
  outline: none;
}

.account-sync-button.is-syncing i {
  animation: spin 700ms linear infinite;
}

.account-sync-button.is-error {
  border-color: #d7b7ae;
  color: var(--danger);
}

.sync-button {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 2px;
  border: 1px solid #cbd5c8;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.sync-button:hover {
  border-color: #aebaaa;
  background: #dfe8dc;
}

.sync-button.is-synced i {
  color: #3f714a;
}

.app-version {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.brand-row {
  justify-content: space-between;
  margin: 0 4px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px 12px 12px 4px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 19px;
  box-shadow: 0 6px 18px rgb(64 83 64 / 18%);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.brand-mark:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.14em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.new-note-button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 24px rgb(64 83 64 / 16%);
  transition: background 150ms ease, transform 150ms ease;
}

.new-note-button:hover {
  background: var(--accent-dark);
}

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

.search-box {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  margin: 18px 0 14px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: rgb(255 255 255 / 58%);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: #aebaaa;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgb(82 104 82 / 9%);
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-box kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #8e9188;
  font-size: 10px;
}

.notes-heading {
  justify-content: space-between;
  padding: 0 7px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
}

.categories {
  margin-bottom: 15px;
}

.categories-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
}

.categories-heading button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.categories-heading button:hover {
  background: rgb(255 255 255 / 55%);
  color: var(--ink);
}

.category-list {
  max-height: 154px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.category-row {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  border-radius: 9px;
  color: var(--muted);
}

.category-row:hover {
  background: rgb(255 255 255 / 45%);
  color: var(--ink);
}

.category-row.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 650;
}

.category-row.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: #d2dfce;
}

.category-item {
  display: flex;
  min-width: 0;
  min-height: 34px;
  flex: 1;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.category-item:hover {
  color: inherit;
}

.category-item i {
  width: 16px;
  text-align: center;
}

.category-item .category-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  min-width: 22px;
  color: inherit;
  font-size: 10px;
  text-align: right;
  opacity: 0.72;
}

.category-actions {
  display: flex;
  flex: 0 0 auto;
  padding-right: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.category-row:hover .category-actions,
.category-row:focus-within .category-actions {
  opacity: 1;
}

.category-actions button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.category-actions button:hover {
  background: rgb(255 255 255 / 75%);
}

.notes-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c9c8bf transparent;
}

.note-card {
  position: relative;
  width: 100%;
  margin-bottom: 5px;
  padding: 13px 34px 13px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.note-card[draggable="true"] {
  cursor: grab;
}

.note-card.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.note-drag-handle {
  position: absolute;
  top: 50%;
  right: 10px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
}

.note-card:hover .note-drag-handle,
.note-card:focus-visible .note-drag-handle {
  opacity: 0.75;
}

.note-card:hover {
  background: rgb(255 255 255 / 45%);
}

.note-card.active {
  background: var(--surface);
  box-shadow: 0 6px 22px rgb(41 44 38 / 7%);
}

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

.note-card-title {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 650;
}

.note-card-meta {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.note-card-category {
  overflow: hidden;
  max-width: 76px;
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card-preview {
  min-width: 0;
  flex: 1;
}

.no-results {
  padding: 28px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.sidebar-footer {
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 6px 0;
  border-top: 1px solid var(--line);
}

.text-button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
}

.install-button::before {
  content: "·";
  margin-right: 8px;
}

.offline-badge {
  margin-left: auto;
  color: #71806d;
  font-size: 10px;
}

.offline-badge.is-offline {
  color: #a17447;
}

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 62px minmax(0, 1fr) 42px;
  background:
    radial-gradient(circle at 82% 10%, rgb(220 229 216 / 38%), transparent 28%),
    var(--surface);
}

.topbar {
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 28px 8px;
  border-bottom: 1px solid rgb(222 221 213 / 70%);
}

.save-state,
.cloud-state,
.updated-time,
.editor-footer {
  color: var(--muted);
  font-size: 11px;
}

.cloud-state {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  margin-left: 18px;
  padding: 5px 10px;
  border: 1px solid #cbd5c8;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #71806d;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.cloud-state:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.cloud-state.is-syncing::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border: 1px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 700ms linear infinite;
}

.cloud-state.is-error {
  color: var(--danger);
}

.save-state.is-saving::before,
.save-state.is-saved::before {
  display: inline-block;
  margin-right: 7px;
  content: "";
}

.save-state.is-saving::before {
  width: 6px;
  height: 6px;
  border: 1px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.save-state.is-saved::before {
  color: var(--accent);
  content: "✓";
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--paper);
  color: var(--ink);
}

.icon-button.danger:hover {
  background: #f7e7e4;
  color: var(--danger);
}

.editor {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden;
  padding: 52px clamp(28px, 3vw, 48px) 28px;
}

.title-input,
.content-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  caret-color: #087d2f;
}

.caret-guide {
  position: fixed;
  z-index: 30;
  width: 3px;
  min-height: 20px;
  border-radius: 3px;
  background: #00a63d;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 90%), 0 0 7px rgb(0 125 47 / 65%);
  pointer-events: none;
  animation: caret-guide-blink 1.05s steps(1, end) infinite;
}

@keyframes caret-guide-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0.22; }
}

.title-input {
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
  font-family: "STSong", "SimSun", Georgia, serif;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.title-input::placeholder,
.content-input::placeholder {
  color: #b1b3aa;
}

.note-properties {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.note-properties label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
}

.note-properties select {
  max-width: 220px;
  height: 30px;
  padding: 0 28px 0 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: 0;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.note-properties select:hover,
.note-properties select:focus {
  border-color: #b9c2b6;
}

.content-input {
  min-height: 0;
  flex: 1;
  padding: 28px 0 80px;
  overflow-y: auto;
  color: #000;
  font-family: DengXian, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.9;
  white-space: normal;
}

.content-input:empty::before {
  color: #b1b3aa;
  content: attr(data-placeholder);
  pointer-events: none;
}

.content-input p {
  margin: 0 0 0.8em;
}

.content-input ul,
.content-input ol {
  padding-left: 1.5em;
}

.content-input .check-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 5px 0;
}

.content-input .check-item input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 7px;
  accent-color: var(--accent);
}

.content-input .task-status {
  display: inline-block;
  margin-left: 0.35em;
  vertical-align: -0.12em;
  font-size: 1.05em;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}

.content-input .task-status-done {
  color: #397148;
}

.content-input .task-status-progress {
  color: #269447;
}

.content-input .task-status-canceled {
  color: #b2524b;
}

.content-input table {
  min-width: 1px;
  width: calc(100% - 30px);
  max-width: none;
  margin: 34px 0 20px 30px;
  border-collapse: collapse;
  overflow: auto;
  resize: none;
  table-layout: fixed;
}

.content-input table.is-selected {
  outline: 2px solid rgb(82 104 82 / 45%);
  outline-offset: 3px;
}

.content-input img.imported-media {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 14px 0;
  border-radius: 8px;
  cursor: zoom-in;
}

.content-input img.imported-media:hover {
  outline: 2px solid rgb(82 104 82 / 28%);
  outline-offset: 3px;
}

.content-input td img,
.content-input th img {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 4px 0;
  object-fit: contain;
}

.content-input img.is-missing-attachment {
  min-height: 72px;
  border: 1px dashed #b9c2b6;
  background: #f3f4ef;
  color: var(--muted);
}

.content-input .imported-attachment {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 6px 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--accent-dark);
  text-decoration: none;
}

.content-input .imported-attachment::before {
  content: "PDF";
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 6px;
  background: #f1e4e1;
  color: var(--danger);
  font-size: 9px;
  font-weight: 750;
}

.content-input .imported-attachment > img.imported-media {
  width: 44px;
  height: 44px;
  margin: 0;
  object-fit: cover;
}

.content-input .attachment-label {
  overflow-wrap: anywhere;
}

.content-input td,
.content-input th {
  position: relative;
  box-sizing: border-box;
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid #bbbdb4;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.75;
  vertical-align: top;
}

.content-input td.is-selected-cell,
.content-input th.is-selected-cell {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.column-resizer {
  position: absolute;
  z-index: 5;
  top: -2px;
  right: -7px;
  bottom: -2px;
  width: 14px;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.column-resizer::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  content: "";
}

.column-resizer:hover::after,
.column-resizer.is-dragging::after {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgb(82 104 82 / 15%);
}

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

.table-width-resizer {
  position: absolute;
  z-index: 6;
  right: -12px;
  bottom: -12px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgb(29 49 32 / 28%);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.table-width-resizer::before {
  position: absolute;
  inset: 6px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  content: "";
}

.table-width-resizer:hover,
.table-width-resizer.is-dragging {
  transform: scale(1.12);
}

.table-quick-handle {
  position: absolute;
  z-index: 7;
  display: grid;
  width: 22px;
  height: 22px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  font: 700 17px/1 Arial, sans-serif;
  touch-action: manipulation;
  user-select: none;
}

.table-quick-handle::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b7bbb6;
  content: "";
}

.table-quick-handle:hover,
.table-quick-handle:focus-visible,
.table-quick-handle:active {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.content-input table:not(.is-selected) .column-resizer,
.content-input table:not(.is-selected) .table-width-resizer,
.content-input table:not(.is-selected) .table-quick-handle {
  visibility: hidden;
  pointer-events: none;
}

.table-quick-handle:hover::before,
.table-quick-handle:focus-visible::before,
.table-quick-handle:active::before {
  display: none;
}

.table-insert-column-handle {
  top: -11px;
  right: -11px;
}

.table-insert-column-handle::after,
.table-insert-row-handle::after {
  content: "+";
}

.table-insert-row-handle {
  bottom: -11px;
  left: -11px;
}

.table-select-all-handle {
  top: -13px;
  left: -13px;
  width: 25px;
  height: 25px;
  background: #aeb3ad;
  color: #fff;
}

.table-select-all-handle::before {
  display: none;
}

.table-select-all-handle::after {
  content: "=";
}

.table-select-all-handle:hover,
.table-select-all-handle:focus-visible,
.table-select-all-handle:active {
  background: var(--accent);
}

.format-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  align-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.format-toolbar button,
.format-toolbar select,
.color-tool {
  flex: 0 0 auto;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
}

.format-toolbar button {
  display: grid;
  min-width: 32px;
  place-items: center;
  padding: 0 8px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 15px;
}

.format-toolbar button .bi,
.table-toolbar button .bi {
  font-size: 15px;
  line-height: 1;
}

.format-toolbar button.wide-tool {
  display: flex;
  min-width: auto;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 12px;
}

.format-toolbar button.primary-tool {
  border-color: #b8c4b4;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.format-toolbar button.primary-tool:hover {
  border-color: var(--accent);
  background: #d2dfcd;
}

.format-toolbar button.status-tool {
  width: 30px;
  min-width: 30px;
  padding: 0;
  border-color: #d9ddd4;
  background: #faf9f5;
}

.format-toolbar button.status-tool-done {
  color: #397148;
}

.format-toolbar button.status-tool-progress {
  color: #b7791f;
  background: #fbf2dd;
}

.format-toolbar button.status-tool-canceled {
  color: #b2524b;
}

.format-toolbar button:hover,
.format-toolbar select:hover,
.color-tool:hover {
  border-color: var(--line);
  background: var(--paper);
}

.format-toolbar select {
  max-width: 116px;
  padding: 0 23px 0 8px;
  outline: 0;
  font-size: 12px;
  cursor: pointer;
}

#fontFamilySelect {
  max-width: 150px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0 3px;
  background: var(--line);
}

.table-toolbar,
.image-toolbar {
  display: flex;
  min-height: 43px;
  align-items: center;
  align-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.table-toolbar-label {
  flex: 0 0 auto;
  margin-right: 3px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.table-toolbar button,
.image-toolbar button {
  display: flex;
  min-height: 30px;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.table-toolbar button:hover,
.image-toolbar button:hover {
  border-color: #adb9a9;
  color: var(--ink);
}

.table-toolbar button.danger-tool:hover {
  border-color: #d9b6b2;
  background: #f9ecea;
  color: var(--danger);
}

.table-fill-scope {
  height: 30px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.table-color-picker {
  position: relative;
  flex: 0 0 auto;
}

.table-color-tool {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.table-color-preview {
  width: 16px;
  height: 16px;
  border: 1px solid rgb(40 42 38 / 18%);
  border-radius: 50%;
  background: #fff2b2;
}

.table-color-preview.is-clear {
  background: linear-gradient(135deg, #fff 44%, #d46666 45%, #d46666 55%, #fff 56%);
}

.table-color-palette {
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  left: 0;
  width: 258px;
  max-width: calc(100vw - 48px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgb(41 44 38 / 18%);
}

.table-color-palette[hidden] {
  display: none;
}

.table-color-palette > strong {
  display: block;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.table-color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.table-toolbar .table-color-swatch {
  position: relative;
  display: grid;
  width: 30px;
  height: 30px;
  min-height: 30px;
  min-width: 30px;
  place-items: center;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  color: #d46666;
}

.table-toolbar .table-color-swatch:hover,
.table-toolbar .table-color-swatch:focus-visible {
  border-color: #118dc2;
  outline: 2px solid var(--surface);
  box-shadow: 0 0 0 3px #118dc2;
}

.table-toolbar .table-color-swatch.is-clear {
  border-color: #d7d7d3;
  background: #fff;
}

.table-toolbar .table-color-swatch.is-default {
  box-shadow: 0 0 0 2px #118dc2;
}

.table-custom-color {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 0 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.table-custom-color input {
  width: 28px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.table-width-control {
  display: flex;
  min-width: 190px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.table-width-control input {
  width: 82px;
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  accent-color: var(--accent);
}

.table-width-control output {
  width: 34px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.image-width-control {
  display: flex;
  min-width: 190px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.image-width-control input {
  width: 100px;
  accent-color: var(--accent);
}

.image-width-control output {
  width: 34px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.content-input td img.is-selected-image,
.content-input th img.is-selected-image {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.font-color-picker {
  position: relative;
  flex: 0 0 auto;
}

.color-tool {
  position: relative;
  display: grid;
  width: 34px;
  place-items: center;
  cursor: pointer;
  font-family: Georgia, serif;
  font-weight: 700;
}

.font-color-preview {
  position: absolute;
  right: 7px;
  bottom: 3px;
  width: 20px;
  height: 4px;
  border-radius: 2px;
  background: #000;
}

.font-color-palette {
  position: absolute;
  z-index: 45;
  top: calc(100% + 7px);
  left: 0;
  width: 244px;
  max-width: calc(100vw - 48px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgb(41 44 38 / 18%);
}

.font-color-palette[hidden] {
  display: none;
}

.font-color-palette > strong {
  display: block;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.font-color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.format-toolbar .font-color-swatch {
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgb(32 35 30 / 14%);
  border-radius: 1px;
}

.format-toolbar .font-color-swatch:hover,
.format-toolbar .font-color-swatch:focus-visible {
  border-color: #118dc2;
  outline: 2px solid #118dc2;
  outline-offset: 1px;
}

.font-custom-color {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
  padding: 7px 3px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.font-custom-color input {
  width: 28px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.format-toolbar button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  padding: 11px max(28px, calc((100% - 748px) / 2));
  border-top: 1px solid rgb(222 221 213 / 70%);
}

.empty-state {
  align-self: center;
  max-width: 460px;
  padding: 40px;
  text-align: center;
}

.empty-icon {
  display: block;
  margin-bottom: 20px;
  color: var(--accent);
  font-size: 38px;
}

.empty-state h1 {
  margin: 0 0 10px;
  font-family: "STSong", "SimSun", Georgia, serif;
  font-size: 30px;
}

.empty-state p {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.7;
}

.new-note-button.compact {
  width: auto;
  min-width: 180px;
  margin: auto;
  padding: 0 22px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 11px;
  background: #2f342d;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.note-context-menu {
  position: fixed;
  z-index: 70;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgb(41 44 38 / 18%);
}

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

.note-context-menu button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.note-context-menu button:hover,
.note-context-menu button:focus-visible {
  outline: 0;
  background: var(--accent-soft);
}

.note-context-menu i {
  color: var(--accent);
  font-size: 16px;
}

.note-context-menu button.danger,
.note-context-menu button.danger i {
  color: var(--danger);
}

.note-context-menu button.danger:hover,
.note-context-menu button.danger:focus-visible {
  background: #f7e7e4;
}

.rename-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 60;
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.import-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 60;
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.attachment-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 70;
  width: min(1040px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.attachment-dialog-content {
  display: grid;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
}

.attachment-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.attachment-dialog header small {
  color: var(--muted);
  font-size: 10px;
}

.attachment-dialog h2 {
  overflow: hidden;
  max-width: min(600px, 55vw);
  margin: 2px 0 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.attachment-dialog-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.attachment-dialog-actions .dialog-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.attachment-preview {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: #ebe9e2;
}

.attachment-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.attachment-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.attachment-preview-fallback {
  max-width: 360px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.attachment-preview-fallback .bi {
  font-size: 34px;
}

.attachment-preview-fallback p {
  line-height: 1.7;
}

.import-dialog-content {
  padding: 30px;
}

.import-dialog h2 {
  margin: 0 0 8px;
  font-family: "STSong", "SimSun", Georgia, serif;
  font-size: 23px;
}

.import-intro,
.import-warning {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.import-intro {
  margin: 0 0 19px;
}

.import-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
}

.import-file-card > .bi {
  color: var(--accent);
  font-size: 24px;
}

.import-file-card strong,
.import-file-card span {
  display: block;
}

.html-assets {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 12px 13px;
  border: 1px dashed #b8c4b4;
  border-radius: 10px;
  background: var(--accent-soft);
}

.html-assets[hidden] {
  display: none;
}

.html-assets strong,
.html-assets span {
  display: block;
}

.html-assets strong {
  font-size: 12px;
}

.html-assets span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.html-assets button {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.import-file-card strong {
  overflow: hidden;
  max-width: 380px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.import-file-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.import-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 13px;
}

.import-stats > div {
  padding: 12px 8px;
  border-radius: 9px;
  background: var(--accent-soft);
  text-align: center;
}

.import-stats strong,
.import-stats span {
  display: block;
}

.import-stats strong {
  color: var(--accent-dark);
  font-size: 18px;
}

.import-stats span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.import-progress,
.import-result {
  margin-top: 15px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.import-progress progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 10px;
  accent-color: var(--accent);
}

.import-result {
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1.6;
}

.import-result.is-error {
  background: #f9e7e4;
  color: var(--danger);
}

.import-encrypted-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 15px;
  padding: 11px 13px;
  border: 1px solid #e4c99d;
  border-radius: 9px;
  background: #fff6e7;
  color: #6b4b1d;
  font-size: 12px;
  line-height: 1.55;
}

.import-encrypted-warning[hidden] {
  display: none;
}

.import-encrypted-warning .bi {
  margin-top: 1px;
  font-size: 16px;
}

.import-encrypted-warning strong,
.import-encrypted-warning span {
  display: block;
}

.import-encrypted-warning span {
  margin-top: 2px;
}


.import-warning {
  margin: 13px 0 0;
  font-size: 11px;
}

.rename-dialog::backdrop {
  background: rgb(27 31 26 / 38%);
  backdrop-filter: blur(4px);
}

.rename-dialog form {
  padding: 30px;
}

.dialog-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.rename-dialog h2 {
  margin: 0 0 8px;
  font-family: "STSong", "SimSun", Georgia, serif;
  font-size: 23px;
}

.rename-dialog p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.rename-dialog label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 650;
}

.rename-dialog input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--paper);
  color: var(--ink);
}

.rename-dialog input:focus {
  border-color: #aebaaa;
  box-shadow: 0 0 0 3px rgb(82 104 82 / 10%);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.dialog-button {
  min-width: 88px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
}

.dialog-button.secondary {
  background: var(--paper);
  color: var(--muted);
}

.dialog-button.primary {
  background: var(--accent);
  color: white;
}

.dialog-button.danger {
  border: 1px solid #d9b4b0;
  background: #f7e7e4;
  color: var(--danger);
}

.dialog-button.danger:hover,
.dialog-button.danger:focus-visible {
  background: #f1d6d2;
}

.dialog-button.full-width {
  width: 100%;
  margin-top: 12px;
}

.sync-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 12px;
  background: var(--paper);
}

.sync-mode-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.sync-mode-switch button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgb(41 44 38 / 8%);
}

#syncPasswordFields label,
#syncOtpFields label {
  margin-top: 12px;
}

.sync-login-hint {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.sync-dialog #syncCodeFields {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sync-account {
  display: grid;
  gap: 8px;
  padding: 15px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.remember-login-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.remember-login-option input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.remember-login-option span {
  display: grid;
  gap: 3px;
}

.remember-login-option small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sync-account[hidden],
.sync-dialog [hidden] {
  display: none;
}

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

.sync-account span {
  color: var(--muted);
  font-size: 12px;
}

.mobile-only {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 330px);
    border-right: 0;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: block;
    background: rgb(20 23 19 / 34%);
    backdrop-filter: blur(2px);
  }

  .workspace {
    height: 100dvh;
    grid-template-rows: max(58px, calc(48px + env(safe-area-inset-top))) minmax(0, 1fr) max(38px, calc(30px + env(safe-area-inset-bottom)));
  }

  .topbar {
    padding-inline: 16px;
  }

  .save-state {
    display: none;
  }

  .updated-time {
    display: none;
  }

  .editor {
    width: 100vw;
    max-width: 100vw;
    padding: 18px 10px 8px;
  }

  .format-toolbar {
    flex-wrap: nowrap;
    gap: 3px;
    padding-block: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .format-toolbar button,
  .format-toolbar select,
  .color-tool {
    height: 30px;
  }

  .format-toolbar button.wide-tool {
    padding-inline: 7px;
    font-size: 11px;
  }

  .format-toolbar .tool-label {
    display: none;
  }

  .format-toolbar button.wide-tool {
    min-width: 30px;
    justify-content: center;
  }

  .format-toolbar select {
    max-width: 104px;
    padding-left: 6px;
  }

  #fontFamilySelect {
    max-width: 112px;
  }

  .table-toolbar,
  .image-toolbar {
    gap: 4px;
    padding-block: 6px;
  }

  .table-toolbar {
    position: fixed;
    z-index: 18;
    top: max(62px, calc(52px + env(safe-area-inset-top)));
    right: 8px;
    left: 8px;
    min-height: 44px;
    flex-wrap: nowrap;
    padding: 6px 8px;
    border: 1px solid #d3d7cf;
    border-radius: 11px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    background: rgb(255 254 249 / 96%);
    box-shadow: 0 8px 28px rgb(37 41 34 / 18%);
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .table-toolbar-label {
    position: sticky;
    z-index: 1;
    left: 0;
    padding: 7px 8px;
    border-radius: 7px;
    background: var(--surface);
  }

  .table-color-palette {
    position: fixed;
    top: max(114px, calc(104px + env(safe-area-inset-top)));
    left: 10px;
  }

  .table-toolbar button,
  .image-toolbar button {
    min-height: 29px;
    padding-inline: 7px;
  }

  .table-width-control,
  .image-width-control {
    min-width: 220px;
    padding-block: 3px;
  }

  .table-width-control input,
  .image-width-control input {
    min-width: 120px;
    flex: 1;
  }

  .title-input {
    padding-bottom: 12px;
    font-size: 30px;
  }

  .note-properties {
    min-height: 36px;
  }

  .content-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 14px 2px 72px;
    font-size: 14px;
    line-height: 1.9;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
    caret-color: #008f36;
  }

  .content-input table {
    width: 100%;
    min-width: 900px;
    max-width: none;
    resize: none;
    touch-action: pan-x pan-y;
  }

  .content-input table[style*="width"] {
    min-width: 1px;
  }

  .table-width-resizer {
    right: -16px;
    bottom: -16px;
    width: 32px;
    height: 32px;
  }

  .table-width-resizer::before {
    inset: 8px;
  }

  .column-resizer {
    right: -10px;
    width: 20px;
  }

  .column-resizer::after {
    left: 9px;
  }

  .table-quick-handle {
    width: 28px;
    height: 28px;
  }

  .table-insert-column-handle {
    top: -14px;
    right: -14px;
  }

  .table-insert-row-handle {
    bottom: -14px;
    left: -14px;
  }

  .table-select-all-handle {
    top: -15px;
    left: -15px;
    width: 30px;
    height: 30px;
  }

  .content-input td,
  .content-input th {
    scroll-margin-top: 120px;
  }

  .editor-footer {
    padding-inline: 20px;
  }

  .editor-footer span:last-child {
    display: none;
  }

  .cloud-state {
    display: inline-flex;
    max-width: 155px;
    margin: 0 auto 0 8px;
    overflow: hidden;
    padding-inline: 9px;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  .toast {
    right: 16px;
    bottom: calc(58px + env(safe-area-inset-bottom));
  }

  .rename-dialog form {
    padding: 25px 22px;
  }

  .import-dialog-content {
    padding: 25px 22px;
  }

  .import-file-card strong {
    max-width: 250px;
  }
}

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