/* =========================================================================
   Content Radar — App styles
   Built on Agency One design system. Adds:
   - Theme tokens (light/dark)
   - App-shell chrome (sidebar, topbar, panes)
   - Status semantics for triage workflow
   ========================================================================= */

/* Theme — light is default. Tokens are remapped under [data-theme="dark"]. */
:root,
[data-theme="light"] {
  --bg-page:       #FFFFFF;
  --bg-surface:    #FFFFFF;
  --bg-sunken:     #F6F5F8;     /* sidebar / sections */
  --bg-card:       #FFFFFF;
  --bg-card-muted: #FAFAFA;     /* approved/archived cards */
  --bg-overlay:    rgba(35,35,35,0.45);
  --bg-banner:     #F6F5F8;
  --bg-code:       #F4F3F6;

  --fg-primary:    #000000;
  --fg-secondary:  #232323;
  --fg-muted:      #929292;
  --fg-on-red:     #FFFFFF;
  --fg-on-dark:    #FFFFFF;

  --border:        #DDDCE1;
  --border-strong: #000000;
  --border-soft:   #ECEAF0;

  /* Semantic statuses */
  --status-approved-fg:  #2C7A4B;
  --status-approved-bg:  #E8F1EB;
  --status-rejected-fg:  #8C2A3A;
  --status-rejected-bg:  #FBEDF0;
  --status-info-fg:      #2D4A8E;
  --status-info-bg:      #E8EEFB;
  --status-warn-fg:      #8C5A1F;
  --status-warn-bg:      #FBF1E0;
  --status-error-fg:     #B5253A;
  --status-error-bg:     #FBE7EB;

  /* Brand tokens carried from design system */
  --brand-red:       #DA435D;
  --brand-red-deep:  #DA3555;
  --brand-red-coral: #ED4851;
  --brand-indigo:    #45435D;

  --shadow-elev: 0 4px 16px rgba(69,67,93,0.08);
  --shadow-modal: 0 24px 64px rgba(35,35,35,0.18);
}

[data-theme="dark"] {
  --bg-page:       #0E0E10;
  --bg-surface:    #161618;
  --bg-sunken:     #0A0A0C;     /* sidebar / outer chrome */
  --bg-card:       #1A1A1D;
  --bg-card-muted: #141416;
  --bg-overlay:    rgba(0,0,0,0.6);
  --bg-banner:     #1A1A1D;
  --bg-code:       #0A0A0C;

  --fg-primary:    #F2F1F4;
  --fg-secondary:  #C8C7CC;
  --fg-muted:      #6E6D74;
  --fg-on-red:     #FFFFFF;
  --fg-on-dark:    #FFFFFF;

  --border:        #26262A;
  --border-strong: #F2F1F4;
  --border-soft:   #1F1F22;

  --status-approved-fg:  #6FCB95;
  --status-approved-bg:  #15281E;
  --status-rejected-fg:  #E47A8C;
  --status-rejected-bg:  #2A1A1F;
  --status-info-fg:      #8FA9E8;
  --status-info-bg:      #14192A;
  --status-warn-fg:      #D9A763;
  --status-warn-bg:      #2A1F12;
  --status-error-fg:     #E47A8C;
  --status-error-bg:     #2A1418;

  --brand-red:       #ED4851;
  --brand-red-deep:  #DA3555;
  --brand-red-coral: #F25C66;
  --brand-indigo:    #B7B5CC;

  --shadow-elev: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.6);
}

/* Reset + base */
* { box-sizing: border-box; }
html, body, #root {
  height: 100%;
  margin: 0;
  background: var(--bg-page);
  color: var(--fg-primary);
  font-family: "Geometria", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { overflow: hidden; }

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

::selection { background: var(--brand-red); color: #fff; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   App shell
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  grid-template-rows: 56px 1fr auto;
  height: 100vh;
  min-width: 1024px;
}

.topbar {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__logo {
  width: 22px; height: 22px;
  background-color: var(--brand-red);
  -webkit-mask: url("assets/logo_red.png") center/contain no-repeat;
          mask: url("assets/logo_red.png") center/contain no-repeat;
}
.topbar__name {
  font-family: "TT Lakes", sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-primary);
}
.topbar__divider { width: 1px; height: 24px; background: var(--border); }

.topbar__brand-select {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--fg-primary);
  border-radius: 2px;
  font-size: 13px;
  cursor: pointer;
}
.topbar__brand-select:hover { border-color: var(--fg-muted); }
.topbar__brand-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--brand-red); }

.topbar__spacer { flex: 1; }

.topbar__theme {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-surface);
}
.topbar__theme button {
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.topbar__theme button + button { border-left: 1px solid var(--border); }
.topbar__theme button.is-on { color: var(--fg-primary); background: var(--bg-sunken); }

.topbar__icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--fg-secondary);
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar__icon-btn:hover { color: var(--fg-primary); border-color: var(--fg-muted); }

.topbar__user {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--brand-indigo);
  color: var(--fg-on-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* Sidebar */
.sidebar {
  grid-row: 2 / 3;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px 10px;
  overflow: hidden;
}
.sidebar__section-label {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 6px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 2px;
  cursor: pointer;
  color: var(--fg-secondary);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--bg-surface); color: var(--fg-primary); }
.nav-item.is-active {
  background: var(--bg-surface);
  color: var(--fg-primary);
  box-shadow: inset 2px 0 0 var(--brand-red);
}
.nav-item__icon { width: 16px; height: 16px; flex: none; color: var(--fg-muted); }
.nav-item.is-active .nav-item__icon { color: var(--brand-red); }
.nav-item__count {
  margin-left: auto;
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.nav-item.is-active .nav-item__count { color: var(--brand-red); border-color: var(--brand-red); }

.sidebar__footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar__footer-row { display: flex; justify-content: space-between; }
.sidebar__footer-row .accent { color: var(--brand-red); }

/* Main pane */
.main {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
}

/* Joblog row at the bottom spans full width */
.joblog-host {
  grid-column: 1 / 3;
  grid-row: 3 / 4;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

/* =========================================================================
   Common UI primitives
   ========================================================================= */
.btn {
  font-family: "Geometria", sans-serif;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 2px;
  border: 0;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .12s cubic-bezier(.2,0,0,1);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--brand-red); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-red-deep); }
.btn--primary:active:not(:disabled) { background: var(--brand-red-coral); transform: translateY(1px); }
.btn--secondary {
  background: var(--bg-surface); color: var(--fg-primary);
  border: 1px solid var(--border-strong);
}
.btn--secondary:hover:not(:disabled) { background: var(--bg-sunken); }
.btn--ghost { background: transparent; color: var(--fg-secondary); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-sunken); color: var(--fg-primary); }
.btn--approve {
  background: var(--bg-surface);
  color: var(--status-approved-fg);
  border: 1px solid currentColor;
}
.btn--approve:hover:not(:disabled) { background: var(--status-approved-bg); }
.btn--reject {
  background: var(--bg-surface);
  color: var(--status-rejected-fg);
  border: 1px solid currentColor;
}
.btn--reject:hover:not(:disabled) { background: var(--status-rejected-bg); }
.btn--icon { padding: 8px; width: 32px; justify-content: center; }
.btn--lg { padding: 11px 18px; font-size: 14px; }
.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--danger { background: transparent; color: var(--status-error-fg); border: 1px solid currentColor; }
.btn--danger:hover:not(:disabled) { background: var(--status-error-bg); }

.input, .textarea, .select {
  font-family: "Geometria", sans-serif;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--fg-primary);
  border-radius: 2px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(218,67,93,0.18);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.textarea--mono {
  font-family: "JetBrains Mono", "SF Mono", "Menlo", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.label {
  display: block;
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--fg-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag--keyword {
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: "Geometria", sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--fg-secondary);
  border-color: var(--border-soft);
}
.tag--keyword::before {
  content: "#";
  color: var(--fg-muted);
  margin-right: -2px;
}
.tag--approved { background: var(--status-approved-bg); color: var(--status-approved-fg); border-color: transparent; }
.tag--rejected { background: var(--status-rejected-bg); color: var(--status-rejected-fg); border-color: transparent; }
.tag--info     { background: var(--status-info-bg);     color: var(--status-info-fg);     border-color: transparent; }
.tag--warn     { background: var(--status-warn-bg);     color: var(--status-warn-fg);     border-color: transparent; }
.tag--error    { background: var(--status-error-bg);    color: var(--status-error-fg);    border-color: transparent; }
.tag--solid {
  background: var(--brand-red); color: #fff; border-color: transparent;
}

.dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--fg-muted);
  display: inline-block;
}
.dot--approved { background: var(--status-approved-fg); }
.dot--rejected { background: var(--status-rejected-fg); }
.dot--info { background: var(--status-info-fg); }
.dot--error { background: var(--status-error-fg); }
.dot--pulse { position: relative; }
.dot--pulse::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 999px;
  border: 2px solid currentColor;
  opacity: 0.5;
  animation: dotPulse 1.4s ease-out infinite;
}
@keyframes dotPulse {
  0%   { transform: scale(0.6); opacity: 0.6; }
  70%  { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

.section-label {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-indigo);
}

/* =========================================================================
   Screen header (shared)
   ========================================================================= */
.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen__header {
  padding: 20px 32px 0;
  background: var(--bg-page);
  flex: none;
}
.screen__header-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.screen__title {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--fg-primary);
  margin: 0;
}
.screen__title-count {
  color: var(--brand-red);
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.02em;
  margin-left: 8px;
}
.screen__subtitle {
  margin-top: 6px;
  color: var(--fg-muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 18px;
  border-bottom: 1px solid var(--border);
}
.tab {
  position: relative;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--fg-primary); }
.tab.is-active { color: var(--fg-primary); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--brand-red);
}
.tab__count {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.tab.is-active .tab__count { color: var(--brand-red); }

/* =========================================================================
   Queue
   ========================================================================= */
.queue-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 48px;
  min-width: 0;
}
.queue-list {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.job-banner {
  max-width: 1240px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--status-info-bg);
  color: var(--status-info-fg);
  border-radius: 2px;
  border-left: 3px solid var(--status-info-fg);
}
.job-banner__progress {
  flex: 1;
  height: 4px;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  overflow: hidden;
}
[data-theme="dark"] .job-banner__progress { background: rgba(255,255,255,0.08); }
.job-banner__progress-bar {
  height: 100%;
  background: currentColor;
  border-radius: 999px;
  transition: width .3s ease;
}
.job-banner__link {
  color: currentColor;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.error-banner {
  max-width: 1240px;
  margin: 0 auto 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--status-error-bg);
  color: var(--status-error-fg);
  border-radius: 2px;
  border-left: 3px solid var(--status-error-fg);
}
.error-banner__title { font-weight: 600; }
.error-banner__body { font-size: 13px; opacity: 0.85; margin-top: 2px; }

/* TopicCard */
.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .12s, transform .12s;
  min-width: 0;
}
.topic-card:hover { border-color: var(--fg-muted); }
.topic-card--approved { background: var(--bg-card-muted); }
.topic-card--rejected { background: var(--bg-card-muted); opacity: 0.85; }
.topic-card__header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.topic-card__title {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--fg-primary);
  margin: 0;
  flex: 1;
  text-wrap: pretty;
}
.topic-card__summary {
  color: var(--fg-secondary);
  font-size: 13.5px;
  line-height: 1.5;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-card__sources {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: auto;
}
.topic-card__source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-secondary);
}
.topic-card__source-icon {
  width: 14px; height: 14px;
  border-radius: 2px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "TT Lakes", sans-serif;
  font-weight: 700;
  font-size: 8px;
  color: var(--fg-secondary);
}
.topic-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--fg-muted);
}
.topic-card__meta-sep { color: var(--border); }
.topic-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.topic-card__actions .spacer { flex: 1; }
.topic-card__reject-block {
  background: var(--status-rejected-bg);
  color: var(--status-rejected-fg);
  border-radius: 2px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.topic-card__reject-block strong { font-weight: 600; }
.topic-card__reject-quote {
  font-family: "Geometria", sans-serif;
  font-style: italic;
  color: var(--status-rejected-fg);
  flex: 1;
}

/* Skeleton (loading state) */
.skel {
  background: linear-gradient(90deg,
    var(--bg-sunken) 0%,
    var(--border-soft) 50%,
    var(--bg-sunken) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 2px;
}
[data-theme="dark"] .skel {
  background: linear-gradient(90deg, #1A1A1D 0%, #232327 50%, #1A1A1D 100%);
  background-size: 200% 100%;
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-card { padding: 20px 22px; }
.skel-line { height: 14px; margin-bottom: 10px; }

/* Empty state */
.empty-state {
  max-width: 540px;
  margin: 80px auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.empty-state__icon {
  width: 56px; height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--fg-muted);
  background: var(--bg-surface);
}
.empty-state__title {
  font-family: "Geometria", sans-serif;
  font-weight: 500;
  font-size: 20px;
  color: var(--fg-primary);
}
.empty-state__body {
  color: var(--fg-muted);
  font-size: 14px;
  max-width: 420px;
  line-height: 1.55;
}
.empty-state__actions { display: flex; gap: 8px; margin-top: 6px; }

/* =========================================================================
   Articles
   ========================================================================= */
.split {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}
.split__aside {
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.split__aside-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.split__aside-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}
.split__main { display: flex; flex-direction: column; overflow: hidden; }

.article-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--fg-secondary);
  border: 1px solid transparent;
}
.article-list-item:hover { background: var(--bg-surface); }
.article-list-item.is-active {
  background: var(--bg-surface);
  border-color: var(--border);
  box-shadow: inset 2px 0 0 var(--brand-red);
  color: var(--fg-primary);
}
.article-list-item__icon { margin-top: 3px; }
.article-list-item__title {
  font-weight: 500;
  line-height: 1.35;
  text-wrap: pretty;
}
.article-list-item__meta {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 4px;
}

.article-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}
.article-view__inner {
  width: 100%;
  max-width: 900px;
  padding: 28px 32px 56px;
}
.article-view__main {
  min-width: 0;
}
.article-view__main h1 {
  font-family: "Geometria", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  line-height: 1.3;
}
.article-view__main h2 {
  font-family: "Geometria", sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 24px 0 8px;
}
.article-view__main h3 {
  font-family: "Geometria", sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 6px;
}
.article-view__aside {
  position: sticky;
  top: 28px;
  align-self: start;
}

.article-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.article-toolbar__title {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.005em;
  color: var(--fg-primary);
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.version-select {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--bg-page);
  color: var(--fg-primary);
  border: 1px solid var(--border);
  padding: 6px 10px 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.article-meta-card {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 2px;
  font-size: 12.5px;
}
.article-meta-card h4 {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 10px;
}
.article-meta-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.article-meta-card dt {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.article-meta-card dd {
  margin: 2px 0 0;
  color: var(--fg-primary);
  font-family: "Geometria", sans-serif;
  font-size: 13px;
  word-break: break-all;
}
.article-meta-card dd.mono {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 12px;
  color: var(--fg-secondary);
}

/* Markdown body */
.md {
  color: var(--fg-primary);
  line-height: 1.65;
  font-size: 15.5px;
}
.md > * + * { margin-top: 14px; }
.md h2 {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.005em;
  margin-top: 28px;
}
.md h3 {
  font-family: "Geometria", sans-serif;
  font-weight: 500;
  font-size: 17px;
  margin-top: 20px;
}
.md p { color: var(--fg-secondary); }
.md ul { padding-left: 18px; }
.md li { color: var(--fg-secondary); margin-bottom: 6px; }
.md li::marker { color: var(--brand-red); }
.md blockquote {
  border-left: 2px solid var(--brand-red);
  padding-left: 14px;
  margin-left: 0;
  color: var(--fg-secondary);
  font-style: italic;
}
.md sup a {
  color: var(--brand-red);
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  text-decoration: none;
  margin-left: 2px;
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.md .footnotes {
  font-size: 13px;
  color: var(--fg-muted);
}
.md .footnotes ol { padding-left: 18px; }
.md .footnotes li { color: var(--fg-muted); margin-bottom: 8px; }
.md .footnotes a.footnote-url {
  color: var(--fg-muted);
  text-decoration: underline;
  word-break: break-all;
}
.md strong { color: var(--fg-primary); font-weight: 600; }

.editor-area {
  width: 100%;
  min-height: 500px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 18px 20px;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg-primary);
  outline: none;
  resize: vertical;
}
.editor-area:focus { border-color: var(--brand-red); box-shadow: 0 0 0 3px rgba(218,67,93,0.18); }

/* =========================================================================
   Posts
   ========================================================================= */
.post-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid transparent;
}
.post-list-item:hover { background: var(--bg-surface); }
.post-list-item.is-active {
  background: var(--bg-surface);
  border-color: var(--border);
  box-shadow: inset 2px 0 0 var(--brand-red);
}
.post-list-item__title {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--fg-primary);
  text-wrap: pretty;
  line-height: 1.3;
}
.post-list-item__meta {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.post-stage {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 56px;
  background: var(--bg-page);
}
.post-stage__inner {
  max-width: 720px;
  margin: 0 auto;
}
.tg-frame {
  background: var(--bg-sunken);
  border-radius: 4px;
  padding: 30px;
  display: flex;
  justify-content: flex-start;
}
[data-theme="dark"] .tg-frame {
  background: #17212B; /* telegram dark wallpaper */
}
[data-theme="light"] .tg-frame {
  background: #E7EBF0;
}

.tg-bubble {
  background: #FFFFFF;
  color: #000;
  padding: 12px 14px 8px;
  border-radius: 12px 12px 12px 4px;
  max-width: 540px;
  font-family: "Geometria", -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
[data-theme="dark"] .tg-bubble {
  background: #182533;
  color: #FFFFFF;
}
.tg-bubble__channel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #DA435D;
  margin-bottom: 6px;
}
[data-theme="dark"] .tg-bubble__channel { color: #ED4851; }
.tg-bubble__text { white-space: pre-wrap; }
.tg-bubble__text strong { font-weight: 700; }
.tg-bubble__text em { font-style: italic; }
.tg-bubble__source {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
  color: #5288c1;
}
[data-theme="dark"] .tg-bubble__source {
  border-color: rgba(255,255,255,0.08);
  color: #6AB3F3;
}
.tg-bubble__time {
  text-align: right;
  font-size: 11px;
  color: #93999F;
  margin-top: 2px;
}

.post-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.post-toolbar__title {
  font-family: "Geometria", sans-serif;
  font-weight: 600;
  font-size: 16px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast */
.toast-host {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--fg-primary);
  color: var(--bg-page);
  padding: 10px 16px;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-modal);
  animation: toast-in .25s cubic-bezier(.2,0,0,1);
}
.toast__hash {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  opacity: 0.7;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* =========================================================================
   Settings
   ========================================================================= */
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 56px;
}
.settings-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
}
.settings-grid--single { grid-template-columns: 1fr; }
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 20px 22px;
}
.settings-card h3 {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 6px;
}
.settings-card p { color: var(--fg-secondary); font-size: 14px; line-height: 1.55; }
.settings-helper-card h4 {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 10px;
}
.settings-helper-card ul { margin: 0; padding-left: 16px; }
.settings-helper-card li { color: var(--fg-secondary); font-size: 13px; margin-bottom: 6px; }
.settings-helper-card li code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--brand-red);
  background: var(--bg-code);
  padding: 1px 5px;
  border-radius: 2px;
}

.settings-warning {
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
  padding: 10px 12px;
  border-radius: 2px;
  font-size: 13px;
  border-left: 3px solid currentColor;
  margin: 12px 0;
}

/* =========================================================================
   JobLog drawer
   ========================================================================= */
.joblog {
  width: 100%;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  transition: height .22s cubic-bezier(.2,0,0,1);
  overflow: hidden;
}
.joblog--collapsed { height: 36px; }
.joblog--expanded { height: 320px; }
.joblog__bar {
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  cursor: pointer;
  user-select: none;
  border-top: 1px solid var(--border-soft);
}
.joblog__bar:hover { background: var(--bg-sunken); }
.joblog__bar-stat {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.joblog__bar-stat .accent { color: var(--brand-red); }
.joblog__bar-stat .info { color: var(--status-info-fg); }
.joblog__bar-active {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--status-info-fg);
}
.joblog__bar-spacer { flex: 1; }
.joblog__bar-toggle {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.joblog__body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
.joblog__list {
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
  overflow-y: auto;
  padding: 6px;
}
.joblog__job {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid transparent;
}
.joblog__job:hover { background: var(--bg-surface); }
.joblog__job.is-active {
  background: var(--bg-surface);
  border-color: var(--border);
  box-shadow: inset 2px 0 0 var(--brand-red);
}
.joblog__job-icon { margin-top: 2px; }
.joblog__job-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--fg-primary);
  font-weight: 500;
}
.joblog__job-sub {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 3px;
}
.joblog__job-tail {
  font-size: 11.5px;
  color: var(--fg-muted);
  margin-top: 4px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.joblog__detail { display: flex; flex-direction: column; overflow: hidden; }
.joblog__detail-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.joblog__detail-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--fg-primary);
}
.joblog__detail-meta {
  font-family: "TT Lakes", sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.joblog__phase-banner {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-info-subtle, rgba(0, 100, 200, 0.05));
  font-size: 12px;
  color: var(--status-info-fg);
}
.joblog__stream {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-code);
  padding: 12px 16px;
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
}
.joblog__line {
  display: flex;
  gap: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.joblog__line-time { color: var(--fg-muted); flex: none; }
.joblog__line-tag {
  font-weight: 600;
  flex: none;
  width: 70px;
}
.joblog__line-tag--info  { color: var(--status-info-fg); }
.joblog__line-tag--tool  { color: var(--brand-indigo); }
.joblog__line-tag--ok    { color: var(--status-approved-fg); }
.joblog__line-tag--err   { color: var(--status-error-fg); }
.joblog__line-tag--warn  { color: var(--status-warn-fg); }
.joblog__line-text { flex: 1; color: var(--fg-secondary); }

[data-theme="dark"] .joblog__stream { background: #08080A; }

/* =========================================================================
   Modal
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  width: 520px;
  max-width: calc(100vw - 48px);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  animation: modal-in .18s cubic-bezier(.2,0,0,1);
}
@keyframes modal-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal__header {
  padding: 18px 22px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal__title {
  font-family: "Geometria", sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.005em;
  margin: 0;
  flex: 1;
}
.modal__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 4px;
  display: inline-flex;
}
.modal__close:hover { color: var(--fg-primary); }
.modal__body { padding: 6px 22px 14px; }
.modal__hint {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--status-info-bg);
  color: var(--status-info-fg);
  border-radius: 2px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 10px;
}
.modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  background: var(--bg-sunken);
  color: var(--fg-secondary);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--brand-red); color: var(--brand-red); }
.chip.is-on { background: var(--brand-red); color: #fff; border-color: transparent; }
.modal__footer {
  padding: 14px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-soft);
}

/* =========================================================================
   History Drawer
   ========================================================================= */
.history-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
}

.history-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
}

.history-drawer__header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.history-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-drawer__empty {
  padding: 24px 16px;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.6;
}

.history-entry {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry--pre-restore {
  background: var(--status-warn-bg);
}

.history-entry__time {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-entry__badge {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.85;
}

.history-entry__channel {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 3px;
  font-family: "JetBrains Mono", monospace;
}

.history-entry__files {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 4px;
}

.history-entry__actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

/* =========================================================================
   Misc
   ========================================================================= */
.kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  background: var(--bg-sunken);
  color: var(--fg-secondary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 1px 6px;
  border-radius: 3px;
}

/* ====== Search palette (⌘K) ====== */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 9000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 11vh;
}
.search-palette {
  width: min(640px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.search-palette__input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-palette__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--fg);
}
.search-palette__body {
  overflow: auto;
  padding: 8px 0;
}
.search-palette__hint {
  padding: 16px 18px;
  color: var(--fg-muted);
  font-size: 13px;
}
.search-palette__group {
  padding: 4px 0 8px;
}
.search-palette__group-label {
  font-family: "TT Lakes", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 6px 18px 4px;
}
.search-palette__row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  padding: 8px 18px;
  cursor: pointer;
  font: inherit;
  color: var(--fg);
}
.search-palette__row:hover {
  background: var(--surface-hover, #f5f5f5);
  border-left-color: var(--brand-red, #DA435D);
}
.search-palette__row-title {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.3;
}
.search-palette__row-meta {
  color: var(--fg-muted);
  font-size: 11px;
  margin-top: 2px;
  font-family: "JetBrains Mono", monospace;
}
.search-palette__row-snippet {
  color: var(--fg-secondary);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.45;
}
