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

:root {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --surface2: #222;
  --border: #3a3a3a;
  --primary: #4a9eff;
  --primary-hover: #3a8eef;
  --danger: #dc3545;
  --danger-hover: #c82333;
  --text: #e0e0e0;
  --text-muted: #999;
  --text-dim: #ccc;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Login */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.login-error {
  background: rgba(220,53,69,0.15);
  border: 1px solid rgba(220,53,69,0.35);
  color: #ff6b6b;
  border-radius: 5px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.visible { display: block; }

/* Admin Layout */
.admin-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-header-left { display: flex; align-items: center; gap: 0.75rem; }
.site-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.site-title:hover { color: var(--primary); }
.admin-badge {
  font-size: 0.7rem;
  background: var(--primary);
  color: #fff;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-weight: 500;
}
.admin-header-right { display: flex; gap: 0.5rem; }

.admin-content {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Post List */
.posts-list { }
.post-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.post-item:last-child { border-bottom: none; }
.post-item:hover { background: rgba(255,255,255,0.02); }

.post-item-info { flex: 1; min-width: 0; }
.post-item-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.status-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.status-badge.published { background: rgba(74,158,255,0.15); color: var(--primary); }
.status-badge.draft { background: rgba(255,255,255,0.07); color: var(--text-muted); }

.post-item-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.empty-posts {
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Editor Panel */
.editor-panel { margin-top: 1rem; }
.editor-actions { display: flex; gap: 0.5rem; }

.editor-form { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hint {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #666;
}
input[type="text"],
input[type="password"],
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 80px; }

/* Status Toggle */
.status-group { flex-direction: row; align-items: center; }
.status-group label { margin-bottom: 0; }
.status-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.status-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.status-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Editor toolbar */
.editor-group { flex: 1; }
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.content-editor {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  min-height: 340px;
}
.post-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1rem;
  min-height: 340px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-dim);
  overflow-y: auto;
}
.post-preview h1, .post-preview h2, .post-preview h3,
.post-preview h4, .post-preview h5, .post-preview h6 {
  color: var(--text);
  margin: 1.4em 0 0.4em;
  font-weight: 600;
}
.post-preview p { margin-bottom: 0.8em; }
.post-preview code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: monospace;
  color: #e06c75;
}
.post-preview pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 0.8em;
}
.post-preview pre code { background: none; border: none; color: var(--text-dim); }
.post-preview blockquote {
  border-left: 3px solid var(--primary);
  margin: 1em 0;
  padding: 0.4em 0.8em;
  color: var(--text-muted);
}
.post-preview ul, .post-preview ol { margin-bottom: 0.8em; padding-left: 1.4em; }
.post-preview a { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: #555; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.65rem; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
  width: 100%;
  max-width: 400px;
}
.modal-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.modal-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}
.modal-error {
  background: rgba(220,53,69,0.15);
  border: 1px solid rgba(220,53,69,0.35);
  color: #ff6b6b;
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
  display: none;
}
.modal-error.visible { display: block; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.modal-card .form-group { margin-bottom: 0.75rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.7rem 1.1rem;
  font-size: 0.875rem;
  z-index: 300;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(220,53,69,0.5); color: #ff6b6b; }

@media (max-width: 600px) {
  .admin-content { padding: 1rem; }
  .status-group { flex-direction: column; align-items: flex-start; }
}
