:root {
  color-scheme: only light;
  --paper: #F9F8F6;
  --surface: #EFE9E3;
  --line: #D9CFC7;
  --accent: #C9B59C;
  --ink: #3A332D;
  --muted: #7A6E64;
  --veil: color-mix(in srgb, var(--ink) 34%, transparent);
  --shadow: color-mix(in srgb, var(--ink) 12%, transparent);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { min-height: 44px; border: 0; background: transparent; cursor: pointer; }
button:hover { background: var(--line); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--ink); }
h1, h2, h3, p, blockquote { margin: 0; }
svg { display: block; width: 20px; height: 20px; }
[data-icon] { display: inline-grid; place-items: center; flex: none; }
.sidebar { display: none; }

.workspace {
  height: calc(100dvh - var(--keyboard-height, 0px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}
.topbar {
  min-height: calc(62px + var(--safe-top));
  padding: var(--safe-top) max(12px, var(--safe-right)) 0 max(12px, var(--safe-left));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.top-title {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.actions { display: flex; flex: none; gap: 4px; }
.button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary { background: var(--accent); font-weight: 650; }
[data-action="navigation"], [data-action="more"] { font-size: 20px; }
.scroll-area {
  overflow: auto;
  scrollbar-color: var(--line) var(--paper);
  padding: 0 var(--safe-right) 62px var(--safe-left);
}

.note {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 22px 54px;
  overflow-wrap: anywhere;
}
[data-layout="A"] :is(.topbar, .scroll-area) { background: var(--surface); }
[data-layout="A"] .note {
  width: calc(100% - 24px);
  min-height: min(540px, 60dvh);
  margin-top: 12px;
  padding-inline: clamp(17px, 5vw, 54px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
}
.note-kicker { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.note-mark { width: 34px; height: 34px; border-radius: 10px; color: var(--ink); background: var(--accent); }
.brand-mark { width: 31px; height: 31px; border-radius: 10px; color: var(--ink); background: var(--accent); }
.brand-mark svg { width: 21px; height: 21px; }
.page-title {
  margin: 23px 0 12px;
  min-height: 44px;
  font-size: clamp(36px, 8.4vw, 56px);
  line-height: 1.05;
  letter-spacing: -.04em;
  font-weight: 760;
}
.page-title[data-empty="true"]::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.note-content { line-height: 1.6; }
.block { position: relative; margin: 8px 0; }
.block :is(h1, h2) { margin-top: 20px; line-height: 1.22; }
.block h1 { font-size: 27px; }
.block h2 { font-size: 21px; }
.block ul { padding-left: 23px; }
.block [contenteditable] { min-height: 44px; padding-block: 9px; white-space: pre-wrap; caret-color: var(--ink); }
.block [contenteditable]:focus { outline-offset: 3px; outline: 1px solid var(--line); border-radius: 3px; }
.callout { border-radius: 12px; background: var(--surface); display: flex; gap: 10px; padding: 12px; }
.callout strong { display: block; }
.callout [data-icon] { margin-top: 9px; }
blockquote { border-left: 2px solid var(--accent); padding-left: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.check { display: flex; align-items: center; }
.check-target { display: grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.check input {
  appearance: none;
  display: grid;
  place-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--muted);
  border-radius: 5px;
  background: var(--paper);
  cursor: pointer;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border: solid var(--ink);
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
}
.check:has(:checked) > span { text-decoration: line-through; color: var(--muted); }

.add-block { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; border-radius: 9px; color: var(--muted); font-size: 14px; }

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 5px max(6px, var(--safe-right), calc((100% - 600px) / 2)) calc(5px + var(--safe-bottom)) max(6px, var(--safe-left), calc((100% - 600px) / 2));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar button { display: grid; justify-items: center; align-content: center; gap: 3px; padding: 0; border-radius: 10px; min-height: 58px; font-size: 11px; font-weight: 600; }
.tab-icon { height: 31px; width: 44px; border-radius: 11px; }
.tabbar .current .tab-icon { background: var(--accent); }
.tabbar [data-action="new"] .tab-icon { background: var(--accent); width: 38px; }
.desktop-new { display: none; }

.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 4px; border-radius: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.035em; }
.row { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 4px 10px; border-radius: 9px; text-align: left; font-size: 14px; overflow-wrap: anywhere; }
.row :last-child { min-width: 0; }
.row .end { margin-left: auto; }
.switch-view { color: inherit; text-decoration: none; }
.switch-view:hover { background: var(--line); }
.row[aria-current="page"], .row[aria-pressed="true"] { background: var(--line); font-weight: 650; }
.nav-section { padding: 9px 10px 3px; font-size: 13px; color: var(--muted); }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .end { rotate: 90deg; }
.children { margin-left: 19px; border-left: 1px solid var(--line); padding-left: 7px; }
.children .children .children { margin-left: 0; }
.trash-entry { border-bottom: 1px solid var(--line); padding: 10px 0; overflow-wrap: anywhere; }
.trash-entry h3 { font-size: 15px; }
.trash-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.trash-actions .button { border: 1px solid var(--line); }

dialog {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: none;
  max-height: 86dvh;
  margin: 0;
  padding: 9px max(18px, var(--safe-right)) calc(18px + var(--safe-bottom)) max(18px, var(--safe-left));
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 23px 23px 0 0;
  overflow: auto;
}
dialog[open] { animation: rise 210ms ease-out; }
dialog::backdrop { background: var(--veil); }
@keyframes rise { from { transform: translateY(22px); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
.sheet-handle { width: 34px; height: 4px; border-radius: 8px; background: var(--muted); margin: 0 auto; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 3px 0 9px; }
.sheet-header h2 { font-size: 22px; letter-spacing: -.025em; }
.sheet-copy { margin: 8px 0 14px; line-height: 1.5; }
.sheet-field { display: grid; gap: 6px; min-width: 0; font-size: 14px; margin-bottom: 10px; }
.sheet-field input { width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 10px; background: var(--paper); border: 1px solid var(--muted); font-size: 16px; }
.toast { position: fixed; z-index: 2; bottom: calc(80px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); padding: 10px 14px; border-radius: 12px; background: var(--accent); box-shadow: 0 6px 20px var(--shadow); width: max-content; max-width: calc(100% - 28px); text-align: center; }
.toast:empty { display: none; }
.calendar { max-width: 1040px; margin-inline: auto; padding: 24px 16px; }
.calendar h1 { margin: 0 0 20px; font-size: clamp(29px, 4vw, 42px); letter-spacing: -.03em; }
.calendar-toolbar, .calendar-controls { display: flex; align-items: center; gap: 4px; }
.calendar-toolbar { justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.calendar-toolbar h2 { margin: 0; font-size: clamp(16px, 3vw, 24px); }
.calendar-controls .button { min-width: 44px; min-height: 44px; font-size: 22px; }
.calendar-controls .calendar-today { padding-inline: 8px; background: var(--surface); font-size: 13px; font-weight: 650; }
.calendar-controls button:disabled { opacity: .45; cursor: default; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-week { margin-bottom: 6px; text-align: center; font-size: 12px; font-weight: 650; color: var(--muted); }
.calendar-day {
  display: grid; justify-items: center; align-content: start; gap: 4px;
  min-width: 0; min-height: 44px; padding: 5px 2px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 14px;
}
.calendar-day.has-notes { background: var(--accent); }
.calendar-day[aria-current="date"] { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 750; }
.calendar-label { display: none; }
.calendar-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
@media (min-width: 768px) {
  .calendar { padding: 32px clamp(18px, 4vw, 50px); }
  .calendar-grid { gap: 6px; }
  .calendar-day { justify-items: start; min-height: 66px; padding: 7px; }
  .calendar-label { display: block; width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; font-size: 12px; }
  .calendar-dot { display: none; }
}

@media (min-width: 768px) {
  .topbar { padding-inline: max(25px, var(--safe-left)) max(25px, var(--safe-right)); min-height: calc(67px + var(--safe-top)); }
  .note { padding: 32px 50px 64px; }
  [data-layout="A"] .note { margin-top: 36px; padding-top: 37px; }
  dialog { width: min(420px, calc(100% - 40px)); inset: 78px 24px auto auto; border-radius: 16px; box-shadow: 0 12px 35px var(--shadow); }
  .sheet-handle { display: none; }
}
@media (min-width: 1024px) {
  body.sidebar-open { display: grid; grid-template-columns: 294px minmax(0, 1fr); }
  .sidebar-open .sidebar { display: flex; flex-direction: column; align-items: stretch; height: 100dvh; overflow: auto; padding: max(20px, var(--safe-top)) 15px calc(72px + var(--safe-bottom)) max(15px, var(--safe-left)); border-right: 1px solid var(--line); background: var(--surface); }
  .sidebar .brand { align-self: flex-start; margin-bottom: 17px; }
  .sidebar .search { border: 1px solid var(--line); background: var(--paper); }
  .sidebar .calendar-nav { margin-top: 6px; }
  .workspace { grid-template-rows: auto minmax(0, 1fr); }
  .tabbar { display: none; }
  .desktop-new { display: inline-flex; position: fixed; right: max(24px, var(--safe-right)); bottom: calc(20px + var(--safe-bottom)); width: 52px; height: 52px; border-radius: 16px; box-shadow: 0 4px 16px var(--shadow); }
  .toast { bottom: 23px; }
}

[data-layout="A"] .row[aria-current="page"] { background: var(--accent); }
@media (min-width: 1160px) {
}
.mobile-brand { flex: none; padding: 0; margin-left: 2px; font-size: 19px; }
.mobile-brand:hover { background: transparent; }
.mobile-brand:active { background: var(--line); }
.topbar { gap: 4px; }
.actions { gap: 2px; }
@media (min-width: 620px) {
  .topbar { gap: 10px; }
  .top-title { padding-left: 12px; border-left: 1px solid var(--line); }
}
@media (max-width: 380px) { .mobile-brand { font-size: 18px; gap: 6px; } }
.meta { color: var(--muted); font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 21px; }
.meta svg { width: 15px; height: 15px; }
.cover { position: relative; overflow: hidden; height: 107px; margin-top: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; display: flex; align-items: center; padding: 15px; }
.cover-lines { position: absolute; inset: 0 0 0 auto; width: min(78%, 480px); height: 100%; color: var(--accent); }
.cover-icon { position: relative; width: 62px; height: 62px; border-radius: 16px; background: var(--accent); }
.cover-icon svg { width: 30px; height: 30px; stroke-width: 1.5; }
[data-layout="A"] .cover { background: var(--paper); }
@media (min-width: 768px) {
  .cover { height: 145px; padding: 24px; }
  .cover-icon { width: 78px; height: 78px; border-radius: 20px; }
  .cover-icon svg { width: 35px; height: 35px; }
}
.workspace-name { margin: -10px 0 14px 9px; font-size: 13px; color: var(--muted); }
.account { display: flex; align-items: center; gap: 10px; border-radius: 12px; text-align: left; padding: 8px; min-height: 54px; margin-top: auto; border-top: 1px solid var(--line); }
.account > span:nth-child(2) { flex: 1; }
.account strong, .account small { display: block; }
.account strong { font-size: 14px; }
.account small { color: var(--muted); font-size: 12px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); font-size: 12px; font-weight: 750; flex: none; }

.block [contenteditable] { font-size: max(16px, 1em); }
.block h1[contenteditable] { font-size: 27px; }
.block h2[contenteditable] { font-size: 21px; }
.check span[contenteditable] { flex: 1; min-width: 0; }
.callout > div { flex: 1; min-width: 0; }
.check-target:focus-within { border-radius: 8px; }
button:active { background: var(--line); }
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 140ms ease, box-shadow 140ms ease; }
}
@media (max-width: 619px) {
  .topbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 47px auto; padding-bottom: 7px; }
  .topbar .actions { grid-column: 3; grid-row: 1; }
  .top-title { display: block; grid-column: 1 / -1; grid-row: 2; padding-left: 2px; font-size: 12px; }
  .mobile-brand { justify-self: start; }
  .calendar { padding-inline: 14px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .note { max-width: 640px; padding-inline: 42px; }
  [data-layout="A"] .note { margin-top: 48px; min-height: 570px; }
  dialog {
    inset: auto 0 max(16px, var(--safe-bottom));
    width: min(560px, calc(100% - 48px));
    margin-inline: auto;
  }
}
.keyboard-open .tabbar, .keyboard-open .desktop-new { display: none; }
.keyboard-open dialog[open] {
  inset: auto 0 var(--keyboard-height);
  width: 100%;
  max-height: calc(100dvh - var(--keyboard-height) - var(--safe-top) - 8px);
  margin: 0;
  border-radius: 23px 23px 0 0;
}
