﻿:root {
  color-scheme: light;
  --paper: #F9F8F6;
  --surface: #EFE9E3;
  --line: #D9CFC7;
  --accent: #C9B59C;
  --ink: #3A332D;
  --muted: #7A6E64;
  --shadow: color-mix(in srgb, var(--ink) 12%, transparent);
  --sans: "Segoe UI", sans-serif;
  --serif: Georgia, serif;
}
:root[data-theme="redup"] {
  --paper: #EFE9E3;
  --surface: #D9CFC7;
  --line: #C9B59C;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); }
button, input { font: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
button:hover { background: var(--line); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input::placeholder { color: var(--muted); opacity: 1; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.symbols { position: absolute; width: 0; height: 0; }
.icon { display: inline-grid; place-items: center; width: 44px; min-height: 44px; border-radius: 8px; font-size: 22px; flex: none; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar, .tabbar, .toolbar { padding-inline: max(16px, calc((100vw - 1328px) / 2)); }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 70px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.045em; padding: 0 8px 0 0; min-height: 44px; border-radius: 8px; }
.brand-icon, .page-icon { display: grid; place-items: center; background: var(--accent); border: 1px solid var(--line); }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; }
.search-toggle { display: flex; align-items: center; gap: 9px; min-height: 44px; border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 0 10px; }
.search-toggle span { display: none; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); font: 12px/1.65 var(--sans); white-space: nowrap; }
.tabbar { display: flex; gap: 5px; align-items: end; }
.tabs { display: flex; min-width: 0; gap: 4px; }
.tab { display: flex; align-items: center; gap: 8px; min-width: 0; width: 155px; min-height: 44px; padding: 0 10px; border: 1px solid transparent; border-radius: 10px 10px 0 0; text-align: left; }
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab svg { display: none; }
.tab.active { position: relative; background: var(--paper); border-color: var(--line); border-bottom-color: var(--paper); font-weight: 650; }
.tab.active::before { content: ""; position: absolute; inset: 0 16px auto; height: 3px; background: var(--accent); border-radius: 0 0 4px 4px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 60px; border-bottom: 1px solid var(--line); }
.crumbs, .tools { display: flex; align-items: center; min-width: 0; }
.crumbs { gap: 6px; color: var(--muted); font-size: 13px; }
.crumbs button { padding: 0 5px; min-height: 44px; white-space: nowrap; border-radius: 6px; }
#crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.tools { flex: none; }
#share { min-height: 44px; border-radius: 7px; background: var(--accent); padding: 0 9px; font-weight: 650; font-size: 13px; }
#favorite[aria-pressed="true"] svg { fill: var(--accent); }
.more-wrap { position: relative; }
.popover { position: absolute; z-index: 2; right: 0; top: 48px; width: 208px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 20px var(--shadow); }
.popover button { display: block; min-height: 44px; width: 100%; text-align: left; border-radius: 5px; }
.desk { width: min(100% - 32px, 1140px); margin: 22px auto 64px; }
.palette { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 14px 32px var(--shadow); overflow: hidden; margin-bottom: 28px; }
.panel-head, .palette-footer, .slash-title { display: flex; align-items: center; justify-content: space-between; }
.panel-head { padding: 4px 8px 4px 17px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.query { display: flex; align-items: center; gap: 10px; padding-inline: 12px; margin: 0 12px; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; }
.query input { width: 100%; min-width: 0; min-height: 46px; padding: 0; border: 0; background: transparent; }
.results { padding: 5px 10px 9px; }
.group-title { margin: 9px 9px 2px; color: var(--muted); font-size: 12px; font-weight: 650; }
.result, .tree-toggle { min-height: 44px; border-radius: 7px; }
.result-row { display: flex; }
.result { display: flex; align-items: center; flex: 1; gap: 10px; text-align: left; min-width: 0; padding: 0 9px; }
.result.active { background: var(--line); box-shadow: inset 3px 0 var(--accent); }
.result small { margin-left: auto; color: var(--muted); }
.result.child { padding-left: 30px; }
.tree-toggle { flex: none; width: 44px; }
.palette-footer { justify-content: flex-start; gap: 15px; flex-wrap: wrap; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 12px; }
.editor { min-width: 0; width: 100%; max-width: 680px; margin-inline: auto; }
.page-head { padding-bottom: 22px; border-bottom: 1px solid var(--line); margin-bottom: 19px; }
.page-icon { width: 54px; height: 54px; border-radius: 13px; }
.page-icon svg { width: 27px; height: 27px; }
h1 { font: 500 clamp(38px, 6vw, 68px)/1.04 var(--serif); letter-spacing: -.055em; margin: 14px 0 8px; overflow-wrap: anywhere; }
#page-meta { margin: 0; color: var(--muted); }
.block { position: relative; margin: 8px 0; overflow-wrap: anywhere; }
.block > :last-child { margin-block: 0; }
.block h2, .block h3 { font-family: var(--serif); font-weight: 500; }
.block h2 { font-size: 31px; padding-top: 8px; }
.block h3 { font-size: 23px; padding-top: 5px; }
.block ul { padding-left: 23px; }
.check { display: flex; align-items: center; min-height: 40px; gap: 9px; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }
blockquote { margin-inline: 0; border-left: 3px solid var(--accent); padding: 4px 13px; font: italic 18px/1.5 var(--serif); }
.callout { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; }
.callout svg { margin-top: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin-top: 17px; }
.handles { display: none; }
.insert { position: relative; margin-top: 8px; }
.insert-line { display: flex; align-items: center; }
.insert-line input { border: 0; background: transparent; min-width: 0; flex: 1; min-height: 44px; }
.slash-menu { width: min(254px, 100%); border: 1px solid var(--line); padding: 4px; background: var(--surface); border-radius: 10px; box-shadow: 0 8px 24px var(--shadow); }
.slash-title { padding: 5px 9px; font-size: 12px; color: var(--muted); }
.slash-menu button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; border-radius: 6px; text-align: left; }
.slash-menu button b { display: grid; place-items: center; width: 30px; height: 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; }
.toast { position: fixed; bottom: 18px; right: 16px; max-width: calc(100% - 32px); z-index: 3; background: var(--accent); padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; }
@media (min-width: 768px) {
  .bar, .tabbar, .toolbar { padding-inline: max(32px, calc((100vw - 1328px) / 2)); }
  .search-toggle span, .tab svg { display: inline; }
  .tools { gap: 5px; }
  #share { padding-inline: 15px; }
  .desk { width: min(100% - 96px, 1120px); margin-top: 46px; position: relative; }
  .desk:has(.palette:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .63fr); column-gap: clamp(24px, 5vw, 80px); align-items: start; }
  .palette { grid-column: 2; grid-row: 1; margin: 0; }
  .editor { grid-column: 1; grid-row: 1; }
}
@media (min-width: 960px) and (hover: hover) {
  .handles { display: flex; position: absolute; right: 100%; top: -7px; opacity: 0; }
  .block:hover .handles, .block:focus-within .handles { opacity: 1; }
  .handles .icon { width: 24px; min-height: 36px; font-size: 16px; }
}
@media (max-width: 420px) {
  .toolbar { padding-inline: 10px; }
}
.command-symbol { display: inline-grid; place-items: center; width: 19px; font-size: 19px; }
.editor:focus { outline: none; }
@media (max-width: 767px) {
  .results { max-height: 254px; overflow-y: auto; }
}
.check input {
  appearance: none;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: var(--paper);
}
.check input:checked { background: var(--accent); }
.check input:checked::after {
  content: "";
  width: 7px;
  height: 4px;
  border: solid var(--ink);
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
}
@media (min-width: 768px) {
  .tab { width: 174px; }
}

.tab.calendar-tab { width: auto; flex: none; }
.tab.calendar-tab svg { display: block; }
.calendar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.calendar-header h1 { margin: 0; font-size: clamp(32px, 5vw, 58px); }
.calendar-controls { display: flex; gap: 5px; }
.calendar-controls button, #calendar-notes button { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#calendar-today, #calendar-notes button { padding-inline: 12px; }
.calendar-controls button:disabled { opacity: .5; cursor: default; }
.calendar-controls button:not(:disabled):hover, #calendar-notes button:hover { background: var(--line); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-weekday { color: var(--muted); text-align: center; font-size: 13px; padding-bottom: 5px; }
.calendar-day { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; min-height: 46px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); }
.calendar-day.has-notes { background: var(--accent); }
.calendar-day:hover, .calendar-day[aria-expanded="true"] { border-color: var(--ink); }
.calendar-day[aria-current="date"] { outline: 2px solid var(--ink); outline-offset: -4px; font-weight: 700; }
.calendar-day span { display: none; }
.calendar-details { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow-wrap: anywhere; }
#calendar-notes { display: grid; gap: 6px; padding: 0 12px 14px; }
#calendar-notes p { margin: 0 0 5px; }
#calendar-notes button { background: var(--paper); text-align: left; }
#calendar-notes button:only-child:not(:hover), #calendar-notes p + button:not(:hover) { border-color: var(--accent); }
@media (max-width: 767px) {
  .calendar-day.has-notes::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
  .calendar-details { position: fixed; z-index: 4; inset: auto 0 0; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px var(--shadow); max-height: 50vh; overflow: auto; padding-bottom: env(safe-area-inset-bottom); }
}
@media (min-width: 768px) {
  .desk:has(#calendar:not([hidden])) #calendar { grid-column: 1 / -1; }
  .desk:has(#calendar:not([hidden])):has(.palette:not([hidden])) #calendar { margin-top: 24px; }
  .calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 24%); gap: 20px; align-items: start; }
  .calendar-grid { gap: 6px; }
  .calendar-day { min-height: 76px; padding: 8px; align-items: flex-start; }
  .calendar-day span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
}

/* The tab strip stays in place while the note takes the full reading width. */
body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
input, [contenteditable] { font-size: 16px; scroll-margin-block: 24px; }
#page-title { font-size: clamp(38px, 6vw, 68px); }
#blocks { font-size: 16px; line-height: 1.65; }
button { transition: background-color 150ms ease, border-color 150ms ease; }
button:active { background-color: var(--accent); }
#share { min-width: 44px; }
#page-meta, .result span, #calendar-notes button { overflow-wrap: anywhere; }
.result.child { padding-left: calc(9px + 13px * var(--depth, 1)); }
.result > span { min-width: 0; }
.results { max-height: min(48dvh, 440px); overflow-y: auto; overscroll-behavior: contain; }
.search-toggle:focus-visible, .tab:focus-visible, .result:focus-visible { outline-offset: -3px; }
.block { margin-block: 12px; }
.block [contenteditable] { min-height: 1.65em; white-space: pre-wrap; }
.block .callout span { min-width: 0; flex: 1; }
.block h2 { font-size: 31px; }
.block h3 { font-size: 23px; }
.block blockquote { font-size: 18px; }
.check { min-height: 44px; cursor: pointer; }
.check input {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  margin-inline: -11px -9px;
}
.check input::before, .check input::after { grid-area: 1 / 1; }
.check input::before {
  content: "";
  width: 17px;
  height: 17px;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--paper);
}
.check input:checked { background: transparent; }
.check input:checked::before { background: var(--accent); }
.block .slash-menu { margin-top: 8px; }
.handles { display: flex; gap: 0; color: var(--muted); }
.handles .icon { width: 44px; min-height: 44px; font-size: 16px; }
.toast { bottom: max(18px, env(safe-area-inset-bottom)); }
.calendar-details { max-height: 60dvh; overflow: auto; }

@media (max-width: 767px) {
  .bar { min-height: 60px; }
  .tabbar { padding-inline: 8px; gap: 3px; }
  .tabs { gap: 2px; }
  .tab { min-width: 44px; padding-inline: 6px; font-size: 13px; }
  .tab.calendar-tab { gap: 5px; }
  .tab.calendar-tab svg { width: 15px; height: 15px; }
  .toolbar { min-height: 54px; }
  .crumbs { gap: 3px; }
  .desk { width: calc(100% - 24px); margin-top: 18px; }
  #blocks .block { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .block > :nth-child(2) { grid-column: 1; grid-row: 1; margin-top: 9px; }
  .block > .handles { grid-column: 2; grid-row: 1; }
  .block > .slash-menu { grid-column: 1 / -1; }
  .palette.overlay {
    position: fixed;
    z-index: 5;
    inset: auto max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    margin: 0;
  }
  .palette.overlay .results { max-height: min(45dvh, 360px); }
  .palette-footer { display: none; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .desk, .desk:has(.palette:not([hidden])) { display: block; width: min(100% - 96px, 680px); }
  .editor { width: min(100% - 36px, 590px); }
  .palette {
    position: fixed;
    z-index: 4;
    top: max(130px, env(safe-area-inset-top));
    right: max(32px, env(safe-area-inset-right));
    width: 330px;
  }
  .palette:not(.overlay) { position: static; width: 100%; margin-bottom: 32px; }
  .calendar-layout { grid-template-columns: minmax(0, 1fr); }
  .calendar-day { min-height: 70px; }
}
@media (min-width: 768px) {
  .handles { position: absolute; right: 100%; top: -8px; opacity: 1; }
  .editor { padding-left: 44px; }
  .desk:has(#editor[hidden]) .palette { grid-column: 1 / -1; width: min(100%, 460px); justify-self: end; }
}
@media (min-width: 1024px) {
  .palette.overlay {
    position: fixed;
    z-index: 4;
    top: max(70px, env(safe-area-inset-top));
    right: max(32px, calc((100vw - 1328px) / 2));
    width: min(440px, 45vw);
  }
  .desk:has(.palette.overlay:not([hidden])) { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
