:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #65758b;
  --line: #d9e2ec;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --success: #167a3f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05rem 0.25rem;
  background: #f1f5f9;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 251, 0.92);
  backdrop-filter: blur(16px);
}

.brand, .nav, .actions, .row-actions, .tag-row, .section-head {
  display: flex;
  align-items: center;
}

.brand { gap: 0.65rem; font-weight: 800; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

.nav { gap: 0.25rem; }
.nav a, .button {
  min-height: 2.35rem;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-weight: 700;
  font-size: 0.92rem;
}
.nav a.active, .nav a:hover { background: #e6f3f1; color: var(--accent-strong); }

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 5rem); line-height: 0.95; font-weight: 900; }
.page-head.compact h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
.eyebrow { margin: 0 0 0.45rem; color: var(--accent-strong); font-weight: 800; text-transform: uppercase; font-size: 0.78rem; }
.stat { color: var(--muted); font-weight: 800; }

.filters, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(20, 33, 61, 0.06);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 0.55fr) minmax(170px, 0.55fr) auto auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

label { display: grid; gap: 0.35rem; font-weight: 750; color: var(--ink); }
label span { font-size: 0.82rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.68rem 0.78rem;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-strong); }
.button.ghost { border-color: var(--line); background: white; color: var(--ink); }
.button.danger { background: #fff1f0; border-color: #f6b8b2; color: var(--danger); }
.button.small { min-height: 2rem; padding: 0.35rem 0.6rem; font-size: 0.82rem; }

.sections { display: grid; gap: 1rem; }
.bookmark-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.bookmark-section summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  cursor: pointer;
  font-weight: 850;
  list-style: none;
}
.bookmark-section summary::-webkit-details-marker { display: none; }
.bookmark-section summary span:last-child { color: var(--muted); }
.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}
.bookmark-card {
  min-height: 170px;
  padding: 1rem;
  background: #fff;
}
.bookmark-title { display: block; font-weight: 850; line-height: 1.25; margin-bottom: 0.45rem; }
.bookmark-title:hover { color: var(--accent-strong); }
.bookmark-url, .bookmark-description, .muted {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.bookmark-url { margin: 0 0 0.75rem; font-size: 0.82rem; }
.bookmark-description { margin: 0 0 0.75rem; }
.tag-row { gap: 0.35rem; flex-wrap: wrap; }
.tag {
  border: 1px solid #c8ddd9;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: #eef8f6;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 750;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel { padding: 1.1rem; margin-bottom: 1rem; }
.panel h2 { margin: 0 0 0.8rem; font-size: 1.1rem; }
.panel form { display: grid; gap: 0.8rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.actions, .row-actions { gap: 0.5rem; }
.section-head { justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.inline-search { display: flex !important; flex-direction: row; gap: 0.5rem !important; width: min(420px, 100%); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
td small { display: block; margin-top: 0.25rem; color: var(--muted); overflow-wrap: anywhere; }
.row-actions { justify-content: flex-end; }
.row-actions form { display: inline; }
.source-list { display: grid; gap: 0.75rem; }
.source-list div { display: grid; gap: 0.2rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.source-list span, .source-list em { color: var(--muted); }

.notice, .empty {
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.notice.success { border: 1px solid #a9dfbf; background: #ecfdf3; color: var(--success); }
.notice.danger { border: 1px solid #f6b8b2; background: #fff1f0; color: var(--danger); }
.empty {
  display: grid;
  place-items: start;
  gap: 0.75rem;
  border: 1px dashed var(--line);
  background: #fff;
}
.empty h1, .empty h2, .empty p { margin: 0; }

@media (max-width: 820px) {
  .topbar, .page-head, .section-head { align-items: stretch; flex-direction: column; }
  .filters, .admin-grid, .two-col { grid-template-columns: 1fr; }
  .filters .button { width: 100%; }
  .bookmark-grid { grid-template-columns: 1fr; }
}
