/* Preserve this order: later layers intentionally refine earlier component rules. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --motion-duration: 180ms;
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --overlay-enter-duration: 180ms;
  --overlay-exit-duration: 140ms;
  --overlay-enter-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --overlay-exit-ease: cubic-bezier(0.4, 0, 1, 1);
  --overlay-radius: 12px;
  --overlay-shadow: 0 12px 32px rgb(15 23 42 / 0.2);
  --overlay-backdrop: rgb(15 23 42 / 0.38);
  --bg: #fafafa;
  --fg: #0a4067;
  --muted: #5f6f82;
  --border: #e2e8f0;
  --accent: #ae2448;
  --accent-hover: #8a1d3a;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --card-bg: #fff;
  --surface: var(--bg);
  --radius: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, sfmono-regular, menlo, monaco, consolas, 'Liberation Mono', monospace;
  --shadow: 0 1px 3px rgb(0, 0, 0, 0.06);
  --border-strong: color-mix(in srgb, var(--border) 72%, var(--fg));
  --surface-hover: color-mix(in srgb, var(--fg) 5%, var(--surface));
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--card-bg));
  --focus-ring: color-mix(in srgb, var(--accent) 24%, transparent);
  --shadow-control: 0 1px 2px color-mix(in srgb, var(--fg) 8%, transparent);
  --shadow-card: 0 8px 24px color-mix(in srgb, var(--fg) 7%, transparent);
  color-scheme: light;
}

:root.dark {
  --bg: #0e1124;
  --fg: #cfd1fc;
  --muted: #7c7fa8;
  --border: #1e293b;
  --accent: #f13c66;
  --accent-hover: #d42e55;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --card-bg: #1a1d31;
  --surface: var(--bg);
  --shadow: 0 1px 3px rgb(0, 0, 0, 0.2);
  color-scheme: dark;
}

html {
  font-size: 16px;
  background: var(--bg);
  scrollbar-gutter: stable;
}

/* A shared, quiet scrollbar keeps every scrollable surface predictable. */
* {
  scrollbar-color: color-mix(in srgb, var(--muted) 42%, transparent) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 0.75rem;
  height: 0.75rem;
}

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

*::-webkit-scrollbar-thumb {
  border: 0.2rem solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 42%, transparent);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 62%, transparent);
  background-clip: padding-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  text-rendering: optimizelegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

textarea {
  scrollbar-gutter: stable;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

#app {
  width: 100%;
}

#login-screen,
#dashboard,
#editor {
  background: var(--bg);
}

#boot-screen {
  display: none;
  min-height: 100dvh;
  padding: 1.5rem;
  place-items: center;
}

#app.booting > #boot-screen {
  display: grid;
}

#app.booting > :not(#boot-screen) {
  display: none !important;
}

.boot-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: boot-spin 0.7s linear infinite;
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

@keyframes app-content-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes app-content-return {
  from {
    opacity: 0;
    transform: scale(1.015);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes app-content-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: scale(0.985);
  }
}
/* Navigation keeps the outgoing DOM briefly, not a cloned or raster snapshot.
   Logical visibility is already hidden; only the compositor finishes its exit. */
#app > .screen-leaving.hidden {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block !important;
  pointer-events: none;
  animation: app-content-out var(--motion-duration) var(--motion-ease) both;
}

#app > #editor.screen-leaving.hidden {
  display: flex !important;
}

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

.icon {
  display: block;
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* Shared controls */
.btn-text,
.btn-primary,
.btn-secondary,
.prefs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  gap: 0.45rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    color 0.15s,
    transform 0.15s;
}

.btn-text {
  padding: 0.45rem 0.7rem;
  background: transparent;
  color: var(--muted);
}

.btn-text:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--fg);
}

.btn-text.danger {
  color: var(--danger);
}

.btn-text.danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.btn-primary {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--accent) 28%, transparent);
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}

.btn-primary:active {
  box-shadow: none;
  transform: translateY(1px);
}

.btn-primary.danger {
  border-color: var(--danger);
  background: var(--danger);
  box-shadow: 0 2px 5px color-mix(in srgb, var(--danger) 28%, transparent);
}

.btn-primary.danger:hover {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.btn-secondary {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border-strong);
  background: var(--card-bg);
  color: var(--fg);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.btn-secondary.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-secondary.danger:hover {
  border-color: var(--danger-hover);
  background: color-mix(in srgb, var(--danger) 10%, var(--card-bg));
  color: var(--danger-hover);
}

.prefs-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.prefs-btn:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.prefs-btn .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.icon-btn {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  place-items: center;
  gap: 0;
  line-height: 1;
}

.icon-btn .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.btn-text.icon-btn {
  color: var(--muted);
}

.btn-text.icon-btn:hover {
  color: var(--fg);
}

.back-chevron {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2;
}

/* Shared dialog shell. Content-specific layouts live with their features. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 1rem;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-backdrop);
}

.modal-body {
  position: relative;
  width: min(100%, 28rem);
  max-height: calc(100dvh - 2rem);
  padding: 1.5rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--card-bg);
  border: 0;
  border-radius: var(--overlay-radius);
  box-shadow: var(--overlay-shadow);
}

.modal-body--standard {
  width: min(100%, 34rem);
}

.modal-body--form {
  width: min(100%, 36rem);
  max-height: min(90dvh, 52rem);
}

.modal-body--wide {
  width: min(100%, 68rem);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.modal-heading :is(h2, h3) {
  margin: 0;
  font-size: 1.125em;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.modal-close {
  display: grid;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.5rem;
  place-items: center;
  border-radius: var(--radius-action);
  background: transparent;
  color: var(--muted);
}

.modal-close:hover {
  background: var(--surface);
  color: var(--fg);
}

.modal-close .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.modal-copy {
  margin: -0.25rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.modal-copy + .modal-copy {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-actions button {
  min-height: 2.25rem;
}

@keyframes modal-backdrop-in {
  from {
    opacity: var(--overlay-backdrop-start-opacity, 0);
  }
  to {
    opacity: 1;
  }
}
@keyframes modal-backdrop-out {
  from {
    opacity: var(--overlay-backdrop-start-opacity, 1);
  }
  to {
    opacity: 0;
  }
}
.modal:not(.hidden) .modal-backdrop {
  animation: modal-backdrop-in var(--overlay-enter-duration) var(--overlay-enter-ease) both;
}

.modal:not(.hidden) .modal-body {
  animation: overlay-content-in var(--overlay-enter-duration) var(--overlay-enter-ease) backwards;
  backface-visibility: hidden;
}

.modal.is-closing .modal-backdrop {
  animation: modal-backdrop-out var(--overlay-exit-duration) var(--overlay-exit-ease) both;
}

.modal.is-closing .modal-body {
  animation: overlay-content-out var(--overlay-exit-duration) var(--overlay-exit-ease) both;
  backface-visibility: hidden;
}

@media (max-width: 640px) {
  .modal-body {
    padding: 1.25rem;
  }
  .modal-body--form {
    max-height: calc(100dvh - 1rem);
  }
}
/* Login */
#login-screen {
  display: grid;
  min-height: 100dvh;
  padding: 1.5rem;
  place-items: center;
}

#login-form {
  width: min(100%, 24rem);
  padding: 2.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#login-form h1 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

#login-form h1 {
  margin: 0 0 1.5rem;
}

#login-form .app-brand {
  justify-content: center;
}

#login-credentials[hidden],
#login-secure-context-notice[hidden] {
  display: none;
}

#login-credentials > button[type='submit'] {
  width: 100%;
  padding: 0.72rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  transition: background 0.15s;
}

#login-credentials > button[type='submit']:hover {
  background: var(--accent-hover);
}

#login-secure-context-notice {
  margin: 0;
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.5;
}

#login-secure-context-notice a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

#login-secure-context-notice a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#login-form .login-forgot-password {
  display: block;
  width: fit-content;
  min-height: 2.25rem;
  margin: 0.5rem 0 0 auto;
  padding: 0.25rem 0.125rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

#login-form .login-forgot-password[hidden] {
  display: none;
}

#login-form .login-forgot-password:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

#login-form .login-forgot-password:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body:has(
    #login-recovery-modal:not(.hidden),
    #login-recovery-entry-modal:not(.hidden),
    #login-recovery-lost-modal:not(.hidden)
  )
  #toast-region {
  visibility: hidden;
  pointer-events: none;
}

.recovery-signin-notice[hidden] {
  display: none;
}

#login-recovery-form {
  display: grid;
  gap: 0.75rem;
}

.login-recovery-word-row {
  display: block;
}

.login-recovery-word-row[hidden] {
  display: none;
}

.login-recovery-count {
  color: var(--muted);
  font-size: 0.875rem;
}

.login-recovery-words {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.5rem;
  height: calc(10.5rem + 2px);
  padding: 0.5rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-action);
  background: var(--surface);
  scrollbar-gutter: stable;
}

.login-recovery-words[hidden] {
  display: none;
}

.login-recovery-words:empty::before {
  content: 'Entered words appear here';
  color: var(--muted);
  font-size: 0.875rem;
}

.login-recovery-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  height: 2rem;
  padding: 0.125rem 0.25rem 0.125rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.login-recovery-chip:hover {
  border-color: var(--accent);
}

.login-recovery-placeholder {
  box-sizing: border-box;
  flex: none;
  border: 1px dashed color-mix(in srgb, var(--accent) 58%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  pointer-events: none;
}

.login-recovery-ghost {
  position: fixed;
  z-index: 140;
  margin: 0;
  opacity: 0.96;
  box-shadow: 0 0.6rem 1.4rem rgba(15, 23, 42, 0.16);
  pointer-events: none;
  cursor: grabbing;
  will-change: transform;
}

.login-recovery-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-recovery-chip-remove {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  place-items: center;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.login-recovery-chip-remove:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.recovery-signin-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: calc(100% - var(--page-gutter) - var(--page-gutter));
  max-width: calc(var(--content-max-width) - var(--page-gutter) - var(--page-gutter));
  margin: 1rem auto 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--fg);
  font-size: 0.875rem;
  line-height: 1.4;
}

.recovery-signin-notice > div {
  display: flex;
  align-items: center;
  flex: none;
}

.recovery-signin-notice .icon {
  width: 1rem;
  height: 1rem;
}

@media (max-width: 640px) {
  .recovery-signin-notice {
    align-items: flex-start;
    flex-direction: column;
    margin-inline: 1rem;
    width: auto;
  }
}
.error {
  min-height: 1.25rem;
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-size: 0.875rem;
  text-align: center;
}

/* Dashboard */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

#dashboard > header {
  padding-right: max(
    var(--page-gutter),
    (100% - var(--content-max-width)) / 2 + var(--page-gutter)
  );
  padding-left: max(var(--page-gutter), (100% - var(--content-max-width)) / 2 + var(--page-gutter));
}

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

.header-left {
  gap: 0.35rem;
}

.header-right {
  gap: 0.5rem;
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fg);
}

.app-brand img {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
}

.app-brand span {
  display: block;
}

.dashboard-body {
  width: 100%;
  max-width: 54rem;
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

#dashboard:not(.hidden) .dashboard-body {
  animation: app-content-in var(--motion-duration) var(--motion-ease) backwards;
}

#dashboard:not(.hidden).returning-from-editor .dashboard-body {
  animation-name: app-content-return;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0 var(--page-gutter) 0.625rem;
}

.toolbar .btn-primary {
  font-size: 0.875rem;
}

#tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.25rem var(--page-gutter) 0.75rem;
}

.tag {
  display: inline-block;
  min-height: 1.875rem;
  padding: 0.32rem 0.625rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s,
    color 0.15s;
}

.tag:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.tag.active {
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

#note-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin: 0;
  padding: 0.75rem var(--page-gutter);
  list-style: none;
}

.note-item-row {
  position: relative;
}

.note-item {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 6.125rem;
  padding: 1rem 3.25rem 0.95rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: var(--shadow-control);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.note-item:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  box-shadow: var(--shadow-card);
}

.note-item .note-title {
  margin-bottom: 0.25rem;
  font-size: 1rem;
  font-weight: 680;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.note-item .note-meta {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.note-item .note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.note-item .note-tags .tag {
  min-height: auto;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-micro);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: default;
}

.note-pin {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.1rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.note-pin .icon {
  width: 1rem;
  height: 1rem;
}

.note-pin .unpin-icon {
  display: none;
}

.note-pin[aria-pressed='true']:hover .pin-icon {
  display: none;
}

.note-pin[aria-pressed='true']:hover .unpin-icon {
  display: block;
}

.note-item-row:hover .note-pin,
.note-pin:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.note-pin:hover,
.note-pin[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.note-empty {
  padding: 2.5rem 0;
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: center;
}

/* Editor chrome */
.note-pin[aria-pressed='true'] {
  opacity: 1;
  pointer-events: auto;
}

#editor {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

#editor.header-hidden > header {
  display: none;
}

.editor-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.625rem;
  width: 100%;
  padding: 0.75rem var(--page-gutter) 1rem;
  overflow: hidden;
}

#editor:not(.hidden) .editor-body {
  animation: app-content-in var(--motion-duration) var(--motion-ease) backwards;
}

.meta-pane {
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.meta-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--card-bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  text-align: left;
  text-transform: none;
}

.meta-toggle:hover {
  background: var(--surface-hover);
}

.meta-toggle:focus-visible {
  outline-offset: -3px;
}

.meta-toggle .icon {
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s;
}

.meta-pane.collapsed .meta-toggle .icon {
  transform: rotate(-90deg);
}

.meta-body {
  display: grid;
  align-items: end;
  gap: 0.75rem;
  padding: 0.25rem 0.75rem 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.meta-pane.collapsed .meta-body {
  display: none;
}

.editor-panels {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.editor-panels:not(.panels-single) .panel-editor {
  flex: 0 0 var(--editor-panel-width, 50%);
}

.panel {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.3;
  flex-shrink: 0;
}

.panel-label {
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.panel-layout {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  place-items: center;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.panel-layout:hover {
  background: var(--border);
  color: var(--fg);
}

.panel-layout .icon {
  width: 0.875rem;
  height: 0.875rem;
  stroke-width: 2;
}

.panel-resizer {
  position: relative;
  z-index: 2;
  flex: 0 0 0.75rem;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.panel-resizer::before,
.panel-resizer::after {
  content: none;
}

.panel-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.fmt-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem 0.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.fmt-bar button {
  display: grid;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0.25rem;
  place-items: center;
  border-radius: 5px;
  background: transparent;
  color: var(--fg);
}

.fmt-bar button:hover {
  background: var(--surface);
}

.fmt-bar button:active {
  background: var(--accent);
  color: #fff;
}

.fmt-bar .icon {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2;
}

.fmt-bar .fmt-heading-trigger {
  font-weight: 700;
}

.fmt-sep {
  width: 1px;
  height: 1.125rem;
  margin: 0 0.2rem;
  background: var(--border);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .meta-body {
    grid-template-columns: 1fr;
  }
}
/* Writing and rendered Markdown use the same deliberate type scale. */
#note-content {
  padding-bottom: 4.95em;
  scroll-padding-bottom: 4.95em;
}

#note-content,
.preview {
  flex: 1;
  min-height: 0;
  padding: 1rem var(--editor-content-gutter, 1.125rem);
  border: 0;
  border-radius: 0;
  background: var(--card-bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.preview {
  outline: none;
  overflow-wrap: anywhere;
}

.dark #note-content {
  color-scheme: dark;
}

#note-content {
  resize: none;
  outline: none;
  tab-size: 2;
}

.preview > :first-child {
  margin-top: 0;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  margin: 1.65em 0 0.65em;
  color: var(--fg);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.preview h1 {
  font-size: 2rem;
}

.preview h2 {
  font-size: 1.625rem;
}

.preview h3 {
  font-size: 1.3125rem;
}

.preview h4 {
  font-size: 1.125rem;
}

.preview h5 {
  font-size: 1rem;
}

.preview h6 {
  font-size: 0.875rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.preview p {
  margin: 0 0 1em;
}

.preview ul,
.preview ol {
  margin: 0 0 1em;
  padding-left: 1.5rem;
}

.preview li + li {
  margin-top: 0.25rem;
}

.preview code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  font-family: var(--mono);
  font-size: 0.875em;
}

.preview pre {
  margin: 0 0 1.125rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.preview pre code {
  display: block;
  padding: 1rem;
  overflow-x: auto;
  scrollbar-gutter: stable;
  background: transparent;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.preview blockquote {
  margin: 0 0 1em;
  padding: 0.2rem 0 0.2rem 0.875rem;
  border-left: 1px solid var(--accent);
  color: var(--muted);
}

.preview a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.preview a:hover {
  text-decoration-thickness: 2px;
}

.preview img {
  max-width: 100%;
  border-radius: var(--radius);
}

.preview hr {
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.preview table {
  display: block;
  width: 100%;
  margin: 0 0 1em;
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-gutter: stable;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.45;
}

.preview th,
.preview td {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.preview th {
  background: var(--surface);
  font-weight: 700;
}

.offline-snackbar {
  position: fixed;
  z-index: 120;
  top: 4.15rem;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: calc(100vw - 1.5rem);
  padding: 0.55rem 0.75rem 0.55rem 1rem;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
}

.offline-retry {
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.offline-retry:disabled {
  color: var(--muted);
  text-decoration: none;
}

.toast-region {
  position: fixed;
  z-index: 130;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  max-width: min(22rem, 100vw - 2rem);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(0.35rem);
  transition:
    opacity 0.18s,
    transform 0.18s;
}

.toast.visible {
  opacity: 1;
  transform: none;
}

.toast.warning {
  border-color: color-mix(in srgb, #b45309 40%, var(--border));
}

.toast.update {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
}

.toast.update span {
  min-width: 0;
}

.toast-action {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.25rem;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.toast-action:disabled {
  color: var(--muted);
  text-decoration: none;
}

/* Interactive Markdown preview: controls never displace rendered content. */
.interactive-preview-locked {
  opacity: 0.55;
  pointer-events: none;
}

.interactive-preview-active {
  --preview-action-size: 1.75rem;
  --preview-action-gap: 0.125rem;
  --preview-action-inset: 0.375rem;
  --preview-controls-width: calc(var(--preview-action-size) + var(--preview-action-size));
  --preview-controls-space: calc(var(--preview-action-gap) + var(--preview-action-inset));
  --preview-action-lane: calc(var(--preview-controls-width) + var(--preview-controls-space));
}

.interactive-preview-card {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 var(--preview-action-lane) 0 0;
  border-radius: 6px;
  outline: 1px solid transparent;
  outline-offset: -1px;
  transition:
    background-color 0.12s,
    outline-color 0.12s;
}

.interactive-preview-card:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  outline-color: var(--border);
}

.preview-drag-handle {
  position: absolute;
  z-index: 1;
  top: 0;
  right: calc(var(--preview-action-inset) + var(--preview-action-size) + var(--preview-action-gap));
  display: grid;
  width: var(--preview-action-size);
  height: var(--preview-action-size);
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  font: inherit;
  opacity: 0;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition:
    color 0.12s,
    opacity 0.12s;
}

.interactive-preview-card:is(:hover, :focus-within) > .preview-drag-handle,
.preview-drag-ghost .preview-drag-handle {
  color: var(--fg);
  opacity: 0.9;
}

.interactive-preview-card.is-drag-pending {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  outline-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.interactive-preview-card.is-drag-pending > .preview-drag-handle {
  color: var(--accent);
  opacity: 1;
}

.preview-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.preview-drag-handle .icon {
  width: 0.75rem;
  height: 1.125rem;
  fill: currentcolor;
}

.preview-edit-button {
  position: absolute;
  z-index: 1;
  top: 0;
  right: var(--preview-action-inset);
  display: grid;
  width: var(--preview-action-size);
  height: var(--preview-action-size);
  padding: 0.35rem;
  place-items: center;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition:
    background-color 0.12s,
    color 0.12s,
    opacity 0.12s;
}

.preview-edit-button:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--fg);
}

.preview-edit-button:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--fg);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.preview-edit-button .icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 1.8;
}

.interactive-preview-card:is(:hover, :focus-within, .is-selected) > .preview-edit-button {
  opacity: 1;
  pointer-events: auto;
}

.interactive-preview-rule-card > .preview-edit-button {
  top: 50%;
  transform: translateY(-50%);
}

.preview-drag-ghost .preview-edit-button {
  display: none;
}

.preview-drag-content {
  min-width: 0;
  cursor: text;
}

.preview-block-content > :first-child,
.preview-list-item-body > :first-child {
  margin-top: 0;
}

.preview-block-content > :last-child,
.preview-list-item-body > :last-child {
  margin-bottom: 0;
}

.interactive-preview-block-card {
  margin-bottom: 0;
  padding-block: 0.125rem;
}

.interactive-preview-block-card + .interactive-preview-block-card {
  margin-top: 0.75rem;
}

.interactive-preview-block-card:not(:first-child):has(
    > .preview-block-content > :is(h1, h2, h3, h4, h5, h6)
  ) {
  margin-top: 1rem;
}

.interactive-preview-block-card:has(> .preview-block-content > :is(h1, h2, h3, h4, h5, h6))
  + .interactive-preview-block-card {
  margin-top: 0.5rem;
}

.interactive-preview-rule-card {
  width: 100%;
}

.interactive-preview-rule-card > .preview-drag-handle {
  top: 50%;
  transform: translateY(-50%);
}

.interactive-preview-rule-card > .preview-block-content {
  width: 100%;
}

.interactive-preview-rule-card hr {
  width: 100%;
  margin: 0;
}

.interactive-preview-active :is(ul, ol) {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.interactive-preview-list-item {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.interactive-preview-list-item + .interactive-preview-list-item {
  margin-top: 0.375rem;
}

.interactive-preview-list-item > :is(ul, ol) {
  margin: 0.5rem 0 0.25rem 1.5rem;
}

.interactive-preview-list-card {
  padding-block: 0.125rem;
}

.interactive-preview-active > :is(ul, ol) {
  margin-bottom: 0.75rem;
}

.interactive-preview-active > .interactive-preview-block-card + :is(ul, ol) {
  margin-top: 0.75rem;
}

.preview-list-content {
  display: grid;
  grid-template-columns: minmax(1.5rem, max-content) minmax(0, 1fr);
  column-gap: 0.25rem;
}

.interactive-preview-list-card.is-task:not(.has-marker) > .preview-list-content {
  grid-template-columns: minmax(0, 1fr);
}

.preview-list-marker {
  display: block;
  align-self: start;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.65;
  text-align: right;
  white-space: nowrap;
  user-select: none;
}

.preview-list-marker[data-kind='bullet']::before {
  display: block;
  width: 0.35rem;
  height: 0.35rem;
  margin: 0.65em auto 0;
  border-radius: 50%;
  background: currentcolor;
  content: '';
}

.preview-list-item-body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.preview-list-item-body > p {
  margin: 0;
}

.interactive-preview-block-card[data-preview-drop='before'],
.interactive-preview-list-item[data-preview-drop='before'] > .interactive-preview-card {
  box-shadow: inset 0 2px 0 var(--accent);
}

.interactive-preview-block-card[data-preview-drop='after'],
.interactive-preview-list-item[data-preview-drop='after'] > .interactive-preview-card {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.preview-drag-placeholder {
  display: block !important;
  box-sizing: border-box;
  min-height: 1.5rem;
  margin: 0;
  border: 1px dashed color-mix(in srgb, var(--accent) 58%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  opacity: 0.9;
  pointer-events: none;
}

.preview-drag-portal.preview {
  position: fixed;
  inset: 0;
  z-index: 140;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.preview-drag-ghost {
  position: fixed;
  z-index: 1;
  box-sizing: border-box;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  cursor: grabbing;
  user-select: none;
  will-change: transform;
  contain: layout paint style;
  background: var(--card-bg);
  outline-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0.6rem 1.4rem rgba(15, 23, 42, 0.16);
  opacity: 0.96;
}

.preview-drag-active,
.preview-drag-active * {
  cursor: grabbing !important;
}

.preview-drag-active.preview-drag-outside,
.preview-drag-active.preview-drag-outside * {
  cursor: not-allowed !important;
}

@media (max-width: 640px) {
  .preview:not(.interactive-preview-active) {
    padding-inline: 1rem;
  }
  .interactive-preview-active {
    --preview-action-size: 2.75rem;
    --preview-action-inset: 0px;
    --preview-action-tray-left: 0px;
    --preview-action-tray-top: 0px;
  }
  .interactive-preview-card {
    width: fit-content;
    padding-right: 0;
  }
  .interactive-preview-list-item {
    width: fit-content;
    max-width: 100%;
  }
  .interactive-preview-list-item > :is(ul, ol) {
    margin-left: 1.25rem;
  }
  .interactive-preview-card.is-selected {
    background: color-mix(in srgb, var(--accent) 5%, transparent);
    outline-color: var(--border);
  }
  .interactive-preview-card > .preview-drag-handle,
  .interactive-preview-card > .preview-edit-button {
    width: var(--preview-action-size);
    height: var(--preview-action-size);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }
  .interactive-preview-card.is-selected > .preview-drag-handle,
  .interactive-preview-card.is-selected > .preview-edit-button {
    position: fixed;
    z-index: 8;
    top: var(--preview-action-tray-top);
    height: var(--preview-action-size);
    padding: 0;
    color: var(--fg);
    opacity: 1;
    border: 0;
    background: transparent;
    pointer-events: auto;
    visibility: visible;
    transform: none;
  }
  .interactive-preview-card.is-selected > .preview-drag-handle {
    right: auto;
    left: var(--preview-action-tray-left);
  }
  .interactive-preview-card.is-selected > .preview-drag-handle::before {
    position: absolute;
    z-index: -1;
    inset: 5px 0 5px 5px;
    width: calc(var(--preview-action-size) * 2 - 10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-micro);
    background: var(--card-bg);
    content: '';
    pointer-events: none;
  }
  .interactive-preview-card.is-selected > .preview-edit-button {
    right: auto;
    left: calc(var(--preview-action-tray-left) + var(--preview-action-size));
  }
  .interactive-preview-card.is-selected > :is(.preview-drag-handle, .preview-edit-button):active {
    color: var(--fg);
  }
  .preview-drag-ghost :is(.preview-drag-handle, .preview-edit-button) {
    visibility: hidden;
  }
  .interactive-preview-card:not(.is-selected):is(:hover, :focus-within) > .preview-drag-handle,
  .interactive-preview-card:not(.is-selected):is(:hover, :focus-within) > .preview-edit-button {
    opacity: 0;
    pointer-events: none;
  }
}
/* Table picker */
.table-picker,
.heading-picker {
  position: fixed;
  z-index: 110;
  width: max-content;
  padding: 0.6rem;
  border: 0;
  border-radius: var(--overlay-radius);
  background: var(--card-bg);
  box-shadow: var(--overlay-shadow);
}

.heading-picker {
  display: flex;
  gap: 0.25rem;
}

.heading-picker button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: var(--radius-action);
  background: transparent;
  color: var(--fg);
  font-weight: 600;
}

.heading-picker button:is(:hover, :focus-visible) {
  background: var(--surface);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.table-picker-label {
  min-width: 8rem;
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(8, 1.15rem);
  gap: 0.2rem;
}

.table-grid-cell {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
}

.table-grid-cell:hover,
.table-grid-cell:focus-visible,
.table-grid-cell.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  outline: 0;
}

/* Valid margin declarations for paragraph rhythm. */
.preview p {
  margin: 0 0 1em;
}

/* Note metadata uses the available desktop width without changing mobile. */
.meta-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.meta-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
  border: 0;
}

.meta-actions .btn-text {
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
}

/* Preferences */
.device-row {
  cursor: default;
}

.device-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.device-row > button {
  flex: none;
  white-space: nowrap;
}

.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.35;
  cursor: pointer;
}

.pref-row:first-of-type {
  border-top: 0;
}

.pref-row input[type='checkbox'] {
  position: relative;
  width: 2.375rem;
  height: 1.375rem;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  outline: none;
  transition: background 0.15s;
  flex-shrink: 0;
}

.pref-row input[type='checkbox']::before {
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  content: '';
  transition: transform 0.15s;
}

.pref-row input[type='checkbox']:checked {
  background: var(--accent);
}

.pref-row input[type='checkbox']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pref-row input[type='checkbox']:checked::before {
  transform: translateX(1rem);
}

.app-version {
  display: block;
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
}

.prefs-encryption [hidden] {
  display: none !important;
}

.vault-overview {
  position: relative;
  margin-bottom: 1.15rem;
  padding: 0 3rem 0 0;
}

.vault-overview strong {
  font-size: 0.9375rem;
}

.vault-status-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.vault-status-icon {
  display: none;
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  color: #16834a;
}

.prefs-encryption:has(#vault-active:not([hidden])) .vault-status-icon {
  display: block;
}

.vault-overview p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.vault-secure-context-note {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.vault-secure-context-note a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.vault-secure-context-note a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vault-info summary {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.vault-info summary::-webkit-details-marker {
  display: none;
}

.vault-info summary:hover,
.vault-info[open] summary {
  border-color: var(--accent);
  color: var(--accent);
}

.vault-info summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vault-info .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.vault-info-copy {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.vault-info-copy p:first-child {
  margin-top: 0;
}

.vault-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.85rem 0.25rem;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
}

.vault-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.vault-option > span {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.vault-option strong {
  font-size: 1rem;
  font-weight: 600;
}

.vault-option small {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.35;
}

.vault-option .icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: var(--muted);
}

.vault-option:is(:hover, :focus-visible) strong {
  color: var(--accent);
}

.vault-option:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.vault-option:disabled:hover strong {
  color: inherit;
}

.vault-master-methods p {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.vault-master-methods .vault-option:last-child {
  border-bottom: 1px solid var(--border);
}

.vault-master-fields {
  display: grid;
  gap: 0.9rem;
}

.vault-master-method-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.vault-setup-form {
  display: grid;
  width: 100%;
  max-width: none;
  gap: 0.9rem;
  padding: 0.25rem 0 0;
}

.vault-setup-form [hidden] {
  display: none !important;
}

.vault-form-actions {
  padding-top: 0.5rem;
}

.vault-passphrase-field {
  display: grid;
  gap: 0.35rem;
}

.vault-setup-form input:not([type='checkbox'], [type='radio'], .label-input__control),
.vault-setup-form textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.8rem;
  color: var(--fg);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
}

.vault-setup-form input[type='checkbox']:focus-visible,
.vault-setup-form textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vault-check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.vault-check {
  justify-content: flex-start;
  font-size: 0.875rem;
}

.vault-hint {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.vault-hint,
.vault-progress,
.vault-setup-form .error {
  margin: 0;
}

.vault-hint[data-score='0'],
.vault-hint[data-score='1'] {
  color: var(--danger);
}

.vault-hint[data-score='2'],
.vault-hint[data-score='3'] {
  color: #8a4b08;
}

.dark .vault-hint[data-score='2'],
.dark .vault-hint[data-score='3'] {
  color: #fbbf24;
}

.vault-hint[data-score='4'] {
  color: #16834a;
}

.vault-recovery {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 8px;
  background: var(--surface);
}

.vault-reset-warning {
  padding: 1rem;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.5;
}

.vault-reset-warning p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.vault-recovery-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vault-recovery-words li {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 6.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--fg);
  font-size: 0.875rem;
}

.vault-recovery-number {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.vault-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.vault-recovery-entry-step {
  display: grid;
  gap: 0.75rem;
}

.vault-recovery-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.vault-recovery button {
  justify-self: start;
}

.vault-progress {
  color: var(--muted);
  font-size: 0.875rem;
}

.vault-progress:empty,
.vault-setup-form .error:empty,
.vault-setup-form .vault-hint:empty {
  display: none;
}

@media (max-width: 640px) {
  .vault-recovery {
    padding: 0.85rem;
  }
}
/* Conflict resolution keeps both durable versions visible while the result remains editable. */
.conflict-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.conflict-metadata-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.conflict-metadata-compare section {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.75rem;
}

.conflict-metadata-compare section:first-child {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.conflict-metadata-compare section:last-child {
  border-color: color-mix(in srgb, var(--status-syncing) 45%, var(--border));
}

.conflict-metadata-compare span {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.conflict-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.conflict-version {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.conflict-version h4 {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.conflict-version-local h4 {
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
}

.conflict-version-remote h4 {
  background: color-mix(in srgb, var(--status-syncing) 12%, var(--surface));
}

.conflict-version pre,
.conflict-base pre {
  min-height: 7rem;
  max-height: 17rem;
  margin: 0;
  padding: 0.7rem;
  overflow: auto;
  scrollbar-gutter: stable;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.conflict-line {
  padding: 0 0.08rem;
  background: color-mix(in srgb, var(--status-syncing) 20%, transparent);
  color: inherit;
}

.conflict-line-local {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

.conflict-line-remote {
  background: color-mix(in srgb, var(--status-syncing) 22%, transparent);
}

.conflict-result {
  margin-top: 1rem;
}

.conflict-result textarea {
  min-height: 15rem;
  resize: vertical;
}

.conflict-base {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.conflict-base summary {
  cursor: pointer;
}

.conflict-base pre {
  margin-top: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.conflict-actions {
  margin-top: 1rem;
}

.conflict-actions-top {
  justify-content: flex-end;
  margin-top: 0;
}

.conflict-actions-spacer {
  flex: 1;
}

.note-conflict {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.45rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--status-offline) 24%, var(--border));
  border-radius: 5px;
  background: color-mix(in srgb, var(--status-offline) 8%, var(--card-bg));
  color: var(--status-offline);
  font-size: 0.6875rem;
  font-weight: 750;
  vertical-align: middle;
}

.note-conflict::before {
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: currentcolor;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentcolor 13%, transparent);
  content: '';
}

.conflict-version.is-selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.conflict-version-remote.is-selected {
  border-color: var(--status-syncing);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-syncing) 16%, transparent);
}

.conflict-select {
  width: 100%;
  min-height: 2.5rem;
  border-radius: 0;
  background: var(--surface);
  font-weight: 700;
}

.conflict-select[aria-pressed='true'] {
  background: var(--accent);
  color: #fff;
}

.conflict-version-remote .conflict-select[aria-pressed='true'] {
  background: var(--status-syncing);
  color: #fff;
}

.conflict-selection-status {
  margin: -0.25rem 0 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 640px) {
  .conflict-fields,
  .conflict-metadata-compare,
  .conflict-compare {
    grid-template-columns: 1fr;
  }
  .conflict-version pre {
    max-height: 10rem;
  }
  .conflict-actions {
    flex-wrap: wrap;
  }
  .conflict-actions-spacer {
    display: none;
    flex-basis: 100%;
    height: 0;
  }
  .conflict-actions #conflict-later {
    margin-left: auto;
  }
}
/* Focus and narrow screens */
.panel-resizer::before {
  display: none;
}

.editor-body:has(.panels-single) .meta-pane {
  display: none;
}

.panels-single {
  justify-content: center;
}

.panels-single .panel {
  flex: 0 1 54rem;
}

.panels-single .panel-resizer {
  display: none;
}

.editor-body:has(.panels-single) .meta-pane {
  align-self: center;
  width: 100%;
  max-width: 54rem;
}

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

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }
  #login-form {
    padding: 1.75rem 1.25rem;
  }
  header,
  #dashboard > header,
  #editor:has(.panels-single) > header {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }
  .editor-body {
    padding: 0.5rem 0.75rem 0.75rem;
  }
  .dashboard-body {
    padding-top: 0.5rem;
  }
  .toolbar {
    padding: 0 0.75rem 0.5rem;
  }
  #tag-bar {
    padding: 0.25rem 0.75rem 0.5rem;
  }
  #note-list {
    padding: 0.5rem 0.75rem 1rem;
  }
  .editor-panels {
    flex-direction: column;
    gap: 0.625rem;
  }
  .editor-panels:not(.panels-single) .panel-editor {
    flex: 1 1 0;
  }
  .panel-resizer {
    display: none !important;
  }
  .panels-single .panel {
    flex: 1;
    max-width: 100%;
  }
  .panel-preview {
    min-height: 35%;
  }
  .fmt-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .fmt-bar button {
    flex: 0 0 1.5rem;
  }
  .preview h1 {
    font-size: 1.75rem;
  }
  .preview h2 {
    font-size: 1.45rem;
  }
  .preview h3 {
    font-size: 1.2rem;
  }
  .header-left {
    gap: 0.25rem;
  }
  .header-left .btn-text {
    padding-inline: 0.35rem;
  }
  .app-brand {
    gap: 0.35rem;
  }
  .app-brand img {
    width: 1.5rem;
    height: 1.5rem;
  }
  .app-brand span {
    font-size: 1rem;
  }
  .header-right {
    gap: 0.25rem;
  }
  .header-right .btn-primary {
    padding-inline: 0.7rem;
  }
}
@media (max-width: 640px) {
  .meta-fields {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }
  .note-pin {
    opacity: 1;
    pointer-events: auto;
  }
}
@media (max-width: 640px) {
  .toast-region {
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: 0.75rem;
    align-items: stretch;
  }
  .toast {
    width: 100%;
    max-width: none;
  }
  .toast.update {
    justify-content: space-between;
  }
  .offline-snackbar {
    top: 3.75rem;
  }
}
/* Preferences stays over the current screen while its sections share one navigator. */
.prefs-modal-body {
  width: min(100%, 68rem);
  height: min(46rem, 100dvh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: hidden;
}

.prefs-page-body {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.prefs-sidebar {
  display: flex;
  flex: 0 0 14rem;
  flex-direction: column;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.prefs-sidebar-title {
  display: flex;
  align-items: center;
  margin: 0 0 1.5rem;
  padding: 0 0.65rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.prefs-sidebar nav {
  display: grid;
  gap: 0.2rem;
}

.prefs-nav {
  min-height: 2.125rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

.prefs-nav:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.prefs-nav.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.prefs-content {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 1.5rem 1.75rem 2rem;
  overflow: hidden;
}

.prefs-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex: none;
  width: 100%;
  padding-inline: 0.5rem;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.prefs-content-header .modal-close:focus-visible {
  outline-offset: -2px;
}

.prefs-content-header h2 {
  margin: 0;
  font-size: 1.125em;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.prefs-section {
  display: none;
}

.prefs-section.active {
  display: block;
  box-sizing: border-box;
  min-height: 0;
  width: 100%;
  padding: 0.5rem 0.5rem 1rem;
  overflow-y: auto;
  scroll-padding: 0.5rem;
  scrollbar-gutter: stable;
}

.sync-indicator-label {
  display: inline;
}

.sync-indicator[data-state='offline'] .sync-indicator-label {
  display: inline;
}

:root[data-status-display='compact'] .sync-indicator-label {
  display: none;
}

:root[data-status-display='off'] .sync-indicator {
  display: none;
}

#editor.hide-save-button #save-btn {
  display: none;
}

.pref-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
}

.prefs-section > .pref-control:first-child {
  padding-top: 0.5rem;
  border-top: 0;
}

.prefs-content :is(.pref-control, .pref-row):is(:hover, :focus-within) > span strong {
  color: var(--accent);
}

.pref-control > span {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.pref-control small,
.pref-row small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.pref-control select {
  width: min(13rem, 45%);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--fg);
}

.pref-control select:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong));
}

.pref-control select:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.pref-control input[type='color'] {
  width: 3rem;
  height: 2rem;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  cursor: pointer;
}

.accent-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.accent-actions select {
  width: min(13rem, 45vw);
}

.prefs-content .pref-row {
  padding: 0.85rem 0;
}

.prefs-content .pref-row > span {
  display: grid;
  gap: 0.2rem;
}

.pref-restore-settings {
  align-items: center;
}

.pref-restore-settings button {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .prefs-modal-body {
    height: calc(100dvh - 2rem);
  }
  .prefs-tabs-scroll {
    margin: 0;
    padding-bottom: 0.625rem;
    overflow: auto hidden;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }
  .prefs-sidebar nav {
    display: flex;
    gap: 0;
    width: max-content;
    min-width: 100%;
    border-bottom: 1px solid var(--border);
  }
  .prefs-nav {
    flex: 0 0 auto;
    padding: 0.65rem 1rem;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    text-align: center;
    white-space: nowrap;
  }
  .prefs-nav:hover {
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
    color: var(--fg);
  }
  .prefs-nav.active {
    border-bottom-color: var(--accent);
    background: transparent;
    color: var(--accent);
  }
  .prefs-nav:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--accent);
    outline-offset: -3px;
  }
  .prefs-content {
    padding: 1rem 1rem 1.5rem;
  }
  .pref-control {
    align-items: flex-start;
    flex-direction: column;
  }
  .pref-control select,
  .accent-actions,
  .accent-actions select {
    width: 100%;
  }
  .accent-actions {
    justify-content: stretch;
  }
  .pref-control input[type='color'] {
    width: 100%;
  }
}
.toast:has(.toast-action) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: auto;
}

select,
option {
  font: inherit;
}

#note-content {
  font-family: var(--editor-font);
}

.preview {
  font-family: var(--preview-font);
}

.font-input-row {
  min-width: 0;
}

body {
  font-size: var(--font-size);
}

#note-content {
  font-size: var(--editor-font-size);
}

.preview {
  font-size: var(--preview-font-size);
}

.preview h1 {
  font-size: 2em;
}

.preview h2 {
  font-size: 1.625em;
}

.preview h3 {
  font-size: 1.3125em;
}

.preview h4 {
  font-size: 1.125em;
}

.preview h5 {
  font-size: 1em;
}

.preview h6 {
  font-size: 0.875em;
}

.preview pre code {
  font-size: 0.8125em;
}

.preview table {
  font-size: 0.875em;
}

.preview .highlight {
  background: transparent;
}

.about-list {
  border-top: 1px solid var(--border);
}

.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
}

.about-row > span:first-child {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.about-row small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.about-row:hover {
  color: var(--accent);
}

.about-row:hover small {
  color: var(--muted);
}

.about-row:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.about-row-static {
  cursor: default;
}

.about-row-static:hover {
  color: var(--fg);
}

.app-version {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
}

.panel-switch {
  display: none;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  place-items: center;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
}

.panel-switch:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.panel-switch .icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}

.panels-single .panel-editor:not(.panel-hidden) .panel-switch,
.panels-single .panel-preview:not(.panel-hidden) .panel-switch {
  display: grid;
}

@media (max-width: 640px) {
  .prefs-page-body {
    flex-direction: column;
  }
  .prefs-sidebar {
    flex: 0 0 auto;
    padding: 1rem 1rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .prefs-sidebar-title {
    margin-bottom: 0.75rem;
    padding: 0;
    font-size: 1rem;
  }
}
.font-control {
  align-items: stretch;
  flex-direction: column;
  gap: 0.45rem;
}

.font-input-wrap {
  display: grid;
  gap: 0.3rem;
  width: 100%;
}

.font-fetch-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  cursor: default;
}

.font-fetch-toggle input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.font-fetch-toggle a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.font-fetch-toggle a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.font-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.75rem;
  line-height: 1.35;
}

.font-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10rem;
  align-items: end;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .font-input-row {
    grid-template-columns: 1fr;
  }
}
/* Connectivity and notifications use the same restrained card language as the editor. */
:root {
  --status-online: var(--online, #167a42);
  --status-syncing: var(--syncing, #a65f00);
  --status-offline: var(--offline, #c24141);
}

.sync-indicator {
  --sync-color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.25rem 0.375rem;
  border: 0;
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--sync-color) 10%, var(--card-bg));
  color: var(--sync-color);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.sync-indicator-dot {
  display: block;
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: currentcolor;
}

.sync-indicator[data-state='online'] {
  --sync-color: var(--status-online);
}

.sync-indicator[data-state='local'],
.sync-indicator[data-state='saving'],
.sync-indicator[data-state='syncing'] {
  --sync-color: var(--status-syncing);
}

.sync-indicator[data-state='offline'],
.sync-indicator[data-state='unsaved'] {
  --sync-color: var(--status-offline);
}

.sync-indicator[data-state='syncing'] .sync-indicator-dot,
.sync-indicator[data-state='saving'] .sync-indicator-dot {
  animation: sync-pulse 1s ease-in-out infinite;
}

@keyframes sync-pulse {
  50% {
    opacity: 0.3;
    transform: scale(0.72);
  }
}
:root[data-status-display='compact'] .sync-indicator {
  padding: 0.25rem;
}

.offline-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  padding: 0.5rem 1.25rem;
  border: 0;
  background: var(--status-offline);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
}

.offline-notice-message {
  flex: 1 1 16rem;
  min-width: 0;
}

.offline-notice .offline-retry {
  flex: none;
  min-height: 2rem;
  padding: 0.25rem 0.35rem;
  border-radius: 4px;
  color: #fff;
  font-size: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.75);
  text-underline-offset: 0.15em;
}

.offline-notice .offline-retry:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.offline-notice .offline-retry:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#dashboard > .offline-notice {
  padding-right: max(1.25rem, (100% - 54rem) / 2 + 1.25rem);
  padding-left: max(1.25rem, (100% - 54rem) / 2 + 1.25rem);
}

.offline-snackbar {
  top: 4.35rem;
  gap: 0.75rem;
  max-width: min(27rem, 100vw - 1.5rem);
  padding: 0.65rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--status-offline) 30%, var(--border));
  border-left: 1px solid var(--status-offline);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
}

.offline-retry {
  min-height: 2rem;
  padding: 0.25rem 0.35rem;
  border-radius: 5px;
  color: var(--accent);
  font-weight: 750;
}

.offline-retry:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.toast-region {
  right: auto;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  align-items: center;
  width: min(100vw - 2rem, 26rem);
  transform: translateX(-50%);
}

.toast {
  width: 100%;
  max-width: none;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-left: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
  font-size: 0.8125rem;
  font-weight: 600;
}

.toast.warning {
  border-color: var(--border);
  border-left-color: var(--status-syncing);
}

.toast.success {
  border-color: var(--border);
  border-left-color: var(--status-online);
}

.toast.update {
  gap: 1rem;
}

.toast-action {
  min-width: 0;
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
  border-radius: 5px;
}

.toast-action:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.offline-snackbar {
  border-left-width: 1px;
  background: color-mix(in srgb, var(--status-offline) 5%, var(--card-bg));
}

.toast {
  border-left-width: 1px;
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
  background: color-mix(in srgb, var(--accent) 4%, var(--card-bg));
}

.toast.warning {
  border-color: color-mix(in srgb, var(--status-syncing) 28%, var(--border));
  background: color-mix(in srgb, var(--status-syncing) 5%, var(--card-bg));
}

.toast.success {
  border-color: color-mix(in srgb, var(--status-online) 28%, var(--border));
  background: color-mix(in srgb, var(--status-online) 5%, var(--card-bg));
}

@media (max-width: 640px) {
  .offline-notice,
  #dashboard > .offline-notice,
  #editor:not(.zen-mode) > .offline-notice {
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }
  .offline-notice-message {
    max-width: none;
  }
  .offline-snackbar {
    top: 3.9rem;
  }
  .toast-region {
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: 0.75rem;
    width: auto;
    transform: none;
  }
  .toast-action {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
}
.prefs-content-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
}

/* Keep full-width borders, but align each shell to the same responsive content rail. */
:root {
  --content-max-width: 76.25rem;
  --page-gutter: 1.25rem;
  --font-size: 1rem;
  --editor-font-size: 1rem;
  --preview-font-size: 1rem;
}

:root[data-content-width='compact'] {
  --content-max-width: 54rem;
}

:root[data-content-width='wide'] {
  --content-max-width: 90rem;
}

:root[data-content-width='full'] {
  --content-max-width: 100%;
}

:root {
  --zen-content-max-width: 76.25rem;
}

:root[data-zen-page-width='compact'] {
  --zen-content-max-width: 54rem;
}

:root[data-zen-page-width='wide'] {
  --zen-content-max-width: 90rem;
}

:root[data-zen-page-width='full'] {
  --zen-content-max-width: 100%;
}

header {
  display: block;
  padding: 0;
}

#dashboard > header,
#editor > header,
#editor:has(.panels-single) > header {
  padding: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: min(100%, var(--content-max-width));
  min-height: 3.25rem;
  margin-inline: auto;
  padding: 0.65rem var(--page-gutter);
}

.dashboard-body {
  max-width: var(--content-max-width);
}

.editor-body {
  max-width: var(--content-max-width);
  margin-inline: auto;
}

#dashboard > .offline-notice,
#editor:not(.zen-mode) > .offline-notice {
  padding-right: max(
    var(--page-gutter),
    (100% - var(--content-max-width)) / 2 + var(--page-gutter)
  );
  padding-left: max(var(--page-gutter), (100% - var(--content-max-width)) / 2 + var(--page-gutter));
}

#editor .panels-single .panel {
  flex: 1 1 auto;
  max-width: none;
}

.back-chevron {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2;
}

.btn-text.icon-btn:hover {
  background: var(--surface);
  color: var(--fg);
}

@media (max-width: 640px) {
  :root {
    --page-gutter: 0.75rem;
  }
}
/* Keep the app header wordmark aligned with the lander brand. */
.app-brand {
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.app-brand img {
  width: 29px;
  height: 29px;
  border-radius: 8px;
}

.app-brand span {
  display: block;
  font-size: inherit;
}

.save-slot {
  display: contents;
}

#panel-save-slot #save-btn {
  width: 1.5rem;
  height: 1.5rem;
  min-height: 1.5rem;
  border-radius: 5px;
}

#panel-save-slot #save-btn .icon {
  width: 1rem;
  height: 1rem;
}

/* Radius scale follows the lander CTA proportion: roughly 10-11% of control height. */
:root {
  --radius-action: 6px;
  --radius-field: 6px;
  --radius-micro: 4px;
}

.btn-text,
.btn-primary,
.btn-secondary,
.prefs-btn {
  border-radius: var(--radius-action);
}

#login-form .label-input__control,
#login-credentials > button[type='submit'],
.pref-control select {
  border-radius: var(--radius-field);
}

#panel-save-slot #save-btn,
.panel-layout,
.fmt-bar button,
.panel-switch,
.prefs-nav,
.offline-retry,
.toast-action {
  border-radius: var(--radius-micro);
}

.pref-control input[type='color'] {
  border-radius: var(--radius-action);
}

.table-grid-cell {
  border-radius: 2px;
}

.offline-snackbar,
.toast {
  border-radius: var(--radius-field);
}

.preview code {
  border-radius: var(--radius-micro);
}

.prefs-nav {
  border-radius: var(--radius-action);
}

@media (max-width: 640px) {
  .prefs-nav {
    border-radius: 0;
  }
}
/* Keep interface text tied to the configured base while structural dimensions remain stable. */
body {
  font-size: var(--font-size);
}

.font-control input[type='text'][aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}

.font-input-wrap > .font-error {
  grid-column: 1/-1;
}

.btn-text,
.btn-primary,
.btn-secondary,
.prefs-btn {
  font-size: 0.875em;
}

header h1 {
  font-size: 1.125em;
}

.app-brand {
  font-size: 1em;
}

#login-form h1 {
  font-size: 1.5em;
}

#login-form .label-input__control {
  font-size: 1em;
}

#login-credentials > button[type='submit'] {
  font-size: 0.9375em;
}

.error {
  font-size: 0.875em;
}

.toolbar .btn-primary {
  font-size: 0.875em;
}

.tag {
  font-size: 0.8125em;
}

.note-item .note-title {
  font-size: 1em;
}

.note-item .note-meta {
  font-size: 0.8125em;
}

.note-item .note-tags .tag {
  font-size: 0.75em;
}

.note-empty {
  font-size: 0.9375em;
}

.meta-toggle {
  font-size: 0.75em;
}

.input-label {
  font-size: 0.75em;
}

.panel-header {
  font-size: 0.6875em;
}

.pref-row {
  font-size: 0.9375em;
}

.prefs-sidebar-title {
  font-size: 1.2em;
}

.prefs-nav {
  font-size: 0.875em;
}

.prefs-content-header h2,
.prefs-content-header h3 {
  font-size: 1.2em;
}

.pref-control {
  font-size: 0.9375em;
}

.pref-control small,
.pref-row small {
  font-size: 0.875rem;
}

.font-fetch-toggle,
.font-error {
  font-size: 0.875rem;
}

.app-version {
  font-size: 0.875em;
}

.offline-notice,
.offline-snackbar,
.toast {
  font-size: 0.8125em;
}

.font-control select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  background: var(--card-bg);
  color: var(--fg);
  font: inherit;
  outline: none;
}

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

.font-control {
  gap: 0.65rem;
  padding: 1.1rem 0;
}

.font-input-wrap {
  gap: 0.55rem;
}

.font-control select {
  height: 2.5rem;
  min-height: 2.5rem;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
}

.table-picker-label {
  font-size: 0.75em;
}

.meta-actions .btn-text {
  font-size: 0.8125em;
}

.conflict-metadata-compare section {
  font-size: 0.75em;
}

.conflict-version h4 {
  font-size: 0.8125em;
}

.conflict-version pre,
.conflict-base pre {
  font-size: 0.75em;
}

.conflict-base {
  font-size: 0.8125em;
}

.note-conflict {
  font-size: 0.6875em;
}

.conflict-selection-status {
  font-size: 0.8125em;
}

.about-row small {
  font-size: 0.875rem;
}

/* A browser-backed mirror keeps the active visual row aligned with native text
   wrapping while the visible cue remains a single lightweight element. */
.editor-source-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--card-bg);
}

.editor-caret-measure {
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  height: auto;
  overflow: visible;
  white-space: pre-wrap;
}

.editor-current-line {
  position: absolute;
  z-index: 0;
  top: var(--editor-caret-top, 1rem);
  right: var(--editor-content-gutter, 1.125rem);
  left: var(--editor-content-gutter, 1.125rem);
  height: var(--editor-caret-height, 1.65rem);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  transition: opacity 0.14s;
}

.editor-source-wrap.is-caret-visible .editor-current-line {
  opacity: 1;
}

#note-content {
  padding-bottom: 1rem;
  scroll-padding-bottom: 1rem;
  caret-color: var(--accent);
}

#note-content::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--fg);
}

#note-content {
  position: relative;
  z-index: 1;
  background: transparent;
}

.zen-source-editor {
  display: none;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.view-control {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  place-items: center;
  border-radius: var(--radius-micro);
  background: transparent;
  color: var(--muted);
}

.view-control:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--fg);
}

.view-control[aria-pressed='true'] {
  background: transparent;
  color: var(--accent);
}

.view-control .icon {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2;
}

/* Regular editor controls float directly over their surface. The panel labels
   duplicated information already conveyed by the split layout and are hidden. */
#editor:not(.zen-mode) {
  --editor-content-gutter: 1.25rem;
  --editor-control-size: 1.5rem;
  --editor-action-row-height: 1.8125rem;
  --editor-writing-inset: 0.75rem;
  --editor-toolbar-height: 1.8125rem;
  --editor-toolbar-writing-inset: calc(var(--editor-toolbar-height) + var(--editor-writing-inset));
}

#editor:not(.zen-mode) .panel-header {
  position: relative;
  z-index: 6;
  width: 100%;
  min-height: var(--editor-action-row-height);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

#editor:not(.zen-mode) .panel-label {
  display: none;
}

#editor:not(.zen-mode) .panel-header-actions {
  align-self: flex-start;
  margin-left: auto;
  padding: 0.125rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 0 0 0 var(--radius);
  background: var(--card-bg);
  pointer-events: auto;
}

#editor:not(.zen-mode) .view-control,
#editor:not(.zen-mode) .panel-header-actions #save-btn {
  width: var(--editor-control-size);
  height: var(--editor-control-size);
  min-height: var(--editor-control-size);
  border-radius: var(--radius-micro);
}

#editor:not(.zen-mode) .panel-header-actions #save-btn .icon {
  width: 1rem;
  height: 1rem;
}

#editor:not(.zen-mode) .panel-editor .fmt-bar {
  flex-wrap: nowrap;
  min-height: var(--editor-toolbar-height);
  overflow-x: auto;
  padding-right: 0.4rem;
  scrollbar-width: thin;
}

#editor:not(.zen-mode) .fmt-bar button:focus-visible {
  outline-offset: -2px;
}

#editor:not(.zen-mode) .panel-editor .fmt-bar:not(.hidden) ~ .editor-source-wrap #note-content {
  padding-top: var(--editor-writing-inset);
}

#editor:not(.zen-mode) .panel-editor .fmt-bar.hidden ~ .editor-source-wrap #note-content {
  padding-top: var(--editor-writing-inset);
}

#editor:not(.zen-mode) .panel-preview .preview {
  padding-inline: var(--editor-content-gutter);
  padding-top: var(--editor-writing-inset);
}

#editor:not(.zen-mode) .editor-panels:not(.panels-single) .panel-preview .preview {
  padding-top: var(--editor-toolbar-writing-inset);
}

#editor:not(.zen-mode)
  .editor-panels:not(.panels-single):has(.fmt-bar.hidden)
  .panel-preview
  .preview {
  padding-top: var(--editor-writing-inset);
}

/* Keep a forgiving, unobtrusive resize target between the two panels. */
#editor:not(.zen-mode) .panel-resizer {
  flex-basis: 0.75rem;
}

@media (max-width: 640px) {
  #editor:not(.zen-mode) {
    --editor-content-gutter: 1rem;
    --editor-writing-inset: 0.75rem;
  }
  #editor:not(.zen-mode) .panel-preview .panel-header:not(:has(.view-controls, #save-btn)) {
    display: none;
  }
  #editor:not(.zen-mode) .panel-editor .fmt-bar {
    padding-right: 0.4rem;
    padding-bottom: 0.5rem;
    scrollbar-gutter: stable;
  }
  #editor:not(.zen-mode) .editor-panels:not(.panels-single) .panel-preview .preview,
  #editor:not(.zen-mode)
    .editor-panels:not(.panels-single):has(.fmt-bar.hidden)
    .panel-preview
    .preview {
    padding-top: var(--editor-writing-inset);
  }
  #editor:not(.zen-mode) .panel-preview .preview {
    padding-bottom: 4rem;
  }
}
.editor-body:has(.panels-single) .meta-pane {
  display: block;
  align-self: stretch;
  width: 100%;
  max-width: none;
}

#editor.zen-mode {
  --zen-page-width: min(100%, var(--zen-content-max-width));
  --zen-writing-gutter: clamp(2.5rem, 6vw, 4rem);
  --zen-writing-top: clamp(4.5rem, 11vh, 8rem);
  --zen-writing-bottom: 4rem;
  --zen-overlay-inline: clamp(2.5rem, 7.5vw, 3.75rem);
  --zen-overlay-block: clamp(2.5rem, 6.25vh, 3.75rem);
  background: var(--surface);
}

#editor.zen-mode .editor-body {
  width: 100%;
  max-width: none;
  gap: 0;
  padding: clamp(0.75rem, 2vh, 1.5rem) 0;
  background: var(--card-bg);
}

#editor.zen-mode .meta-pane,
#editor.zen-mode .panel-header,
#editor.zen-mode .panel-resizer,
#editor.zen-mode .fmt-bar {
  display: none;
}

#editor.zen-mode > .offline-notice {
  position: fixed;
  z-index: 110;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  width: auto;
  max-width: min(34rem, 100vw - 2rem);
  padding: 0.55rem 0.75rem 0.55rem 1rem;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  color: var(--fg);
}

#editor.zen-mode > .offline-notice .offline-retry {
  color: var(--accent);
  text-decoration-color: currentcolor;
}

#editor.zen-mode > .offline-notice .offline-retry:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

#editor.zen-mode > .offline-notice .offline-retry:focus-visible {
  outline-color: var(--accent);
}

#editor.zen-mode .editor-panels {
  justify-content: stretch;
}

#editor.zen-mode .panels-single .panel-editor {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--card-bg);
  box-shadow: none;
}

#editor.zen-mode .editor-source-wrap {
  width: var(--zen-page-width);
  margin: 0 auto;
  padding: var(--zen-writing-top) var(--zen-writing-gutter) var(--zen-writing-bottom);
  background: transparent;
}

#editor.zen-mode #note-content {
  display: none;
}

#editor.zen-mode .zen-source-editor {
  position: relative;
  display: block;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0 0 max(1.5rem, 50dvh);
  overflow: hidden auto;
  outline: 0;
  background: transparent;
  color: var(--fg);
  caret-color: var(--accent);
  font-family: var(--zen-font);
  font-size: var(--zen-font-size);
  font-variant-ligatures: none;
  line-height: 1.65;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  scroll-padding-block: 0 max(1.5rem, 50dvh);
  scrollbar-width: none;
  tab-size: 2;
  white-space: pre-wrap;
  -ms-overflow-style: none;
}

#editor.zen-mode .zen-source-editor::selection,
#editor.zen-mode .zen-source-editor *::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--fg);
}

#editor.zen-mode .zen-source-editor.is-empty::before {
  position: absolute;
  color: var(--muted);
  content: attr(data-placeholder);
  pointer-events: none;
}

#editor.zen-mode .zen-source-editor::-webkit-scrollbar,
#editor.zen-mode .panel-preview .preview::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

#editor.zen-mode .zen-editor-line {
  min-height: 1.65em;
}

#editor.zen-mode .zen-md-blank {
  min-height: 1em;
  line-height: 1;
}

#editor.zen-mode .zen-md-marker {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

#editor.zen-mode .zen-md-heading {
  min-height: 1.2em;
  margin-block: 0.75em 0.25em;
  color: var(--fg);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

#editor.zen-mode .zen-md-heading:first-child {
  margin-top: 0;
}

#editor.zen-mode .zen-md-h1 {
  font-size: 2em;
}

#editor.zen-mode .zen-md-h2 {
  font-size: 1.625em;
}

#editor.zen-mode .zen-md-h3 {
  font-size: 1.3125em;
}

#editor.zen-mode .zen-md-h4 {
  font-size: 1.125em;
}

#editor.zen-mode .zen-md-h5 {
  font-size: 1em;
}

#editor.zen-mode .zen-md-h6 {
  font-size: 0.875em;
  letter-spacing: 0;
  text-transform: uppercase;
}

#editor.zen-mode .zen-md-quote {
  padding-inline-start: 0.8em;
  border-inline-start: 1px solid var(--accent);
  color: var(--muted);
}

#editor.zen-mode .zen-md-list {
  display: flex;
  align-items: baseline;
}

#editor.zen-mode .zen-md-list-marker {
  flex: 0 0 auto;
  white-space: pre;
}

#editor.zen-mode .zen-md-list-content {
  flex: 1;
  min-width: 0;
}

#editor.zen-mode .zen-md-list + .zen-md-list {
  margin-top: 0.25em;
}

#editor.zen-mode .zen-md-strong {
  font-weight: 700;
}

#editor.zen-mode .zen-md-em {
  font-style: italic;
}

#editor.zen-mode .zen-md-strike {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

#editor.zen-mode .zen-md-code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  font-family: var(--mono);
  font-size: 0.875em;
}

#editor.zen-mode .editor-current-line {
  display: none;
}

.zen-overlays {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--zen-page-width);
  display: none;
  pointer-events: none;
  transform: translateX(-50%);
}

#editor.zen-mode .zen-overlays {
  display: block;
  animation: zen-chrome-enter 140ms ease-out;
}

@keyframes zen-chrome-enter {
  from {
    opacity: 0.65;
  }
  to {
    opacity: 1;
  }
}
.zen-controls {
  position: absolute;
  top: var(--zen-overlay-block);
  right: var(--zen-overlay-inline);
  display: flex;
  gap: 0.125rem;
  pointer-events: auto;
}

.zen-controls button {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  place-items: center;
  border-radius: var(--radius-micro);
  background: transparent;
  color: var(--muted);
  transition:
    color 120ms ease-out,
    background-color 120ms ease-out;
}

.zen-controls button:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--fg);
}

.zen-controls button[aria-pressed='true'] {
  background: transparent;
  color: var(--accent);
}

.zen-controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.zen-controls .icon {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2;
}

.zen-note-title,
.zen-word-count {
  position: absolute;
  bottom: var(--zen-overlay-block);
  max-width: calc(50% - 1.5rem);
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zen-note-title {
  left: var(--zen-overlay-inline);
}

.zen-word-count {
  right: var(--zen-overlay-inline);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  #editor.zen-mode .editor-body {
    padding: 0;
  }
  #editor.zen-mode .editor-source-wrap {
    --zen-writing-gutter: 1rem;
    --zen-writing-top: 4rem;
    --zen-writing-bottom: 2rem;
  }
  #editor.zen-mode .zen-source-editor {
    font-size: max(1rem, var(--zen-font-size));
  }
  #editor.zen-mode > .offline-notice {
    top: calc(max(0.5rem, env(safe-area-inset-top)) + 3.25rem);
    width: calc(100vw - 1.5rem);
    max-width: none;
    border-radius: var(--radius);
  }
  .zen-controls {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    gap: 0;
  }
  .zen-controls button {
    width: 2.75rem;
    height: 2.75rem;
  }
  .zen-note-title,
  .zen-word-count {
    bottom: max(1rem, env(safe-area-inset-bottom));
    font-size: 0.75rem;
  }
  .zen-note-title {
    left: max(1rem, env(safe-area-inset-left));
  }
  .zen-word-count {
    right: max(1rem, env(safe-area-inset-right));
  }
}
.zen-selection-toolbar,
.zen-link-popup {
  position: fixed;
  z-index: 110;
  max-width: calc(100vw - 1rem);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  color: var(--fg);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.4;
}

.zen-selection-toolbar {
  display: flex;
  gap: 0.125rem;
  padding: 0.25rem;
}

.zen-selection-toolbar[hidden],
.zen-link-popup[hidden],
.zen-link-popup [hidden] {
  display: none;
}

.zen-selection-toolbar button,
.zen-link-popup button {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border-radius: var(--radius-micro);
  background: transparent;
  color: var(--fg);
}

.zen-selection-toolbar button:hover,
.zen-link-popup button:hover {
  background: var(--surface);
  color: var(--accent);
}

.zen-selection-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.zen-selection-toolbar button:focus-visible,
.zen-link-popup button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.zen-link-popup {
  width: 20rem;
}

.zen-link-fields {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.zen-link-popup input {
  width: 100%;
  min-width: 0;
  height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
}

.zen-link-popup input[aria-invalid='true'] {
  border-color: var(--danger);
}

.zen-link-popup p {
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-size: 0.8125rem;
}

@media (pointer: coarse) {
  .zen-selection-toolbar button,
  .zen-link-popup button {
    width: 2.75rem;
    height: 2.75rem;
  }
  .zen-link-popup input {
    height: 2.75rem;
  }
}
.zen-source-editor .zen-md-inline-syntax {
  display: none;
}

.zen-source-editor .zen-md-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  cursor: text;
}

/* Shortcut settings use the same quiet, two-part rows as the rest of Preferences. */
.shortcut-prefix-row,
.shortcut-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.shortcut-prefix-row {
  margin-bottom: 1.5rem;
}

.shortcut-reset-row {
  border-top: 0;
  border-bottom: 1px solid var(--border);
}

.shortcut-groups {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.shortcut-group {
  display: flex;
  flex-direction: column;
}

.shortcut-group + .shortcut-group {
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.shortcut-group-title {
  margin: 0 0 0.45rem;
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.3;
}

.shortcut-row:last-child {
  border-bottom: 0;
}

.shortcut-copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.shortcut-copy strong {
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
}

.shortcut-copy small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.shortcut-row-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.shortcut-binding {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.75rem;
  min-height: 2.25rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-action);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition:
    border-color 0.15s,
    background-color 0.15s,
    color 0.15s;
}

.shortcut-binding:hover {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--accent);
}

.shortcut-binding:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--accent);
}

.shortcut-binding.is-recording {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
}

.shortcut-clear {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  place-items: center;
  border-radius: var(--radius-action);
  background: transparent;
  color: var(--muted);
  transition:
    background-color 0.15s,
    color 0.15s;
}

.shortcut-clear .icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}

.shortcut-clear:not(:disabled):hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
}

.shortcut-recorder-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.shortcut-recorder-status:not(:empty) {
  margin: 0.5rem 0;
}

.shortcut-recorder-status.is-error {
  color: var(--danger);
}

@media (max-width: 640px) {
  .shortcut-prefix-row,
  .shortcut-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    min-height: 0;
    padding: 0.85rem 0;
  }
  .shortcut-prefix-row {
    margin-bottom: 1.25rem;
  }
  .shortcut-groups {
    gap: 1.25rem;
  }
  .shortcut-group + .shortcut-group {
    padding-top: 1rem;
  }
  .shortcut-row-actions {
    justify-content: space-between;
    width: 100%;
  }
  .shortcut-binding {
    min-width: 8rem;
  }
}
.shortcut-binding {
  min-width: 11.25rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
}

.shortcut-clear {
  width: 2.5rem;
  height: 2.5rem;
}

@media (max-width: 640px) {
  .shortcut-binding {
    width: 100%;
    min-width: 0;
  }
}
.font-control input[type='text'],
.font-control select,
.shortcut-binding {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

.shortcut-binding {
  justify-content: flex-start;
  text-align: left;
}

.shortcut-confirm-skip {
  margin-top: 0.25rem;
}

.shortcut-confirm-actions {
  margin-top: 1rem;
}

.shortcut-sequence-hint {
  position: fixed;
  z-index: 95;
  top: 4.25rem;
  left: 50%;
  display: flex;
  gap: 0.65rem;
  max-width: calc(100vw - 2rem);
  padding: 0.55rem 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-size: 0.8125rem;
  line-height: 1.35;
  transform: translate3d(-50%, 0, 0);
}

.shortcut-sequence-hint kbd {
  padding: 0.08rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-weight: 700;
}

.shortcut-sequence-hint span {
  white-space: nowrap;
}

.shortcut-sequence-hint {
  display: block;
  box-sizing: border-box;
  top: 50%;
  width: min(34rem, 100vw - 2rem);
  max-width: none;
  padding: 1.25rem;
  transform: translate3d(-50%, -50%, 0);
  overflow: visible;
  box-shadow: none;
}

.shortcut-sequence-title {
  display: block;
  font-size: 1rem;
  line-height: 1.3;
}

.shortcut-sequence-subtitle {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  white-space: normal;
}

.shortcut-sequence-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
}

.shortcut-sequence-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-action);
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
}

.shortcut-sequence-hint kbd {
  display: inline-grid;
  min-width: 2rem;
  min-height: 1.8rem;
  padding: 0.25rem 0.45rem;
  place-items: center;
  border-radius: var(--radius-micro);
  background: var(--card-bg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.shortcut-sequence-option > span {
  min-width: 0;
  white-space: normal;
}

@media (max-width: 640px) {
  .shortcut-sequence-hint {
    padding: 1rem;
  }
  .shortcut-sequence-options {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }
}
.pref-subsection {
  margin: 1.75rem 0 0;
  padding: 1.3rem 0 0;
  border-top: 1px solid var(--border);
}

.pref-subsection:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.pref-subsection h3 {
  margin: 0;
  color: var(--fg);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.pref-subsection > p {
  max-width: 60ch;
  margin: 0.25rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.pref-subsection .pref-control:first-of-type {
  border-top: 0;
  padding-top: 0.5rem;
}

.pref-subsection .pref-row:last-child {
  border-bottom: 0;
}

.pref-row input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

body:has(#editor.zen-mode) .offline-snackbar {
  display: none !important;
}

body:has(#editor.zen-mode) #toast-region {
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 2.25rem);
}

body:has(#editor.zen-mode) #toast-region .toast {
  display: none;
}

body:has(#editor.zen-mode) #toast-region .toast.warning {
  display: block;
}

body:has(#editor.zen-mode) #toast-region .toast.update {
  display: flex;
}

.zen-controls.is-minimal [data-zen-action='editor'],
.zen-controls.is-minimal [data-zen-action='preview'] {
  display: none;
}

#editor.zen-mode {
  position: relative;
}

#editor.zen-mode .panels-single .panel-preview {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--card-bg);
  box-shadow: none;
}

#editor.zen-mode .panel-preview .preview {
  width: var(--zen-page-width);
  margin: 0 auto;
  padding: var(--zen-writing-top) var(--zen-writing-gutter) max(var(--zen-writing-bottom), 50dvh);
  background: transparent;
  scroll-padding-block: 0 50dvh;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.label-input {
  position: relative;
  display: block;
  min-width: 0;
  width: 100%;
}

.label-input__control {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0 0.875rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  background: var(--card-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.label-input__control::placeholder {
  color: transparent;
}

.label-input__control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.label-input__control:focus-visible {
  outline: none;
}

.label-input__control:-webkit-autofill {
  box-shadow: 0 0 0 1000px var(--card-bg) inset;
  -webkit-text-fill-color: var(--fg);
}

.label-input__label {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 0.4375rem;
  max-width: calc(100% - 1rem);
  padding: 0 0.5rem;
  overflow: hidden;
  transform: translateY(-50%);
  transform-origin: top left;
  border-radius: 2px;
  background: var(--card-bg);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.25;
  pointer-events: none;
  text-overflow: ellipsis;
  transition: transform 0.2s;
  white-space: nowrap;
}

.label-input__control:focus + .label-input__label,
.label-input__control:not(:placeholder-shown) + .label-input__label {
  transform: translateY(calc(-1.25rem - 50%)) scale(0.8);
}

.label-input__toggle,
.label-input__action {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  width: 2.25rem;
  height: 100%;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition:
    color 0.15s,
    box-shadow 0.15s;
}

.label-input__toggle:hover,
.label-input__action:hover {
  color: var(--fg);
}

.label-input__toggle:focus-visible,
.label-input__action:focus-visible {
  z-index: 2;
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.label-input__toggle .icon,
.label-input__action .icon {
  width: 1rem;
  height: 1rem;
}

.label-input__toggle [hidden] {
  display: none;
}

.label-input:has(.label-input__toggle, .label-input__action) .label-input__control {
  padding-right: 2.75rem;
}

#login-form .label-input {
  margin-bottom: 0.875rem;
}

#login-form .label-input__control {
  margin-bottom: 0;
  padding-block: 0;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1;
}

.vault-setup-form .label-input .label-input__control {
  min-height: 2.5rem;
  padding-block: 0;
  font-size: 0.875rem;
}

.font-control .label-input .label-input__control {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

.label-input #note-title,
.label-input #note-tags {
  width: 100%;
  padding-block: 0;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1;
}

.label-input #note-title:hover,
.label-input #note-tags:hover {
  border-color: var(--border-strong);
}

.label-input #note-title:focus,
.label-input #note-tags:focus {
  border-color: var(--accent);
}

.vault-setup-form .label-input__label {
  font-size: 0.875rem;
  font-weight: 400;
}

/* One policy covers every CSS effect, including native popup and form surfaces.
   Until preferences load, System honors the browser's accessibility setting. */
*,
*::before,
*::after {
  transition-property: transform, opacity !important;
}

@keyframes overlay-content-in {
  from {
    opacity: var(--overlay-start-opacity, 0);
    transform: var(--overlay-start-transform, translateY(6px));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes overlay-content-out {
  from {
    opacity: var(--overlay-start-opacity, 1);
    transform: var(--overlay-start-transform, none);
  }
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}
.table-picker:not(.hidden),
.heading-picker:not(.hidden) {
  animation: overlay-content-in var(--overlay-enter-duration) var(--overlay-enter-ease) backwards;
}

.table-picker.popup-leaving.hidden,
.heading-picker.popup-leaving.hidden {
  display: block !important;
  pointer-events: none;
  animation: overlay-content-out var(--overlay-exit-duration) var(--overlay-exit-ease) both;
}

.heading-picker.popup-leaving.hidden {
  display: flex !important;
}

:root[data-reduce-motion='always'] *,
:root[data-reduce-motion='always'] *::before,
:root[data-reduce-motion='always'] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-reduce-motion='never']) *,
  :root:not([data-reduce-motion='never']) *::before,
  :root:not([data-reduce-motion='never']) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
