:root {
  color-scheme: light;
  --paper: #f5f0e7;
  --paper-deep: #ece5d8;
  --card: rgba(255, 253, 248, 0.7);
  --ink: #26352e;
  --muted: #7f857e;
  --line: rgba(65, 78, 69, 0.16);
  --green: #557d69;
  --green-soft: #dfe6dd;
  --red: #a34e3e;
  --shadow: 0 14px 40px rgba(42, 54, 47, 0.08);
  --ui-font: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --reading-font: "FangSong", "STFangsong", "FangSong_GB2312", serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 8%, rgba(255,255,255,.9), transparent 28%),
    repeating-linear-gradient(90deg, rgba(95,75,46,.017) 0 1px, transparent 1px 5px),
    var(--paper);
  font-family: var(--ui-font);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid rgba(75, 118, 96, .55);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.app-shell {
  display: grid;
  grid-template-columns: minmax(238px, 21%) minmax(320px, 28%) 1fr;
  height: 100dvh;
  max-width: 1920px;
  margin: auto;
  box-shadow: var(--shadow);
}
.panel {
  min-width: 0;
  height: 100%;
  border-right: 1px solid var(--line);
  background: rgba(251, 248, 241, .68);
}
.shelf-panel {
  position: relative;
  padding: 42px 26px 36px;
  overflow: hidden;
}
.brand { position: relative; z-index: 2; margin: 0 8px 38px; }
.brand > div { display: flex; align-items: center; gap: 15px; }
.brand-name {
  font: 400 clamp(42px, 4vw, 62px)/1 var(--reading-font);
  letter-spacing: .14em;
  color: #143b2d;
}
.seal {
  display: grid; place-items: center;
  width: 24px; height: 30px;
  margin-top: 10px;
  border: 1px solid var(--red);
  border-radius: 4px;
  color: var(--red);
  font: 16px/1 var(--reading-font);
}
.brand p { margin: 14px 0 0; color: #7f7d77; letter-spacing: .18em; font-family: var(--reading-font); }
.search-box {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  height: 50px;
  padding: 0 14px;
  border: 1px solid #d1c8b9;
  border-radius: 8px;
  background: rgba(255,255,255,.4);
}
.search-box span { font-size: 28px; color: var(--muted); transform: rotate(-15deg); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search-box input::placeholder { color: #918e86; }
.bookshelf { position: relative; z-index: 2; margin-top: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading h1 { margin: 0; font: 400 21px/1.4 var(--reading-font); letter-spacing: .08em; }
.icon-button {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: transparent; color: #657068;
}
.icon-button:hover { background: rgba(73, 100, 84, .09); }
.shelf-actions { display: flex; gap: 18px; margin: 12px 0 18px; }
.text-button { border: 0; padding: 4px 0; background: transparent; color: var(--green); font-size: 13px; }
.text-button span { font-size: 17px; margin-right: 2px; }
.category-list {
  max-height: calc(100dvh - 330px);
  overflow: auto;
  margin: 0 -10px;
  padding: 0 4px 120px;
  scrollbar-width: thin;
}
.category-block { margin: 3px 0 11px; }
.category-row, .book-row {
  display: grid; align-items: center;
  min-height: 42px;
  border-radius: 8px;
}
.category-row { grid-template-columns: 26px 24px 1fr 28px; padding: 0 3px; font-family: var(--reading-font); font-size: 17px; }
.category-row .toggle { border: 0; background: transparent; padding: 0; font-size: 15px; transition: transform .2s; }
.category-block.collapsed .toggle { transform: rotate(-90deg); }
.category-block.collapsed .book-list { display: none; }
.folder-icon { color: var(--green); }
.row-menu { opacity: .2; }
.category-row:hover .row-menu, .book-row:hover .row-menu { opacity: 1; }
.book-list { display: grid; gap: 3px; }
.book-row {
  grid-template-columns: 28px 1fr auto 26px;
  width: 100%;
  padding: 0 4px 0 33px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: var(--reading-font);
  font-size: 16px;
}
.book-row:hover { background: rgba(97, 122, 105, .07); }
.book-row.selected { background: linear-gradient(90deg, rgba(116,143,124,.2), rgba(116,143,124,.08)); color: #214b39; }
.book-count { padding: 0 5px; color: #68746c; font: 12px var(--ui-font); }
.mountains {
  position: absolute;
  z-index: 0;
  left: -8%; right: -8%; bottom: -8px;
  height: 245px;
  opacity: .78;
  background: url("assets/ink-mountains.svg") center bottom / cover no-repeat;
  pointer-events: none;
}
.entries-panel { display: flex; flex-direction: column; padding: 42px 26px 32px; background: rgba(248,245,238,.5); }
.panel-header { display: flex; align-items: center; justify-content: space-between; min-height: 70px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.panel-header h2, .editor-header h2 { margin: 0; font: 400 clamp(24px, 2.2vw, 32px)/1.25 var(--reading-font); }
.entry-list { flex: 1; overflow: auto; padding: 8px 3px 20px; scrollbar-width: thin; }
.entry-card {
  position: relative;
  width: 100%;
  margin-bottom: 12px;
  padding: 17px 20px;
  border: 1px solid rgba(95, 90, 77, .13);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 3px 10px rgba(46,47,42,.04);
  text-align: left;
}
.entry-card:hover { border-color: rgba(78,119,97,.35); }
.entry-card.selected { border-color: #5d8a73; box-shadow: 0 4px 12px rgba(53,91,70,.09); }
.entry-date { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: #777d78; font-size: 12px; }
.bookmark { color: var(--red); font-size: 17px; }
.snippet { display: grid; grid-template-columns: 35px 1fr; gap: 7px; margin: 6px 0; }
.snippet-label { color: var(--red); font: 14px var(--reading-font); }
.snippet p { margin: 0; overflow: hidden; color: #485048; font: 15px/1.55 var(--reading-font); white-space: nowrap; text-overflow: ellipsis; }
.empty-list { padding: 70px 15px; text-align: center; color: var(--muted); }
.empty-list strong { display: block; margin-bottom: 8px; color: var(--ink); font: 20px var(--reading-font); }
.primary-outline {
  flex: 0 0 58px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: rgba(255,255,255,.3);
  color: var(--green);
  font: 17px var(--reading-font);
}
.primary-outline:hover { background: rgba(86,126,105,.08); }
.primary-outline:disabled, #book-menu:disabled { opacity: .35; cursor: not-allowed; }
.primary-outline span { font-size: 26px; vertical-align: -2px; }
.editor-panel { display: flex; flex-direction: column; border-right: 0; padding: 42px clamp(28px, 4vw, 64px) 30px; background: rgba(252,250,245,.66); }
.editor-header { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.editor-tools { display: flex; align-items: center; gap: 10px; }
.sync-pill {
  display: flex; align-items: center; gap: 7px;
  border: 0; border-radius: 20px; padding: 8px 10px;
  background: transparent; color: var(--green); font-size: 12px;
}
.sync-pill:hover { background: rgba(77,118,96,.08); }
.sync-dot { width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.sync-pill.connected .sync-dot { border: 0; background: #4f8569; box-shadow: 0 0 0 3px rgba(79,133,105,.13); }
.sync-pill.syncing .sync-dot { border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.75); } }
.font-select select { padding: 8px 28px 8px 10px; border: 1px solid #d7cfc2; border-radius: 6px; background: rgba(255,255,255,.42); font-family: var(--reading-font); }
.danger-hover:hover { color: var(--red); background: rgba(163,78,62,.08); }
.mobile-back { display: none; }
.editor-fields { display: grid; grid-template-rows: minmax(190px, .78fr) minmax(240px, 1fr) auto; flex: 1; min-height: 0; }
.writing-field { display: flex; flex-direction: column; min-height: 0; padding-top: 24px; }
.writing-field > span { flex: 0 0 auto; margin-bottom: 14px; color: var(--red); font: 20px var(--reading-font); }
.writing-field textarea {
  flex: 1; width: 100%; resize: none;
  border: 1px solid #d8cdbd; border-radius: 8px;
  padding: 24px 27px;
  background: rgba(255,253,248,.43);
  font: 23px/1.9 var(--reading-font);
  letter-spacing: .035em;
  outline: 0;
}
.writing-field textarea:focus { border-color: rgba(83,126,104,.6); box-shadow: inset 0 0 0 1px rgba(83,126,104,.08); }
.reflection-field { padding-bottom: 16px; }
.save-status { color: #8b8e88; font-size: 11px; }
.save-status .divider { margin: 0 12px; color: #c3bcb0; }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 15px 0 8px; color: var(--ink); font: 24px var(--reading-font); }
.empty-state p { margin: 0; font-size: 13px; }
.empty-mark {
  display: grid; place-items: center;
  width: 60px; height: 76px; margin: auto;
  border: 1px solid #9aae9f; border-radius: 3px 12px 3px 3px;
  color: var(--green); font: 28px var(--reading-font);
}
.mobile-nav { display: none; }
.modal {
  width: min(92vw, 480px);
  border: 1px solid rgba(79,91,82,.18);
  border-radius: 15px;
  padding: 0;
  background: #faf7f0;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(30,39,34,.22);
}
.modal::backdrop { background: rgba(35,42,37,.34); backdrop-filter: blur(4px); }
.modal form { padding: 28px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 25px; }
.modal-heading h2 { margin: 0; font: 28px var(--reading-font); }
.modal-copy { color: #6f756f; font-size: 13px; line-height: 1.75; }
.form-field { display: grid; gap: 8px; margin: 17px 0; }
.form-field span { color: #656d66; font-size: 12px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 1px solid #d2c8b8; border-radius: 7px; padding: 11px 12px; background: rgba(255,255,255,.55); outline: 0;
}
.form-field textarea { resize: vertical; font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.quiet-button, .solid-button { border-radius: 7px; padding: 10px 18px; }
.quiet-button { border: 1px solid #d4cabd; background: transparent; }
.solid-button { border: 1px solid var(--green); background: var(--green); color: white; }
.delete-link { margin-top: 18px; border: 0; padding: 0; background: transparent; color: var(--red); font-size: 12px; }
.form-message { min-height: 18px; color: var(--red); font-size: 12px; }
.connected-card { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 10px; background: #e8eee8; }
.connected-card p { margin: 5px 0 0; color: #667068; font-size: 12px; }
.large-sync-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(85,125,105,.13); }
.settings-list { display: grid; gap: 8px; }
.settings-list button {
  display: grid; gap: 5px;
  width: 100%; border: 0; border-radius: 9px; padding: 14px 16px;
  background: rgba(95,116,101,.06); text-align: left;
}
.settings-list button:hover { background: rgba(95,116,101,.11); }
.settings-list small { color: #81867f; }
.toast {
  position: fixed; z-index: 20; left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 40px); padding: 10px 16px;
  border-radius: 7px; background: #26352e; color: white; font-size: 12px;
  opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 230px 300px 1fr; }
  .shelf-panel, .entries-panel { padding-left: 18px; padding-right: 18px; }
  .editor-panel { padding-left: 25px; padding-right: 25px; }
  .sync-pill span:last-child { display: none; }
}

@media (max-width: 820px) {
  body { overflow: hidden; }
  .app-shell { display: block; height: calc(100dvh - 66px); box-shadow: none; }
  .panel { display: none; width: 100%; height: 100%; border: 0; }
  .panel.active { display: flex; }
  .shelf-panel.active { display: block; padding: 28px 22px 16px; overflow-y: auto; }
  .brand { margin-bottom: 24px; }
  .brand-name { font-size: 46px; }
  .category-list { max-height: none; overflow: visible; padding-bottom: 160px; }
  .mountains { position: fixed; bottom: 50px; height: 185px; }
  .entries-panel { padding: 25px 20px 18px; }
  .editor-panel { padding: 20px 18px 13px; }
  .editor-header { align-items: flex-start; min-height: 78px; padding-bottom: 12px; }
  .editor-header h2 { font-size: 22px; }
  .editor-tools { gap: 1px; }
  .font-select select { max-width: 75px; padding-left: 6px; padding-right: 4px; }
  .mobile-back { display: inline; border: 0; padding: 0 8px 0 0; background: transparent; font-size: 30px; vertical-align: -3px; }
  .writing-field { padding-top: 15px; }
  .writing-field > span { margin-bottom: 8px; font-size: 17px; }
  .writing-field textarea { padding: 16px; font-size: 19px; line-height: 1.75; }
  .editor-fields { grid-template-rows: minmax(150px, .78fr) minmax(180px, 1fr) auto; }
  .mobile-nav {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 7px 8px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: rgba(250,248,242,.95); backdrop-filter: blur(14px);
  }
  .mobile-nav button { display: grid; place-items: center; gap: 2px; border: 0; background: transparent; color: #737a73; font-size: 10px; }
  .mobile-nav button span { font-size: 18px; }
  .mobile-nav button.active { color: var(--green); }
  .mobile-nav .new-mobile {
    align-self: start; justify-self: center;
    width: 45px; height: 45px; margin-top: -17px;
    border-radius: 50%; background: var(--green); color: white; font-size: 27px;
    box-shadow: 0 5px 15px rgba(46,92,68,.22);
  }
  .toast { bottom: 80px; }
}

@media (max-width: 430px) {
  .editor-tools .danger-hover { display: none; }
  .sync-pill { padding-left: 5px; padding-right: 5px; }
  .panel-header h2 { font-size: 27px; }
  .entry-card { padding: 15px 16px; }
}
