:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --danger: #d64545;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden; /* a very long unbroken URL must never widen the page */
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.topbar .locale-form { margin-inline-start: auto; }
.topbar select { padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid var(--border); }

.app-shell { display: flex; min-height: calc(100vh - 53px); }
.sidenav {
  width: 200px;
  flex-shrink: 0;
  padding: 1rem 0.5rem;
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidenav a {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
}
.sidenav a:hover { background: var(--border); text-decoration: none; }

main.content { flex: 1; min-width: 0; padding: 1.5rem; max-width: 960px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.item-card { display: flex; gap: 0.85rem; max-width: 100%; }
.item-card img.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--border); flex-shrink: 0; }
.item-card .item-body { flex: 1; min-width: 0; } /* min-width:0 is what lets a flex child actually shrink below its content size, so the ellipsis rules on .url-line below can take effect instead of the card stretching wider than its column */
.item-card .meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.item-card .title { font-weight: 600; color: var(--text); }
.item-card .description { color: var(--text-muted); font-size: 0.85rem; margin: 0.35rem 0 0; overflow-wrap: anywhere; }
.item-card .actions-row { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.85rem; }
.item-card .actions-row button, .item-card .actions-row a { background: none; border: none; padding: 0; cursor: pointer; color: var(--text-muted); font: inherit; }
.item-card .actions-row button:hover, .item-card .actions-row a:hover { color: var(--accent); }
.badge { display: inline-block; font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--border); color: var(--text-muted); margin-inline-end: 0.35rem; white-space: nowrap; }
.collection-badge { display: inline-flex; align-items: center; gap: 0.2rem; }
.collection-badge button { font-size: 0.9rem; line-height: 1; padding: 0 0.1rem; }
.item-card select { font-size: 0.82rem; padding: 0.2rem 0.4rem; border-radius: 6px; border: 1px solid var(--border); max-width: 12rem; }

.quick-save-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.quick-save-form .field { margin-bottom: 0; flex: 1 1 220px; }

/* Wherever a URL (or any single unbroken piece of text -- a title, a
   domain) needs to fit in a card's width instead of forcing the page to
   scroll sideways: one line, ellipsis, never wider than its container. */
.url-line {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters a, .filters span { padding: 0.3rem 0.7rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; }
.filters a.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

form.inline { display: inline; }

.search-bar { margin-bottom: 1rem; }
.search-bar input[type="search"] { width: 100%; padding: 0.6rem 0.9rem; border-radius: 999px; border: 1px solid var(--border); font-size: 0.95rem; }

.auth-shell { max-width: 380px; margin: 4rem auto; padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.auth-shell h1 { font-size: 1.4rem; margin-top: 0; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
button.primary, input[type="submit"].primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}
button.secondary { background: var(--surface); border: 1px solid var(--border); padding: 0.55rem 1rem; border-radius: 8px; cursor: pointer; }
button.danger { color: var(--danger); }
.error-msg { color: var(--danger); font-size: 0.85rem; margin-bottom: 1rem; }
.muted { color: var(--text-muted); }
.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 1rem; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: start; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.action-list-group { margin-bottom: 1.5rem; }
.action-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.action-item.completed .title { text-decoration: line-through; color: var(--text-muted); }
.action-item .due { margin-inline-start: auto; font-size: 0.8rem; color: var(--text-muted); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.plan-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }
.plan-card.active { border-color: var(--accent); }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidenav { width: 100%; flex-direction: row; overflow-x: auto; border-inline-end: none; border-bottom: 1px solid var(--border); }
  main.content { padding: 1rem; }
}
