:root {
  --bg: #0f1218;
  --panel: #1b1f29;
  --panel-2: #232835;
  --line: #323848;
  --text: #f5f7fb;
  --label: #e8edf7;
  --muted: #b4bdd0;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --ok: #3dd68c;
  --warn: #f5c15c;
  --err: #ff6b7a;
  --radius: 14px;
  --sidebar: #0c0f16;
  --sidebar-width: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
}
button.ghost, button.nav-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
button.danger { background: var(--err); }
.muted { color: var(--muted); }
.error { color: var(--err); }
.brand-mark, .brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.brand-mark {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: var(--accent);
}
.auth-shell:not([hidden]):not(.is-hidden) {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: radial-gradient(1200px 600px at 10% -10%, #1d263b 0%, var(--bg) 45%);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.auth-card, .modal-card { width: min(420px, 100%); }
label {
  display: block;
  margin: 0.85rem 0;
  color: var(--label);
  font-weight: 400;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}
input, select, textarea {
  width: 100%;
  margin-top: 0.4rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  color: var(--text);
}
textarea { min-height: 160px; resize: vertical; }

.app-shell:not([hidden]):not(.is-hidden) {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sidebar .brand {
  padding: 0.35rem 0.75rem;
  font-size: 1.15rem;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.side-nav .nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.side-nav .nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.side-nav .nav-btn.active {
  background: var(--accent-soft);
  color: #fff;
}
.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 24, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.topbar-right, .profile {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.7rem 0.35rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  max-width: min(420px, 60vw);
}
.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
#current-user {
  color: var(--label);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
main { padding: 1.5rem; max-width: 1200px; width: 100%; }
.section-head, .filters, .cal-nav, .modal-actions, .row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.stat-grid, .split, .item-grid {
  display: grid;
  gap: 1rem;
}
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.split { grid-template-columns: 1fr 1fr; }
.item-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat, .item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat b { font-size: 1.6rem; display: block; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
}
.badge.planned { color: var(--warn); }
.badge.draft { color: var(--accent); }
.badge.published { color: var(--ok); }
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}
.cal-cell {
  min-height: 110px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem;
}
.cal-cell.muted-day { opacity: 0.45; }
.cal-item {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem; border-bottom: 1px solid var(--line); }
dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(0,0,0,.55); }
.modal-card { width: min(640px, 92vw); }
.modal-card label { color: var(--label); }
.composer-form {
  max-width: 760px;
  display: grid;
  gap: 1.1rem;
}
.composer-form small { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.site-info-panel, .publish-date-group, .wysiwyg-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.site-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.site-info-item {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 0.7rem;
}
.site-info-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.site-info-value { font-size: 1.15rem; font-weight: 600; margin-top: 0.2rem; }
.article-suggestions-header, .composer-actions, .checkbox-row, .wysiwyg-header {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.article-suggestions-list { display: grid; gap: 0.65rem; margin-top: 0.75rem; }
.suggestion-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.suggestion-card:hover { border-color: var(--accent); }
.suggestion-card h4 { margin: 0 0 0.35rem; }
.languages-checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.lang-chip {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  background: var(--panel-2);
}
.checkbox-field .checkbox-row { justify-content: flex-start; margin-top: 0.4rem; }
.urls-details { margin-top: 0.75rem; }
.urls-details summary { cursor: pointer; color: var(--label); }
.urls-by-language, .processed-sitemaps { margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); max-height: 240px; overflow: auto; }
.image-preview { margin-top: 0.6rem; display: flex; gap: 0.75rem; align-items: center; }
.image-preview img { max-width: 160px; border-radius: 8px; }
.wysiwyg-toolbar { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.6rem 0; }
.wysiwyg-toolbar button { background: var(--panel-2); border: 1px solid var(--line); padding: 0.35rem 0.55rem; }
.wysiwyg-editor {
  min-height: 180px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
}
.wysiwyg-editor:empty:before { content: "Paste your rough draft here…"; color: var(--muted); }
@media (max-width: 900px) {
  .site-info-grid { grid-template-columns: 1fr 1fr; }
  .split, .calendar { grid-template-columns: 1fr; }
  .app-shell:not([hidden]):not(.is-hidden) { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.75rem;
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav .nav-btn { width: auto; }
  .profile-chip { max-width: 46vw; }
}

/* Must follow display rules so login overlay can actually hide after sign-in. */
#auth-view[hidden],
#auth-view.is-hidden,
#app-view[hidden],
#app-view.is-hidden,
[hidden],
.is-hidden {
  display: none !important;
}
