:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222636;
  --border: #2a2e3d;
  --text: #e4e6ef;
  --text-muted: #8b8fa3;
  --accent: #0a66c2;
  --accent-dim: #084e96;
  --ok: #2dd4bf;
  --warn: #e0a23a;
  --err: #ef4444;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.accent {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0 6px;
  font-weight: 800;
}

/* ---- header ---- */
header {
  background: linear-gradient(135deg, #141620 0%, #1a1d27 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.4rem 1.5rem;
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; }
.header-actions { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.li-status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }
.li-status a { color: var(--accent); text-decoration: none; }
.li-status a:hover { text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--text-muted); }

.ghost-btn {
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
  padding: 0.4rem 0.9rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--text); }

/* ---- main ---- */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-btn {
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
  padding: 0.4rem 1rem; border-radius: 20px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#search {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 0.45rem 0.9rem; border-radius: 8px; font-size: 0.85rem; min-width: 220px;
}
#search:focus { outline: none; border-color: var(--accent); }

/* ---- cards ---- */
.articles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.2rem; }
.article-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; transition: all 0.2s; display: flex; flex-direction: column; gap: 0.6rem;
}
.article-card:hover { border-color: var(--accent-dim); background: var(--surface-hover); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.category-badge {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0.2rem 0.5rem; border-radius: 4px; white-space: nowrap;
  background: rgba(10,102,194,0.15); color: #4f9be0;
}
.published-badge {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0.2rem 0.5rem; border-radius: 4px; background: rgba(45,212,191,0.15); color: var(--ok);
}
.source { font-size: 0.75rem; color: var(--text-muted); }
.article-card h3 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.article-card h3 a { color: var(--text); text-decoration: none; }
.article-card h3 a:hover { color: var(--accent); }
.summary {
  font-size: 0.85rem; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.date { font-size: 0.75rem; color: var(--text-muted); margin-top: auto; }
.share-btn {
  margin-top: 0.4rem; background: var(--accent); color: #fff; border: none;
  padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: all 0.2s;
}
.share-btn:hover { background: var(--accent-dim); }

.loading { grid-column: 1 / -1; text-align: center; padding: 3rem; color: var(--text-muted); }
#load-more-wrap { text-align: center; padding: 2rem; }
#load-more-btn {
  background: var(--surface); color: var(--accent); border: 1px solid var(--border);
  padding: 0.6rem 2rem; border-radius: 8px; cursor: pointer; font-size: 0.9rem;
}
#load-more-btn:hover { background: var(--accent); color: #fff; }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.8rem; width: 100%; max-width: 560px; position: relative; max-height: 90vh; overflow-y: auto;
}
.modal-wide { max-width: 720px; }
.modal-close {
  position: absolute; top: 1rem; right: 1.2rem; background: none; border: none; color: var(--text-muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.modal-article { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
.modal-article-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.modal-article-url { font-size: 0.78rem; color: var(--accent); text-decoration: none; word-break: break-all; }
.field-label, .preview-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; display: block; }
.preview-label { margin-top: 1rem; }
#m-comment {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.8rem; font-size: 0.9rem; font-family: inherit; resize: vertical;
}
#m-comment:focus { outline: none; border-color: var(--accent); }
.preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem;
  font-size: 0.85rem; color: var(--text); white-space: pre-wrap; word-break: break-word; font-family: inherit; min-height: 3rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }
.primary-btn {
  background: var(--accent); color: #fff; border: none; padding: 0.6rem 1.4rem;
  border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.primary-btn:hover { background: var(--accent-dim); }
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.modal-msg { margin-top: 1rem; font-size: 0.85rem; min-height: 1.2rem; }
.modal-msg.ok { color: var(--ok); }
.modal-msg.err { color: var(--err); }
.modal-msg a { color: var(--accent); }

/* ---- history ---- */
.history-list { display: flex; flex-direction: column; gap: 0.8rem; }
.history-row { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem 1rem; }
.history-main { display: flex; align-items: center; gap: 0.6rem; }
.history-title { font-weight: 600; font-size: 0.9rem; }
.history-comment { font-size: 0.83rem; color: var(--text-muted); margin-top: 0.3rem; }
.history-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.4rem; }
.history-meta a { color: var(--accent); text-decoration: none; }
.history-meta .err { color: var(--err); }
.status-pill {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 4px;
}
.status-pill.published { background: rgba(45,212,191,0.15); color: var(--ok); }
.status-pill.draft { background: rgba(139,143,163,0.15); color: var(--text-muted); }
.status-pill.failed { background: rgba(239,68,68,0.15); color: var(--err); }

/* ---- login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.4rem; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 0.9rem; text-align: center;
}
.login-card h1 { font-size: 1.5rem; }
.login-card .subtitle { margin-bottom: 0.5rem; }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 0.7rem 0.9rem; border-radius: 8px; font-size: 0.95rem;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  background: var(--accent); color: #fff; border: none; padding: 0.7rem; border-radius: 8px;
  cursor: pointer; font-size: 0.95rem; font-weight: 600; margin-top: 0.3rem;
}
.login-card button:hover { background: var(--accent-dim); }
.login-error { color: var(--err); font-size: 0.85rem; min-height: 1rem; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--ok); color: var(--text);
  padding: 0.8rem 1.4rem; border-radius: 8px; font-size: 0.88rem; z-index: 200;
}
.toast.err { border-color: var(--err); }

@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .articles-grid { grid-template-columns: 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
}
