:root {
  --ink: #17211d;
  --muted: #69736e;
  --paper: #f9faf6;
  --surface: #ffffff;
  --line: #dde4dc;
  --sage: #2e6650;
  --sage-dark: #1d4535;
  --mist: #e8f2ec;
  --danger: #a2332c;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(90deg, rgba(46, 102, 80, 0.025) 1px, transparent 1px), linear-gradient(rgba(46, 102, 80, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: Georgia, "Times New Roman", serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-layout { display: flex; min-height: 100vh; }
.sidebar { display: flex; width: 278px; min-height: 100vh; flex-direction: column; flex: 0 0 278px; padding: 25px 14px 18px; border-right: 1px solid #d4ded5; color: var(--ink); background: #edf4ee; overflow: hidden; transition: width 220ms ease, flex-basis 220ms ease, padding 220ms ease, transform 220ms ease; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 31px; font-size: 22px; font-weight: 400; white-space: nowrap; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; color: white; background: var(--sage); font-family: "Trebuchet MS", sans-serif; font-size: 14px; font-weight: 700; }
.sidebar-close { display: none; width: 32px; height: 32px; margin-left: auto; place-items: center; border: 0; border-radius: 5px; color: var(--sage); background: transparent; font-size: 24px; line-height: 1; }
.sidebar-close:hover { background: #d5e6d8; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; white-space: nowrap; }
.sidebar-add-button { display: grid; width: 26px; height: 26px; place-items: center; border: 0; border-radius: 5px; color: var(--sage); background: transparent; font-size: 21px; line-height: 1; }
.sidebar-add-button:hover { color: white; background: var(--sage); }
.notebook-list { display: grid; gap: 4px; }
.notebook-tab { width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 5px; color: #516058; text-align: left; background: transparent; font-family: "Trebuchet MS", sans-serif; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notebook-tab:hover { background: rgba(46, 102, 80, 0.09); }
.notebook-tab[aria-selected="true"] { color: var(--sage-dark); background: #d5e6d8; font-weight: 700; }
.sidebar-footer { margin-top: auto; padding: 16px 4px 0; border-top: 1px solid #d4ded5; white-space: nowrap; }
.rename-button { min-height: 35px; padding: 0 8px; border: 0; color: var(--muted); background: transparent; font-family: "Trebuchet MS", sans-serif; font-size: 12px; }
.rename-button:hover { color: var(--sage); }
.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; padding: 30px 20px 48px; }
.app-header, .section-heading, .dialog-header, .dialog-footer, .dialog-actions, .header-actions, .app-title { display: flex; align-items: center; }
.app-header, .section-heading, .dialog-header, .dialog-footer { justify-content: space-between; }
.app-header { margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; color: var(--sage); font-family: "Trebuchet MS", sans-serif; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 38px; line-height: 1; font-weight: 400; }
h2 { margin-bottom: 0; font-size: 18px; font-weight: 400; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--sage); border-radius: 50%; color: white; background: var(--sage); font-family: "Trebuchet MS", sans-serif; font-size: 29px; line-height: 1; transition: background 160ms ease, transform 160ms ease; }
.icon-button:hover { background: var(--sage-dark); transform: translateY(-1px); }
.menu-toggle { display: grid; width: 42px; height: 42px; margin-right: 13px; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--sage); background: var(--surface); font-family: "Trebuchet MS", sans-serif; font-size: 21px; line-height: 1; }
.menu-toggle:hover { border-color: var(--sage); background: var(--mist); }
.header-actions { gap: 10px; }
.outline-button { min-height: 38px; padding: 0 12px; border: 1px solid var(--sage); border-radius: 5px; color: var(--sage); background: transparent; font-family: "Trebuchet MS", sans-serif; font-size: 13px; font-weight: 700; }
.outline-button:hover { background: var(--mist); }

body:not(.menu-visible) .sidebar { width: 0; flex-basis: 0; padding-right: 0; padding-left: 0; border-right-color: transparent; }
body:not(.menu-visible) .sidebar > * { opacity: 0; pointer-events: none; }

.search-section { margin-bottom: 32px; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface); }
.search-field span { font-family: "Trebuchet MS", sans-serif; font-size: 25px; transform: rotate(-15deg); }
.search-field input { width: 100%; height: 48px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-field:focus-within { outline: 2px solid rgba(46, 102, 80, 0.25); border-color: var(--sage); }
.section-heading { margin-bottom: 12px; }
.section-heading span { color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 13px; }
.notes-list { display: grid; gap: 10px; }
.note-card { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; box-shadow: 0 2px 8px rgba(23, 33, 29, 0.03); }
.note-open-button { width: 100%; padding: 17px 18px; border: 0; text-align: left; color: inherit; background: transparent; }
.note-open-button:hover { background: var(--mist); }
.note-open-button h3 { margin-bottom: 7px; font-size: 18px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-open-button p { display: -webkit-box; margin-bottom: 11px; color: var(--muted); font-size: 15px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.note-open-button time { color: var(--sage); font-family: "Trebuchet MS", sans-serif; font-size: 12px; }
.empty-state { padding: 54px 20px; border: 1px dashed #b7c8bb; border-radius: 6px; text-align: center; background: rgba(255, 255, 255, 0.72); }
.empty-mark { margin-bottom: 14px; color: var(--sage); font-size: 26px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { margin-bottom: 22px; color: var(--muted); }
.primary-button, .text-button { border-radius: 5px; font-family: "Trebuchet MS", sans-serif; font-size: 14px; font-weight: 700; }
.primary-button { min-height: 42px; padding: 0 18px; border: 1px solid var(--sage); color: white; background: var(--sage); }
.primary-button:hover { background: var(--sage-dark); }

dialog { width: min(calc(100% - 28px), 680px); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 7px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(23, 33, 29, 0.28); }
dialog::backdrop { background: rgba(23, 33, 29, 0.44); backdrop-filter: blur(2px); }
dialog form { display: flex; min-height: min(580px, calc(100vh - 28px)); flex-direction: column; }
.dialog-header { height: 62px; padding: 0 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 13px; font-weight: 700; }
.close-button { width: 33px; height: 33px; border-color: transparent; color: var(--ink); background: transparent; font-size: 28px; }
.close-button:hover { color: white; background: var(--sage); }
.title-input { width: 100%; padding: 24px 22px 12px; border: 0; outline: 0; color: var(--ink); font-size: 26px; font-weight: 400; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 17px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-x: auto; }
.editor-toolbar button { display: grid; width: 34px; height: 32px; flex: 0 0 34px; place-items: center; border: 0; border-radius: 4px; color: var(--ink); background: transparent; font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.editor-toolbar button:hover, .editor-toolbar button:focus-visible { background: var(--mist); outline: 0; }
.toolbar-divider { width: 1px; height: 23px; flex: 0 0 1px; margin: 0 4px; background: var(--line); }
.rich-editor { width: 100%; min-height: 250px; flex: 1; padding: 16px 22px 24px; outline: 0; color: var(--ink); font-size: 17px; line-height: 1.55; overflow-y: auto; }
.rich-editor:empty::before { content: attr(data-placeholder); color: #929b95; pointer-events: none; }
.rich-editor h2 { margin: 0 0 12px; font-size: 23px; }
.rich-editor ul, .rich-editor ol { padding-left: 25px; }
.rich-editor p { margin-bottom: 12px; }
.dialog-footer { min-height: 72px; padding: 14px 18px; border-top: 1px solid var(--line); }
#save-status { color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 12px; }
.dialog-actions { gap: 10px; }
.text-button { min-height: 42px; padding: 0 10px; border: 0; background: transparent; }
.danger-button { color: var(--danger); }
.danger-button:hover { background: #fff0ef; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small-dialog-form { display: flex; flex-direction: column; }
.notebook-label { padding: 25px 22px 7px; color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 13px; }
.notebook-input { margin: 0 22px 30px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); outline: 0; color: var(--ink); font-size: 20px; }
.notebook-input:focus { border-color: var(--sage); }

@media (max-width: 480px) {
  .sidebar { position: fixed; z-index: 4; top: 0; bottom: 0; width: min(82vw, 290px); flex-basis: auto; box-shadow: 14px 0 35px rgba(23, 33, 29, 0.14); transform: translateX(-105%); }
  body.menu-visible .sidebar { transform: translateX(0); }
  body:not(.menu-visible) .sidebar { width: min(82vw, 290px); flex-basis: auto; padding-right: 14px; padding-left: 14px; border-right-color: #d4ded5; }
  body:not(.menu-visible) .sidebar > * { opacity: 1; pointer-events: auto; }
  .sidebar-close { display: grid; }
  .app-shell { padding: 22px 16px 32px; }
  .app-header { margin-bottom: 24px; }
  .outline-button { padding: 0 9px; font-size: 12px; }
  h1 { font-size: 34px; }
  .search-section { margin-bottom: 28px; }
  dialog form { min-height: calc(100vh - 28px); }
  .title-input { font-size: 23px; }
}