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

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --yellow: #b45309;
  --yellow-bg: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

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

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

/* ── Nav ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.nav-brand { font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.3px; }
.nav-brand span { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-user { color: var(--muted); font-size: 13px; }
.nav-link { color: var(--muted); font-size: 13px; }
.nav-link:hover { color: var(--text); text-decoration: none; }

/* ── Layout ── */
.container { max-width: 900px; margin: 0 auto; padding: 32px 24px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--red-bg);   color: var(--red);   }
.badge-gray  { background: #f1f5f9;         color: var(--muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fca5a5; }
.btn-warn { background: var(--yellow-bg); color: var(--yellow); }
.btn-warn:hover { background: #fde68a; }
.btn-google {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  padding: 10px 20px;
  box-shadow: var(--shadow);
}
.btn-google:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-input, .form-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid #fca5a5; }
.alert-warn    { background: var(--yellow-bg); color: var(--yellow); border: 1px solid #fde68a; }

/* ── Broken error box ── */
.error-detail {
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--red);
}
.error-detail strong { display: block; margin-bottom: 3px; }

/* ── Post log ── */
.post-list-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.post-count-note {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.post-list { list-style: none; margin-top: 0; padding-top: 6px; }
.post-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 12px;
}
.post-list li:last-child { border-bottom: none; }
.post-title { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.post-date { color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.post-empty { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ── Stats row ── */
.stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.stat { font-size: 12px; color: var(--muted); }
.stat strong { color: var(--text); }

/* ── Platform labels ── */
.platform-label {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  vertical-align: middle;
  margin-left: 6px;
}
.platform-label.blogger { background: #fce8e6; color: #b31412; }
.platform-label.tumblr  { background: #e8edf7; color: #35465c; }

/* ── Platform sections in connect form ── */
.platform-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.platform-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.platform-section-header .platform-label { margin-left: 0; font-size: 11px; padding: 3px 9px; }

/* ── Tumblr account rows ── */
.tumblr-no-accounts { font-size: 13px; color: var(--muted); margin-top: 10px; }
.tumblr-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.tumblr-account-row:last-of-type { border-bottom: none; }
.tumblr-account-name { font-size: 13px; font-weight: 600; color: var(--text); }
.tumblr-account-actions { display: flex; gap: 8px; flex-shrink: 0; }
.fetch-status { font-size: 12px; color: var(--muted); margin-top: 5px; min-height: 16px; }
.blog-list-container { margin-top: 4px; }

/* ── Connect form ── */
.connect-section { margin-top: 32px; }
.connect-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
#fetch-status { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; }

/* ── Blog list (inline, replaces dropdown) ── */
#blog-list { margin-top: 14px; }
.blog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.blog-row:last-child { border-bottom: none; }
.blog-row-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.blog-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  text-align: center;
  width: 360px;
}
.login-logo { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.login-logo span { color: var(--accent); }
.login-tagline { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.login-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Admin ── */
.admin-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: #1e40af;
  margin-bottom: 20px;
}
.user-section { margin-bottom: 32px; }
.user-section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error page ── */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}
.error-page h1 { font-size: 48px; color: var(--border); }
.error-page p { color: var(--muted); }
