﻿:root {
  color-scheme: only light;
  --paper: #F9F8F6;
  --linen: #EFE9E3;
  --stitch: #D9CFC7;
  --accent: #C9B59C;
  --ink: #3A332D;
  --muted: #7A6E64;
  --thread: color-mix(in srgb, var(--accent) 16%, transparent);
  --shadow: color-mix(in srgb, var(--accent) 38%, transparent);
  --veil: color-mix(in srgb, var(--ink) 35%, transparent);
  --ground: var(--paper);
  --surface: var(--linen);
  --text: var(--ink);
  --secondary: var(--muted);
  --serif: Georgia, 'Times New Roman', serif;
}
:root[data-theme="teduh"] {
  --ground: var(--linen);
  --surface: var(--stitch);
  --secondary: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; scrollbar-color: var(--accent) var(--surface); }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--ink); }
body { margin: 0; background: var(--ground); color: var(--text); font: 15px/1.55 system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
button, summary { -webkit-tap-highlight-color: var(--thread); }
@media (hover: hover) {
  button:not(:disabled):hover, summary:hover { background-color: var(--stitch); }
}
button:not(:disabled):active, summary:active { background-color: var(--stitch); }
:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
html { scroll-padding-block: calc(76px + env(safe-area-inset-top)) 24px; }
input, [contenteditable] { font-size: 16px; }
[contenteditable] { min-height: 1.5em; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; border-radius: 3px; }
[contenteditable]:empty::before { content: attr(aria-label); color: var(--secondary); pointer-events: none; }
[contenteditable]:focus { outline: 1px solid var(--muted); outline-offset: 3px; }
svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.symbols { position: absolute; width: 0; height: 0; }
.weave {
  background-image: repeating-linear-gradient(0deg, var(--thread) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, var(--thread) 0 1px, transparent 1px 3px);
}
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 5; width: min(300px, 88vw);
  display: none; flex-direction: column; max-height: 100dvh;
  padding: max(19px, env(safe-area-inset-top)) 19px max(16px, env(safe-area-inset-bottom)) max(19px, env(safe-area-inset-left));
  background-color: var(--surface); border-right: 1px solid var(--stitch);
  overflow-y: auto;
}
.sidebar.open { display: flex; }
.sidebar > :not(.navigation) { flex-shrink: 0; }
.brand { display: flex; gap: 11px; align-items: center; font: bold 28px/1 var(--serif); letter-spacing: -.04em; }
.workspace-name { margin: 12px 0 18px; padding-inline: 2px; color: var(--secondary); }
.brand-mark, .page-mark { display: grid; place-items: center; flex: none; background-color: var(--accent); color: var(--ink); }
.brand-mark { width: 40px; height: 40px; border-radius: 6px; }
.brand-mark svg { width: 25px; height: 25px; }
.close-drawer { margin-left: auto; }
.search, .nav-item, summary {
  width: 100%; min-height: 44px; padding: 0 10px; border-radius: 5px;
  display: flex; align-items: center; gap: 9px; text-align: left;
}
.search { border: 1px solid var(--stitch); background-color: var(--ground); }
.switch-view { color: inherit; text-decoration: none; }
.switch-view:hover, .switch-view:active { background-color: var(--stitch); }
kbd { margin-left: auto; padding: 1px 5px; border: 1px solid var(--stitch); border-radius: 3px; font: 12px system-ui; white-space: nowrap; }
.navigation { min-height: 0; margin-top: 14px; padding: 2px 4px; overflow-y: auto; scrollbar-width: thin; }
.navigation h2 { margin: 18px 0 4px 10px; font: 600 13px system-ui; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.arrow { width: 13px; height: 13px; }
details[open] > summary .arrow { transform: rotate(90deg); }
.nested { margin-left: 17px; padding-left: 9px; border-left: 1px dashed var(--stitch); }
.tree-row { position: relative; }
.tree-row > .nav-item { margin-left: 44px; width: calc(100% - 44px); padding-left: 3px; }
.tree-row > details > summary { position: absolute; inset: 0 auto auto 0; width: 44px; justify-content: center; padding: 0; }
.tree-row .nested { margin-left: min(4%, 8px); padding-left: min(3%, 6px); }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item[aria-current="page"] { background: var(--accent); color: var(--ink); font-weight: 650; border-radius: 5px 13px 4px 4px; }
.add-page { margin-top: auto; }
.trash { border-top: 1px dashed var(--stitch); border-radius: 0; }
.scrim { position: fixed; inset: 0; z-index: 4; background: var(--veil); }
.topbar {
  position: sticky; top: 0; z-index: 3; min-height: 63px;
  display: flex; align-items: center; gap: 4px; padding: 8px 10px;
  background: var(--ground); border-bottom: 1px solid var(--stitch);
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}
.breadcrumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.breadcrumb > :first-child, .breadcrumb svg { display: none; }
#crumb-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 2px; }
.icon, .share { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 44px; min-height: 44px; border-radius: 5px; }
.share { padding-inline: 10px; background-color: var(--accent); color: var(--ink); font-weight: 650; }
.share span { display: none; }
.icon[aria-pressed="true"] use[href="#star"] { fill: var(--accent); }
.popover { position: absolute; right: 10px; top: calc(100% + 6px); z-index: 2; padding: 5px; }
.popover, .slash-menu, dialog, .status:not(:empty) { border: 1px solid var(--stitch); background-color: var(--surface); box-shadow: 0 7px 18px var(--shadow); }
.popover button, .block-options button { display: flex; align-items: center; gap: 8px; min-height: 44px; text-align: left; border-radius: 3px; }
.desk {
  padding: 18px max(11px, env(safe-area-inset-right)) calc(30px + env(safe-area-inset-bottom) + var(--covered, 0px)) max(11px, env(safe-area-inset-left));
  background: var(--surface); min-height: calc(100dvh - 63px);
}
.sheet {
  max-width: 1032px; min-height: calc(100dvh - 146px); margin: 0 auto;
  padding: 23px 18px 30px; background: var(--ground);
  border: 1px solid var(--stitch); border-radius: 7px 7px 24px 7px;
  box-shadow: 0 3px 0 -1px var(--ground), 0 4px 0 -1px var(--stitch), 0 8px 16px var(--shadow);
}
.sheet-head { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px dashed var(--stitch); }
.sheet-head > div { min-width: 0; }
.page-mark { width: 46px; height: 51px; border: 1px dashed var(--stitch); outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 3px 8px 3px 3px; }
.page-mark svg { width: 26px; height: 26px; }
#title { margin: 0; min-height: 1.06em; font: 500 clamp(27px, 5vw, 55px)/1.06 var(--serif); letter-spacing: -.04em; overflow-wrap: anywhere; }
#date { margin: 6px 0 0; color: var(--secondary); font-size: 13px; }
.writing-area { position: relative; margin-top: 17px; }
#blocks { max-width: 645px; }
.block { position: relative; display: flow-root; min-height: 44px; overflow-wrap: anywhere; }
.block > :last-child:not(hr) { min-width: 0; }
.block > :is(p,h2,h3,ul,blockquote) { margin: 0 0 9px; }
.block h2 { font: 500 30px/1.15 var(--serif); margin-top: 18px; }
.block h3 { font: 600 20px/1.2 var(--serif); margin-top: 14px; }
.block ul { padding-left: 21px; }
.block li + li { margin-top: 3px; }
.block blockquote { padding: 4px 0 4px 13px; border-left: 1px solid var(--accent); font: italic 18px/1.5 var(--serif); }
.callout { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; background-color: var(--surface); border: 1px dashed var(--stitch); border-radius: 4px; }
.callout svg { margin-top: 2px; }
.check-row { display: flex; align-items: center; min-height: 44px; }
.check-row label { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin-left: -9px; cursor: pointer; }
.check-row input { appearance: none; display: grid; place-content: center; width: 18px; height: 18px; margin: 0; flex: none; border: 1px solid var(--muted); border-radius: 3px; background: var(--ground); }
.check-row input:checked { background: var(--accent); }
.check-row input:checked::before { content: ''; width: 9px; height: 5px; border: solid var(--ink); border-width: 0 0 1.5px 1.5px; transform: translateY(-1px) rotate(-45deg); }
.check-row:has(input:checked) span { text-decoration: line-through; }
hr { border: 0; border-top: 1px dashed var(--stitch); margin: 16px 0 8px; }
.block-tools { display: flex; justify-content: flex-end; align-items: center; color: var(--muted); }
.block-tools button { min-width: 44px; min-height: 44px; border-radius: 4px; }
.block-tools button:disabled { visibility: hidden; }
.block-tools svg { width: 17px; height: 17px; vertical-align: middle; }
@media (max-width: 767px) {
  .block { padding-right: 44px; }
  .block-tools { position: absolute; right: 0; top: 0; flex-direction: column; }
  .block-tools button:last-child { display: none; }
  #sidebar kbd { display: none; }
}
.slash-anchor { margin-top: 5px; }
.slash-anchor input, dialog input { width: 100%; min-height: 44px; padding: 5px 9px; background: var(--ground); border: 1px solid var(--stitch); border-radius: 4px; }
.slash-anchor input { width: min(100%, 285px); }
input::placeholder { color: var(--secondary); }
.slash-menu { width: min(100%, 325px); margin-top: 5px; padding: 7px; border-radius: 4px 10px 4px 4px; }
.slash-menu > p { margin: 0; padding: 4px 6px 7px; border-bottom: 1px dashed var(--stitch); font-weight: 650; font-size: 13px; }
.block-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px; padding-top: 3px; }
.block-options button { padding: 3px 5px; font-size: 13px; }
[data-action="move-block"] { min-height: 44px; width: 100%; border-top: 1px dashed var(--stitch); text-align: left; padding: 3px 5px; }
.type-icon { width: 19px; flex: none; font: bold 14px var(--serif); }
dialog { width: min(420px, calc(100% - 32px)); max-height: min(76dvh, calc(100dvh - var(--covered, 0px) - 32px)); color: var(--text); padding: 16px; border-radius: 6px; overflow: auto; }
dialog::backdrop { background: var(--veil); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font: 500 26px var(--serif); }
.copy { margin-top: 10px; }
.trash-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px; margin-top: 4px; }
.status { position: fixed; z-index: 6; bottom: max(16px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); max-width: calc(100% - 32px); }
.status:not(:empty) { padding: 9px 13px; border-radius: 4px; }
@media (min-width: 768px) {
  .mobile { display: none; }
  .sidebar { display: flex; width: 254px; }
  .workspace { margin-left: 254px; }
  .topbar { padding-inline: 22px; }
  .breadcrumb > :first-child, .breadcrumb svg { display: block; }
  .breadcrumb svg { width: 13px; }
  .share span { display: inline; }
  .desk { padding: 32px clamp(20px, 4vw, 72px) calc(38px + var(--covered, 0px)); }
  .sheet { padding: 36px 42px 38px; }
  .sheet-head { gap: 20px; }
  .page-mark { width: 61px; height: 66px; }
  .page-mark svg { width: 33px; height: 33px; }
  .block { padding-left: 88px; }
  .slash-anchor { margin-left: 88px; }
  [data-action="move-block"] { display: none; }
  .block-tools { position: absolute; left: 0; top: -4px; }
  @media (hover: hover) {
    .block-tools { opacity: .7; }
    .block:hover .block-tools, .block:focus-within .block-tools { opacity: 1; }
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 210px; padding-inline: 14px; }
  #sidebar kbd { display: none; }
  .workspace { margin-left: 210px; }
  .desk { padding: 24px 18px calc(30px + var(--covered, 0px)); }
  .sheet { padding: 28px 22px; }
  .sheet-head { gap: 14px; }
  .page-mark { width: 50px; height: 54px; }
  #title { font-size: clamp(32px, 5vw, 45px); }
}
@media (min-width: 1200px) {
  .sidebar { width: 278px; padding-inline: 23px; }
  .workspace { margin-left: 278px; }
  .desk { padding-inline: 54px; }
  .sheet { padding-inline: 50px; }
  .sheet:not(.calendar-sheet) { padding-left: 91px; }
  .block { padding-left: 0; }
  .block-tools { left: auto; right: calc(100% + 2px); }
  #blocks { max-width: calc(100% - 303px); }
  .slash-anchor { position: absolute; top: 113px; right: 0; width: 265px; margin: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  [data-enter] { animation: settle .35s ease-out both; }
  button, summary, .block-tools { transition: background-color .14s ease, opacity .14s ease; }
  @keyframes settle { from { opacity: .75; transform: translateY(4px); } }
}

.show-calendar :is(#crumb-group, .breadcrumb svg, .actions > :not([data-action="theme"])) { display: none; }
#calendar-title { margin: 0; font: 500 clamp(27px, 5vw, 55px)/1.06 var(--serif); letter-spacing: -.04em; }
.calendar-sheet { padding-inline: 13px; }
.calendar-layout { margin-top: 18px; }
.calendar-month { min-width: 0; }
.calendar-toolbar, .calendar-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.calendar-toolbar { flex-wrap: wrap; margin-bottom: 12px; }
#month-title { margin: 0; font: 500 clamp(20px, 3vw, 30px)/1.15 var(--serif); }
.month-prev svg { transform: rotate(180deg); }
.calendar-controls button:disabled { color: var(--muted); background: transparent; cursor: default; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.weekday { text-align: center; color: var(--secondary); font-size: 12px; padding-bottom: 5px; }
.calendar-day {
  min-width: 0; min-height: 46px; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 4px 2px; border: 1px solid var(--stitch); border-radius: 4px;
  background: var(--paper); color: var(--ink); font-variant-numeric: tabular-nums;
}
.calendar-day.has-notes { background: var(--accent); }
.calendar-day:is([aria-current="date"], [aria-pressed="true"]) {
  outline: 1px solid var(--ink); outline-offset: -3px;
}
.calendar-day[aria-current="date"] { outline-width: 2px; font-weight: 700; }
.calendar-day:focus-visible { outline: 2px dashed var(--ink); outline-offset: -3px; }
.day-preview {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink); font-size: 0;
}
#day-panel {
  position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: none;
  max-height: 60dvh; border-radius: 12px 12px 0 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
#day-panel h2 { font-size: 21px; }
#day-notes p { margin: 0 0 12px; }
#day-notes .nav-item + .nav-item { border-top: 1px dashed var(--stitch); }
@media (max-width: 390px) {
  .calendar-sheet { padding-inline: 8px; }
}
@media (min-width: 768px) {
  .calendar-sheet { padding-inline: clamp(18px, 3vw, 46px); }
  .calendar-grid { gap: 5px; }
  .calendar-day { min-height: 66px; align-items: flex-start; padding: 6px; }
  .day-preview {
    width: 100%; height: auto; background: transparent; font-size: 11px;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left;
  }
  #day-panel {
    position: static; width: 100%; max-height: none; margin-top: 14px;
    border-radius: 5px 12px 5px 5px;
  }
}
@media (min-width: 1100px) {
  .calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 212px; gap: 18px; }
  #day-panel { align-self: start; margin-top: 0; }
}
