:root {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: #30262d;
  background: #fffdf8;
  color-scheme: light;
  --paper: #fffdf8;
  --index: #faf7f0;
  --library: #f3eee4;
  --line: #e5ded3;
  --muted: #71656a;
  --ink: #30262d;
  --accent: #5a3450;
  --accent-dark: #46243d;
  --accent-light: #ede2e8;
  --danger: #8a3e43;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button { border: 0; background: transparent; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: #ead5e3; color: var(--ink); }
::placeholder { color: #796e72; opacity: 1; }
[hidden] { display: none !important; }
p, h1, h2, h3 { margin: 0; }
.symbols { position: absolute; width: 0; height: 0; pointer-events: none; }
button svg, summary svg, .search svg, .empty-editor svg, .crumb svg {
  display: block;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: 228px 304px minmax(0, 1fr);
  height: 100dvh;
}
.library, .index, .editor { min-width: 0; min-height: 0; }
.library {
  display: flex;
  flex-direction: column;
  background: var(--library);
  border-right: 1px solid var(--line);
  padding: 25px 16px 16px;
  overflow: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0 7px 30px; }
.brand-name { font-size: 23px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.brand-owner { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .04em; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-content: center;
  grid-template-columns: repeat(2, 7px);
  gap: 2px;
  background: var(--accent);
  border-radius: 9px;
}
.brand-mark i { height: 17px; background: #f5e5d5; border-radius: 2px 1px 1px 2px; transform: skewY(14deg); }
.brand-mark i + i { transform: skewY(-14deg); border-radius: 1px 2px 2px 1px; }
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff9f6;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
}
.primary:hover { background: var(--accent-dark); }
.library nav { margin-top: 25px; }
.nav-group { display: grid; gap: 3px; }
.nav-item {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  text-align: left;
  border-radius: 7px;
  font-size: 14px;
}
.nav-item > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item svg { color: #715a6b; }
.nav-item:hover { background: #eae3d8; }
.nav-item[aria-current="true"] { color: var(--accent-dark); background: var(--accent-light); font-weight: 700; }
.nav-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.folders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 1px 5px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.folder-mark { justify-self: center; width: 9px; height: 9px; border-radius: 50%; background: #956882; }
.folder-mark[data-color="peach"] { background: #b66b58; }
.folder-mark[data-color="iris"] { background: #816395; }
.folder-mark[data-color="sage"] { background: #627854; }
.folder-mark[data-color="honey"] { background: #9a743e; }
.library-bottom { margin-top: auto; padding-top: 24px; }
.device-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin: 15px 0 0; border-top: 1px solid var(--line); padding: 15px 5px 1px; }
.device-note i { width: 6px; height: 6px; border-radius: 50%; background: #6f805e; }

.index {
  display: flex;
  flex-direction: column;
  background: var(--index);
  border-right: 1px solid var(--line);
}
.index-head { padding: 27px 19px 0; }
.index-heading { display: flex; align-items: center; gap: 10px; }
.index-heading h1 { min-width: 0; overflow-wrap: anywhere; font-size: 23px; letter-spacing: -.025em; line-height: 1.3; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 0 10px;
  min-height: 41px;
  background: var(--paper);
  border: 1px solid #dbd1c8;
  border-radius: 7px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search input { width: 100%; min-width: 0; padding: 8px 0; border: 0; background: transparent; font-size: 13px; outline: 0; }
kbd { flex: none; color: var(--muted); font: inherit; font-size: 11px; line-height: 1.2; padding: 2px 4px; border-radius: 4px; background: #f1ebe3; }
.index-meta { display: flex; justify-content: space-between; gap: 6px; padding: 22px 21px 10px; color: var(--muted); font-size: 12px; }
.note-list { overflow: auto; padding: 0 11px 14px; scrollbar-color: #c7b7bf transparent; }
.note-row {
  display: block;
  width: 100%;
  padding: 13px 12px 14px;
  border-radius: 7px;
  text-align: left;
}
.note-row + .note-row { margin-top: 3px; }
.note-row:hover { background: #f0ebe2; }
.note-row[aria-current="true"] { background: var(--accent-light); }
.row-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 750; }
.row-title span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title svg { width: 14px; height: 14px; color: var(--accent); margin-left: auto; }
.row-excerpt { display: block; color: #675b62; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 6px; font-size: 13px; line-height: 1.55; }
.row-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; margin-top: 9px; }
.row-meta > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index-empty { padding: 34px 9px; color: var(--muted); font-size: 14px; text-align: center; line-height: 1.7; }
.index-empty button { color: var(--accent); font-weight: 700; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }

.editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
}
.editor-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 64px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; min-width: 0; gap: 9px; font-size: 13px; color: var(--muted); }
.crumb span:last-child { min-width: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.actions { display: flex; margin-left: auto; align-items: center; gap: 5px; flex-shrink: 0; }
.icon-button, .edit-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 38px;
  min-height: 38px;
  border-radius: 6px;
  color: var(--accent);
}
.edit-button { gap: 6px; padding: 0 10px; font-size: 13px; font-weight: 700; }
.edit-button svg { width: 16px; height: 16px; }
.icon-button:hover, .edit-button:hover, .pin-button[aria-pressed="true"] { background: var(--accent-light); }
.note-menu { position: relative; }
.note-menu summary { list-style: none; }
.note-menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  z-index: 3;
  right: 0;
  top: calc(100% + 6px);
  width: 210px;
  padding: 8px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 6px 25px #34243129, 0 1px 4px #3424311d;
  font-size: 13px;
}
.menu-panel label { display: block; color: var(--muted); padding: 6px 8px 4px; }
.menu-panel select { display: block; width: calc(100% - 16px); margin: 0 8px 8px; padding: 6px; border: 1px solid #d5cbd0; border-radius: 5px; background: var(--paper); }
.menu-panel button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border-radius: 5px; text-align: left; }
.menu-panel button:hover { background: var(--accent-light); }
.menu-panel button svg { width: 16px; height: 16px; }
.delete-button { color: var(--danger); }
.paper { overflow: auto; padding: 61px clamp(24px, 5vw, 82px) 48px; scrollbar-color: #c7b7bf transparent; }
.paper-content { width: min(100%, 660px); min-height: 100%; margin: 0 auto; }
.note-meta { color: var(--muted); font-size: 13px; margin-bottom: 15px; }
#read-title, #title {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  font-size: clamp(33px, 3.5vw, 49px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.02em;
}
#read-title { overflow-wrap: anywhere; }
#title { display: block; width: 100%; margin: 0; padding: 0 0 10px; border: 0; background: transparent; }
#title:focus-visible, #body:focus-visible { outline: 0; }
#title:focus { box-shadow: 0 1px 0 var(--line); }
.prose { margin-top: 27px; line-height: 1.85; font-size: 16px; overflow-wrap: anywhere; }
.prose p { white-space: pre-wrap; margin: 0 0 16px; }
.prose h3 { margin: 29px 0 7px; font-size: 19px; line-height: 1.5; }
.prose ul { padding-left: 21px; margin: 6px 0 18px; }
.prose li { margin: 5px 0; }
.prose ul.tasks { padding: 0; list-style: none; }
.task-row { display: flex; align-items: start; gap: 10px; }
.task-row input { width: 17px; height: 17px; margin: 6px 0 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.task-row input:checked + span { color: var(--muted); text-decoration: line-through; }
.format-bar { display: flex; align-items: center; gap: 5px; padding: 6px 0; margin-top: 14px; border-block: 1px solid var(--line); }
.format-bar button { display: grid; place-items: center; grid-auto-flow: column; min-width: 38px; height: 38px; padding: 0 6px; border-radius: 6px; color: var(--accent); }
.format-bar button:hover { background: var(--accent-light); }
.format-bar button span { align-self: end; padding-bottom: 8px; font-size: 10px; }
.format-bar > span { margin-left: auto; color: var(--muted); font-size: 12px; }
#body { display: block; width: 100%; resize: vertical; min-height: 260px; field-sizing: content; padding: 15px 0 8px; border: 0; background: transparent; line-height: 1.8; font-size: 16px; }
#body:focus { box-shadow: 0 1px 0 var(--line); }
.editor-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 11px 24px max(11px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.editor-footer .error { color: var(--danger); }
.empty-editor { align-self: center; justify-self: center; max-width: 290px; padding: 24px; text-align: center; }
.empty-editor svg { width: 32px; height: 32px; margin: 0 auto 13px; color: var(--accent); }
.empty-editor h2 { font-size: 22px; }
.empty-editor p { margin-top: 8px; color: var(--muted); font-size: 14px; }

dialog { width: min(380px, calc(100vw - 32px)); border: 0; padding: 25px; border-radius: 12px; background: var(--paper); box-shadow: 0 12px 36px #33222d36; }
dialog::backdrop { background: #30262d57; }
dialog h2 { font-size: 20px; margin-bottom: 16px; }
dialog label { font-size: 14px; }
dialog input { display: block; width: 100%; min-height: 39px; padding: 5px 8px; margin: 6px 0 4px; border: 1px solid #cbbec4; background: var(--paper); border-radius: 5px; }
#folder-error { min-height: 20px; color: var(--danger); font-size: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; margin-top: 15px; }
dialog > p { color: var(--muted); font-size: 14px; line-height: 1.7; }
#backup-status { margin-top: 12px; color: var(--accent); }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 55px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 13px; max-width: calc(100% - 24px); background: #382632; color: #fff9f5; border-radius: 8px; box-shadow: 0 4px 15px #38263232; font-size: 14px; }
.toast button { min-height: 31px; padding: 0 6px; color: #ffe0f0; text-decoration: underline; text-underline-offset: 3px; }
.mobile-control, .library-close, .scrim { display: none; }

@media (max-width: 1090px) {
  .workspace { grid-template-columns: 184px 257px minmax(0, 1fr); }
  .library { padding-inline: 12px; }
  .index-head { padding-inline: 13px; }
  .index-meta { padding-inline: 15px; }
}
@media (max-width: 870px) {
  .workspace { grid-template-columns: 254px minmax(0, 1fr); }
  .library { display: none; position: fixed; inset: 0 auto 0 0; width: min(282px, calc(100% - 54px)); z-index: 8; padding: 20px 15px 13px; }
  body[data-library="open"] .library { display: flex; }
  body[data-library="open"] .scrim { display: block; position: fixed; z-index: 7; inset: 0; width: 100%; background: #30262d54; }
  #open-library, .library-close { display: inline-flex; }
  .library-close { margin-left: auto; }
  .index-head { padding-top: 17px; }
}
@media (max-width: 625px) {
  .workspace { display: block; height: 100dvh; }
  .index, .editor { height: 100%; border: 0; }
  .editor, body[data-pane="editor"] .index { display: none; }
  body[data-pane="editor"] .editor { display: grid; }
  #back, .mobile-new { display: inline-flex; }
  .mobile-new { margin-left: auto; background: var(--accent); color: #fff9f5; }
  .mobile-new:hover { background: var(--accent-dark); }
  .index-head { padding: 14px 15px 0; }
  .index-meta { padding-inline: 21px; }
  .index-heading { gap: 7px; }
  .index-heading h1 { font-size: 22px; }
  .search { margin-top: 15px; }
  kbd { display: none; }
  .note-list { padding-inline: 12px; }
  .note-row { padding-inline: 13px; }
  .editor-top { min-height: 58px; padding: 7px 12px; gap: 5px; }
  .editor-footer { padding-inline: 15px; }
  .paper { padding: 37px 21px 35px; }
  .actions { gap: 2px; }
  .actions button, .actions summary { min-width: 41px; min-height: 43px; }
}
