:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --ink: #24302b;
  --muted: #6f786f;
  --line: #d9ded5;
  --wash: #edf4ef;
  --panel: #ffffff;
  --jade: #187a5b;
  --jade-soft: #dff1e9;
  --cinnabar: #c24d36;
  --amber: #f2c46d;
  --blue: #3e7fb7;
  --shadow: 0 18px 44px rgba(39, 53, 45, .12);
  font-family: "Noto Serif SC", "Songti SC", "Microsoft YaHei", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(24,122,91,.04) 1px, transparent 1px),
    linear-gradient(180deg, #f4f7f2 0, var(--paper) 320px);
  background-size: 28px 28px, auto;
  color: var(--ink);
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  background: rgba(251, 250, 246, .86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #2d6f56;
  border-radius: 8px;
  background: #174f40;
  color: #fff7df;
  font-weight: 800;
}

.brand strong, .brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  background: var(--jade);
  color: white;
  box-shadow: 0 10px 24px rgba(24, 122, 91, .22);
}

.ghost-button,
.icon-button {
  border-color: var(--line);
  background: rgba(255,255,255,.72);
  color: var(--ink);
}

.full {
  width: 100%;
}

.hero {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 34px;
  align-items: stretch;
  margin: 18px 0 22px;
  padding: 26px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff 0%, #f3f7ef 64%, #fff4df 100%);
  box-shadow: var(--shadow);
}

.book-cover {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 310px;
  padding: 24px;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(140deg, rgba(255,255,255,.12), transparent 42%),
    linear-gradient(180deg, #2a7b61, #173d34);
  color: #fff7df;
  box-shadow: inset 12px 0 rgba(0,0,0,.12), 0 24px 34px rgba(20, 51, 43, .24);
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 247, 223, .42);
}

.book-cover span,
.book-cover strong,
.book-cover small {
  position: relative;
}

.book-cover span {
  color: var(--amber);
  font-size: 13px;
  letter-spacing: .08em;
}

.book-cover strong {
  margin-top: 10px;
  font-size: 31px;
  line-height: 1.12;
}

.book-cover small {
  margin-top: 12px;
  font-size: 15px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cinnabar);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 12px;
  font-size: clamp(34px, 5.2vw, 62px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metrics div {
  border-left: 3px solid var(--jade);
  padding: 8px 12px;
  background: rgba(255,255,255,.68);
}

.metrics strong,
.metrics span {
  display: block;
}

.metrics strong {
  font-size: 26px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.panel,
.board {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  box-shadow: 0 10px 28px rgba(39, 53, 45, .08);
}

.controls {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.panel-head,
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.board-head h2 {
  margin: 0;
  font-size: 22px;
}

.field,
.note-form {
  display: grid;
  gap: 8px;
}

.field span,
.filter-group h3,
.note-form h3,
.sync-box h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sync-box {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(24, 122, 91, .22);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #f5fbf7, #fff);
}

.sync-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#notebook-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toggle-row input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--jade);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline-color: var(--jade);
}

input {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--wash);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: white;
  color: var(--jade);
  box-shadow: 0 6px 16px rgba(39, 53, 45, .1);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  background: white;
  color: var(--muted);
}

.chip.active {
  border-color: var(--jade);
  background: var(--jade-soft);
  color: var(--jade);
}

.board {
  min-width: 0;
  padding: 20px;
}

.groups {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.group-card {
  border: 1px solid var(--line);
  background: #fff;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  padding: 14px 16px;
  background: #f7faf6;
  color: var(--ink);
  text-align: left;
}

.group-title strong {
  font-size: 18px;
}

.group-title span {
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--jade-soft);
  color: var(--jade);
  font-size: 12px;
}

.note-list {
  display: grid;
  gap: 0;
}

.note-card {
  padding: 16px;
  border-top: 1px solid var(--line);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.note-meta strong {
  color: var(--ink);
}

blockquote {
  margin: 12px 0 10px;
  border-left: 4px solid var(--amber);
  padding: 4px 0 4px 12px;
  font-size: 18px;
  line-height: 1.72;
}

.note-card p {
  margin-bottom: 10px;
  color: #405047;
  line-height: 1.75;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-tags span {
  border-radius: 999px;
  padding: 4px 9px;
  background: #f2f4f0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  width: min(720px, calc(100% - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(20, 29, 24, .42);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin-bottom: 0;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.7;
}

#import-json {
  min-height: 280px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  font-size: 22px;
  line-height: 1;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--cinnabar);
}

@media (max-width: 900px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .book-cover {
    min-height: 240px;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .hero {
    padding: 16px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 34px;
  }
}
