:root {
  --bg: #fdfcf8;
  --bg-tint: #f9f7f2;
  --bg-soft: #f3f1ec;
  --ink: #0f0f0f;
  --ink-soft: #1f1f1f;
  --grey-700: #525252;
  --grey-500: #737373;
  --grey-400: #767676;
  --grey-300: #d4d4d2;
  --border: #e8e6e1;
  --border-soft: #eeecea;
  --accent: #b45309;
  --tag-ink: #57534e;
  --tag-bg: #f0ede8;
  --danger: #b42318;
  --radius: 6px;
  --radius-sm: 4px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Header */
.app-header {
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 96px;
  max-width: 1400px;
  margin: 0 auto;
}
.app-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}
.app-name {
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.app-nav { display: flex; align-items: center; gap: 4px; }
.app-nav a, .app-nav .nav-link {
  color: var(--grey-500);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.app-nav a:hover, .app-nav .nav-link:hover { color: var(--ink); }
.help-btn {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--grey-500);
  font-family: inherit;
}
.help-btn:hover { color: var(--ink); background: var(--bg-soft); }

.btn-primary {
  background: var(--ink) !important;
  color: var(--bg) !important;
  border: 1px solid var(--ink);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.btn-primary:hover { color: var(--bg) !important; }

.btn-ghost {
  background: transparent;
  color: var(--grey-700);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  font-family: inherit;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--grey-300); }

.icon-btn {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-grid; place-items: center;
}

/* Page body */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 72px;
  padding: 32px 96px 40px;
  max-width: 1400px;
  margin: 0 auto;
}
.main { min-width: 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section-header h1 {
  font-size: 22px; font-weight: 600;
  margin: 0; letter-spacing: -0.01em;
  color: var(--ink);
}
.header-controls { display: flex; align-items: center; gap: 8px; }

.search { position: relative; width: 280px; }
.search input {
  width: 100%; height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px; color: var(--ink);
  font-family: inherit; outline: none;
}
.search input::placeholder { color: var(--grey-400); }
.search input:focus { border-color: var(--grey-300); box-shadow: 0 0 0 3px rgba(15,15,15,0.12); }
.search .icon {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--grey-400);
  pointer-events: none;
}

/* Sub nav */
.sub-nav {
  display: flex; gap: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sub-nav a {
  text-decoration: none;
  color: var(--grey-500);
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
}
.sub-nav a.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 500;
}
.sub-nav a:hover { color: var(--ink); }
.sub-nav .count {
  color: var(--grey-400);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
  font-size: 12px;
}
.sub-nav-add {
  margin-left: auto;
  align-self: center;
  padding: 6px 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
  background: var(--bg-tint) !important;
  color: var(--grey-700) !important;
  margin-bottom: 0 !important;
  line-height: 1;
}

/* Active filter pills */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 12px 0 4px;
  font-size: 12.5px; color: var(--grey-500);
  align-items: center;
}
.filters-bar .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 4px 2px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--grey-700);
  font-size: 11.5px;
}
.filters-bar .pill a {
  color: var(--grey-500);
  text-decoration: none;
  font-size: 13px; line-height: 1;
  padding: 0 6px;
  border-radius: 999px;
}
.filters-bar .pill a:hover { color: var(--ink); }

/* Top tags (mobile only — quick filter strip above add-bookmark) */
.top-tags { display: none; }
@media (max-width: 720px) {
  .top-tags {
    display: flex; flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 6px;
  }
  .top-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--grey-700);
    text-decoration: none;
    background: var(--bg);
    line-height: 1.4;
  }
  .top-tag .count { color: var(--grey-500); font-size: 11px; }
  .top-tag.selected {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
  }
  .top-tag.selected .count { color: var(--accent); }
}

/* Add bookmark (collapsible) */
.add-bookmark {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  background: var(--bg-tint);
}
.add-bookmark > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-700);
  display: flex; align-items: center; gap: 8px;
}
.add-bookmark > summary::-webkit-details-marker { display: none; }
.add-bookmark > summary::before {
  content: "+";
  font-size: 16px; line-height: 1;
  color: var(--grey-500);
}
.add-bookmark[open] > summary {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
}
.add-bookmark[open] > summary::before { content: "−"; }
.add-bookmark .form-body { padding: 14px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label {
  font-size: 12px; font-weight: 500;
  color: var(--grey-700);
}
.field .hint { color: var(--grey-400); font-weight: 400; font-size: 11px; margin-left: 4px; }
.field input[type="text"],
.field input[type="url"],
.field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit; font-size: 13px;
  color: var(--ink); background: var(--bg);
  outline: none; resize: vertical;
  width: 100%;
}
.field input:focus, .field textarea:focus {
  border-color: var(--grey-300);
  box-shadow: 0 0 0 3px rgba(15,15,15,0.12);
}
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.field-hint { font-size: 12px; margin-top: 4px; min-height: 16px; color: var(--grey-700); }
.field-hint.is-ok { color: #2e7d32; }
.field-hint.is-err { color: var(--danger); }
.field-hint.is-checking { color: var(--grey-700); }
.field-row {
  display: flex; gap: 16px; flex-wrap: wrap;
  align-items: center; margin-bottom: 12px;
}
.check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--grey-700);
}
.check input { accent-color: var(--ink); }

/* Toggle pills (read later / private) */
.field-row.toggles { gap: 8px; }
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--grey-500);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}
.toggle-pill:hover {
  border-color: var(--grey-300);
  color: var(--grey-700);
}
.toggle-pill input { display: none; }
.toggle-pill svg { display: block; }
.toggle-pill:has(input:checked) {
  background: #fff4e0;
  border-color: #f0c473;
  color: #8a5a00;
}

/* Tag picker (chips + input) */
.field .tag-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-height: 38px;
  cursor: text;
}
.field .tag-field:focus-within {
  border-color: var(--grey-300);
  box-shadow: 0 0 0 3px rgba(15,15,15,0.12);
}
.tag-field .chips {
  display: contents;
}
.tag-field .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 9px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--grey-700);
  line-height: 1.3;
}
.tag-field .chip-x {
  background: none;
  border: none;
  padding: 0 4px;
  color: var(--grey-400);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.tag-field .chip-x:hover { color: var(--ink); }
.field .tag-field .tag-search {
  flex: 1 1 100px;
  min-width: 100px;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}
.field .tag-field .tag-search:focus {
  outline: none;
  border: none;
  box-shadow: none;
}
.suggestions {
  position: relative;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-top: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 5;
}
.suggestions:empty { display: none; }
.sugg {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.sugg:hover, .sugg.active { background: var(--bg-soft); }
.sugg-add { color: var(--grey-700); }
.sugg-add b { color: var(--ink); }

.form-actions {
  display: flex; align-items: center; gap: 8px;
  padding-top: 4px;
}
.form-actions .grow { flex: 1; }
.btn-link {
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: 13px;
  color: var(--grey-700);
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.btn-link:hover { color: var(--ink); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { background: oklch(0.97 0.025 25); }

/* Bookmark list */
.bookmark-list { list-style: none; margin: 0; padding: 0; }
.bookmark {
  position: relative;
  border-bottom: 1px solid var(--border-soft);
}
.bookmark:last-child { border-bottom: none; }
.bookmark-inner {
  display: flex; gap: 14px;
  padding: 12px 0;
  background: var(--bg, #fff);
  position: relative;
  z-index: 1;
  touch-action: pan-y;
}
.bookmark > .swipe-reveal {
  position: absolute;
  top: 0; bottom: 0;
  width: 100%;
  display: flex; align-items: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
.swipe-reveal-delete {
  right: 0;
  justify-content: flex-end;
  padding-right: 24px;
  background: #d33a3a;
}
.swipe-reveal-share {
  left: 0;
  justify-content: flex-start;
  padding-left: 24px;
  background: #2d7a4f;
}
.bookmark.swipe-left > .swipe-reveal-delete { opacity: 1; }
.bookmark.swipe-right > .swipe-reveal-share { opacity: 1; }
.bookmark.is-armed.swipe-left > .swipe-reveal-delete { background: #b32424; }
.bookmark.is-armed.swipe-right > .swipe-reveal-share { background: #205a3a; }

.favicon {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--grey-500);
  font-size: 9px; font-weight: 600;
  outline: 1px solid var(--border);
  overflow: hidden;
}
.favicon img {
  display: none;
  width: 16px; height: 16px;
  object-fit: contain;
}
.favicon.favicon-loaded { color: transparent; font-size: 0; }
.favicon.favicon-loaded img { display: block; }
.bookmark .body { flex: 1 1 0; min-width: 0; }
/* .bookmark .row {
  display: flex; align-items: baseline;
  gap: 10px; min-width: 0; flex-wrap: wrap;
} */
.bookmark .title {
  color: #3346a1;
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
  line-height: 1.35;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
.bookmark .title:hover {
  text-decoration: underline;
  text-decoration-color: rgba(51, 70, 161, 0.3);
  text-underline-offset: 3px;
}
.bookmark .domain {
  color: var(--grey-400);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  flex: 0 0 auto;
  font-weight: 400;
}
.bookmark .domain:hover { color: var(--grey-700); }
.bookmark .description {
  margin-top: 4px;
  color: var(--grey-500);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bookmark .meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 12.5px;
  color: var(--grey-500);
  line-height: 1.5;
  min-width: 0;
}
.dot { color: var(--grey-400); font-size: 11px; user-select: none; }
.bookmark .meta .date { color: var(--grey-500); font-variant-numeric: tabular-nums; }
.bookmark .badge {
  font-size: 11px;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.bookmark .badge-icon {
  display: inline-flex;
  align-items: center;
  color: var(--grey-400);
}
.bookmark .badge-icon svg { display: block; }
.bookmark .tag {
  color: #6b7a4a;
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}
.bookmark .tag:hover {
  color: #565B47;
  text-decoration: underline;
  text-decoration-color: rgba(107, 122, 74, 0.4);
  text-underline-offset: 2px;
}

/* Per-row action buttons (edit + share). Lives at the right edge of .meta.
   Hover-revealed on desktop, always visible on mobile. */
.bookmark-actions {
  margin-left: auto;
  display: none;
  gap: 2px;
  align-items: center;
}
.bookmark:hover .bookmark-actions { display: inline-flex; }
.bookmark .row-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--grey-500);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  line-height: 0;
}
.bookmark .row-btn:hover { color: var(--ink); background: var(--bg-soft); }
.bookmark .row-btn svg { display: block; }

/* Batch edit */
.batch-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  color: var(--grey-500);
  cursor: pointer;
  font-family: inherit;
}
.batch-toggle:hover { color: var(--ink); border-color: var(--grey-300); }
.batch-toggle.is-active { color: var(--ink); background: var(--bg-soft); border-color: var(--grey-300); }

.batch-checkbox { display: none; flex: 0 0 auto; padding-top: 2px; }
.batch-checkbox input { accent-color: var(--ink); cursor: pointer; }
.page.batch-mode .batch-checkbox { display: inline-block; }
.page.batch-mode .bookmark .bookmark-actions { display: none !important; }

.batch-toolbar[hidden], .batch-all-banner[hidden], .filters-bar[hidden], .filters-bar .pill[hidden] { display: none !important; }
.batch-toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin: 12px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tint);
  position: sticky; top: 0;
  z-index: 5;
}
.batch-toolbar .grow { flex: 1; }
.batch-toolbar select,
.batch-toolbar input[type="text"] {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit; font-size: 13px;
  padding: 0 8px;
  outline: none;
}
.batch-toolbar select:focus,
.batch-toolbar input[type="text"]:focus {
  border-color: var(--grey-300);
  box-shadow: 0 0 0 3px rgba(15,15,15,0.12);
}
.batch-toolbar input[type="text"] { min-width: 200px; }
.batch-master-wrap { padding: 0 4px 0 2px; }
.batch-count { font-size: 12.5px; color: var(--grey-500); font-variant-numeric: tabular-nums; }

.batch-all-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tint);
  font-size: 12.5px;
  color: var(--grey-700);
}
.batch-all-banner.is-on { background: oklch(0.97 0.025 80); border-color: oklch(0.92 0.04 80); }
.batch-all-banner button {
  background: none; border: none; cursor: pointer;
  color: var(--ink); font: inherit; font-size: 12.5px;
  text-decoration: underline;
  text-decoration-color: var(--grey-300);
  text-underline-offset: 3px;
  padding: 0;
}
.batch-all-banner button:hover { text-decoration-color: var(--ink); }

/* Edit dialog */
.edit-dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: min(560px, calc(100% - 32px));
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(15,15,15,0.18), 0 2px 8px rgba(15,15,15,0.06);
  font-family: var(--font-sans);
}
.edit-dialog::backdrop {
  background: rgba(20, 20, 20, 0.32);
  backdrop-filter: blur(2px);
}
.edit-dialog .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.edit-dialog .modal-header h3 {
  margin: 0;
  font-size: 14px; font-weight: 600;
  color: var(--ink);
}
.edit-dialog .modal-close {
  background: transparent; border: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--grey-500);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.edit-dialog .modal-close:hover { background: var(--bg-soft); color: var(--ink); }
.edit-dialog .modal-body { padding: 16px 18px; }
.edit-dialog .modal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-tint);
}
.edit-dialog .modal-footer .grow { flex: 1; }

/* Import source picker */
.import-sources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.import-source {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}
.import-source:hover:not(.disabled) {
  border-color: var(--ink);
  background: var(--bg-tint);
}
.import-source .name { font-size: 13px; font-weight: 600; }
.import-source .hint { font-size: 11px; color: var(--grey-400); font-weight: 400; }
.import-source.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
@media (max-width: 480px) {
  .import-sources { grid-template-columns: 1fr; }
}

/* Numbered instructions (import + help) */
.import-steps {
  margin: 8px 0 14px;
  padding-left: 22px;
  color: var(--grey-700);
  font-size: 13px;
  line-height: 1.55;
}
.import-steps li { margin-bottom: 4px; }
.import-steps code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--ink-soft);
}
.import-steps a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* Help dialog body */
.help-body section + section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.help-body h4 {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 600;
  color: var(--grey-700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.help-body p {
  margin: 0 0 10px;
  color: var(--grey-700);
  font-size: 13px;
  line-height: 1.55;
}
.help-features {
  list-style: none;
  padding: 0;
  margin: 8px 0 4px;
  display: flex; flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--grey-700);
  line-height: 1.5;
}
.help-features li {
  padding-left: 14px;
  position: relative;
}
.help-features li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--grey-400);
  font-weight: 700;
}
.help-features code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--ink-soft);
}

/* Share button */
.share-btn {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--grey-500);
  position: relative;
  flex: 0 0 auto;
}
.share-btn:hover { color: var(--ink); background: var(--bg-soft); }
.share-btn[data-copied]::after {
  content: 'Copied';
  position: absolute;
  top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0;
}
.title-with-share {
  display: inline-flex; align-items: center;
  gap: 4px;
}

/* Empty state */
.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--grey-500);
  font-size: 14px;
}

/* Side panel (Tags) */
.side {
  display: flex; flex-direction: column;
  gap: 28px; padding-top: 4px; min-width: 0;
}
.side h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey-500);
  font-weight: 600;
  margin: 0 0 12px 0;
}
.tag-cloud {
  display: flex; flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.5;
}
.tag-cloud .group {
  display: flex; flex-wrap: wrap;
  gap: 2px 6px;
}
.tag-cloud a {
  color: var(--grey-700);
  text-decoration: none;
  white-space: nowrap;
}
.tag-cloud a:hover { color: var(--ink); }
.tag-cloud a.selected { color: var(--accent); font-weight: 500; }
.tag-cloud .char { font-weight: 700; color: var(--ink); }

/* Pagination */
.pagination {
  display: flex; align-items: center;
  gap: 20px; flex-wrap: wrap;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--grey-500);
}
.pager {
  display: flex; gap: 2px; align-items: center;
}
.pager a, .pager span {
  min-width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--grey-700);
  text-decoration: none;
  font-size: 12.5px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--bg-soft); color: var(--ink); }
.pager .current {
  background: var(--ink); color: var(--bg);
}
.pager .ellipsis { color: var(--grey-400); }
.pager .page-link { font-size: 12px; padding: 0 10px; }
.pager .disabled { color: var(--grey-300); cursor: default; }

.pagination-controls {
  display: flex; align-items: center;
  gap: 16px; margin-left: auto;
  font-size: 12.5px; color: var(--grey-700);
}
.pagination-controls label {
  display: inline-flex; align-items: center; gap: 6px;
}
.pagination-controls select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font: inherit; font-size: 12px;
  color: var(--ink); background: var(--bg);
  cursor: pointer; outline: none;
  font-family: inherit;
}
.pagination-controls select:focus {
  border-color: var(--grey-300);
  box-shadow: 0 0 0 3px rgba(15,15,15,0.12);
}

/* Auth pages */
.auth-shell {
  max-width: 360px;
  margin: 80px auto;
  padding: 0 24px;
  text-align: center;
}
.auth-shell h1 {
  font-size: 28px; font-weight: 600;
  margin: 0 0 24px;
}
.auth-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--bg-tint);
}
.auth-shell .lede {
  color: var(--grey-500);
  font-size: 13px;
  margin: 0 0 16px;
}

.welcome-shell {
  max-width: 560px;
  margin: 48px auto;
  padding: 0 24px;
}
.welcome-shell h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; }
.welcome-shell .lede { color: var(--grey-500); font-size: 14px; margin: 0 0 24px; }
.welcome-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 0 0 24px;
}
.welcome-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  background: var(--bg-tint);
  display: flex; flex-direction: column; gap: 10px;
}
.welcome-card-icon { font-size: 22px; line-height: 1; }
.welcome-card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.welcome-card .hint { margin: 0; font-size: 12px; color: var(--grey-500); line-height: 1.5; }
.welcome-card-btn { align-self: flex-start; }
.welcome-card-btn-row { display: flex; align-items: center; gap: 6px; }
.welcome-copy-btn { position: relative; color: var(--grey-500); }
.welcome-copy-btn:hover { color: var(--ink); }
.welcome-copy-btn[data-copied]::after {
  content: 'Link copied!';
  position: absolute;
  top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
@media (max-width: 480px) {
  .welcome-cards { grid-template-columns: 1fr; }
}

.welcome-privacy {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.welcome-privacy h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.welcome-privacy .hint { margin: 0 0 12px; font-size: 12px; color: var(--grey-500); }
.welcome-radio-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.welcome-radio {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; background: var(--bg);
  font-size: 13px;
}
.welcome-radio:has(input:checked) { border-color: var(--ink); background: var(--bg-tint); }
.welcome-radio input { margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.welcome-radio-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.welcome-radio-text strong { font-weight: 600; color: var(--ink); }
.welcome-radio-text small { color: var(--grey-500); font-size: 11px; line-height: 1.3; }

@media (max-width: 480px) {
  .welcome-radio-row { grid-template-columns: 1fr; }
}

.privacy-section { margin: 0 0 20px; }
.privacy-section h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.privacy-section p { margin: 0 0 8px; font-size: 13px; color: var(--grey-700); }
.privacy-section ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--grey-700); }
.privacy-section li { margin: 0 0 4px; }
.privacy-section a { text-decoration: underline; }
.privacy-section code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* New bookmark page */
.new-bookmark-shell {
  max-width: 560px;
  margin: 40px auto;
  padding: 0 24px 40px;
}
.new-bookmark-shell h1 {
  font-size: 20px; font-weight: 600;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}
@media (max-width: 600px) {
  .new-bookmark-shell { margin: 20px auto; padding: 0 16px 32px; }
}

/* Home / landing */
.home-shell { max-width: 560px; margin: 56px auto 48px; padding: 0 24px; }
.home-hero { text-align: center; max-width: 380px; margin: 0 auto 40px; }
.home-hero h1 { font-size: 28px; font-weight: 600; margin: 0 0 6px; }
.home-hero .lede { color: var(--grey-500); font-size: 13px; margin: 0 0 16px; }
.home-hero .auth-card { padding: 20px; }
.home-section { margin: 0 0 20px; }
.home-section h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.home-section p { margin: 0 0 8px; font-size: 13px; color: var(--grey-700); }
.home-section ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--grey-700); }
.home-section li { margin: 0 0 4px; }
.home-section code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.home-foot { margin: 32px 0 0; text-align: center; font-size: 12px; color: var(--grey-500); }
.home-foot a { color: inherit; text-decoration: underline; }
.dot-sep { display: inline-block; margin: 0 8px; width: 2px; height: 2px; border-radius: 50%; background: var(--grey-300); vertical-align: middle; }

.flash {
  padding: 10px 16px;
  background: var(--bg-tint);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--grey-700);
  text-align: center;
}

/* Mobile */
@media (max-width: 720px) {
  .app-header-inner { padding: 12px 16px; }
  .page {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px 24px;
    gap: 24px;
  }
  .side { order: 2; padding-top: 0; border-top: 1px solid var(--border); padding-top: 20px; }
  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .section-header h1 { font-size: 20px; }
  .search { width: 100%; }
  .header-controls { gap: 6px; }
  .app-nav .nav-text { display: none; }
  .app-nav .btn-primary { padding: 6px 10px; font-size: 12px; }
  .app-nav .btn-primary span { font-size: 0; }
  .app-nav .btn-primary span::before { content: "Import"; font-size: 12px; }
  .bookmark .title { white-space: normal; }
  .bookmark-actions { display: inline-flex; }
  .page.batch-mode .bookmark .bookmark-actions { display: none !important; }
  .batch-toolbar input[type="text"] { min-width: 0; flex: 1 1 100%; }
  .pagination { gap: 12px; }
  .pagination-controls { margin-left: 0; }
}
