:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #e1e6f2;
  --text: #111827;
  --text-muted: #5b667b;
  --border: rgba(55, 65, 81, 0.12);
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --danger: #ef4444;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #070b15;
  --surface: #0f172a;
  --surface-strong: #111827;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.16);
  --primary: #60a5fa;
  --primary-soft: #1e293b;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.14), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select {
  border: 1px solid var(--border);
  border-radius: 999px;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px 24px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.user-name {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.pill {
  padding: 0.9rem 1.25rem;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, background 0.15s ease;
}

.pill:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

.secondary {
  background: transparent;
}

main {
  margin-top: 24px;
  display: grid;
  gap: 24px;
}

.toolbar {
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}

.pill.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

.card-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.delete-btn {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}

.delete-btn:hover {
  background: var(--danger);
  color: white;
}

.bookmark-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: stretch;
}

.category-card {
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-header-actions {
  display: flex;
  gap: 8px;
}

.category-header h3 {
  margin: 0;
}

.link-list {
  display: grid;
  gap: 14px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-strong);
  color: inherit;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.link-card:hover {
  transform: translateY(-1px);
  border-color: var(--border);
}

.link-content {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.site-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #fff;
  object-fit: contain;
  border: 1px solid var(--border);
}

.site-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.site-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-url {
  color: var(--text-muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-cats span {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--text);
  font-size: 0.8rem;
}

.link-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}


.repo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}

.repo-button:hover {
  background: #1d4ed8;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 21, 0.55);
  padding: 20px;
}

.hidden {
  display: none;
}

.modal-panel {
  width: min(540px, 100%);
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-strong);
  font-size: 1.2rem;
  line-height: 1;
}

.bookmark-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}


@media (max-width: 640px) {
  .topbar,
  .toolbar {
    padding: 18px;
  }

  .brand {
    flex-wrap: wrap;
  }

  .controls {
    width: 100%;
    justify-content: stretch;
  }

  .controls button {
    width: 100%;
  }

  .link-card {
    flex-direction: column;
    align-items: stretch;
  }

  .link-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
