:root {
  color-scheme: light dark;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --text: #282828;
  --secondary: #666;
  --paper: #fff;
  --sidebar: #f8f8f8;
  --toolbar: #f5f5f5;
  --hover: #efefef;
  --border: #dcdcdc;
  --folder: #f7ebe2;
  --focus: #396db4;
  --action: #343434;
  --action-text: #fff;
  background: var(--paper);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #eee;
    --secondary: #b7b7b7;
    --paper: #202020;
    --sidebar: #262626;
    --toolbar: #282828;
    --hover: #333;
    --border: #464646;
    --folder: #3d3028;
    --focus: #9fc4ff;
    --action: #eee;
    --action-text: #222;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
h1, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.3; font-weight: 650; }
.sidebar { padding: 0 14px 20px; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; justify-content: center; align-items: center; gap: 9px; height: 57px; font-size: 1.14rem; font-weight: 650; letter-spacing: .025em; }
.brand-mark { display: inline-block; width: 24px; height: 24px; flex: none; background: linear-gradient(105deg, #346de1 18%, #6993e1 45%, #ed8643 82%); mask: url("/mark.svg") center / contain no-repeat; }
.folder, nav button, .record { padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.folder { display: grid; width: 100%; gap: 2px; margin-bottom: 15px; background: var(--folder); }
.folder span { font-size: .85rem; color: var(--secondary); }
.folder strong { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav { display: grid; gap: 4px; }
nav button:hover, .record:hover { background: var(--hover); }
nav button[aria-current], .record[aria-current] { background: var(--folder); }
.workspace { min-width: 0; }
header { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 20px; border-bottom: 1px solid var(--border); background: var(--toolbar); }
header span, .muted, .status { color: var(--secondary); font-size: .92rem; }
main { padding: 30px clamp(18px, 4vw, 50px); }
.status:empty { display: none; }
.status { margin-bottom: 18px; overflow-wrap: anywhere; }
#welcome { max-width: 530px; margin: clamp(40px, 15vh, 160px) auto 30px; text-align: center; display: grid; justify-items: center; gap: 14px; }
#welcome .brand-mark { width: 36px; height: 36px; }
#library { display: grid; grid-template-columns: minmax(190px, 300px) minmax(0, 1fr); gap: clamp(20px, 4vw, 46px); max-width: 1280px; margin: 0 auto; }
.records, .editor { min-width: 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
label { display: grid; gap: 5px; min-width: 0; font-weight: 550; }
form, .fields { display: grid; gap: 14px; }
.fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
input, textarea, select { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; background: var(--paper); font-weight: 400; }
input::placeholder, textarea::placeholder { color: var(--secondary); }
textarea { resize: vertical; }
#list { list-style: none; padding: 0; margin: 10px 0; }
#list li + li { margin-top: 4px; }
.record { display: grid; width: 100%; overflow-wrap: anywhere; }
.record small { color: var(--secondary); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions button, .section-header button, .primary { border: 1px solid var(--border); border-radius: 7px; background: var(--toolbar); padding: 7px 12px; }
.primary, .actions .primary { color: var(--action-text); background: var(--action); border-color: var(--action); }
@media (max-width: 780px) {
  body { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { justify-content: flex-start; }
  nav { display: flex; flex-wrap: wrap; }
  #library { grid-template-columns: 1fr; }
  #list { max-height: 185px; overflow: auto; }
}
@media (max-width: 415px) {
  .fields { grid-template-columns: 1fr; }
}
