:root {
  --bg: #0e1117;
  --panel: #141923;
  --panel-alt: #1a212e;
  --border: #262b36;
  --border-strong: #374151;
  --text: #f1ede6;
  --muted: #9b968d;
  --accent: #38bdf8;
  --gold: #eab308;
  --primary: #2563eb;
  --green: #16c784;
  --green-soft: rgba(22, 199, 132, 0.14);
  --red: #ea3943;
  --red-soft: rgba(234, 57, 67, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --purple: #c084fc;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.up { color: var(--green); }
.down { color: var(--red); }
.hidden { display: none !important; }

/* Masthead (Editorial Newspaper Layout) */
.masthead {
  background: #10141c;
  border-bottom: 3px double var(--border-strong);
}

.masthead-utility {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.utility-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.masthead-date {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
}

.masthead-top {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 18px 14px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.masthead-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: left;
}

.news-badge {
  background: #f1ede6;
  color: #0e1117;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 18px;
  padding: 6px 13px;
  border-radius: 4px;
  letter-spacing: 0.6px;
  border: 1px solid #d6d0c4;
}

.nameplate-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.1;
}

.subtitle {
  margin-top: 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 11px;
  color: var(--muted);
}

.conn-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.conn-pill.connected .dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.wire-bar {
  background: #0a0d12;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.wire-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 7px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wire-tag {
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.wire-text {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-nav {
  max-width: 1320px;
  margin: 0 auto;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  cursor: pointer;
}

.nav-tab:hover { color: var(--text); }

.nav-tab.active {
  color: var(--text);
  background: rgba(241, 237, 230, 0.08);
  border-bottom: 2px solid var(--accent);
}

.nav-spacer { flex: 1; }

/* Buttons & Inputs */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.12); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-accent { background: #b45309; border-color: #d97706; color: #fff; }
.btn-ghost { background: transparent; }

.btn-chip {
  background: #0d111a;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
}

input, select, textarea {
  background: #0b0e14;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 9px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* Container & Views */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 18px 44px;
}

.view { display: none; }
.view.active { display: block; }

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.filter-bar input { flex: 1; min-width: 220px; }

.frontpage-grid {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
}

.lead-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lead-following-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border-strong);
  border-radius: 6px;
  padding: 14px 16px;
}

.lead-following-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.lead-following-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
}

.lead-following-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.following-subcard {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 12px 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.following-subcard:hover {
  border-color: var(--accent);
}

.following-subcard h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.3;
}

.following-subcard .story-summary {
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.lead-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 22px 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-card:hover { border-color: var(--accent); }

.story-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}

.lead-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.byline {
  font-size: 12px;
  color: var(--muted);
}

.story-summary {
  margin: 2px 0;
  color: #dedad2;
}

.arcs-sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--amber);
  border-radius: 6px;
  padding: 16px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
}

.arc-mini {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.arc-mini:hover { border-color: var(--accent); }

.progress-track {
  height: 4px;
  background: #0b0e14;
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
}

.section-heading {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 14px;
  border-top: 2px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.story-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-card:hover { border-color: var(--accent); }

.story-card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.3;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
}

.badge-up { background: var(--green-soft); border-color: rgba(22, 199, 132, 0.45); color: var(--green); }
.badge-down { background: var(--red-soft); border-color: rgba(234, 57, 67, 0.45); color: var(--red); }
.badge-arc { background: var(--amber-soft); border-color: rgba(245, 158, 11, 0.45); color: #fcd34d; }
.badge-inv { background: rgba(192, 132, 252, 0.15); border-color: rgba(192, 132, 252, 0.45); color: var(--purple); }

.impact-strip {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--mono);
}

/* Following Stories Board */
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.section-header-row h2 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 24px;
}

.section-header-row p { margin: 0; }

.arcs-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

/* Editorial Desk */
.newsroom-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: start;
}

.newsroom-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

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

.panel-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
}

.panel-body { padding: 14px; }

.editor-form {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.inline-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.npc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.npc-item {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(38, 43, 54, 0.75);
}

/* Prewritten Release Queue & Revision Log */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
}

.queue-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-wrap: wrap;
}

.queue-row.flagged {
  border-left: 3px solid var(--amber);
}

.queue-row.published {
  opacity: 0.72;
}

.queue-meta {
  flex: 1;
  min-width: 240px;
}

.queue-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.revision-item {
  padding: 10px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 8px;
}

.schema-pre {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-x: auto;
  max-height: 420px;
  color: #d6e4ff;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-note-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 9px 13px;
  margin-bottom: 12px;
  font-size: 12px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.article-modal {
  width: min(820px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 24px 26px;
}

.article-body {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 22px;
  margin: 16px 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.72;
  color: #ede9e0;
}

.article-body p:first-child::first-letter {
  font-size: 2.3em;
  font-weight: 700;
  float: left;
  line-height: 0.9;
  padding-right: 7px;
  padding-top: 4px;
  color: var(--text);
}

.article-link-btn {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
}

.outcome-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.impact-box {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.tag-btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
}

.tag-btn:hover { color: var(--accent); border-color: var(--accent); }

.related-item {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  margin-top: 8px;
}

.related-item:hover { border-color: var(--accent); }

#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
}

.toast {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 5px;
  max-width: 380px;
}

@media (max-width: 960px) {
  .frontpage-grid, .newsroom-grid, .form-grid-2, .lead-following-grid {
    grid-template-columns: 1fr;
  }
  .nameplate-text h1 {
    font-size: 24px;
  }
}
