:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f7f5;
  --pane: #ffffff;
  --pane-muted: #fbfbfa;
  --line: #e7e6e3;
  --line-strong: #d7d5d0;
  --text: #242424;
  --muted: #787774;
  --muted-strong: #5f5e5b;
  --hover: #efefed;
  --active: #e7e7e4;
  --accent: #2f6feb;
  --accent-soft: #eaf1ff;
  --danger: #d44c47;
  --shadow: 0 18px 48px rgba(15, 15, 15, 0.16);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --sidebar: #202020;
  --pane: #191919;
  --pane-muted: #1f1f1f;
  --line: #303030;
  --line-strong: #444;
  --text: #ededed;
  --muted: #9b9b9b;
  --muted-strong: #b8b8b8;
  --hover: #2a2a2a;
  --active: #333;
  --accent: #6aa4ff;
  --accent-soft: #1f2d42;
  --danger: #ff736d;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(280px, 350px) minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

.folders-pane,
.notes-pane,
.editor-pane {
  min-height: 100dvh;
  min-width: 0;
}

.folders-pane {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.notes-pane {
  display: flex;
  flex-direction: column;
  background: var(--pane-muted);
  border-right: 1px solid var(--line);
}

.editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--pane);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 14px 10px;
  gap: 10px;
}

.pane-header.compact {
  min-height: 58px;
  padding: 12px;
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  font-weight: 650;
}

.folder-list,
.notes-list {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.folder-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px;
  overflow: auto;
}

.folder-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 32px;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  font-size: 14px;
}

.folder-button:hover,
.folder-button.active {
  background: var(--hover);
  color: var(--text);
}

.folder-button.active {
  font-weight: 600;
}

.folder-count {
  color: var(--muted);
  font-size: 12px;
}

.pane-footer {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.search-wrap {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--hover);
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
}

.search-wrap:focus-within {
  background: var(--pane);
  border-color: var(--line-strong);
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.text-button,
.chip {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  border-radius: 5px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  padding: 0;
  font-weight: 650;
}

.icon-button:hover,
.text-button:hover,
.chip:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-button.danger {
  color: var(--danger);
}

.text-button {
  padding: 0 10px;
  white-space: nowrap;
  font-size: 14px;
}

.text-button.primary {
  background: var(--text);
  color: var(--bg);
}

.text-button.primary:hover {
  background: var(--muted-strong);
  color: var(--bg);
}

.list-tools {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.list-tools::-webkit-scrollbar {
  display: none;
}

.chip {
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 13px;
}

.chip.active {
  background: var(--active);
  color: var(--text);
  font-weight: 600;
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 14px;
  overflow: auto;
}

.note-item {
  width: 100%;
  display: block;
  margin: 0 0 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.note-item:hover,
.note-item.active {
  background: var(--hover);
}

.note-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.note-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.note-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
}

.note-date {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
}

.note-preview {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--pane) 92%, transparent);
}

.toolbar-spacer {
  flex: 1;
  min-width: 12px;
}

.editor-surface {
  width: min(900px, 100%);
  flex: 1;
  margin: 0 auto;
  padding: 48px clamp(24px, 7vw, 86px) 28px;
  overflow: hidden;
}

.title-input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
}

.title-input::placeholder,
.body-input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.body-input {
  width: 100%;
  height: calc(100dvh - 188px);
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.72;
  letter-spacing: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}

dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(780px, calc(100dvh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  background: var(--pane);
  color: var(--text);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(15, 15, 15, 0.32);
}

.dialog-content {
  display: grid;
  gap: 12px;
  padding: 18px;
  max-height: min(780px, calc(100dvh - 32px));
  overflow: auto;
}

.dialog-content.wide {
  width: 100%;
}

.dialog-title-row,
.section-heading,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-title-row,
.section-heading {
  justify-content: space-between;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.settings-section:first-of-type {
  border-top: 0;
}

.settings-section label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.settings-section label span,
.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.section-heading strong {
  font-size: 14px;
}

.button-row {
  flex-wrap: wrap;
}

.dialog-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-copy.compact {
  font-size: 12px;
}

.dialog-input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--pane);
  color: var(--text);
}

.dialog-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.sync-grid {
  display: grid;
  gap: 8px;
}

.sync-grid div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.sync-grid span {
  color: var(--muted);
}

.mobile-only {
  display: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(260px, 320px) minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .folders-pane,
  .notes-pane,
  .editor-pane {
    position: fixed;
    inset: 0;
    min-height: 100dvh;
    transition: transform 180ms ease;
  }

  .folders-pane {
    z-index: 3;
  }

  .notes-pane {
    z-index: 2;
  }

  .editor-pane {
    z-index: 1;
  }

  .app-shell[data-view="folders"] .folders-pane,
  .app-shell[data-view="notes"] .notes-pane,
  .app-shell[data-view="editor"] .editor-pane {
    transform: translateX(0);
  }

  .app-shell[data-view="notes"] .folders-pane,
  .app-shell[data-view="editor"] .folders-pane,
  .app-shell[data-view="editor"] .notes-pane {
    transform: translateX(-100%);
  }

  .app-shell[data-view="folders"] .notes-pane,
  .app-shell[data-view="folders"] .editor-pane,
  .app-shell[data-view="notes"] .editor-pane {
    transform: translateX(100%);
  }

  .mobile-only {
    display: inline-grid;
  }

  .editor-toolbar {
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .toolbar-spacer {
    min-width: 24px;
  }

  .editor-surface {
    padding: 28px 20px 18px;
  }

  .title-input {
    font-size: clamp(30px, 9vw, 38px);
  }

  .body-input {
    height: calc(100dvh - 156px);
    font-size: 16px;
  }

  dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .dialog-content {
    padding: 14px;
    max-height: calc(100dvh - 20px);
  }

  .button-row .text-button {
    flex: 1 1 auto;
  }
}

@media (max-width: 420px) {
  .pane-footer {
    flex-wrap: wrap;
  }

  .pane-footer .text-button {
    flex: 1 1 100%;
  }

  .editor-toolbar .text-button {
    padding: 0 8px;
  }
}
