/* ===== Design Tokens — Dark (default) ===== */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --bg-input: #0d1117;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --pill-bg: rgba(88, 166, 255, 0.1);
  --overlay: rgba(0, 0, 0, 0.6);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'Consolas', 'Courier New', monospace;
  --radius: 6px;
  --max-width: 1200px;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-card: #f6f8fa;
  --bg-hover: #eef1f5;
  --bg-input: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --yellow: #9a6700;
  --red: #cf222e;
  --purple: #8250df;
  --pill-bg: rgba(9, 105, 218, 0.08);
  --overlay: rgba(0, 0, 0, 0.3);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 32px;
}

.site-header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.site-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-row .admin-link {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.header-row .admin-link:hover {
  color: var(--text);
  border-color: var(--text-muted);
  text-decoration: none;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  transition: border-color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--text-muted);
}

/* ===== Filters ===== */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

.filters select:focus,
.filters input:focus {
  border-color: var(--accent);
}

.filters input {
  flex: 1;
  min-width: 200px;
}

/* ===== Cards Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.card-tagline {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}

/* ===== Status Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-active { color: var(--green); border-color: rgba(63, 185, 80, 0.3); }
.badge-active::before { background: var(--green); }

.badge-wip { color: var(--yellow); border-color: rgba(210, 153, 34, 0.3); }
.badge-wip::before { background: var(--yellow); }

.badge-archived { color: var(--text-muted); border-color: var(--border); }
.badge-archived::before { background: var(--text-muted); }

.badge-concept { color: var(--purple); border-color: rgba(188, 140, 255, 0.3); }
.badge-concept::before { background: var(--purple); }

/* ===== Tech Pills ===== */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 8px;
  background: var(--pill-bg);
  color: var(--accent);
  border-radius: 4px;
  white-space: nowrap;
}

/* ===== Type Label ===== */
.type-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== Card Footer ===== */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.card-date {
  font-size: 12px;
  color: var(--text-muted);
}

.featured-star {
  color: var(--yellow);
  font-size: 14px;
}

/* ===== Detail Page ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.back-link:hover { color: var(--accent); text-decoration: none; }

.detail {
  max-width: 800px;
}

.detail h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail .tagline {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 20px;
}

.detail-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.detail .description {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.highlights {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.highlights li {
  font-size: 14px;
  padding-left: 20px;
  position: relative;
}

.highlights li::before {
  content: '>';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}

.links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}

.link-btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 13px;
  color: var(--text-muted);
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ===== Admin Page ===== */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header h2 {
  font-size: 18px;
}

.login-box {
  max-width: 400px;
  margin: 80px auto;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 16px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}

.login-box input:focus {
  border-color: var(--accent);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--red);
  border-color: rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--red);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ===== Table ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tr:hover td {
  background: var(--bg-hover);
}

.actions {
  display: flex;
  gap: 6px;
}

/* ===== Form ===== */
.form-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.form-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

.form-modal h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"] {
  width: auto;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  animation: slideIn 0.2s ease-out;
}

.toast-success {
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid var(--green);
  color: var(--green);
}

.toast-error {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty p {
  font-size: 15px;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ===== Card Cover Image ===== */
.card-cover {
  width: calc(100% + 40px);
  margin: -20px -20px 0;
  height: 160px;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== Hero Stats ===== */
.hero-stats {
  display: flex;
  gap: 32px;
  padding: 20px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.hero-stat {
  text-align: center;
}

.hero-stat .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.hero-stat .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ===== Card Link Badges ===== */
.card-links {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.card-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.card-link-icon:hover {
  color: var(--accent);
  background: var(--pill-bg);
  text-decoration: none;
}

.card-link-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ===== Visibility Badge ===== */
.badge-private {
  color: var(--text-muted);
  border-color: var(--border);
  font-size: 11px;
}

.badge-private::before {
  content: none;
}

/* ===== Nav Links ===== */
.nav-links {
  display: flex;
  gap: 12px;
  margin-left: auto;
  align-items: center;
}

.nav-link {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.nav-link:hover {
  color: var(--text);
  border-color: var(--text-muted);
  text-decoration: none;
}

/* ===== Comments ===== */
.comments-section {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.comment-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.comment-form .comment-form-row {
  margin-bottom: 12px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: var(--accent);
}

.comment-form textarea {
  min-height: 80px;
  resize: vertical;
}

.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-name {
  font-weight: 600;
  font-size: 14px;
}

.comment-date {
  font-size: 12px;
  color: var(--text-muted);
}

.comment-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.comments-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* ===== Admin Tabs ===== */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.admin-tab {
  padding: 8px 16px;
  font-size: 14px;
  font-family: var(--font);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover {
  color: var(--text);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .admin-table { font-size: 13px; }
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) { display: none; }
  .hero-stats { gap: 16px; flex-wrap: wrap; justify-content: center; }
  .hero-stat .stat-value { font-size: 22px; }
  .comment-form .comment-form-row { flex-direction: column; }
  .nav-links { gap: 6px; }
}

@media (max-width: 480px) {
  .detail h1 { font-size: 22px; }
  .card { padding: 16px; }
}
