:root {
  color-scheme: light;
  --ink: #132a25;
  --muted: #506660;
  --paper: #f5f7f3;
  --line: #dbe5df;
  --accent: #176c61;
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .57; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #4d9d8a;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.shell { min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 33px; padding: 31px 18px 24px; background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px; text-decoration: none; color: inherit; }
.brand strong { display: block; font-size: 19px; letter-spacing: .05em; line-height: 1.4; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.sidebar-caption { margin: 0 10px 10px; font-size: 12px; color: var(--muted); }
.topics { display: grid; gap: 4px; }
.topic-button { width: 100%; display: flex; gap: 9px; align-items: center; padding: 10px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--ink); font-size: 14px; }
.topic-button:hover { background: #f3f6f3; }
.topic-button[aria-pressed="true"] { background: #e8f3ed; color: #13554a; font-weight: 700; }
.topic-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-icon { width: 18px; color: var(--accent); }
.topic-count { color: var(--muted); font-size: 12px; }
.export { margin-top: auto; align-self: flex-start; }
main { width: min(100%, 1320px); margin: 0 auto; padding: 40px clamp(22px, 4vw, 65px); }
.hero { position: relative; isolation: isolate; overflow: hidden; display: flex; gap: 22px; justify-content: space-between; align-items: end; min-height: 195px; padding: 29px clamp(22px, 4vw, 44px); border-radius: 20px; background: #123b35; color: #f8fffb; }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: repeating-radial-gradient(ellipse at 87% 145%, transparent 0 24px, #6ab09b25 25px 26px, transparent 27px 41px), linear-gradient(120deg, transparent 38%, #1b594a); }
.eyebrow { margin: 0 0 9px; color: #b7dfce; font-size: 13px; letter-spacing: .17em; }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.15; letter-spacing: -.04em; }
.hero-copy > p:last-child { margin: 12px 0 0; color: #d8ece3; font-size: 14px; }
.primary, .secondary, .danger { min-height: 39px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; white-space: nowrap; font-weight: 650; font-size: 14px; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:enabled { background: #11574d; }
.hero .primary { background: #e0f4e7; color: #123b35; }
.hero .primary:hover:enabled { background: #fff; }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:hover:enabled { background: #eef4ef; }
.danger { color: #9b302b; background: #fff2ef; }
.danger:hover:enabled { background: #ffe4dc; }
.toolbar { margin: 29px 0 15px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 13px; }
.listing-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
h2 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.search { display: flex; width: min(100%, 330px); align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 11px; background: #fff; }
.search > span { color: var(--accent); font-size: 23px; }
.search input { min-width: 0; width: 100%; height: 40px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); font-size: 14px; }
.search:focus-within { outline: 2px solid #4d9d8a; outline-offset: 2px; }
.search input:focus { outline: none; }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; }
.note-card { display: flex; flex-direction: column; align-items: stretch; gap: 12px; min-width: 0; min-height: 171px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: inherit; text-align: left; }
.note-card:hover { border-color: #79af9c; box-shadow: 0 6px 17px #163c2910; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tag { display: inline-block; max-width: 100%; padding: 4px 8px; border-radius: 6px; background: #e9f4ed; color: #17574b; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.arrow { color: var(--accent); }
.note-title { font-size: 17px; overflow-wrap: anywhere; }
.excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; color: var(--muted); }
.card-date { margin-top: auto; font-size: 12px; color: var(--muted); }
.empty, .loading { grid-column: 1 / -1; margin: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); text-align: center; padding: 43px 20px; }
.empty h3 { margin: 12px 0 5px; font-size: 18px; color: var(--ink); }
.empty p { margin: 0 0 17px; font-size: 14px; }
.empty-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; background: #edf5ef; color: var(--accent); border-radius: 11px; font-size: 23px; }
.pages { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 20px auto 0; color: var(--muted); font-size: 14px; }
.notice { border-left: 3px solid var(--accent); padding: 9px 13px; background: #e8f3ed; font-size: 14px; }
dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); box-shadow: 0 24px 100px #071b2350; }
dialog::backdrop { background: #0b292677; }
.dialog-body { display: grid; gap: 15px; padding: clamp(16px, 4vw, 29px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.close { padding: 0; width: 38px; min-height: 38px; font-size: 22px; line-height: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.muted, .source { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.source { padding-top: 12px; border-top: 1px solid var(--line); }
.source a { color: var(--accent); }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 650; }
label small { color: var(--muted); font-weight: 400; }
label input, label textarea { width: 100%; padding: 9px 11px; border: 1px solid #c6d6cd; border-radius: 8px; background: #fcfdfb; color: var(--ink); font-weight: 400; }
textarea { resize: vertical; line-height: 1.6; min-height: 115px; }
.error { color: #922b25; margin: 0; font-size: 14px; }
@media (max-width: 710px) {
  .shell { display: block; }
  .sidebar { display: grid; grid-template-columns: 1fr auto; gap: 13px; padding: 13px 15px 9px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; }
  .export { grid-column: 2; grid-row: 1; align-self: center; margin: 0; }
  .sidebar nav { min-width: 0; grid-column: 1 / -1; }
  .sidebar-caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .topics { display: flex; padding: 3px; overflow-x: auto; }
  .topic-button { width: auto; flex: 0 0 auto; max-width: min(250px, 80vw); }
  main { padding: 18px 15px 32px; }
  .hero { min-height: 0; align-items: flex-start; flex-direction: column; }
  .toolbar { margin-top: 20px; }
}
button, input, textarea, select { font: inherit; }
.auth-button { align-self: flex-end; background: #e0f4e7; border-color: transparent; color: #123b35; }
.auth-button:hover:enabled { background: #fff; }
.add-topic { margin-top: 7px; color: var(--accent); font-weight: 650; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; justify-content: flex-end; }
.toolbar-actions .search { width: clamp(205px, 26vw, 330px); }
.empty > button { margin-top: 13px; }
.small-dialog { width: min(470px, calc(100% - 24px)); }
.wide-editor { width: min(1120px, calc(100% - 40px)); height: min(860px, calc(100dvh - 40px)); max-height: none; }
.note-form { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.note-details { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
label select { width: 100%; padding: 9px 11px; border: 1px solid #c6d6cd; border-radius: 8px; background: #fcfdfb; color: var(--ink); }
select:focus-visible { outline: 3px solid #4d9d8a; outline-offset: 3px; }
.body-editor { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 190px; gap: 8px; }
.body-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.body-toolbar > div { display: flex; align-items: center; gap: 6px; }
.body-toolbar button { min-height: 34px; padding: 6px 10px; }
.body-editor textarea, .body-preview { flex: 1 1 auto; min-height: 120px; width: 100%; border: 1px solid #c6d6cd; border-radius: 8px; padding: 13px; background: #fcfdfb; color: var(--ink); line-height: 1.65; }
.body-editor textarea { resize: none; }
.body-preview { overflow: auto; }
.prose img { display: block; max-width: 100%; max-height: 680px; width: auto; height: auto; border-radius: 7px; }
@media (max-width: 710px) {
  .auth-button { align-self: flex-start; }
  .sidebar nav { display: flex; align-items: center; gap: 5px; }
  .topics { min-width: 0; }
  .add-topic { flex: 0 0 auto; margin: 0; }
  .toolbar-actions { width: 100%; justify-content: flex-start; }
  .toolbar-actions .search { flex: 1 0 165px; width: auto; }
  .wide-editor { width: calc(100% - 12px); height: calc(100dvh - 12px); }
  .note-form { gap: 10px; }
  .note-details { grid-template-columns: 1fr; gap: 9px; }
}
