*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --bg-2: #1a1a1a;
  --bg-3: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --font: 'Inter', -apple-system, sans-serif;
  --sidebar-w: 220px;
  --radius: 8px;
}

body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Sidebar ─── */

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
}

.logo-text {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  font-size: 13.5px;
}

.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); }
.nav-item.active svg { stroke: var(--accent); }

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }

/* ─── Main content ─── */

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  max-width: 900px;
}

.tab { display: none; }
.tab.active { display: block; }

/* ─── Page header ─── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.date {
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Dashboard ─── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.dashboard-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.section { margin-bottom: 32px; }

.section-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Tool grid ─── */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.tool-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.tool-card:hover { border-color: var(--accent); background: var(--bg-3); }

.tool-card a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  display: block;
}

.tool-card a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.tool-category {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-3);
  border-radius: 4px;
  padding: 2px 6px;
  width: fit-content;
}

.tool-actions {
  display: flex;
  gap: 6px;
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}

.tool-card:hover .tool-actions { opacity: 1; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
  line-height: 0;
  position: relative;
  z-index: 1;
  transition: color 0.15s;
}

.icon-btn:hover { color: var(--text); }
.icon-btn.pinned { color: var(--accent); }

/* ─── Link cards ─── */

.link-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  transition: border-color 0.15s;
}

.link-card:hover { border-color: var(--accent); }

.link-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.link-body { flex: 1; min-width: 0; }

.link-title {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-title::after {
  content: '';
  position: absolute;
  inset: 0;
}

.link-url {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.link-memo {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.link-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.tag {
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-muted);
}

.link-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  position: relative;
  z-index: 1;
}

.link-card:hover .link-actions { opacity: 1; }

/* ─── Search bar ─── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 20px;
  color: var(--text-muted);
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ─── Buttons ─── */

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13.5px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--bg-2); }

/* ─── Modal ─── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  place-items: center;
}

.modal-overlay.open { display: grid; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}

.modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group select option { background: var(--bg-3); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ─── Empty state ─── */

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
  grid-column: 1 / -1;
}

/* ─── Project grid ─── */

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.view-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--bg-3); color: var(--text); }

.project-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.project-list-row {
  display: grid;
  grid-template-columns: 72px minmax(160px, 1.2fr) minmax(180px, 2fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.project-list-row:last-child { border-bottom: none; }
.project-list-row:hover { background: var(--bg-3); }

.plist-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.plist-main .project-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plist-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.plist-links {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.plist-date {
  white-space: nowrap;
  flex-shrink: 0;
}

.project-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-bar--inline {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

.filter-chips {
  display: flex;
  gap: 6px;
}

.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover { color: var(--text); background: var(--bg-3); }
.chip.active { background: var(--accent); border-color: var(--accent); color: white; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.project-card:hover { border-color: var(--accent); background: var(--bg-3); }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.project-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proj-stack {
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text-muted);
  white-space: nowrap;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  border-radius: 20px;
  padding: 2px 8px;
  font-weight: 500;
  white-space: nowrap;
}

.status--active { background: rgba(34,197,94,0.15); color: #4ade80; }
.status--paused { background: rgba(234,179,8,0.15); color: #facc15; }
.status--done   { background: rgba(156,163,175,0.12); color: #9ca3af; }

.project-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.project-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.proj-links {
  display: flex;
  gap: 8px;
}

.proj-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  transition: color 0.15s, border-color 0.15s;
}

.proj-link:hover { color: var(--text); border-color: var(--accent); }
.proj-link--live:hover { color: #4ade80; border-color: #4ade80; }

.project-date {
  font-size: 11px;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── Link list (dashboard) ─── */

.link-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.15s;
}

.link-row:hover { border-color: var(--accent); }
