:root {
  color-scheme: dark;
  --bg: #0a0e17;
  --panel: #131a28;
  --panel-2: #0f1521;
  --line: #1f2a3d;
  --text: #e7ecf5;
  --muted: #8a97b4;
  --accent: #5b8cff;
  --green: #34d399;
  --red: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1320, #0a0e17);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: 1px; }
.brand .sub { color: var(--muted); font-size: 12px; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
  align-self: center;
}

.stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  padding: 18px;
}

.stage-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.badge {
  background: rgba(91, 140, 255, 0.15);
  color: #acc4ff;
  border: 1px solid rgba(91, 140, 255, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}
.last-summary { color: var(--muted); font-size: 13px; flex: 1; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 15px;
}
.ghost:hover { color: var(--text); border-color: var(--accent); }

.frame-wrap {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
#app-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

.side-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.panel h2 { font-size: 14px; margin: 0 0 12px; color: var(--text); }
.panel-loading { color: var(--muted); font-size: 13px; }

.panel-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.pending-text, .submit-area {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.pending-text { font-size: 15px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

.vote-row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-approve { background: linear-gradient(180deg, #2bbd83, #1f9c6b); color: #fff; }
.btn-reject { background: linear-gradient(180deg, #e25b5b, #c44545); color: #fff; }
.btn-primary {
  background: linear-gradient(180deg, #5b8cff, #4070e6);
  color: #fff; width: 100%; margin-top: 12px;
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
}
textarea:focus { outline: none; border-color: var(--accent); }
.count { text-align: right; color: var(--muted); font-size: 12px; margin-top: 6px; }

.hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 10px; }

.timeline-panel { flex: 1; min-height: 0; overflow: auto; }
#action-panel { flex: 0 0 auto; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 10px 0 10px 18px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px; top: 14px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li.t-rejected::before { background: var(--red); }
.timeline li.t-genesis::before { background: var(--green); }
.tl-head { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.tl-tag { font-weight: 600; }
.tl-tag.applied { color: #acc4ff; }
.tl-tag.rejected { color: var(--red); }
.tl-tag.genesis { color: var(--green); }
.tl-instruction { font-size: 13px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.tl-instruction.struck { text-decoration: line-through; color: var(--muted); }
.tl-summary { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1a2335;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 50;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }

@media (max-width: 900px) {
  body { min-height: 0; }
  .layout { grid-template-columns: 1fr; }
  .timeline-panel { flex: none; max-height: 38vh; }
  .frame-wrap { min-height: 60vh; }
}
