:root {
  color-scheme: light;
  --bg: #efeae2;
  --paper: #fbf9f5;
  --ink: #1d2420;
  --muted: #667069;
  --line: #e2dbd1;
  --accent: #1f4d3a;
  --accent-ink: #f4f7f5;
  --warn: #8a4b12;
  --warn-bg: #fff4e8;
  --danger: #8d2f2f;
  --shadow: 0 18px 50px rgba(70, 52, 31, 0.08);
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Palatino Linotype", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth, .modal {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(38, 32, 25, 0.35);
}
.card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 28px 22px;
}
.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 13px;
}
h1, h2 { font-family: var(--serif); font-weight: 600; }
h1 { font-size: 34px; line-height: 1.25; margin: 8px 0 10px; }
h2 { margin: 0 0 14px; font-size: 26px; }
.lead, .hint, .empty p { color: var(--muted); line-height: 1.6; }
label { display: block; margin: 14px 0; font-size: 14px; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
}
label input { margin-top: 6px; }
input:focus, textarea:focus {
  outline: 2px solid rgba(31, 77, 58, 0.25);
  border-color: var(--accent);
}
.row { display: flex; gap: 10px; }
button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
}
button.ghost, button.text {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}
button.text { border: 0; padding: 8px 4px; }
.error { color: var(--danger); min-height: 0; margin: 0 0 10px; }

.shell {
  height: 100%;
  display: grid;
  grid-template-columns: 300px 1fr;
}
aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #f7f4ee;
  min-height: 0;
}
.brand { display: flex; gap: 10px; align-items: center; }
.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--serif);
}
.brand strong, .brand em { display: block; }
.brand em { color: var(--muted); font-style: normal; font-size: 13px; }
.list { overflow: auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; }
.note {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
}
.note strong, .note span { display: block; }
.note span { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note.active { background: #fff; border-color: var(--line); }
.side-actions { display: flex; justify-content: space-between; }

main { min-width: 0; min-height: 0; display: flex; }
.empty, .editor { width: min(820px, 100%); margin: 0 auto; }
.empty { align-self: center; text-align: center; padding: 24px; }
.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 22px 28px 16px;
}
#title {
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 32px;
  padding: 8px 0 12px;
  border-radius: 0;
}
#body {
  flex: 1;
  min-height: 240px;
  overflow: auto;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}
#body:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
#body img {
  display: block;
  max-width: min(100%, 720px);
  height: auto;
  margin: 10px 0;
  border-radius: 10px;
}
.conflict {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.conflict p { margin: 0 0 8px; }
.save-state { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.note-sharing { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.note-sharing p { margin:0; color:var(--muted); font-size:14px; line-height:1.6; flex:1; min-width:140px; }
.note-sharing button { min-height:44px; }
.note-shared-badge { color:var(--accent); font-size:14px; font-weight:600; }
#title[readonly] { color:var(--ink); }
#body[contenteditable=false] { cursor:text; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  #title { font-size: 26px; }
  .editor { padding: 14px 14px 10px; }
}
