:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #667085;
  --accent: #1769e0;
  --accent-dark: #0f4fae;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 10px 14px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled,
button.is-loading {
  cursor: wait;
  opacity: 0.72;
}

.button-link {
  display: inline-block;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
}

.button-link:hover {
  background: var(--accent-dark);
  color: white;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #7a271a;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.secondary-button:hover {
  background: #f2f4f7;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  font: inherit;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hint {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #98a2b3;
  border-radius: 50%;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.hint::after {
  position: absolute;
  z-index: 10;
  bottom: calc(100% + 8px);
  left: 50%;
  width: min(320px, 72vw);
  border: 1px solid #344054;
  border-radius: 7px;
  background: #101828;
  color: white;
  content: attr(aria-label);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  padding: 10px 11px;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.hint::before {
  position: absolute;
  z-index: 11;
  bottom: calc(100% + 3px);
  left: 50%;
  width: 10px;
  height: 10px;
  background: #101828;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) rotate(45deg);
  transition: opacity 120ms ease;
}

.hint:hover::after,
.hint:focus::after,
.hint:hover::before,
.hint:focus::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hint:hover::before,
.hint:focus::before {
  transform: translateX(-50%) rotate(45deg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  border-right: 1px solid var(--line);
  background: #101828;
  color: white;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: #38bdf8;
  color: #062235;
}

nav {
  display: grid;
  gap: 6px;
}

nav a,
.ghost-button {
  border-radius: 7px;
  color: #d0d5dd;
  display: block;
  padding: 10px 12px;
}

nav a.active,
nav a:hover {
  background: #1d2939;
  color: white;
}

.ghost-button {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  border: 1px solid #344054;
  background: transparent;
  text-align: left;
}

.content {
  margin-left: 240px;
  padding: 32px;
}

.login-content {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel,
.panel,
.card,
.candidate,
.error-box,
.notice,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
}

.stack {
  display: grid;
  gap: 16px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1,
.login-panel h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.page-header p,
.panel p {
  color: var(--muted);
  margin: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card,
.panel,
.candidate,
.empty {
  padding: 18px;
}

.card h2,
.panel h2,
.candidate h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.metric {
  font-size: 30px;
  font-weight: 700;
  margin: 8px 0;
}

.metric-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.metric-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
}

.monitor-live-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fafb;
  margin-top: 12px;
  padding: 10px 12px;
}

.monitor-live-status.is-running {
  border-color: #a6f4c5;
  background: #ecfdf3;
}

.monitor-live-status.is-delayed {
  border-color: #fedf89;
  background: #fffaeb;
}

.monitor-live-status.has-error {
  border-color: #fecdca;
  background: #fef3f2;
}

.monitor-live-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #98a2b3;
}

.monitor-live-status.is-running .monitor-live-dot {
  background: #17b26a;
  box-shadow: 0 0 0 5px rgb(23 178 106 / 14%);
  animation: monitor-pulse 1.4s ease-in-out infinite;
}

.monitor-live-status.is-delayed .monitor-live-dot {
  background: #f79009;
  box-shadow: 0 0 0 5px rgb(247 144 9 / 14%);
}

.monitor-live-status.has-error .monitor-live-dot {
  background: #d92d20;
  box-shadow: 0 0 0 5px rgb(217 45 32 / 12%);
}

.monitor-live-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.monitor-live-copy strong {
  font-size: 14px;
}

.monitor-live-copy small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

@keyframes monitor-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .monitor-live-status.is-running .monitor-live-dot {
    animation: none;
  }
}

.source-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-chip-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
}

.source-chip-list small {
  color: var(--muted);
  margin-left: 4px;
}

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

.wide {
  grid-column: 1 / -1;
}

.actions {
  margin-top: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  color: #067647;
}

.error,
.error-box {
  color: var(--danger);
}

.error-box {
  margin-bottom: 16px;
  padding: 14px;
}

.table {
  display: grid;
  gap: 10px;
}

.source-row {
  display: grid;
  grid-template-columns: 80px 1.5fr 1.5fr 110px;
  gap: 10px;
  align-items: center;
}

.source-channel {
  align-items: center;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.source-channel-fields {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.source-avatar {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
}

.source-avatar-placeholder {
  align-items: center;
  background: #e9eef6;
  color: #344054;
  display: flex;
  font-size: 15px;
  font-weight: 700;
  justify-content: center;
}

.source-verified,
.source-unverified {
  color: #067647;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-unverified {
  color: var(--muted);
}

.table-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check {
  display: flex;
  justify-content: center;
}

.check input {
  width: 18px;
  height: 18px;
}

.monitor-check {
  align-items: center;
  display: flex;
  justify-content: flex-start;
}

.add-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.source-import {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}

.source-import summary,
.import-errors summary {
  cursor: pointer;
  font-weight: 700;
}

.source-import textarea {
  margin: 12px 0 10px;
}

.import-result {
  line-height: 1.5;
}

.import-errors {
  color: var(--danger);
  margin-top: 8px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 300px) minmax(170px, 220px) auto;
  gap: 10px;
}

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

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  width: 100%;
}

.preview-action-group {
  display: grid;
  gap: 6px;
}

.action-group-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-language-filter {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  justify-self: start;
  min-height: 36px;
  padding: 6px 10px 6px 7px;
  width: auto;
}

.language-filter-badge {
  align-items: center;
  background: #eef4ff;
  border: 1px solid #c7d7fe;
  border-radius: 5px;
  color: #3538cd;
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  height: 22px;
  justify-content: center;
  letter-spacing: 0;
  width: 26px;
}

.compact-language-filter.is-active {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.compact-language-filter.is-active .language-filter-badge {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}

.usage-panel {
  border-block: 1px solid var(--line);
  margin-bottom: 18px;
  padding: 14px 0;
}

.usage-heading {
  align-items: baseline;
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.usage-heading span,
.usage-stats dt {
  color: var(--muted);
  font-size: 13px;
}

.usage-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  margin: 0;
}

.usage-stats div {
  border-left: 1px solid var(--line);
  padding: 2px 14px;
}

.usage-stats div:first-child {
  border-left: 0;
  padding-left: 0;
}

.usage-all-time {
  color: var(--muted);
  font-size: 11px;
  margin: 9px 0 0;
}

.usage-all-time strong {
  color: #475467;
  font-weight: 700;
}

.usage-stats dt {
  margin-bottom: 3px;
}

.usage-stats dd {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.analysis-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 18px;
  padding: 14px;
}

.analysis-progress[hidden] {
  display: none;
}

.analysis-progress.has-error {
  border-color: #fda29b;
  color: var(--danger);
}

.analysis-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.analysis-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

.meta-line {
  margin-top: 12px;
}

.section-heading-row {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
}

.section-heading-row h2 {
  margin-bottom: 6px;
}

.snapshot-table {
  display: grid;
  gap: 8px;
}

.snapshot-details {
  padding: 0;
}

.snapshot-details summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 18px;
}

.snapshot-details summary::-webkit-details-marker {
  display: none;
}

.snapshot-details summary::after {
  color: var(--muted);
  content: "+";
  font-size: 22px;
  font-weight: 500;
}

.snapshot-details[open] summary::after {
  content: "-";
}

.snapshot-details summary span {
  font-size: 18px;
  font-weight: 700;
}

.snapshot-details summary small {
  color: var(--muted);
  margin-left: auto;
}

.snapshot-details-content {
  border-top: 1px solid var(--line);
  padding: 10px 18px 18px;
}

.snapshot-row {
  display: grid;
  grid-template-columns: 96px 130px 70px 90px minmax(180px, 1fr) minmax(220px, 1.4fr);
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.snapshot-row:last-child {
  border-bottom: 0;
}

.snapshot-row a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.monitor-post-list {
  display: grid;
}

.monitor-post-card {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.monitor-post-card:first-child {
  padding-top: 0;
}

.monitor-post-card:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.monitor-post-media {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f2f4f7;
}

.monitor-post-media iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.monitor-media-launch,
.monitor-media-missing {
  width: 100%;
  height: 100%;
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.monitor-media-launch {
  border-radius: 0;
  background: #172033;
}

.monitor-media-launch:hover {
  background: #26334a;
}

.monitor-media-launch span {
  font-size: 36px;
  line-height: 1;
}

.monitor-media-launch small,
.monitor-media-missing {
  color: #98a2b3;
}

.monitor-post-body {
  align-content: start;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.monitor-post-heading,
.monitor-post-identity,
.monitor-post-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.monitor-post-heading {
  justify-content: space-between;
}

.monitor-post-identity {
  flex-wrap: wrap;
  min-width: 0;
}

.monitor-post-identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-icon-button {
  width: 34px;
  height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  justify-content: center;
  padding: 0;
}

.monitor-icon-button:hover {
  border-color: #98a2b3;
  background: #f2f4f7;
  color: var(--text);
}

.monitor-icon-button.is-loading {
  cursor: wait;
  opacity: 0.55;
}

.monitor-post-title {
  color: var(--text) !important;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.monitor-tech-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.monitor-tech-panel[hidden] {
  display: none;
}

.monitor-tech-panel div {
  display: grid;
  gap: 3px;
}

.monitor-tech-panel span,
.monitor-tech-panel small {
  color: var(--muted);
  font-size: 12px;
}

.monitor-tech-panel strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.monitor-tech-wide {
  grid-column: 1 / -1;
}

.hot-label,
.watch-label {
  border-radius: 7px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 7px;
  text-align: center;
}

.hot-label {
  background: #fee4e2;
  color: #912018;
}

.watch-label {
  background: #eef4ff;
  color: #3538cd;
}

.monitor-state {
  border-radius: 7px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 7px;
  text-align: center;
}

.state-confirmed_hot {
  background: #dcfae6;
  color: #067647;
}

.state-rising {
  background: #ecfdf3;
  color: #087443;
}

.state-cooling {
  background: #fff4e8;
  color: #b54708;
}

.state-watch {
  background: #eef4ff;
  color: #3538cd;
}

.state-collecting,
.state-collecting_baseline {
  background: #f2f4f7;
  color: #475467;
}

.candidate-list {
  display: grid;
  gap: 14px;
}

.candidate {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 360px;
  gap: 18px;
  border-left-width: 5px;
}

.candidate[hidden] {
  display: none;
}

.candidate.fit-top {
  border-left-color: #079455;
}

.candidate.fit-strong {
  border-left-color: #47cd89;
}

.candidate.fit-medium {
  border-left-color: #eaaa08;
}

.candidate.fit-low {
  border-left-color: #f79009;
}

.candidate.fit-poor {
  border-left-color: #d92d20;
}

.candidate.fit-none {
  border-left-color: #98a2b3;
}

.fit-order {
  float: right;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f2f4f7;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
  padding: 4px 7px;
}

.fit-order[hidden] {
  display: none;
}

.candidate.no-media {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.media-gallery {
  position: relative;
  align-self: start;
  width: 96px;
}

.media-gallery.is-album {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 6px;
}

.media-thumb {
  align-self: start;
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f2f4f7;
  padding: 0;
  overflow: hidden;
}

.media-gallery.is-album .media-thumb {
  width: 44px;
  height: 44px;
}

.album-count {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.media-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-dialog {
  max-width: min(920px, 92vw);
  max-height: 90vh;
  border: 0;
  border-radius: 8px;
  background: #101828;
  padding: 14px;
}

.media-dialog::backdrop {
  background: rgb(16 24 40 / 72%);
}

.media-dialog img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.dialog-close {
  float: right;
  margin-bottom: 10px;
  background: #ffffff;
  color: #101828;
}

.candidate p {
  color: var(--muted);
  line-height: 1.45;
}

.candidate .published-at {
  font-size: 12px;
  margin: 6px 0 0;
}

.audience-fit {
  grid-column: 2 / -1;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.candidate.no-media .audience-fit {
  grid-column: 1 / -1;
}

.audience-fit p {
  margin: 0 0 9px;
}

.signal-row,
.fit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.fit-tags {
  margin-top: 8px;
}

.signal-row span,
.fit-tags span {
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 7px;
}

.signal-positive {
  background: #dcfae6;
  color: #085d3a;
}

.signal-negative {
  background: #fff1f3;
  color: #a11043;
}

.fit-tags span {
  background: #f2f4f7;
  color: #344054;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

dl div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

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

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.priority-top {
  color: #067647;
}

.priority-strong {
  color: #087443;
}

.priority-medium {
  color: #8a6100;
}

.priority-low {
  color: #b54708;
}

.priority-poor {
  color: #b42318;
}

.priority-none {
  color: var(--muted);
}

.priority {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.priority-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: 100%;
  }

  .ghost-button {
    position: static;
    margin-top: 16px;
    width: 100%;
  }

  .content {
    margin-left: 0;
    padding: 20px;
  }

  .grid.two,
  .form-grid,
  .candidate,
  .toolbar,
  .analyze-form,
  .source-row,
  .monitor-post-card,
  .snapshot-row {
    grid-template-columns: 1fr;
  }

  .toolbar-group,
  .analyze-form,
  .preview-actions {
    display: grid;
  }

  .snapshot-details summary {
    align-items: flex-start;
  }

  .usage-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }

  .usage-stats div {
    border-left: 0;
    padding: 0;
  }

  .wide {
    grid-column: auto;
  }

  .monitor-post-media {
    min-height: 260px;
  }

  .monitor-tech-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
