.app-body {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------ Top bar ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-height);
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex: none;
  z-index: 30;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding-right: 4px;
}

.topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  flex: none;
  box-shadow: var(--shadow-sm);
}

.topbar-logo svg {
  width: 17px;
  height: 17px;
}

.topbar-wordmark {
  font-size: 14.5px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  margin: 0 2px;
  background: var(--border);
}

.topbar-workspace {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
  max-width: 210px;
}

.topbar-workspace:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topbar-workspace svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.topbar-search {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.topbar-search .search-box {
  position: relative;
  width: min(100%, 420px);
}

.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 62px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 12.5px;
  transition: background var(--fast), border-color var(--fast), box-shadow var(--fast);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--border-strong);
}

.search-box .search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}

.topbar-actions .icon-btn {
  width: 34px;
  height: 34px;
}

.topbar-actions .search-mobile-btn {
  display: none;
}

.topbar-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  margin-left: 4px;
  padding: 0 6px 0 5px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
}

.topbar-avatar-btn:hover {
  background: var(--surface-2);
}

.topbar-avatar-btn svg {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.topbar-mobile-menu {
  display: none;
}

/* ------------------------------ Workspace grid ------------------------------ */

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) var(--list-width) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

/* ------------------------------ Sidebar ------------------------------ */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 10px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.side-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 18px;
}

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 26px;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.side-label button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: -5px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.side-label button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-label button svg {
  width: 14px;
  height: 14px;
}

.side-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 33px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.8px;
  font-weight: 500;
  text-align: left;
  transition: background var(--fast), color var(--fast);
}

.side-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-muted);
  transition: color var(--fast);
}

.side-item .side-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.side-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-item:hover svg {
  color: var(--text-secondary);
}

.side-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.side-item.is-active svg {
  color: var(--accent);
}

.side-item.is-active .side-count {
  color: var(--accent);
  opacity: 0.7;
}

.side-item .side-color {
  width: 8px;
  height: 8px;
  margin: 0 4px;
  border-radius: 50%;
  flex: none;
}

.side-item .side-more {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: -4px;
  margin-left: auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.side-item:hover .side-more {
  display: inline-flex;
}

.side-item .side-more:hover {
  background: var(--surface-3);
  color: var(--text);
}

.side-item .side-more svg {
  width: 13px;
  height: 13px;
}

.side-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px 7px;
}

.side-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
}

.side-tag::before {
  content: "#";
  color: var(--text-muted);
}

.side-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.side-tag.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.side-foot {
  margin-top: auto;
  padding: 10px 4px 2px;
}

.side-storage {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-storage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.side-storage-head strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.storage-bar {
  height: 5px;
  margin: 8px 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.storage-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 400ms var(--ease);
}

.side-storage-note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.side-storage-note svg {
  width: 12px;
  height: 12px;
}

/* ------------------------------ Note list pane ------------------------------ */

.list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.list-head {
  flex: none;
  padding: 14px 14px 0;
}

.list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.list-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.list-title h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.list-title .count {
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.list-head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.list-filters {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 0 11px;
  overflow-x: auto;
  scrollbar-width: none;
}

.list-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-chip.is-active {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text);
}

.filter-chip svg {
  width: 12px;
  height: 12px;
}

.list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 9px 14px;
}

.list-group-label {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 7px 6px 5px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 10px 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast);
}

.note-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2.5px;
  border-radius: var(--radius-pill);
  background: transparent;
  transition: background var(--fast);
}

.note-card:hover {
  background: var(--bg-subtle);
}

.note-card.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 16%, transparent);
}

.note-card.is-active::before {
  background: var(--accent);
}

.note-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.note-card-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13.2px;
  font-weight: 650;
  letter-spacing: -0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card.is-active .note-card-title {
  color: var(--accent);
}

.note-card-flags {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  color: var(--text-muted);
}

.note-card-flags svg {
  width: 12px;
  height: 12px;
}

.note-card-flags .starred {
  color: #e8a317;
}

.note-card-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.note-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  min-width: 0;
}

.note-card-meta .dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex: none;
}

.note-card-meta .meta-tag {
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card-meta svg {
  width: 11px;
  height: 11px;
  flex: none;
}

.list-empty {
  padding-top: 40px;
}

/* ------------------------------ Editor pane ------------------------------ */

.editor-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.editor-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  text-align: center;
}

.editor-empty-art {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  margin-bottom: 6px;
  border-radius: var(--radius-xl);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.editor-empty-art svg {
  width: 42px;
  height: 42px;
}

.editor-empty-art::before,
.editor-empty-art::after {
  content: "";
  position: absolute;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.editor-empty-art::before {
  width: 38px;
  height: 46px;
  left: -22px;
  bottom: 8px;
  transform: rotate(-9deg);
}

.editor-empty-art::after {
  width: 38px;
  height: 46px;
  right: -22px;
  top: 8px;
  transform: rotate(8deg);
}

.editor-empty h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.editor-empty p {
  max-width: 330px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.editor-empty .empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  height: 46px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.editor-breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
}

.editor-breadcrumb svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.editor-breadcrumb span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-breadcrumb .crumb-current {
  color: var(--text-secondary);
}

.editor-head-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 70px;
}

.editor-doc {
  width: min(100%, calc(var(--content-width) + 96px));
  margin: 0 auto;
  padding: 30px 48px 80px;
}

.editor-title {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-content);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.03em;
  resize: none;
  overflow: hidden;
}

.editor-title::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
}

.editor-title:focus {
  outline: none;
}

.editor-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 13px;
  margin: 12px 0 16px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.editor-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.editor-meta svg {
  width: 12px;
  height: 12px;
}

.editor-meta .meta-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}

.editor-meta .meta-tag {
  height: 21px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 21px;
}

.editor-meta .meta-tag::before {
  content: "#";
  opacity: 0.5;
  margin-right: 1px;
}

.editor-toolbar {
  position: sticky;
  top: 6px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  min-height: 44px;
  margin: 0 -6px 24px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.editor-toolbar:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.rich-tools,
.md-tools {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  flex: 0 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.rich-tools::-webkit-scrollbar,
.md-tools::-webkit-scrollbar {
  height: 4px;
}

.rich-tools::-webkit-scrollbar-thumb,
.md-tools::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

/* Plain-text mode is minimal: no rich-text tools, no markdown tools. */
.rich-tools {
  display: flex;
}

/* Markdown source + preview shows the markdown toolbar instead. */
.md-tools {
  display: none;
}

.editor-toolbar.is-preview .rich-tools,
.editor-toolbar.is-plain .rich-tools {
  display: none;
}

.editor-toolbar.is-preview .md-tools {
  display: flex;
}

.editor-toolbar > .tool-sep {
  display: none;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  flex: none;
  transition: background var(--fast), color var(--fast), transform var(--fast);
}

.tool-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tool-btn:active {
  transform: scale(0.92);
}

.tool-btn.is-active,
.tool-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-btn svg {
  width: 15.5px;
  height: 15.5px;
}

.tool-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.tool-btn.md-h {
  width: auto;
  min-width: 30px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.preview-btn {
  width: auto;
  gap: 5px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.preview-btn svg {
  width: 14px;
  height: 14px;
}

.preview-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border);
  flex: none;
}

.toolbar-select {
  height: 28px;
  padding: 0 23px 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background-color: transparent;
  background-position: calc(100% - 11px) 12px, calc(100% - 7px) 12px;
  background-size: 4px 4px, 4px 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  appearance: none;
}

.toolbar-select:hover {
  background-color: var(--surface-2);
}

.toolbar-select:focus {
  outline: none;
  background-color: var(--surface-2);
}

.toolbar-spacer {
  flex: 1 1 0;
  min-width: 0;
}

/* Markdown mode: let the tool strip scroll horizontally instead of squeezing buttons. */
.editor-toolbar.is-preview .toolbar-spacer {
  flex: 0 0 auto;
}

.editor-toolbar.is-preview .md-tools {
  flex: 1 1 auto;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex: none;
}

.mode-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 88px;
  height: 25px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.mode-toggle button svg {
  width: 12px;
  height: 12px;
}

.mode-toggle button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Rich text surface */

.editor-content {
  height: 58vh;
  min-height: 380px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  font-family: var(--font-content);
  font-size: var(--font-size);
  line-height: var(--line-height);
  outline: none;
  word-break: break-word;
}

.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: 0.6;
  pointer-events: none;
}

.editor-content .prose > :first-child {
  margin-top: 0;
}

/* Markdown surface */

.md-shell {
  display: block;
  margin: 0;
}

.md-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.md-pane--preview {
  display: none;
}

.md-shell.show-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.md-shell.show-preview .md-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.md-shell.show-preview .md-pane--preview {
  display: flex;
}

.md-pane-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.md-shell:not(.show-preview) .md-pane-label {
  display: none;
}

.md-pane-hint {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.md-pane-label svg {
  width: 12px;
  height: 12px;
}

.md-source {
  width: 100%;
  height: 58vh;
  min-height: 380px;
  padding: 2px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-content);
  font-size: calc(var(--font-size) + 0.5px);
  line-height: var(--line-height);
  resize: none;
  outline: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  tab-size: 2;
  caret-color: var(--accent);
}

.md-source::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
}

.md-shell.show-preview .md-source {
  height: 58vh;
  min-height: 380px;
  padding: 16px 18px;
  background: var(--surface);
  font-size: 13.5px;
  line-height: 1.75;
}

.md-preview {
  min-height: 420px;
  max-height: 66vh;
  padding: 18px 20px;
  overflow-y: auto;
  background: var(--bg);
  font-family: var(--font-content);
  font-size: calc(var(--font-size) - 1px);
  line-height: var(--line-height);
}

.md-shell.show-preview .md-preview {
  background: transparent;
  padding: 16px 18px;
}

.md-preview .prose > :first-child {
  margin-top: 0;
}

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  height: 34px;
  padding: 0 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-saved {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-saved svg {
  width: 12px;
  height: 12px;
  color: var(--success);
}

.status-saved.is-saving svg {
  color: var(--text-muted);
  animation: spin 1s linear infinite;
}

.status-saved.is-dirty svg {
  color: var(--warning);
}

.status-save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  transition: color var(--fast), border-color var(--fast), background var(--fast),
    transform var(--fast);
}

.status-save svg {
  width: 12px;
  height: 12px;
}

.status-save:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.status-save:active {
  transform: scale(0.94);
}

.status-save.has-changes {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.editor-back {
  display: none;
}

/* ------------------------------ Prose content ------------------------------ */

.prose {
  font-family: var(--font-content);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 1.5em 0 0.55em;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

.prose h1 {
  font-size: 1.95em;
  letter-spacing: -0.03em;
}

.prose h2 {
  font-size: 1.5em;
}

.prose h3 {
  font-size: 1.24em;
}

.prose h4 {
  font-size: 1.08em;
}

.prose h5,
.prose h6 {
  font-size: 1em;
  color: var(--text-secondary);
}

.prose p {
  margin: 0.75em 0;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose strong {
  font-weight: 700;
}

.prose em {
  font-style: italic;
}

.prose u {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose s {
  color: var(--text-muted);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: var(--accent-hover);
}

.prose ul,
.prose ol {
  margin: 0.7em 0;
  padding-left: 1.5em;
}

.prose li {
  margin: 0.28em 0;
}

.prose li > p {
  margin: 0.2em 0;
}

.prose ul li::marker {
  color: var(--text-muted);
}

.prose ol li::marker {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.prose blockquote {
  margin: 1em 0;
  padding: 0.2em 0 0.2em 1.05em;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  background: linear-gradient(90deg, var(--accent-soft), transparent 65%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prose blockquote p {
  margin: 0.4em 0;
}

.prose code {
  padding: 0.16em 0.4em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.87em;
}

.prose pre {
  margin: 1em 0;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  line-height: 1.62;
}

.prose pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 0.86em;
  white-space: pre;
}

.prose hr {
  height: 1px;
  margin: 1.8em 0;
  border: 0;
  background: var(--border);
}

.prose img {
  max-width: 100%;
  margin: 1em 0;
  border-radius: var(--radius);
}

.prose table {
  width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.92em;
}

.prose th,
.prose td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.prose th {
  background: var(--bg-subtle);
  font-weight: 650;
}

.prose input[type="checkbox"] {
  margin-right: 0.45em;
  accent-color: var(--accent);
}

.prose .task-list {
  padding-left: 0;
  list-style: none;
}

.prose .task-list li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.prose .task-list li input {
  margin-top: 0.42em;
  flex: none;
}

.prose .task-list li.done {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ------------------------------ Settings modal ------------------------------ */

.settings-backdrop {
  padding: 20px;
}

.settings-modal {
  width: min(1080px, 96vw);
  max-width: none;
  height: min(760px, 92vh);
  max-height: none;
}

.settings-modal .modal-header {
  display: flex;
  align-items: center;
  flex: none;
  height: 58px;
  padding: 0 16px 0 22px;
  border-bottom: 1px solid var(--border);
}

.settings-modal .modal-body {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.settings-modal .settings-body {
  height: 100%;
  min-height: 0;
}

.settings-modal .modal-close {
  margin: 0;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: none;
  height: 58px;
  padding: 0 16px 0 22px;
  border-bottom: 1px solid var(--border);
}

.settings-head-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-head-title svg {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.settings-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-body {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow-y: auto;
}

.settings-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 14px;
  padding: 9px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings-user-info {
  min-width: 0;
}

.settings-user-info strong {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-user-info span {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 35px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.8px;
  font-weight: 500;
  text-align: left;
  flex: none;
}

.settings-nav-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex: none;
}

.settings-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.settings-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.settings-nav-item.is-active svg {
  color: var(--accent);
}

.settings-content {
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 38px 48px;
}

.settings-pane {
  max-width: 720px;
  animation: settings-in 180ms var(--ease);
}

/* About pane pins its copyright line to the bottom of the content area. */
.settings-pane-about {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.settings-pane-about .settings-foot {
  margin-top: auto;
  padding-top: 40px;
  color: var(--text-muted);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  text-align: center;
}

@keyframes settings-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.settings-pane-head {
  margin-bottom: 22px;
}

.settings-pane-head h2 {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.settings-pane-head p {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.settings-group {
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings-group + .settings-group {
  margin-top: 13px;
}

.settings-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.settings-group-title .badge {
  font-weight: 600;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 40px;
  padding: 8px 0;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--border);
}

.setting-copy {
  min-width: 0;
}

.setting-copy strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.setting-copy span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.setting-control .select {
  width: auto;
  min-width: 128px;
  height: 32px;
  font-size: 12px;
}

.setting-control .input {
  width: 150px;
  height: 32px;
  font-size: 12px;
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-wrap input[type="range"] {
  width: 146px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-value {
  min-width: 38px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Account pane */

.settings-account {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings-account-copy {
  flex: 1;
  min-width: 0;
}

.settings-account-copy h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-account-copy p {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 650;
}

.plan-pill svg {
  width: 11px;
  height: 11px;
}

/* Manage — user list + detail (secondary menu) */

.user-manager-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.user-manager-entry:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover, var(--accent-soft));
}

.user-manager-entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.user-manager-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
}

.user-manager-icon svg {
  width: 18px;
  height: 18px;
}

.user-manager-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-manager-copy strong {
  font-size: 13.5px;
  font-weight: 650;
}

.user-manager-copy span {
  font-size: 12px;
  color: var(--text-muted);
}

.user-manager-entry > svg {
  flex: none;
  color: var(--text-muted);
}

.user-search {
  position: relative;
  margin-bottom: 8px;
}

.user-search [data-icon] {
  position: absolute;
  left: 11px;
  top: 50%;
  display: inline-flex;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.user-search [data-icon] svg {
  width: 15px;
  height: 15px;
}

.user-search .input {
  padding-left: 34px;
  height: 34px;
  font-size: 12.5px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background var(--fast);
}

.user-row:hover {
  background: var(--surface-2);
}

.user-row > svg {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--text-muted);
  flex: none;
}

.user-row-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.user-row-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row-sub {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}

.user-back:hover {
  color: var(--text);
}

.user-back svg {
  width: 14px;
  height: 14px;
}

.user-detail {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.user-detail-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.user-detail-info strong {
  font-size: 14.5px;
  font-weight: 700;
}

.user-detail-info > span {
  color: var(--text-muted);
  font-size: 11.5px;
}

.user-detail-info .badge {
  align-self: flex-start;
  margin-top: 2px;
}


/* Theme picker */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}

.theme-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-card-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
}

.theme-card.is-active .theme-card-check {
  display: inline-flex;
}

.theme-card-check svg {
  width: 10px;
  height: 10px;
}

.theme-card-preview {
  height: 52px;
  padding: 7px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.theme-mini-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 5px;
}

.theme-mini-bar i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0.45;
}

.theme-mini-line {
  height: 3px;
  margin-top: 3px;
  border-radius: var(--radius-pill);
  opacity: 0.35;
}

.theme-mini-line.w60 {
  width: 60%;
}

.theme-mini-line.w85 {
  width: 85%;
}

.theme-mini-accent {
  width: 16px;
  height: 5px;
  margin-top: 5px;
  border-radius: var(--radius-pill);
}

.theme-card-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 2px 2px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}

.theme-card-name .badge {
  height: 17px;
  padding: 0 5px;
  font-size: 9.5px;
}

/* Theme live preview */

.theme-live-preview {
  margin-top: 13px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}

.theme-live-preview-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.preview-window {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.preview-window-top {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 11px;
}

.preview-window-top i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.preview-window-top span {
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 9.5px;
}

.preview-window h4 {
  font-family: var(--font-content);
  font-size: calc(var(--font-size) * 0.95);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.preview-window p {
  margin-top: 5px;
  font-family: var(--font-content);
  font-size: calc(var(--font-size) * 0.66);
  line-height: var(--line-height);
  color: var(--text-secondary);
}

.preview-window .preview-actions {
  display: flex;
  gap: 6px;
  margin-top: 11px;
}

.preview-window .preview-btn {
  height: 21px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 9px;
  font-weight: 650;
  line-height: 21px;
}

.preview-window .preview-btn.ghost {
  background: var(--surface-2);
  color: var(--text-secondary);
}

/* Accent swatches */

.accent-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.accent-swatch {
  position: relative;
  width: 25px;
  height: 25px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform var(--fast), box-shadow var(--fast);
}

.accent-swatch:hover {
  transform: scale(1.08);
}

.accent-swatch.is-active {
  box-shadow: 0 0 0 2px var(--accent);
}

.accent-swatch.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.accent-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border: 1px dashed var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  overflow: hidden;
}

.accent-custom svg {
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.accent-custom input {
  position: absolute;
  inset: -6px;
  width: 40px;
  height: 40px;
  opacity: 0;
  cursor: pointer;
}

/* Custom theme builder */

.custom-theme-box {
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}

.custom-theme-colors {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.color-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.color-field span {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
}

.color-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 33px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.color-input-wrap input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: var(--radius-sm);
}

.color-input-wrap code {
  flex: 1;
  padding-left: 7px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.custom-theme-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.custom-theme-actions .input {
  height: 32px;
  font-size: 12px;
}

/* About / data */

.about-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 24px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.about-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-md);
}

.about-logo svg {
  width: 27px;
  height: 27px;
}

.about-card h3 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.about-card p {
  max-width: 380px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.about-version {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
}

.data-stat {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 13px;
}

.data-stat-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}

.data-stat-item strong {
  display: block;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.data-stat-item span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
}

/* ------------------------------ Share modal ------------------------------ */

.share-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}

.share-link-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  outline: none;
}

.share-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}

.share-option + .share-option {
  border-top: 1px solid var(--border);
}

.share-option strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.share-option span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ------------------------------ Account popover ------------------------------ */

.account-pop {
  position: fixed;
  z-index: 140;
  width: 248px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  animation: menu-in 130ms var(--ease);
}

.account-pop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 9px 11px;
}

.account-pop-head div {
  min-width: 0;
}

.account-pop-head strong {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-pop-head span {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------ Dropdown anchor ------------------------------ */

.dropdown-anchor {
  position: relative;
}

/* ------------------------------ Mobile drawer ------------------------------ */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--normal), visibility var(--normal);
}

.sidebar-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: var(--sidebar-width) 300px minmax(0, 1fr);
  }

  .editor-doc {
    padding-left: 38px;
    padding-right: 38px;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 232px 290px minmax(0, 1fr);
  }

  .editor-doc {
    padding-left: 30px;
    padding-right: 30px;
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 60;
    width: 268px;
    transform: translateX(-104%);
    transition: transform var(--normal);
    box-shadow: var(--shadow-lg);
    background: var(--bg-subtle);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar-mobile-menu {
    display: inline-flex;
  }

  .topbar-workspace {
    display: none;
  }

  .topbar-divider {
    display: none;
  }
}

@media (max-width: 820px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .list-pane {
    border-right: 0;
  }

  .editor-pane {
    display: none;
  }

  .workspace.is-editor-open .list-pane {
    display: none;
  }

  .workspace.is-editor-open .editor-pane {
    display: flex;
  }

  .editor-back {
    display: inline-flex;
  }

  .topbar-search {
    display: none;
  }

  .topbar-actions .search-mobile-btn {
    display: inline-flex;
  }

  .editor-doc {
    padding: 22px 22px 72px;
  }

  .editor-head {
    padding-left: 8px;
  }

  .editor-title {
    font-size: 28px;
  }

  .md-shell.show-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .md-shell.show-preview .md-pane--source {
    display: none;
  }

  .md-shell.show-preview .md-pane--preview {
    display: flex;
  }

  .md-preview {
    display: block;
  }

  .settings-backdrop {
    padding: 0;
  }

  .settings-modal {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }

  .settings-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    flex-direction: row;
    gap: 4px;
    padding: 9px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-user {
    display: none;
  }

  .settings-nav-item {
    width: auto;
    flex: none;
  }

  .settings-content {
    padding: 20px 18px 40px;
  }

  .theme-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .custom-theme-colors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 8px 0 10px;
    gap: 6px;
  }

  .topbar-wordmark {
    display: none;
  }

  .topbar-brand {
    padding-right: 0;
  }

  .topbar-avatar-btn > svg {
    display: none;
  }

  .editor-doc {
    padding: 18px 16px 60px;
  }

  .editor-toolbar {
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .toolbar-select {
    display: none;
  }

  .editor-head-actions .optional-action {
    display: none;
  }

  .settings-head {
    padding-left: 16px;
  }

  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .setting-control {
    width: 100%;
    justify-content: space-between;
  }

  .setting-control .select {
    flex: 1;
  }

  .data-stat {
    grid-template-columns: 1fr;
  }

  .list-head {
    padding-left: 10px;
    padding-right: 10px;
  }

  .toast-stack {
    bottom: 16px;
    width: calc(100% - 24px);
  }

  .toast {
    max-width: 100%;
  }
}

/* Hide scrollbars inside editor while keeping scroll */

.editor-scroll {
  scrollbar-gutter: stable;
}

/* ============================================================
   Motion & polish
   ============================================================ */

@keyframes note-card-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes editor-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.list-scroll.is-entering .note-card {
  animation: note-card-in 300ms var(--ease) both;
}

.list-scroll.is-entering .note-card:nth-child(2) { animation-delay: 18ms; }
.list-scroll.is-entering .note-card:nth-child(3) { animation-delay: 36ms; }
.list-scroll.is-entering .note-card:nth-child(4) { animation-delay: 54ms; }
.list-scroll.is-entering .note-card:nth-child(5) { animation-delay: 72ms; }
.list-scroll.is-entering .note-card:nth-child(6) { animation-delay: 90ms; }
.list-scroll.is-entering .note-card:nth-child(7) { animation-delay: 108ms; }
.list-scroll.is-entering .note-card:nth-child(8) { animation-delay: 126ms; }
.list-scroll.is-entering .note-card:nth-child(n + 9) { animation-delay: 144ms; }

.note-card {
  transition: background var(--fast), border-color var(--fast), transform var(--fast),
    box-shadow var(--fast);
}

.note-card.is-active {
  box-shadow: var(--shadow-sm);
}

@media (hover: hover) {
  .note-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }

  .note-card.is-active:hover {
    transform: none;
  }
}

.filter-chip {
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}

.filter-chip:active {
  transform: scale(0.97);
}

.side-item,
.side-tag,
.icon-btn,
.tool-btn {
  -webkit-tap-highlight-color: transparent;
}

.status-saved {
  transition: color var(--fast);
}

.editor-content,
.md-source {
  caret-color: var(--accent);
}

@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;
  }
}

/* Print */

@media print {
  .topbar,
  .sidebar,
  .list-pane,
  .editor-head,
  .editor-toolbar,
  .editor-status,
  .settings-backdrop,
  .toast-stack {
    display: none !important;
  }

  .workspace {
    display: block;
  }

  .editor-pane,
  .editor-scroll {
    display: block;
    overflow: visible;
  }

  .editor-doc {
    width: 100%;
    padding: 0;
  }
}