:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f0ec;
  --text: #181817;
  --text-on-accent: #ffffff;
  --muted: #777770;
  --border: #deded8;
  --accent: #181817;
  --focus-border: #9c9c94;
  --focus-ring: rgba(20, 20, 15, .05);
  --danger: #b42318;
  --danger-border: #e5c7c4;
  --placeholder: #9b9b92;
  --row-preview: #45453f;
  --hover-border: #bdbdb5;
  --hover-shadow: 0 8px 24px rgba(20, 20, 15, .04);
  --modal-backdrop: rgba(247, 247, 245, .88);
  --toast-bg: #181817;
  --toast-text: #ffffff;
  --selection-bg: rgba(24, 24, 23, .12);
  --code-border: transparent;
  --loader-line: #181817;
  --shadow: 0 20px 60px rgba(20, 20, 15, 0.07);
  --radius: 18px;
  --max: 960px;
  --body-font-size: 16px;
  --note-font-size: 16px;
  --note-line-height: 1.64;
  --note-heading-line-height: 1.22;
  --note-h1-size: calc(var(--note-font-size) * 1.62);
  --note-h2-size: calc(var(--note-font-size) * 1.38);
  --note-h3-size: calc(var(--note-font-size) * 1.18);
  --note-h4-size: calc(var(--note-font-size) * 1.08);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #111210;
  --surface: #191a17;
  --surface-soft: #23241f;
  --text: #eeeee7;
  --text-on-accent: #111210;
  --muted: #9c9d93;
  --border: #303129;
  --accent: #ded9bf;
  --focus-border: #6f715f;
  --focus-ring: rgba(222, 217, 191, .12);
  --danger: #ff8f83;
  --danger-border: #5a332e;
  --placeholder: #727466;
  --row-preview: #c2c2b8;
  --hover-border: #555747;
  --hover-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  --modal-backdrop: rgba(17, 18, 16, .88);
  --toast-bg: #e8e5d6;
  --toast-text: #111210;
  --selection-bg: rgba(222, 217, 191, .2);
  --code-border: #34362d;
  --loader-line: #ffffff;
  --shadow: 0 22px 70px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

[data-font-size="small"] {
  --body-font-size: 15px;
}

[data-font-size="large"] {
  --body-font-size: 17px;
}

[data-note-font-size="small"] {
  --note-font-size: 14px;
}

[data-note-font-size="large"] {
  --note-font-size: 18px;
}

[data-note-font-size="extra-large"] {
  --note-font-size: 20px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scrollbar-color: var(--border) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--body-font-size);
  line-height: 1.5;
}

[data-auth-state="loading"],
[data-surface="app"][data-auth-state="unauthenticated"] {
  overflow: hidden;
}

::selection {
  background: var(--selection-bg);
}

body::-webkit-scrollbar,
.note-content pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body::-webkit-scrollbar-track,
.note-content pre::-webkit-scrollbar-track {
  background: var(--bg);
}

body::-webkit-scrollbar-thumb,
.note-content pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid var(--bg);
  border-radius: 999px;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.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;
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
}

[data-auth-state="loading"] .app-loader {
  display: grid;
}

.loader-brand {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.loader-mark {
  position: relative;
  width: 72px;
  height: 72px;
}

.loader-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .22;
}

.loader-mark .brand-mark-dark {
  display: none;
}

[data-theme="dark"] .loader-mark .brand-mark-light {
  display: none;
}

[data-theme="dark"] .loader-mark .brand-mark-dark {
  display: block;
}

.loader-line {
  position: absolute;
  left: 27%;
  height: 5px;
  border-radius: 999px;
  background: var(--loader-line);
  opacity: 0;
  transform: scaleX(.18);
  transform-origin: left center;
  animation: loaderLineSweep 1.35s ease-in-out infinite;
}

.loader-line-1 {
  top: 31%;
  width: 49%;
  animation-delay: 0s;
}

.loader-line-2 {
  top: 44%;
  width: 49%;
  animation-delay: .16s;
}

.loader-line-3 {
  top: 57%;
  width: 34%;
  animation-delay: .32s;
}

@keyframes loaderLineSweep {
  0% {
    opacity: 0;
    transform: scaleX(.18);
  }

  22%,
  58% {
    opacity: 1;
    transform: scaleX(1);
  }

  82%,
  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

.app-shell {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding-bottom: 80px;
}

[data-surface="landing"] .app-shell {
  display: none;
}

[data-auth-state="loading"] .app-shell,
[data-surface="app"][data-auth-state="unauthenticated"] .app-shell {
  visibility: hidden;
}

.landing-shell {
  display: none;
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding-bottom: 80px;
}

[data-surface="landing"] .landing-shell {
  display: block;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand {
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  padding: 0;
  flex: 0 0 auto;
}

.brand-static {
  margin-bottom: 34px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
}

.brand-mark-dark {
  display: none;
}

[data-theme="dark"] .brand-mark-light {
  display: none;
}

[data-theme="dark"] .brand-mark-dark {
  display: block;
}

nav {
  display: flex;
  gap: 5px;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-link,
.text-btn,
.back-btn,
.new-note-link,
.theme-toggle {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface-soft);
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  flex: 0 0 auto;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--hover-border);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.theme-icon {
  grid-area: 1 / 1;
  font-size: 15px;
  line-height: 1;
  transition: opacity .15s, transform .15s;
}

.theme-icon-dark {
  opacity: 0;
  transform: scale(.8) rotate(-20deg);
}

[data-theme="dark"] .theme-icon-light {
  opacity: 0;
  transform: scale(.8) rotate(20deg);
}

[data-theme="dark"] .theme-icon-dark {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.hero {
  text-align: center;
  padding: 110px 0 90px;
  max-width: 720px;
  margin: auto;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  margin: 16px 0 22px;
}

.hero-copy {
  color: var(--muted);
  max-width: 560px;
  margin: auto;
  font-size: 16px;
}

.search-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px;
  border-radius: var(--radius);
  margin: 38px auto 16px;
}

.search-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 9px;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input,
.list-search,
#emailInput,
#passwordInput,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search-row input {
  font-size: 22px;
  letter-spacing: .12em;
  padding: 13px 15px;
  text-transform: lowercase;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

button:focus-visible,
.large-code:focus-visible,
.note-row:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: 10px;
  padding: 11px 17px;
  border: 1px solid var(--border);
  transition: transform .12s, opacity .12s;
}

.primary-btn {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.secondary-btn {
  background: var(--surface);
  color: var(--text);
}

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

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

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

.new-note-link {
  font-size: 14px;
  padding: 10px;
}

.new-note-link span {
  font-size: 20px;
  vertical-align: -1px;
  margin-right: 4px;
}

.recent-section {
  padding-bottom: 40px;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading h2,
.page-heading h1 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.03em;
}

.page-heading {
  padding-top: 60px;
}

.page-heading h1 {
  font-size: 42px;
}

.text-btn {
  font-size: 13px;
}

.text-btn:hover,
.back-btn:hover,
.new-note-link:hover {
  color: var(--text);
}

.note-list {
  display: grid;
  gap: 8px;
}

.note-row {
  width: 100%;
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 18px;
  align-items: center;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px;
  color: var(--text);
}

.note-row:hover {
  border-color: var(--hover-border);
  box-shadow: var(--hover-shadow);
}

.row-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.row-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--row-preview);
}

.row-date {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 13px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.list-search {
  padding: 11px 13px;
}

select {
  max-width: 180px;
  padding: 11px 13px;
}

.editor-top,
.note-page-top {
  padding-top: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  font-size: 13px;
}

.editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 25px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-header {
  padding: 22px 26px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-body {
  padding: 18px 26px 0;
}

.autosave-recovery {
  --autosave-accent: #6f5734;
  --autosave-accent-soft: #fbf6ed;
  --autosave-accent-border: #e5d0a8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid var(--autosave-accent-border);
  border-radius: 12px;
  background: var(--autosave-accent-soft);
}

[data-theme="dark"] .autosave-recovery {
  --autosave-accent: #d8c092;
  --autosave-accent-soft: #211d16;
  --autosave-accent-border: #4a3e2b;
}

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

.autosave-recovery strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.autosave-recovery span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.autosave-recovery-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

#autosaveContinueBtn {
  background: var(--autosave-accent);
  border-color: var(--autosave-accent);
  color: var(--text-on-accent);
}

.editor-field {
  display: block;
}

.editor-field + .editor-field {
  margin-top: 18px;
}

.editor-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.editor-title-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 0 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 500;
  outline: none;
}

.editor-title-input::placeholder {
  color: var(--muted);
}

.editor-title-input:focus {
  box-shadow: none;
}

.code-preview,
.large-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
}

.code-preview {
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--code-border);
  border-radius: 8px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 430px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 0 0 28px;
  color: var(--text);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--note-font-size);
  line-height: var(--note-line-height);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

#noteContent:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.editor-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
}

.autosave-status {
  color: var(--muted);
}

.editor-actions,
.note-actions {
  display: flex;
  gap: 8px;
}

.note-page {
  max-width: 760px;
  margin: auto;
}

.note-meta {
  text-align: center;
  padding: 75px 0 55px;
}

.large-code {
  border: 0;
  background: transparent;
  font-size: 31px;
  font-weight: 700;
  margin: 10px 0 6px;
  padding: 4px 9px;
  color: var(--text);
}

.large-code:hover {
  background: var(--surface-soft);
  border-radius: 8px;
}

.note-date {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.note-date span {
  white-space: nowrap;
}

.note-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 500;
  letter-spacing: -.03em;
  margin: 8px 0 10px;
}

.note-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 38px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--note-font-size);
  line-height: var(--note-line-height);
  min-height: 260px;
}

.note-content > * {
  margin: 0 0 .9em;
}

.note-content > *:last-child {
  margin-bottom: 0;
}

.note-content > *:first-child {
  margin-top: 0;
}

.note-content h1,
.note-content h2,
.note-content h3,
.note-content h4,
.note-content h5,
.note-content h6 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: var(--note-heading-line-height);
  color: var(--text);
  margin: 1.3em 0 .55em;
}

.note-content strong {
  color: var(--text);
}

.note-content em {
  color: var(--row-preview);
}

.note-content h1 {
  font-size: var(--note-h1-size);
}

.note-content h2 {
  font-size: var(--note-h2-size);
}

.note-content h3 {
  font-size: var(--note-h3-size);
}

.note-content h4,
.note-content h5,
.note-content h6 {
  font-size: var(--note-h4-size);
}

.note-content ul,
.note-content ol {
  padding-left: 1.45em;
}

.note-content code {
  background: var(--surface-soft);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .86em;
  padding: .08em .28em;
}

.note-content pre {
  background: var(--surface-soft);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  overflow-x: auto;
  padding: .95em;
  scrollbar-color: var(--border) var(--surface-soft);
}

.note-content pre code {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: block;
  line-height: 1.55;
  padding: 0;
  white-space: pre;
}

.note-content a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.note-reference {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .78em;
  font-weight: 650;
}

.note-reference.unresolved {
  color: var(--muted);
}

.note-content blockquote {
  border-left: 3px solid var(--hover-border);
  color: var(--muted);
  padding-left: 1em;
}

.note-content blockquote p {
  margin: 0;
}

.backlinks {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.backlinks h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.backlink-list {
  display: grid;
  gap: 6px;
}

.backlink-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
}

.backlink-row:hover {
  border-color: var(--hover-border);
}

.backlink-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.backlink-title {
  overflow: hidden;
  color: var(--row-preview);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.welcome-page {
  max-width: 780px;
  margin: 0 auto;
  padding: 54px 0 24px;
}

.welcome-hero {
  padding: 44px 0 42px;
  text-align: center;
}

.welcome-hero h1,
.welcome-section h2,
.welcome-final h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
}

.welcome-hero h1 {
  margin: 12px 0 8px;
  font-size: clamp(42px, 8vw, 66px);
  line-height: 1;
}

.welcome-lede {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.1;
  color: var(--text);
}

.welcome-copy {
  max-width: 610px;
  margin: 18px auto 0;
  color: var(--muted);
}

.welcome-primary {
  margin-top: 26px;
}

.welcome-section {
  border-top: 1px solid var(--border);
  padding: 36px 0;
}

.welcome-section h2,
.welcome-final h2 {
  margin: 8px 0 12px;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.12;
}

.welcome-section p,
.welcome-final p {
  max-width: 660px;
  margin: 0 0 12px;
  color: var(--muted);
}

.welcome-section p:last-child,
.welcome-final p:last-child {
  margin-bottom: 0;
}

.welcome-example-section h2 {
  max-width: 680px;
}

.welcome-example {
  margin-top: 24px;
  display: grid;
  gap: 18px;
}

.welcome-writing-sample,
.welcome-note-sample {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.welcome-writing-sample {
  padding: 24px;
}

.welcome-sample-label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.welcome-writing-sample p {
  margin: 0 0 10px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--note-font-size);
  line-height: var(--note-line-height);
}

.welcome-writing-sample p:last-child {
  margin-bottom: 0;
}

.welcome-code-line {
  color: var(--muted);
}

.welcome-code-line strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  letter-spacing: .08em;
  color: var(--text);
}

.welcome-arrow {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.welcome-note-sample {
  overflow: hidden;
}

.welcome-note-body {
  padding: 22px 26px 28px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--note-font-size);
  line-height: var(--note-line-height);
}

.welcome-note-body h3 {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--note-h2-size);
  font-weight: 500;
  line-height: var(--note-heading-line-height);
  letter-spacing: 0;
}

.welcome-note-body p {
  margin: 0 0 12px;
  color: var(--row-preview);
}

.welcome-note-body p:last-child {
  margin-bottom: 0;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.welcome-steps div {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
}

.welcome-steps h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.welcome-steps p {
  margin: 0;
  font-size: 13px;
}

.welcome-trust {
  padding-bottom: 28px;
}

.welcome-final {
  border-top: 1px solid var(--border);
  padding: 38px 0 20px;
  text-align: center;
}

.welcome-final p {
  margin-inline: auto;
}

.welcome-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.landing-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 22px 0 0;
  text-align: center;
}

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

.settings-section {
  border-bottom: 1px solid var(--border);
  padding: 24px 0;
}

.settings-section h2 {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -.03em;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 54px;
  padding: 10px 0;
}

.setting-row h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.setting-value {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.segmented-control.compact {
  flex-wrap: nowrap;
}

.segmented-control label {
  min-width: 76px;
}

.segmented-control.compact label {
  min-width: 52px;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: block;
  width: 100%;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  transition: background .15s, color .15s;
}

.segmented-control input:checked + span {
  background: var(--surface-soft);
  color: var(--text);
}

.segmented-control input:focus-visible + span {
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.danger-section {
  border-bottom-color: var(--danger-border);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

[data-auth-state="loading"] #passwordModal,
[data-auth-state="authenticated"] #passwordModal {
  display: none;
}

[data-auth-state="unauthenticated"] #passwordModal {
  display: grid;
}

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

.password-modal {
  width: min(100%, 390px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.confirm-modal {
  width: min(100%, 340px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.password-modal h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
  margin: 10px 0 7px;
}

.confirm-modal h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -.03em;
}

.password-modal p,
.confirm-modal p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.confirm-modal p {
  margin-top: 0;
}

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

#emailInput,
#passwordInput {
  padding: 12px 13px;
  margin-bottom: 10px;
}

.full-btn {
  width: 100%;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  margin-top: 14px;
}

.auth-links button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
}

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

.login-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  margin-top: 10px;
}

.offline-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-block: 40px;
}

.offline-panel {
  width: min(100%, 480px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px;
}

.offline-panel h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin: 12px 0 12px;
}

.offline-panel p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 650px) {
  .app-shell {
    width: min(calc(100% - 24px), var(--max));
  }

  .landing-shell {
    width: min(calc(100% - 24px), var(--max));
  }

  .topbar {
    height: 70px;
    gap: 12px;
  }

  nav {
    gap: 0;
  }

  .nav-link {
    padding: 7px 8px;
    font-size: 12px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
  }

  .hero {
    padding: 75px 0 60px;
  }

  .hero h1 {
    font-size: 45px;
  }

  .welcome-page {
    padding-top: 34px;
  }

  .welcome-hero {
    padding: 30px 0 34px;
  }

  .welcome-section {
    padding: 30px 0;
  }

  .welcome-writing-sample {
    padding: 20px;
  }

  .welcome-note-body {
    padding: 20px;
  }

  .welcome-steps {
    grid-template-columns: 1fr;
  }

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

  .search-row {
    flex-direction: column;
  }

  .search-row .primary-btn {
    width: 100%;
  }

  .section-heading,
  .page-heading {
    align-items: start;
    flex-direction: column;
  }

  .note-row {
    grid-template-columns: 70px 1fr;
  }

  .row-date {
    display: none;
  }

  .toolbar {
    flex-direction: column;
  }

  select {
    max-width: none;
  }

  .editor-header,
  .autosave-recovery,
  .editor-footer {
    gap: 15px;
  }

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

  .autosave-recovery-actions {
    flex-direction: column;
  }

  .editor-header {
    padding: 20px 20px 0;
  }

  .editor-body {
    padding: 18px 20px 0;
  }

  .editor-title-input {
    font-size: 16px;
  }

  textarea {
    padding: 0 0 22px;
    min-height: 380px;
  }

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

  .editor-actions {
    justify-content: stretch;
  }

  .editor-actions button {
    flex: 1;
  }

  .note-page-top {
    padding-top: 30px;
  }

  .note-meta {
    padding: 55px 0 35px;
  }

  .note-content {
    padding: 24px;
  }

  .setting-row {
    align-items: start;
    flex-direction: column;
  }

  .segmented-control,
  #defaultSortSelect {
    width: 100%;
  }

  .segmented-control label {
    flex: 1 1 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .loader-line {
    opacity: 1;
    transform: scaleX(1);
  }
}

@media (max-width: 430px) {
  .topbar .brand span {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .nav-link {
    padding-inline: 6px;
  }
}

