:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --border: #2d3a4f;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  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;
}

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

a:hover {
  color: var(--accent-hover);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.logo img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.logo span {
  color: var(--accent);
}

.hero-profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.hero-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
  flex-shrink: 0;
}

.hero-profile-text h1 {
  margin-bottom: 0.35rem;
}

@media (max-width: 540px) {
  .hero-profile {
    flex-direction: column;
    text-align: center;
  }
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.hero {
  padding: 3.5rem 0 2rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 600px;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 0.5rem 0 1rem;
}

.feed-section {
  margin-bottom: 2.5rem;
}

.feed-header {
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.feed-header h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.feed-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.post-card-top {
  margin-bottom: 0.75rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.post-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.post-card .excerpt {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.badge.published {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.draft {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.badge-admin {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.badge-guest {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.post-detail {
  padding: 2.5rem 0 4rem;
  max-width: 760px;
}

.post-detail h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
  line-height: 1.25;
}

.post-detail .meta {
  color: var(--muted);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.empty-state,
.loading,
.error-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}

.error-state {
  color: var(--danger);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Admin */
.admin-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card,
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.admin-panel {
  max-width: 960px;
  margin: 2rem auto;
}

.auth-card h1,
.admin-panel h1 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.auth-card p,
.admin-panel .subtitle {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.hidden {
  display: none !important;
}

.api-config-bar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  font-size: 0.85rem;
}

.api-config-bar .container {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.api-config-bar input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
}

@media (max-width: 640px) {
  .admin-table {
    font-size: 0.85rem;
  }

  .table-actions {
    flex-direction: column;
  }
}
