:root {
  --paper: #f6f2ea;
  --paper-2: #efe9dd;
  --card: #fffdf8;
  --ink: #2b2723;
  --ink-2: #5c564e;
  --ink-3: #8a8378;
  --line: #e2dbcc;
  --accent: #b45309;
  --accent-soft: #f3e4d0;
  --ok: #3f6b4a;
  --ok-soft: #e3efe6;
  --sidebar: #1f1c19;
  --sidebar-ink: #e8e2d6;
  --sidebar-muted: #9a9286;
  --shadow: 0 1px 2px rgba(43, 39, 35, 0.06), 0 8px 24px rgba(43, 39, 35, 0.05);
  --radius: 10px;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  padding: 4px 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.brand p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--sidebar-muted);
  line-height: 1.45;
}

.nav-group {
  margin-top: 10px;
}

.nav-label {
  font-size: 11px;
  color: var(--sidebar-muted);
  padding: 0 10px 6px;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  gap: 8px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  background: rgba(180, 83, 9, 0.22);
  color: #ffd7a8;
}

.nav-item .count {
  font-size: 11px;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 6px;
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--sidebar-ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  text-align: left;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ghost-btn.primaryish {
  border-color: rgba(180, 83, 9, 0.55);
  color: #f0c48a;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px 8px;
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.topbar .sub {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

.content {
  padding: 8px 26px 40px;
  max-width: 1080px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.btn:hover {
  border-color: #d0c7b4;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(0.96);
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.btn.sm {
  padding: 5px 9px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sync-pill {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.sync-pill.on {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #c5dccb;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.section {
  margin-top: 18px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat .n {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.1;
}

.stat .l {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 12px;
}

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

.list-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
}

.list-item.done {
  opacity: 0.62;
}

.list-item.done .title {
  text-decoration: line-through;
}

.list-item .meta {
  color: var(--ink-3);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.45;
}

.list-item .body {
  flex: 1;
  min-width: 0;
}

.list-item .title {
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

.row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--ink-3);
  border: 1px solid transparent;
}

.icon-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--line);
}

.tick {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid #c4bbab;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 11px;
  color: transparent;
}

.tick.on {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper-2);
  border-radius: 999px;
  padding: 2px 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.note-cell {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
  max-width: 200px;
  word-break: break-word;
}

.url-cell {
  font-size: 12px;
  word-break: break-all;
  max-width: 200px;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.key-cell code {
  font-size: 11px;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-2);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--paper-2);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 12px;
  color: var(--ink-2);
}

.filter-field select {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 96px;
  outline: none;
}

.filter-field select:focus {
  border-color: #d2b48c;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.08);
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.tab {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid transparent;
}

.tab:hover {
  background: var(--paper-2);
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #e8d2b0;
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #d2b48c;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.08);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 28, 25, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  padding: 18px;
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.modal .hint {
  margin: 0 0 14px;
  color: var(--ink-3);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--paper-2);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-2);
}

tr:last-child td {
  border-bottom: none;
}

tr.done td {
  color: var(--ink-3);
}

.empty {
  border: 1px dashed #d5cdbd;
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  background: rgba(255, 253, 248, 0.5);
}

.search {
  width: min(260px, 100%);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}

.note {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper-2);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.55;
}

.home-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  width: 100%;
  text-align: left;
}

.home-link:hover {
  border-color: #d0c7b4;
}

.home-link .t {
  font-size: 14px;
  font-weight: 600;
}

.home-link .d {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 3px;
}

.progress-bar {
  height: 4px;
  background: var(--paper-2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .grid-3,
  .stat-row {
    grid-template-columns: 1fr;
  }

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