/* ─── Auth Gate ─── */
#authGate {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: var(--text-sm);
}

/* ─── Login ─── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem var(--gutter); }
.login-card { width: 100%; max-width: 360px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.login-logo img { width: 40px; height: 40px; border-radius: 9px; }
.login-card h1 { text-align: center; margin-bottom: 0.25rem; font-size: var(--text-2xl); font-weight: 500; letter-spacing: -0.02em; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: var(--text-sm); margin-bottom: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-form .btn-primary { width: 100%; height: 40px; margin-top: 0.25rem; }

/* ─── Admin Container ─── */
.admin-wrap { max-width: var(--max-w-wide); margin: 0 auto; padding: 2rem var(--gutter) 3rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; }
.admin-header h1 { font-size: var(--text-2xl); font-weight: 500; letter-spacing: -0.02em; }
.admin-header-actions { display: flex; gap: 0.5rem; }

/* ─── Filter ─── */
.filter-bar { margin-bottom: 1rem; }
.filter-bar input {
  width: 100%; height: 36px; padding: 0 0.875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-sm); font-family: var(--sans);
  background: var(--surface-alt); color: var(--text);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.filter-bar input::placeholder { color: var(--text-muted); }
.filter-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-muted); background: var(--surface); }

/* ─── Table ─── */
.articles-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.articles-table th, .articles-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.articles-table th {
  background: var(--surface-alt); font-weight: 500; font-size: var(--text-xs);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.articles-table td { font-size: var(--text-sm); }
.articles-table tr:last-child td { border-bottom: none; }
.articles-table tr:hover td { background: var(--surface-alt); }
.articles-table td a { color: var(--text); font-weight: 500; }
.articles-table td a:hover { color: var(--accent); }

/* ─── Status Badge ─── */
.status-badge {
  display: inline-flex; padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full); font-size: var(--text-xs);
  font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase;
}
.status-published { background: var(--success-bg); color: var(--success); }
.status-draft { background: var(--warning-bg); color: var(--warning); }
.actions { display: flex; gap: 0.375rem; }

/* ─── Editor ─── */
.editor-wrap { max-width: var(--max-w-wide); margin: 0 auto; padding: 1.5rem var(--gutter) 3rem; }
.editor-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; }
.editor-top .back-link { color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; display: inline-flex; align-items: center; gap: 0.25rem; }
.editor-top .back-link:hover { color: var(--accent); }
.editor-actions { display: flex; gap: 0.375rem; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 1rem; }

.preview-pane {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; overflow-y: auto; max-height: 80vh;
  background: var(--surface); position: sticky; top: calc(var(--header-h) + 1rem);
}
.preview-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: 0.75rem; }

/* ─── EasyMDE ─── */
.easymd-editor .EasyMDEContainer { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.easymd-editor .CodeMirror { background: var(--surface); color: var(--text); border: none; font-family: var(--mono); font-size: var(--text-sm); }
.easymd-editor .CodeMirror-focused { box-shadow: none; }
.easymd-editor .editor-toolbar { background: var(--surface-alt); border-bottom: 1px solid var(--border); border: none; }
.easymd-editor .editor-toolbar button { color: var(--text-secondary) !important; }
.easymd-editor .editor-toolbar button.active, .easymd-editor .editor-toolbar button:hover { background: var(--accent-muted) !important; color: var(--text) !important; }
.easymd-editor .editor-preview, .easymd-editor .editor-preview-side { background: var(--surface); color: var(--text); }
.easymd-editor .editor-preview-side { border-left: 1px solid var(--border); }
.easymd-editor .CodeMirror-scrollbar-filler, .easymd-editor .CodeMirror-gutter-filler { background: var(--surface); }

/* ─── Upload ─── */
.upload-area {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; cursor: pointer;
  transition: border-color 150ms var(--ease), background 150ms var(--ease); background: var(--surface);
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-muted); }
.upload-area p { color: var(--text-muted); font-size: var(--text-sm); }
.upload-area .upload-icon { display: block; margin: 0 auto 0.5rem; width: 24px; height: 24px; color: var(--text-muted); }
.upload-area input[type="file"] { display: none; }
.upload-preview { max-height: 120px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 0.75rem; border: 1px solid var(--border); }

@media (max-width: 768px) {
  .editor-grid { grid-template-columns: 1fr; }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .preview-pane { position: static; max-height: none; }
}

@media (max-width: 640px) {
  .admin-wrap { padding-top: 1.25rem; }
  .admin-header { margin-bottom: 1rem; }
  .admin-header-actions { width: 100%; }
  .admin-header-actions .btn { width: 100%; }
  .editor-top { align-items: stretch; }
  .editor-actions { flex-wrap: wrap; }
  .editor-actions .btn { flex: 1 1 calc(50% - 0.25rem); }
  .articles-table thead { display: none; }
  .articles-table,
  .articles-table tbody,
  .articles-table tr,
  .articles-table td {
    display: block;
    width: 100%;
  }
  .articles-table {
    border: none;
    background: transparent;
  }
  .articles-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 0.75rem;
    overflow: hidden;
  }
  .articles-table td {
    border-bottom: 1px solid var(--border-light);
    padding: 0.625rem 0.875rem;
  }
  .articles-table td:last-child { border-bottom: none; }
  .articles-table td::before {
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
  }
  .actions { flex-wrap: wrap; }
}