/* ============================================================================
   Trawler design system
   A small, hand-rolled token + component system. No framework, no build step —
   just CSS custom properties as the source of truth, then components on top.
   Aesthetic: quiet slate canvas, editorial serif display, calm — with one
   reserved pop of tennis-ball green on the primary action (the tail wag).
   ========================================================================== */

/* --- Tokens ---------------------------------------------------------------- */
:root {
  /* color */
  --paper:       #f5f6f7;
  --paper-2:     #edeef1;
  --ink:         #23262b;
  --muted:       #5d616a;
  --faint:       #989ca3;
  --line:        #e5e7ea;
  --line-strong: #d5d8dd;
  --accent:      #5c6b7d;   /* quiet slate */
  --accent-deep: #475260;
  --accent-soft: #e6e9ed;
  --accent-tint: #f2f4f6;
  --card:        #ffffff;
  --spark:       #c6dd1c;   /* soggy tennis ball — the only loud color, Save only */
  --spark-deep:  #b2c810;
  --danger:      #8a2f1c;
  --danger-soft: #f6e0db;

  /* type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 30px;

  /* space (8px rhythm) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* radius / elevation / motion */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(35, 38, 43, 0.06), 0 1px 2px rgba(35, 38, 43, 0.04);
  --shadow-md: 0 4px 12px rgba(35, 38, 43, 0.08), 0 1px 3px rgba(35, 38, 43, 0.05);
  --shadow-lg: 0 12px 32px rgba(35, 38, 43, 0.12), 0 2px 6px rgba(35, 38, 43, 0.06);
  --ring: 0 0 0 3px rgba(178, 200, 16, 0.40);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur: 160ms;
  --dur-slow: 240ms;

  /* controls — one source of truth so every button/input is the same height */
  --control-h:  40px;
  --control-px: 15px;
  --control-fz: 14px;
}

/* Every interactive control shares one height, padding, radius, and border. */
.btn,
.quick-add input[type="url"],
.form-card input[type="url"],
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"] {
  height: var(--control-h);
  padding: 0 var(--control-px);
  font-size: var(--control-fz);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  line-height: 1;
}

/* --- Animations ------------------------------------------------------------ */
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(6px); }
}
@keyframes bookmark-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes surfaced-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%) fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: var(--s-7) var(--s-5) var(--s-8);
}

main {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  animation: page-in var(--dur-slow) var(--ease) both;
}

a { color: var(--accent); }

h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
h2 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  font-weight: 600;
  margin: var(--s-6) 0 var(--s-3);
}

:focus-visible { outline: none; box-shadow: var(--ring); }

/* --- Layout: masthead ------------------------------------------------------ */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding-bottom: var(--s-6);
  margin-bottom: var(--s-3);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: var(--s-3); align-items: center; }
.tagline { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.45; max-width: 36ch; }
.masthead-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.masthead-actions form { margin: 0; }

/* --- Components: buttons ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

/* button_to renders <form class="button_to"><button>; keep the form from
   adding height or breaking row alignment. */
.button_to { display: inline-flex; margin: 0; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--spark);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.btn-primary:hover { background: var(--spark-deep); box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--card); color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
/* Compact control for dense, inline contexts (e.g. the bookmark edit form). */
.btn-sm { height: 30px; padding: 0 11px; font-size: var(--text-xs); border-radius: var(--r-sm); }

/* --- Components: flash / toast ---------------------------------------------- */
#flash {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.flash {
  pointer-events: auto;
  background: var(--ink);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  animation: toast-in 260ms var(--ease) both;
  letter-spacing: 0.01em;
}
.flash--out { animation: toast-out 200ms var(--ease) both; }
.flash-error { background: var(--danger); }

@media (max-width: 560px) {
  #flash { bottom: var(--s-4); right: var(--s-4); left: var(--s-4); }
  .flash { max-width: 100%; }
}

/* --- Components: resurfaced chips -------------------------------------------*/
.surfaced {
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-5);
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: var(--r-lg);
  animation: surfaced-in var(--dur-slow) var(--ease) both;
}
.surfaced h2 { margin: 0 0 var(--s-3); }

.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip-pill {
  display: inline-flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 6px 5px 13px;
  gap: 3px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.chip-pill:hover {
  border-color: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.chip-pill a {
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.chip-pill:hover a { color: var(--accent-deep); }
.btn-chip-dismiss {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  font-family: inherit;
  opacity: 0;
  transition: color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.chip-pill:hover .btn-chip-dismiss { opacity: 1; }
.btn-chip-dismiss:hover { color: var(--danger); }

/* --- Components: tag filter ------------------------------------------------- */
.tag-filter { margin-top: var(--s-5); }

.tag-filter-wrap { position: relative; display: inline-block; }

.tag-filter-input {
  height: var(--control-h);
  padding: 0 var(--control-px);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  outline: none;
  width: 220px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tag-filter-input::placeholder { color: var(--faint); }
.tag-filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tag-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 100;
}
.tag-dropdown-item {
  display: block;
  padding: 9px var(--control-px);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tag-dropdown-item:hover,
.tag-dropdown-item.focused {
  background: var(--accent-tint);
  color: var(--accent-deep);
}

.tag-token {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--s-3) 0 var(--s-4);
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
}
.tag-token-label { font-weight: 500; }
.tag-token-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tag-token-clear:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* --- Components: lens strip (primary nav, always visible) ------------------- */
.lenses {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.lens {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lens:hover { background: var(--accent-tint); color: var(--accent-deep); }
.lens.is-active { background: var(--accent-soft); color: var(--ink); }
.lens-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
}
.lens.is-active .lens-count { color: var(--accent-deep); }
.lenses-spacer { flex: 1; min-width: var(--s-3); }
.lenses .tag-filter { margin-top: 0; }

/* The list sits under the lens strip with a calm, deliberate gap. */
.list { margin-top: var(--s-5); }

/* Resurfaced lens intro — makes the core feature prominent and explains it. */
.resurfaced-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: var(--r-lg);
}
.resurfaced-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.resurfaced-intro p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }
.resurfaced-intro .btn { flex-shrink: 0; }

.enrichment-banner {
  pointer-events: auto;
  background: var(--ink);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  letter-spacing: 0.01em;
}

/* --- Components: bulk action bar (multi-select) ----------------------------- */
.bulk-form { display: none; }
.bulk-bar {
  position: sticky;
  top: var(--s-2);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-4);
  padding: var(--s-2) var(--s-3);
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in 180ms var(--ease) both;
}
/* `display: flex` above overrides the [hidden] attribute, so restore it: the
   bar must stay hidden until rows are actually selected. */
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.bulk-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.bulk-act {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 11px;
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.bulk-act:hover { background: rgba(255, 255, 255, 0.22); }
.bulk-danger:hover { background: var(--danger); }
.bulk-tag { display: inline-flex; gap: 4px; }
.bulk-tag-input {
  width: 110px;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: var(--text-xs);
  font-family: inherit;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  outline: none;
}
.bulk-tag-input::placeholder { color: rgba(255, 255, 255, 0.6); }
.bulk-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--text-xs);
  font-family: inherit;
  cursor: pointer;
  padding: 6px;
}
.bulk-clear:hover { color: #fff; }

/* --- Components: the pile --------------------------------------------------- */
.empty {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-style: italic;
  text-align: center;
  padding: var(--s-8) var(--s-4);
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  line-height: 1.6;
}

.bm-list { list-style: none; padding: 0; margin: 0; }
.bm {
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.bm:last-child { border-bottom: none; }
.bm:hover { position: relative; z-index: 1; background: var(--card); box-shadow: var(--shadow-md); }
.bm--new { animation: bookmark-enter 280ms var(--ease) both; }

/* Read view: [select] [favicon] [body] [aside] — one dense grid line. */
.bm-read {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-3);
  margin: 0 calc(var(--s-3) * -1);
  /* Hold a consistent height so rows without a summary/tags (e.g. a just-saved
     link still summarizing) don't look stubby next to two-line rows. */
  min-height: 72px;
}

.bm-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.bm:hover .bm-check,
.bm-check:checked,
.bm-check:focus-visible { opacity: 1; }

.bm-favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--paper-2);
  overflow: hidden;
}
.bm-favicon img { width: 16px; height: 16px; display: block; }

.bm-body { min-width: 0; }
.bm-line1 { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.bm-title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease);
}
.bm-title:hover { color: var(--accent); }
/* Source + saved-date sit together as quiet metadata right after the title. */
.bm-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
}
.bm-meta time { color: inherit; }
.bm-dot { opacity: 0.5; }
.bm-host { white-space: nowrap; }
.bm-line2 {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-top: 2px;
  min-width: 0;
  overflow: hidden;
}
.bm-summary {
  min-width: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-decoration: none;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.bm-tag:hover { background: var(--accent); color: #fff; }

.bm-aside { display: flex; align-items: center; gap: var(--s-3); flex-shrink: 0; }
.bm-aside time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
  white-space: nowrap;
}
.bm-actions { display: flex; align-items: center; gap: var(--s-1); }
.bm-act {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--r-sm);
  opacity: 0;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.bm:hover .bm-act,
.bm-act:focus-visible { opacity: 1; }
.bm-act:hover { color: var(--accent); background: var(--accent-tint); }
.bm-act-danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Enrichment status — the visible AI machinery, top-right of the row. */
.bm-status {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
}
button.bm-status { cursor: pointer; }
.bm-status--pending { color: var(--faint); }
.bm-status--pending::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--spark);          /* the green spark, earned by "live" work */
  vertical-align: middle;
  animation: pulse 1.2s var(--ease) infinite;
}
.bm-status--failed { color: var(--danger); }
.bm-status--failed:hover { text-decoration: underline; }
/* "summarize" — an optional offer to run the AI on a link with no summary yet.
   It's not urgent, so it reveals on hover like the edit/delete actions rather
   than shouting on every row. (In progress + failure states stay visible.) */
.bm-status--todo {
  color: var(--faint);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}
.bm:hover .bm-status--todo,
.bm-status--todo:focus-visible { opacity: 1; }
.bm-status--todo:hover { color: var(--accent); text-decoration: underline; }

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* --- Components: bookmark edit form ---------------------------------------- */
.bm-edit { padding: var(--s-4) var(--s-3); }
.bm-form { display: flex; flex-direction: column; gap: var(--s-3); }
.bm-field { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: var(--s-3); margin: 0; }
.bm-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--faint);
  text-align: right;
}
.bm-field input,
.bm-field textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.bm-field textarea { resize: vertical; line-height: 1.5; }
.bm-field input:focus,
.bm-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.bm-form-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.bm-form-spacer { flex: 1; min-width: var(--s-3); }
/* Re-enrich lives below the save row, clearly labelled as the AI re-run. */
.bm-edit-extra {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}
.bm-edit-hint { flex: 1; font-size: var(--text-xs); color: var(--faint); }

/* Undo toast — the safety net for immediate delete. */
.flash-undo { display: flex; align-items: center; gap: var(--s-3); }
.flash-undo-btn {
  background: var(--spark);
  color: var(--ink);
  border: none;
  border-radius: var(--r-sm);
  padding: 4px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.flash-undo-btn:hover { background: var(--spark-deep); }

/* --- Components: form card -------------------------------------------------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-top: var(--s-5);
  box-shadow: var(--shadow-md);
}
.form-card p { margin-top: 0; color: var(--muted); line-height: 1.6; }
/* Stack multiple cards (e.g. Import / Export) with consistent rhythm instead
   of per-view inline margins. */
.form-card + .form-card { margin-top: var(--s-4); }
.form-card-title { margin-top: 0; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.form-card label {
  display: block;
  margin-bottom: var(--s-5);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}
.form-card .hint { color: var(--faint); font-weight: 400; }
.form-card input[type="url"],
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"] {
  display: block;
  width: 100%;
  margin-top: var(--s-2);
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-card input::placeholder { color: var(--faint); }
.form-card input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.form-card input[type="submit"] { margin-top: var(--s-3); }

/* --- Components: overflow menu --------------------------------------------- */
.menu-wrap { position: relative; }
.menu-panel {
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  min-width: 196px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s-2) 0;
  z-index: 100;
}
.menu-panel:not([hidden]) { animation: menu-in 140ms var(--ease) both; }
.menu-panel a,
.menu-panel button {
  display: block;
  width: 100%;
  padding: 10px var(--s-4);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  letter-spacing: 0.01em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.menu-panel a:hover,
.menu-panel button:hover { background: var(--accent-tint); color: var(--accent-deep); }
.menu-panel .menu-divider { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.menu-panel .menu-danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu-panel .button_to { display: block; width: 100%; }

/* --- Components: auth pages ------------------------------------------------- */
.auth-card {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.auth-card .masthead {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
  justify-content: center;
}
.auth-card .form-card { margin-top: var(--s-5); box-shadow: var(--shadow-lg); }
.auth-footer {
  margin-top: var(--s-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}
.auth-footer a { color: var(--accent); }

/* --- Components: file upload ------------------------------------------------ */
.file-label {
  display: block;
  margin-bottom: var(--s-4);
  font-size: var(--text-sm);
  font-weight: 600;
}
.file-input {
  display: block;
  margin-top: var(--s-2);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* --- Components: pagination ------------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}
.pagination-info { color: var(--faint); font-size: var(--text-sm); }

/* --- Components: inline quick-add ------------------------------------------ */
.quick-add {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  margin-top: var(--s-5);
}
.quick-add input[type="url"] {
  flex: 1;
  min-width: 0;
  border-color: var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.quick-add input[type="url"]::placeholder { color: var(--faint); }
.quick-add input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-md);
}

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 560px) {
  body { padding: var(--s-5) var(--s-4) var(--s-7); }
  h1 { font-size: var(--text-lg); }

  .masthead { flex-direction: column; align-items: flex-start; }
  /* Action buttons span the row so they're easy to hit and read on a phone. */
  .masthead-actions { width: 100%; }
  .masthead-actions .menu-wrap { margin-left: auto; }

  /* One field, one action — stack so the Save target is full width. */
  .quick-add { flex-direction: column; align-items: stretch; }
  .quick-add .btn-primary { width: 100%; }

  .surfaced { padding: var(--s-3) var(--s-4); }

  /* The overflow menu shouldn't run off-screen on narrow viewports. */
  .menu-panel { min-width: 0; width: max-content; max-width: calc(100vw - var(--s-8)); }

  /* Edit form stacks: label sits above the field instead of beside it. */
  .bm-field { grid-template-columns: 1fr; gap: var(--s-1); }
  .bm-label { text-align: left; }

  /* Dense row tightens a little on phones, but keeps its breathing room.
     Drop the host (favicon already shows the source) so the title gets space;
     keep the saved date. */
  .bm-read { gap: var(--s-2); padding: var(--s-3) var(--s-2); margin: 0 calc(var(--s-2) * -1); }
  .bm-meta .bm-host,
  .bm-meta .bm-dot { display: none; }
}

/* On touch devices there's no hover, so controls that only appear on
   :hover (edit, chip dismiss, skipped-enrich) would be unreachable.
   Reveal them whenever the primary pointer can't hover. */
@media (hover: none) {
  .bm-act,
  .bm-check,
  .bm-status--todo,
  .btn-chip-dismiss { opacity: 1; }
}

/* --- Motion preferences ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, main { animation: none !important; transition: none !important; }
  .btn:active { transform: none; }
}
