:root {
  --paper: #f2f6f4;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #747b84;
  --soft: #eef2f0;
  --line: #e1e8e4;
  --lime: #b7ff18;
  --lime-soft: #e8ffb8;
  --red: #d92d20;
  --shadow: 0 14px 40px rgba(23, 23, 23, 0.08);
  --lift: 0 18px 48px rgba(23, 23, 23, 0.15);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(183, 255, 24, 0.16), transparent 28rem),
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar-row,
.notes-header,
.modal-head,
.drawer-head,
.book-row,
.note-row,
.filter-actions,
.form-actions,
.composer,
.tag-edit-row {
  display: flex;
  align-items: center;
}

.topbar h1,
.notes-title,
.empty h2,
.modal-title,
.drawer-title {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.05;
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(23, 23, 23, 0.04);
}

.search-box input,
.field input,
.field textarea,
.field select,
.tag-entry input,
.composer textarea,
.edit-note-dialog textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.filter-button,
.primary-button,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--lime);
  font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.filter-button:hover,
.primary-button:hover,
.save-button:hover,
.fab:hover,
.book-card:hover,
.note-card:hover {
  transform: translateY(-3px);
}

.filter-count {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(183, 255, 24, 0.18);
  font-size: 12px;
}

.status-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 18px 0 20px;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-tab {
  min-height: 44px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.status-tab:hover {
  background: var(--soft);
  color: var(--ink);
}

.status-tab.active {
  background: var(--lime);
  color: var(--ink);
}

.book-grid {
  display: grid;
  gap: 14px;
}

.book-card,
.note-card,
.empty {
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.book-card {
  padding: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card:hover,
.note-card:hover {
  box-shadow: var(--lift);
}

.book-main {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 14px;
  padding: 0;
  text-align: left;
  background: transparent;
}

.cover {
  display: grid;
  width: 78px;
  height: 108px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: var(--ink);
  color: var(--lime);
}

.cover.small {
  width: 48px;
  height: 64px;
  border-radius: 15px;
}

.book-info {
  min-width: 0;
  flex: 1;
  align-self: center;
}

.book-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-author,
.book-meta,
.note-time,
.empty p,
.form-hint {
  color: var(--muted);
}

.book-author {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 700;
}

.book-meta {
  margin-top: 12px;
  font-size: 12px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
  background: var(--ink);
  color: var(--lime);
  transform: rotate(6deg);
}

.icon-button.danger {
  background: #ffe8e6;
  color: var(--red);
}

.icon-button.danger:hover {
  background: #ffd5d1;
  color: var(--red);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: var(--soft);
  padding: 6px 11px;
  color: #59616a;
  font-size: 12px;
  font-weight: 800;
}

.tag.accent {
  background: var(--lime);
  color: var(--ink);
}

.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border-radius: 50%;
  background: var(--lime);
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(183, 255, 24, 0.44);
  transition: transform 0.2s ease;
}

.empty {
  padding: 44px 24px;
  text-align: center;
}

.empty h2 {
  margin-top: 14px;
  font-size: 22px;
  font-weight: 900;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(7px);
}

.drawer,
.modal,
.edit-note-dialog {
  width: min(100%, 560px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 32px;
  background: var(--surface);
  box-shadow: var(--lift);
}

.drawer,
.edit-note-dialog {
  padding: 20px;
}

.modal {
  padding: 22px;
}

.drawer-head,
.modal-head {
  justify-content: space-between;
  gap: 16px;
}

.drawer-title,
.modal-title,
.notes-title {
  font-size: 24px;
  font-weight: 900;
}

.drawer-list {
  display: grid;
  max-height: 260px;
  gap: 6px;
  margin: 18px 0;
  overflow: auto;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s ease;
}

.check-row:hover {
  background: var(--soft);
}

.check-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--lime);
}

.filter-actions,
.form-actions {
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-button,
.cancel-button,
.reset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--soft);
  color: #59616a;
  font-weight: 800;
  transition: background 0.2s ease;
}

.secondary-button:hover,
.cancel-button:hover,
.reset-button:hover {
  background: #e0e7e3;
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #ffe8e6;
  color: var(--red);
  font-weight: 900;
}

.filter-actions > *,
.form-actions > * {
  flex: 1;
  min-width: 96px;
}

.form-section {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 14px;
  font-weight: 800;
}

.input-shell,
.tag-entry,
.composer textarea,
.edit-note-dialog textarea {
  border-radius: 18px;
  background: var(--soft);
  padding: 13px 15px;
}

.preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 24px;
  background: var(--paper);
}

.divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.tag-edit-row {
  flex-wrap: wrap;
  gap: 8px;
}

.tag-entry {
  display: flex;
  min-width: 210px;
  flex: 1;
  gap: 8px;
}

.tag-remove {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
}

.error {
  margin: 14px 0 0;
  border-radius: 18px;
  background: #fff0ef;
  padding: 12px 14px;
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
}

.notes-header {
  gap: 14px;
  padding: 14px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.notes-head-copy {
  min-width: 0;
  flex: 1;
}

.notes-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.notes-list {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.note-card {
  padding: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.note-row {
  align-items: flex-start;
  gap: 14px;
}

.note-content {
  flex: 1;
  min-width: 0;
  margin: 0;
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.7;
}

.note-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.note-time {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 800;
}

.composer-wrap {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(100%, 880px);
  margin: 0 auto;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
}

.composer {
  gap: 10px;
  padding: 12px;
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--lift);
}

.composer textarea {
  min-height: 78px;
  resize: none;
  line-height: 1.5;
}

.composer .primary-button {
  width: 98px;
  min-height: 78px;
  flex: 0 0 auto;
  padding: 0 10px;
}

.composer .primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

@media (min-width: 680px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .topbar-actions {
    flex-direction: row;
    align-items: center;
  }

  .search-box {
    width: 280px;
  }

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

  .overlay {
    align-items: center;
  }
}

@media (min-width: 1024px) {
  .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 12px;
  }

  .book-title {
    font-size: 16px;
  }

  .cover {
    width: 70px;
    height: 98px;
  }
}
