:root {
  --bg: #0f1115;
  --fg: #eaecef;
  --muted: #8a8f98;
  --card: #1a1d24;
  --accent: #4f8cff;
  --accent-fg: #fff;
  --danger: #e0554f;
  --ok: #3fb950;
  --border: #2a2e37;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

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

.topbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
}

main {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

h1 { font-size: 1.3rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; }

.empty { color: var(--muted); }

.request-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.request-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.request-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--fg);
}

.request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  background: #262a33;
  border-radius: 6px;
  padding: 2px 8px;
}

.tag.kind { color: var(--accent); }

.tag.archived {
  color: #ffd580;
}

.stream-header {
  margin-bottom: 12px;
}

.archive-note {
  margin: 12px 0 16px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.stream-message-panel {
  margin: 18px 0 24px;
}

.stream-message-panel h2 {
  margin: 16px 0 8px;
}

.message-form {
  margin: 0;
}

.note-form {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}

.message-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--fg);
  font-weight: 700;
}

.message-form .comment-box {
  min-height: 76px;
  margin-bottom: 10px;
}

.btn.message-send {
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
}

.btn.message-send:disabled {
  opacity: 0.65;
  cursor: progress;
}

.message-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.message-status.is-error {
  color: #ff9b9b;
}

.message-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stream-message {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.stream-message.needs-answer {
  border-color: #3d6fd0;
}

.stream-message.is-consumed {
  color: var(--muted);
  background: #151820;
}

.message-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.message-label {
  color: var(--fg);
  font-weight: 800;
}

.message-text {
  margin: 0 0 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-time {
  color: var(--muted);
  font-size: 0.85rem;
}

.answer-form {
  margin-top: 12px;
}

.message-history {
  margin: 12px 0 16px;
}

.message-history summary {
  min-height: 44px;
  padding: 10px 0;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.status-badge.queued {
  background: #2f2818;
  color: #ffd580;
}

.status-badge.picked-up {
  background: #16301e;
  color: #71d083;
}

.message-form textarea:focus-visible,
.message-form .btn:focus-visible,
.message-history summary:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

.post-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.post-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.post-title {
  color: var(--fg);
  font-weight: 700;
  margin-bottom: 6px;
}

.report-actions {
  margin: 12px 0 10px;
}

.media-link {
  font-weight: 600;
}

.report-frame {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.decision-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  background: #151820;
}

.status-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-badge.pending {
  background: #2f2818;
  color: #ffd580;
}

.status-badge.decided {
  background: #16301e;
  color: #71d083;
}

.search-form {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.search-form input {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
}

.context {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
}

.context pre { white-space: pre-wrap; }

.verdict-banner {
  background: #16301e;
  border: 1px solid #275d38;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
}

.verdict-comment { margin-top: 6px; color: var(--muted); }

.before-after-review {
  margin: 16px 0 10px;
}

.view-switcher {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--card);
}

.view-switcher-option {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.view-switcher-option:last-child {
  border-right: 0;
}

.view-switcher-option[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

.view-switcher-option:focus-visible,
.variant:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

.before-card {
  background: #151820;
  border: 2px solid #596071;
  border-radius: 10px;
  overflow: hidden;
}

.before-side-by-side {
  margin: 0 0 10px;
}

.before-label {
  display: inline-block;
  margin: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #596071;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.before-media img,
.before-media video {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

.toggle-view {
  margin-bottom: 10px;
}

.toggle-frame {
  position: relative;
  min-height: 260px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #07090e;
}

.toggle-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms linear;
}

.toggle-before-layer {
  opacity: 1;
}

.toggle-frame.has-candidate .toggle-before-layer {
  opacity: 0;
}

.toggle-frame.has-candidate .toggle-candidate-layer,
.toggle-frame.show-before .toggle-before-layer {
  opacity: 1;
}

.toggle-frame.show-before .toggle-candidate-layer {
  opacity: 0;
}

.toggle-before-layer .before-label {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.toggle-before-layer .before-media,
.toggle-candidate-media {
  width: 100%;
  height: 100%;
}

.toggle-layer img,
.toggle-layer video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.variant {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.1s ease;
}

.variant.selected {
  border-color: var(--accent);
}

.variant-media img, .variant-media video {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

.variant-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.variant-number {
  font-weight: 700;
  background: #262a33;
  border-radius: 6px;
  min-width: 24px;
  text-align: center;
  padding: 2px 6px;
}

.order-badge {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  padding: 2px 7px;
}

.variant-caption {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-panel {
  margin-top: 20px;
  padding-bottom: 40px;
}

.comment-box {
  width: 100%;
  min-height: 70px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 12px;
  resize: vertical;
}

.btn {
  display: inline-block;
  padding: 14px 22px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.btn.decide {
  background: var(--accent);
  color: var(--accent-fg);
  width: 100%;
}

.approve-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.approve-buttons .btn {
  flex: 1;
}

.btn.approve { background: var(--ok); color: #06210e; }
.btn.reject { background: var(--danger); color: #310705; }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 10px;
  text-align: center;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --fg: #1a1d24;
    --muted: #6b7280;
    --card: #ffffff;
    --border: #e3e6ea;
  }
  .tag { background: #eef0f3; }
  .tag.archived { color: #8a5a00; }
  .verdict-banner { background: #eafaf0; border-color: #bfe8cd; }
  .before-card { background: #f2f4f7; border-color: #9aa3b2; }
  .before-label { background: #4b5563; color: #ffffff; }
  .toggle-frame { background: #eef0f3; }
  .variant-number { background: #eef0f3; }
  .decision-link { background: #f7f8fa; }
  .status-badge.pending { background: #fff3cf; color: #7a4c00; }
  .status-badge.decided { background: #eafaf0; color: #1f7a3a; }
  .stream-message.is-consumed { background: #f7f8fa; }
  .stream-message.needs-answer { border-color: #7aa7ff; }
  .message-status.is-error { color: #a32424; }
  .status-badge.queued { background: #fff3cf; color: #7a4c00; }
  .status-badge.picked-up { background: #eafaf0; color: #1f7a3a; }
}

.back-link {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--muted, #888);
  font-size: 0.9rem;
  text-decoration: none;
}

.back-link:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* Interactive view posts escape main's 720px cap: the view owns its layout. */
.view-frame-bleed {
  width: calc(100vw - 48px);
  margin-left: calc(50% - 50vw + 24px);
}

.view-frame {
  width: 100%;
  height: 88vh;
  border: 0;
  border-radius: 8px;
  background: #000;
}
