:root {
  --bg: #070a10;
  --bg-elevated: #0b0f17;
  --sidebar: rgba(8, 12, 18, 0.96);
  --surface: #101620;
  --surface-2: #151c28;
  --surface-3: #1a2330;
  --editor: #0d121a;
  --ink: #f4f7fb;
  --ink-soft: #d7dee8;
  --muted: #8995a6;
  --muted-2: #667286;
  --line: rgba(163, 184, 210, 0.14);
  --line-strong: rgba(163, 184, 210, 0.24);
  --accent: #45e2c1;
  --accent-strong: #78f6dd;
  --accent-soft: rgba(69, 226, 193, 0.12);
  --violet: #8a7dff;
  --teal: #45e2c1;
  --coral: #ff7d78;
  --saffron: #f1bd62;
  --blue: #6eb7ff;
  --danger: #ff746f;
  --success: #67d6a4;
  --warning: #efbd68;
  --radius-xs: 7px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.52);
  --sidebar-width: 246px;
  --content-max: 1420px;
  --editor-measure: 780px;
  --fast: 140ms;
  --normal: 220ms;
  --z-nav: 20;
  --z-modal: 50;
  --z-toast: 80;
  color-scheme: dark;
}

body[data-theme="library"] {
  --bg: #050d0d;
  --bg-elevated: #081414;
  --sidebar: rgba(5, 14, 14, 0.97);
  --surface: #0c1919;
  --surface-2: #112120;
  --surface-3: #162a28;
  --editor: #091313;
  --line: rgba(116, 220, 194, 0.14);
  --line-strong: rgba(116, 220, 194, 0.25);
}

body[data-theme="night"] {
  --bg: #05060b;
  --bg-elevated: #090b12;
  --sidebar: rgba(5, 6, 11, 0.98);
  --surface: #0e111a;
  --surface-2: #141824;
  --surface-3: #1b2030;
  --editor: #080a10;
  --accent: #7e8cff;
  --accent-strong: #a9b1ff;
  --accent-soft: rgba(126, 140, 255, 0.14);
}

body[data-theme="paper"] {
  --bg: #ece8df;
  --bg-elevated: #f4f0e8;
  --sidebar: rgba(239, 235, 226, 0.97);
  --surface: #f8f5ef;
  --surface-2: #fffdf8;
  --surface-3: #e8e2d8;
  --editor: #fffdf9;
  --ink: #262821;
  --ink-soft: #3b4037;
  --muted: #6d7469;
  --muted-2: #8a9186;
  --line: rgba(49, 59, 51, 0.14);
  --line-strong: rgba(49, 59, 51, 0.24);
  --accent: #167a6c;
  --accent-strong: #0b5e53;
  --accent-soft: rgba(22, 122, 108, 0.1);
  --shadow-sm: 0 8px 24px rgba(45, 40, 32, 0.09);
  --shadow-lg: 0 30px 90px rgba(45, 40, 32, 0.2);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 76% -10%, rgba(57, 197, 169, 0.08), transparent 32rem),
    radial-gradient(circle at 16% 110%, rgba(106, 89, 255, 0.06), transparent 36rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(69, 226, 193, 0.27);
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 22px;
  height: 100vh;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  backdrop-filter: blur(22px) saturate(125%);
}

.brand-lockup,
.brand-lockup > span:last-child,
.page-nav,
.topbar-actions,
.section-head > div,
.workspace-head > div,
.desk-intro,
.process-card,
.rail-section,
.read-panel,
.edit-panel,
.manage-block,
.command-list,
.app-menu-grid,
.filter-stack,
.task-list,
.mini-list {
  display: grid;
}

.brand-lockup {
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 2px 3px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(112, 255, 224, 0.18);
  border-radius: 13px;
  overflow: hidden;
  background: #020907;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34), 0 0 26px rgba(52, 215, 182, 0.07);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-lockup > span:last-child {
  gap: 2px;
  min-width: 0;
}

.brand-lockup strong {
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup strong b {
  font-weight: 900;
  letter-spacing: 0.01em;
}

.brand-lockup small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-nav {
  align-content: start;
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav-label {
  margin: 15px 10px 5px;
  color: var(--muted-2);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-label:first-child {
  margin-top: 0;
}

.page-nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  text-align: left;
  transition: color var(--fast), background var(--fast), border-color var(--fast), transform var(--fast);
}

.page-nav-button:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink-soft);
}

.page-nav-button.is-active {
  border-color: rgba(69, 226, 193, 0.16);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.page-nav-button [data-icon] {
  width: 18px;
  height: 18px;
}

.topbar-actions {
  gap: 8px;
}

.topbar-actions > .primary-action,
.sidebar-command {
  width: 100%;
}

.topbar-actions > .icon-button {
  position: absolute;
  top: 25px;
  right: 16px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}

.sidebar-command {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-command kbd {
  margin-left: auto;
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font: 0.68rem/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
}

main {
  width: min(100%, var(--content-max));
  min-width: 0;
  margin: 0 auto;
  padding: 28px clamp(24px, 4vw, 58px) 72px;
}

.page-masthead {
  display: grid;
  gap: 6px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

body[data-current-page="home"] .page-masthead {
  display: none;
}

.page-masthead h1 {
  font-size: clamp(1.65rem, 3vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.page-masthead p:last-child {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.today-desk,
.workflow-panel,
.notebook-panel,
.category-panel,
.workspace-panel,
.browse-rail {
  display: grid;
  gap: 20px;
}

.desk-intro {
  gap: 13px;
  max-width: 850px;
  padding: clamp(20px, 4vw, 48px) 0 8px;
}

.desk-intro h1 {
  max-width: 820px;
  font-size: clamp(2.65rem, 7vw, 6.8rem);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

.desk-intro p:last-child {
  max-width: 670px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.desk-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr 1fr;
  gap: 12px;
}

.desk-card,
.process-card,
.task-item,
.notebook-card,
.category-card,
.note-card,
.mini-note,
.menu-action,
.template-card,
.command-item,
.manage-block,
.storage-summary div {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 70%), var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.desk-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  min-height: 132px;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: left;
  transition: border-color var(--fast), transform var(--fast), background var(--fast);
}

.desk-card:hover,
.note-card:hover,
.mini-note:hover,
.notebook-card:hover,
.category-card:hover,
.task-item:hover,
.menu-action:hover,
.template-card:hover {
  border-color: var(--line-strong);
  background-color: var(--surface-2);
  transform: translateY(-1px);
}

.desk-card strong,
.desk-card small,
.desk-card em {
  display: block;
}

.desk-card small {
  color: var(--accent);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.desk-card strong {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.desk-card em {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
  line-height: 1.42;
}

.desk-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(69, 226, 193, 0.17);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.desk-pulse,
.storage-summary,
.task-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}

.desk-pulse div,
.storage-summary div,
.task-summary div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 13px 15px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.desk-pulse span,
.storage-summary span,
.task-summary span {
  overflow-wrap: anywhere;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.desk-pulse small,
.storage-summary small,
.task-summary small {
  color: var(--muted);
  font-size: 0.74rem;
}

.desk-lists,
.browse-rail,
.inbox-workflow,
.daily-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.section-head,
.workspace-head,
.list-meta,
.modal-header,
.modal-footer,
.modal-actions,
.modal-header-actions,
.meta-line,
.process-actions,
.backup-actions,
.settings-actions,
.tag-row,
.view-switch,
.editor-tabs,
.color-picker,
.daily-nav {
  display: flex;
  align-items: center;
}

.section-head,
.workspace-head,
.list-meta,
.modal-header,
.modal-footer,
.tag-row {
  justify-content: space-between;
}

.section-head > div,
.workspace-head > div {
  gap: 6px;
}

.section-head h2,
.workspace-head h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  letter-spacing: -0.035em;
}

.section-head.compact h2 {
  font-size: 1.08rem;
}

.rail-section,
.process-card,
.manage-block {
  gap: 13px;
  padding: 16px;
  border-radius: var(--radius-md);
}

.process-card h3 {
  font-size: 1.5rem;
  letter-spacing: -0.035em;
}

.process-card p,
.process-excerpt,
.field-help {
  color: var(--muted);
}

.process-excerpt {
  min-height: 90px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--editor);
  line-height: 1.5;
}

.process-actions,
.modal-actions,
.modal-header-actions,
.meta-line,
.backup-actions,
.settings-actions,
.view-switch,
.editor-tabs,
.color-picker,
.daily-nav {
  gap: 8px;
  flex-wrap: wrap;
}

.backup-reminder {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 11px;
  align-items: center;
  padding: 13px 15px;
  border: 1px solid rgba(239, 189, 104, 0.28);
  border-radius: var(--radius-md);
  background: rgba(239, 189, 104, 0.07);
  color: var(--ink-soft);
  text-align: left;
}

.backup-reminder [data-icon] {
  grid-row: span 2;
  color: var(--warning);
}

.backup-reminder small {
  color: var(--muted);
}

.notebook-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.notebook-card,
.category-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 14px;
  border-radius: var(--radius-md);
  text-align: left;
}

.notebook-card.is-active,
.category-card.is-active,
.mini-note.is-active {
  border-color: rgba(69, 226, 193, 0.5);
  box-shadow: inset 0 0 0 1px rgba(69, 226, 193, 0.18), var(--shadow-sm);
}

.notebook-icon,
.category-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.notebook-name,
.category-name {
  font-weight: 800;
}

.notebook-count,
.category-count,
.mini-note small,
.task-item small,
.command-item small,
.filter-summary,
.list-meta span,
.card-excerpt,
.card-meta,
.meta-line,
.modal-subline,
.backup-copy,
.read-hero p {
  color: var(--muted);
}

.mini-list,
.task-list,
.command-list {
  gap: 8px;
}

.mini-note,
.task-item,
.command-item,
.command-empty {
  display: grid;
  gap: 4px;
  min-height: 60px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
}

.mini-note {
  border-left: 3px solid var(--teal);
}

.mini-note span,
.task-item span,
.command-item span {
  overflow-wrap: anywhere;
  font-weight: 750;
}

.mini-empty,
.empty-list,
.command-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.task-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-item {
  border-left: 3px solid var(--accent);
}

.saved-view-strip,
.tag-cloud,
.card-tags,
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.saved-view-strip {
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.saved-view-strip::-webkit-scrollbar {
  display: none;
}

.saved-view-chip,
.tag-pill,
.notebook-badge,
.category-badge,
.status-badge,
.mini-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
}

.saved-view-chip,
.tag-pill {
  min-height: 31px;
  padding: 0 10px;
}

.tag-pill.is-active,
.saved-view-chip:hover {
  border-color: rgba(69, 226, 193, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.notebook-badge,
.category-badge,
.status-badge {
  width: fit-content;
  padding: 4px 8px;
}

.mini-tag {
  padding: 3px 7px;
}

.status-badge.is-trash {
  color: var(--danger);
}

.status-badge.is-favorite,
.pin-dot {
  color: var(--warning);
}

.status-badge.is-archive {
  color: var(--blue);
}

.notes-command-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: rgba(69, 226, 193, 0.42);
  box-shadow: 0 0 0 3px rgba(69, 226, 193, 0.08);
}

.search-box input,
.field input,
.title-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.filter-summary {
  font-size: 0.82rem;
}

.note-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 11px;
}

.note-list.is-list {
  grid-template-columns: 1fr;
}

.note-card {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 180px;
  padding: 15px;
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-md);
  text-align: left;
}

.note-card .card-title {
  overflow-wrap: anywhere;
  font-size: 1.06rem;
  font-weight: 780;
  line-height: 1.2;
}

.card-excerpt {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-meta {
  margin-top: auto;
  font-size: 0.75rem;
}

.note-list.is-list .note-card {
  grid-template-columns: auto auto minmax(180px, 0.7fr) minmax(240px, 1fr) auto;
  align-items: center;
  min-height: 86px;
}

.note-card[data-color="coral"],
.mini-note[data-color="coral"] { border-left-color: var(--coral); }
.note-card[data-color="saffron"],
.mini-note[data-color="saffron"] { border-left-color: var(--saffron); }
.note-card[data-color="blue"],
.mini-note[data-color="blue"] { border-left-color: var(--blue); }
.note-card[data-color="ink"],
.mini-note[data-color="ink"] { border-left-color: var(--muted-2); }

mark {
  border-radius: 3px;
  background: rgba(241, 189, 98, 0.25);
  color: var(--ink);
}

.primary-action,
.secondary-action,
.icon-button,
.switch-button,
.text-button,
.mode-tab,
.editor-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-weight: 700;
  transition: border-color var(--fast), color var(--fast), background var(--fast), transform var(--fast);
}

.primary-action {
  border-color: rgba(69, 226, 193, 0.4);
  background: linear-gradient(135deg, #2cc5a7, #167e73);
  color: #02110e;
  box-shadow: 0 9px 26px rgba(29, 173, 147, 0.18);
}

.primary-action:hover {
  background: linear-gradient(135deg, #54e7c9, #20978a);
  transform: translateY(-1px);
}

.secondary-action:hover,
.icon-button:hover,
.switch-button:hover,
.mode-tab:hover,
.editor-toolbar button:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--ink);
}

.icon-button {
  width: 39px;
  padding: 0;
}

.text-button {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.switch-button.is-active,
.mode-tab.is-active,
.icon-button.is-active {
  border-color: rgba(69, 226, 193, 0.32);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.danger {
  color: var(--danger) !important;
}

[data-icon] {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

[data-icon] svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

select,
.field input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface-2);
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.filter-stack {
  gap: 11px;
}

.filter-stack label {
  display: grid;
  gap: 6px;
}

.filter-stack label span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 4, 8, 0.72);
  backdrop-filter: blur(18px) saturate(120%);
  animation: backdrop-in var(--fast) ease-out;
}

.note-dialog,
.quick-dialog,
.backup-dialog,
.filters-dialog,
.app-menu-dialog,
.template-dialog,
.command-dialog,
.settings-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(680px, 100%);
  max-height: min(880px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  animation: dialog-in var(--normal) cubic-bezier(.2,.8,.2,1);
}

.note-dialog {
  width: min(1180px, calc(100vw - 48px));
  height: min(920px, calc(100dvh - 48px));
}

.settings-dialog {
  width: min(820px, 100%);
}

.modal-header,
.modal-footer {
  gap: 14px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 17, 25, 0.82);
  backdrop-filter: blur(18px);
}

body[data-theme="paper"] .modal-header,
body[data-theme="paper"] .modal-footer {
  background: rgba(248, 245, 239, 0.88);
}

.modal-header > div:first-child {
  min-width: 0;
}

.modal-header h2 {
  overflow: hidden;
  margin-top: 3px;
  font-size: 1.22rem;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-subline {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 0.76rem;
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  display: grid;
  gap: 15px;
  min-height: 0;
  overflow: auto;
  padding: 17px;
}

.note-dialog .modal-body {
  padding: 0;
  background: var(--editor);
}

.read-panel,
.edit-panel {
  width: min(100%, calc(var(--editor-measure) + 70px));
  margin: 0 auto;
  padding: clamp(26px, 5vw, 58px) 28px 80px;
}

.read-panel {
  gap: 20px;
}

.edit-panel {
  align-content: start;
  gap: 13px;
  min-height: 100%;
}

.title-input {
  padding: 0;
  font-size: clamp(2rem, 5vw, 4.1rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.title-input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

.editor-tabs {
  min-height: 40px;
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none !important;
}

.mode-tab.is-active {
  border-bottom-color: var(--accent);
  background: transparent;
}

.editor-save-state {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 0.74rem;
}

.editor-save-state.is-saving {
  color: var(--warning);
}

.editor-save-state.is-saved {
  color: var(--success);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

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

.editor-toolbar button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.toolbar-hint {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 0.72rem;
  white-space: nowrap;
}

.editor-canvas {
  position: relative;
}

#bodyInput,
.preview-panel {
  width: 100%;
  min-height: min(58vh, 620px);
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.72;
}

#bodyInput {
  padding: 6px 0 90px;
  caret-color: var(--accent);
}

.preview-panel {
  overflow: auto;
  padding: 8px 0 90px;
}

.slash-menu {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 5;
  display: grid;
  width: min(360px, 100%);
  max-height: 320px;
  overflow: auto;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
}

.slash-menu button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  min-height: 49px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.slash-menu button:hover,
.slash-menu button.is-active {
  background: var(--accent-soft);
}

.slash-menu button small {
  grid-column: 1;
  color: var(--muted);
}

.slash-menu button kbd {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.editor-details {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.editor-details summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.editor-details[open] summary {
  margin-bottom: 13px;
  color: var(--ink-soft);
}

.color-picker {
  margin-top: 11px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--teal);
}

.color-swatch[data-color="coral"] { background: var(--coral); }
.color-swatch[data-color="saffron"] { background: var(--saffron); }
.color-swatch[data-color="blue"] { background: var(--blue); }
.color-swatch[data-color="ink"] { background: var(--muted-2); }
.color-swatch.is-active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--editor); }

.note-dialog.is-writing-focus .modal-header,
.note-dialog.is-writing-focus .modal-footer,
.note-dialog.is-writing-focus .editor-details,
.note-dialog.is-writing-focus .editor-tabs,
.note-dialog.is-writing-focus .toolbar-hint {
  display: none;
}

.note-dialog.is-writing-focus .read-panel,
.note-dialog.is-writing-focus .edit-panel {
  width: min(100%, calc(var(--editor-measure) + 90px));
  padding-top: clamp(38px, 9vh, 110px);
}

.read-hero {
  display: grid;
  gap: 10px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.read-hero h3 {
  margin-top: 12px;
  overflow-wrap: anywhere;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.read-content {
  min-height: 300px;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.72;
}

.read-content p,
.preview-panel p {
  margin: 0.72em 0;
}

.read-content h1,
.read-content h2,
.read-content h3,
.preview-panel h1,
.preview-panel h2,
.preview-panel h3 {
  margin: 1.25em 0 0.48em;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.read-content code,
.preview-panel code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--accent-strong);
}

.read-content pre,
.preview-panel pre {
  overflow: auto;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #070a0f;
}

.read-content pre code,
.preview-panel pre code {
  padding: 0;
  background: transparent;
}

.read-content blockquote,
.preview-panel blockquote {
  margin: 1em 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.read-content a,
.preview-panel a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.read-content img,
.preview-panel img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  object-fit: contain;
}

.task-line {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.task-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.embed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.embed-grid figure,
.link-preview-list a {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.embed-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.embed-grid figcaption,
.link-preview-list small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.link-preview-list a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.link-preview-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-nav {
  width: min(100%, calc(var(--editor-measure) + 70px));
  margin: 16px auto 0;
  padding: 0 28px;
}

.note-action-menu {
  position: relative;
}

.note-action-menu summary {
  list-style: none;
}

.note-action-menu summary::-webkit-details-marker {
  display: none;
}

.note-action-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 9px);
  z-index: 8;
  display: grid;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
}

.note-action-list button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.note-action-list button:hover {
  background: var(--surface-3);
}

.app-menu-grid,
.template-grid {
  gap: 9px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.menu-action,
.template-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
  min-height: 78px;
  padding: 13px;
  border-radius: var(--radius-md);
  text-align: left;
}

.menu-action [data-icon] {
  grid-row: span 2;
  color: var(--accent);
}

.menu-action small,
.template-card span {
  color: var(--muted);
}

.template-card {
  grid-template-columns: 1fr;
}

.command-search {
  width: 100%;
}

.command-item.is-active {
  border-color: rgba(69, 226, 193, 0.34);
  background: var(--accent-soft);
}

.manage-block {
  margin-top: 4px;
}

.backup-warning {
  padding: 11px 13px;
  border: 1px solid rgba(239, 189, 104, 0.24);
  border-radius: var(--radius-sm);
  background: rgba(239, 189, 104, 0.07);
  color: var(--warning);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--z-toast);
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--fast), transform var(--fast);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.bottom-app-nav {
  display: none;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1080px) {
  :root { --sidebar-width: 218px; }
  main { padding-right: 28px; padding-left: 28px; }
  .desk-grid { grid-template-columns: 1fr 1fr; }
  .continue-card { grid-column: 1 / -1; }
  .note-list.is-list .note-card { grid-template-columns: auto auto minmax(180px, 1fr); }
  .note-list.is-list .card-excerpt,
  .note-list.is-list .card-tags { display: none; }
}

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

  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    gap: 10px;
    width: 100%;
    height: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-lockup { grid-column: 1; }
  .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
  .brand-lockup small { display: none; }

  .page-nav { display: none; }

  .topbar-actions {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .topbar-actions > .primary-action {
    width: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 0;
  }

  .topbar-actions > .primary-action [data-icon] { width: 20px; height: 20px; }
  .sidebar-command { display: none; }

  .topbar-actions > .icon-button {
    position: static;
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-color: var(--line);
    background: var(--surface-2);
    opacity: 1;
    pointer-events: auto;
  }

  main {
    width: 100%;
    padding: 22px 16px 104px;
  }

  .bottom-app-nav {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: var(--z-nav);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(12, 17, 25, 0.92);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(22px) saturate(130%);
  }

  body[data-theme="paper"] .bottom-app-nav { background: rgba(248, 245, 239, 0.94); }

  .bottom-nav-button {
    display: grid;
    place-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 50px;
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 720;
  }

  .bottom-nav-button.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .bottom-nav-button.primary-tab {
    background: linear-gradient(135deg, #2cc5a7, #167e73);
    color: #02110e;
  }

  .desk-grid,
  .desk-lists,
  .browse-rail,
  .inbox-workflow,
  .daily-workspace { grid-template-columns: 1fr; }

  .continue-card { grid-column: auto; }
  .desk-pulse { grid-template-columns: repeat(5, minmax(105px, 1fr)); overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .note-list.is-list .note-card { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .brand-lockup strong { font-size: 0.85rem; }
  .desk-intro { padding-top: 20px; }
  .desk-intro h1 { font-size: clamp(2.7rem, 16vw, 4.2rem); }
  .desk-grid { gap: 9px; }
  .desk-card { min-height: 108px; padding: 13px; }
  .page-masthead { margin-bottom: 18px; }
  .notes-command-bar { grid-template-columns: 1fr auto; }
  .filter-menu-button { width: 43px; padding: 0; font-size: 0; }
  .filter-menu-button [data-icon] { display: inline-grid; }
  .note-list { grid-template-columns: 1fr; }
  .note-card { min-height: 132px; }
  .note-card .card-tags { display: none; }
  .storage-summary { grid-template-columns: 1fr; }
  .task-summary { grid-template-columns: repeat(2, 1fr); }
  .section-head,
  .workspace-head,
  .modal-footer { align-items: stretch; flex-direction: column; }
  .view-switch,
  .modal-actions { width: 100%; }
  .view-switch > *,
  .modal-actions > .primary-action { flex: 1; }

  .modal-backdrop { padding: 8px; }

  #noteModal.modal-backdrop { padding: 0; }

  .note-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .quick-dialog,
  .backup-dialog,
  .filters-dialog,
  .app-menu-dialog,
  .template-dialog,
  .command-dialog,
  .settings-dialog { max-height: calc(100dvh - 16px); }

  .modal-header { padding: 11px 12px; }
  .note-dialog .modal-header h2,
  .note-dialog .modal-subline { display: none; }
  .note-dialog .modal-header .eyebrow { font-size: 0.65rem; }
  .modal-header-actions { flex-wrap: nowrap; }
  .read-panel,
  .edit-panel { padding: 28px 18px 96px; }
  .title-input { font-size: 2.35rem; }
  .toolbar-hint { display: none; }
  .editor-toolbar { margin-right: -18px; padding-right: 18px; }
  #bodyInput,
  .preview-panel { min-height: 55vh; font-size: 1rem; line-height: 1.68; }
  .editor-details .form-grid { grid-template-columns: 1fr; }
  .daily-nav { padding: 0 18px; }
  .template-grid { grid-template-columns: 1fr; }
  .process-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .process-actions .primary-action { grid-column: 1 / -1; }
  .note-action-list { right: auto; left: 0; }
  .toast { right: 12px; bottom: 84px; }
}

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