:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c2330;
  --muted: #67707f;
  --border: #d9dde5;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d23b3b;
  --shadow: 0 6px 24px rgba(20, 30, 50, 0.10);
  --radius: 12px;
  --gap: 16px;
}

:root[data-theme="dark"] {
  --bg: #12151c;
  --surface: #1b2029;
  --surface-2: #232a35;
  --text: #e7ecf3;
  --muted: #9aa4b3;
  --border: #2c333f;
  --accent: #5b8cff;
  --accent-text: #0d1017;
  --danger: #ff6b6b;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.brand { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.msg { min-height: 1.2em; color: var(--muted); margin: 8px 0 0; }
.version { color: var(--muted); font-size: 0.8rem; margin-left: 8px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
}
button:disabled { opacity: 0.55; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.ghost { background: transparent; }
.danger { background: var(--danger); color: #fff; border-color: transparent; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

input[type="email"], input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* Public auth page */
.public {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-card { width: min(420px, 100%); }
.auth-form { display: grid; gap: 10px; margin-top: 18px; }
.auth-form label { font-size: 0.85rem; color: var(--muted); }
.dev-link { margin-top: 12px; font-size: 0.9rem; }

/* Authenticated shell */
.app { max-width: 860px; margin: 0 auto; padding: 20px; }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-toggle { display: inline-flex; gap: 4px; }

.add-panel { display: grid; gap: 10px; margin-bottom: 18px; }
.add-form { display: flex; gap: 8px; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone.active { border-color: var(--accent); background: var(--surface); color: var(--text); }

/* Bookmarks — list and card presentations share one row markup */
.bookmarks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bookmarks.as-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bookmark {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.bookmarks.as-cards .bookmark { flex-direction: column; align-items: stretch; }
.bookmark .grip { color: var(--muted); cursor: grab; display: inline-flex; }
.bookmark .link { text-decoration: none; color: var(--text); flex: 1; min-width: 0; display: grid; }
.link-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-url { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 4px; }
.row-actions button { padding: 6px 8px; display: inline-flex; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 32px; }

/* Confirmation modal — fixed frame, content scrolls inside (§2.13) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: min(380px, 100%);
  padding: 22px;
}
.modal h2 { margin: 0 0 8px; font-size: 1.1rem; }
.modal-body { margin: 0 0 18px; color: var(--muted); max-height: 40vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

[hidden] { display: none !important; }

/* The build version is minimized on small screens (§1.8) — the header stays
   uncluttered on phones while remaining available via /healthz and /api/version. */
@media (max-width: 600px) {
  .version { display: none; }
}
