:root {
  --red: #e63946;
  --dark: #1d1d1d;
  --gold: #ffd700;
  --bg: #f0f0f0;
  --bg2: #fff;
  --text: #1d1d1d;
  --text2: #666;
  --border: #ddd;
  --green: #2a9d8f;
}

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

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

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--dark);
  padding: 16px;
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--dark);
  margin-bottom: 8px;
}

.login-logo span,
.top-bar-logo span {
  color: var(--red);
}

.login-tagline {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 12px;
}

.login-btn {
  width: 100%;
}

.login-error {
  min-height: 1rem;
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 10px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: var(--dark);
  color: white;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-logo {
  font-size: 1.2rem;
  font-weight: 900;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-hint {
  font-size: 0.78rem;
  color: #aaa;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
}

.content {
  flex: 1;
  padding: 16px;
  padding-bottom: 84px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark);
  display: flex;
  z-index: 50;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: #aaa;
  font-size: 0.65rem;
}

.nav-btn .icon {
  font-size: 1.2rem;
}

.nav-btn.active {
  color: var(--red);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card,
.card {
  background: var(--bg2);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--red);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text2);
}

.card {
  margin-bottom: 14px;
}

.card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.article-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.article-item:last-child {
  border-bottom: none;
}

.article-item-body {
  flex: 1;
  min-width: 0;
}

.article-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
}

.article-item-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text2);
  font-size: 0.75rem;
}

.article-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

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

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

.btn-gray {
  background: #eee;
  color: #333;
}

.btn-danger {
  background: #ff4444;
  color: white;
}

.btn-gold {
  background: var(--gold);
  color: #000;
}

.btn-lg {
  width: 100%;
  margin-top: 8px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg2);
  font-size: 0.82rem;
}

.filter-tab.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
}

.form-group input,
.form-group textarea,
.form-group select,
.category-add-row input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
  background: var(--bg2);
  color: var(--text);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background: var(--red);
}

input:checked + .slider::before {
  transform: translateX(20px);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-message {
  min-height: 1rem;
  margin-top: 10px;
  color: var(--text2);
  font-size: 0.84rem;
}

.ai-section {
  background: linear-gradient(135deg, #1d1d1d, #333);
  color: white;
}

.ai-section h3 {
  color: var(--gold);
}

.ai-section .form-group label {
  color: #ddd;
}

.ai-section input,
.ai-section textarea,
.ai-section select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
}

.settings-section-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.category-add-row,
.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.category-add-row {
  margin-bottom: 14px;
}

.category-add-row input {
  flex: 1;
  min-width: 180px;
}

.category-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.category-name {
  font-weight: 700;
}

.category-meta {
  font-size: 0.78rem;
  color: var(--text2);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-published {
  background: #d4edda;
  color: #155724;
}

.spinner {
  text-align: center;
  padding: 24px;
  color: var(--text2);
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 720px) {
  .form-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
