:root {
  --bg: #f7f9fc;
  --bg-2: #f1f5fb;
  --panel: #ffffff;
  --line: #dbe3ee;
  --text: #24364b;
  --muted: #6a7c93;
  --accent: #3f6fb4;
  --accent-2: #5a89c9;
  --ok: #2d8363;
  --warn: #ba7a21;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -20%, rgba(114, 146, 192, 0.10), rgba(114, 146, 192, 0) 45%),
    radial-gradient(circle at 100% 0%, rgba(124, 154, 197, 0.08), rgba(124, 154, 197, 0) 36%),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 40%, #f4f7fc 100%);
  font-family: "Source Sans Pro", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.01em;
  font-size: 16px;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: #d2dceb;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.hero {
  padding: 36px 26px 28px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.96));
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.035);
}

.hero h1 {
  margin: 0;
  color: #22364f;
  font-family: "Source Serif Pro", "Times New Roman", Georgia, serif;
  font-size: 40px;
  line-height: 1.16;
  letter-spacing: 0.1px;
}

.hero p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.hero .authors {
  margin-top: 16px;
  color: #30445f;
  font-size: 19px;
  font-weight: 610;
  line-height: 1.65;
}

.hero .affiliations {
  margin-top: 6px;
  color: #54657d;
  font-size: 15px;
}

.hero .corresponding {
  margin-top: 4px;
  color: #6c7f96;
  font-size: 14px;
}

.hero .intro {
  margin: 14px auto 0;
  max-width: 1120px;
  color: #5a6f89;
  font-size: 16px;
  line-height: 1.7;
}

.resource-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px auto 0;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 124px;
  justify-content: center;
  border: 1px solid #cdd9e8;
  border-radius: 999px;
  background: #ffffff;
  color: #2d435e;
  padding: 9px 17px 9px 12px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 5px 14px rgba(31, 53, 84, 0.06);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.resource-link:hover {
  transform: translateY(-1px);
  border-color: #9eb9dd;
  background: #f8fbff;
  box-shadow: 0 8px 20px rgba(31, 53, 84, 0.09);
}

.resource-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(36, 54, 75, 0.08);
}

.resource-icon svg {
  width: 17px;
  height: 17px;
}

.resource-link.paper .resource-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.resource-link.code .resource-icon svg {
  fill: currentColor;
  stroke: none;
}

.resource-link.paper {
  color: #8e4c24;
  border-color: #e8c7ad;
  background: linear-gradient(180deg, #fffaf6, #fff4eb);
}

.resource-link.code {
  color: #275f48;
  border-color: #b9d9ca;
  background: linear-gradient(180deg, #f7fcf9, #eef8f3);
}

.hero sup {
  font-size: 0.72em;
  vertical-align: super;
  line-height: 0;
}

.layout {
  display: grid;
  grid-template-columns: 314px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1650px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  box-shadow: 0 8px 20px rgba(28, 44, 70, 0.045);
  position: relative;
  overflow: clip;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(92, 131, 186, 0.30), rgba(92, 131, 186, 0.03));
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.12px;
  color: #2a4160;
  font-family: "Source Serif Pro", "Times New Roman", Georgia, serif;
}

.controls {
  grid-row: span 4;
  position: sticky;
  top: 12px;
  align-self: start;
}

.replay, .files, .judge, .harm {
  grid-column: 2;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: #5b6f88;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

select,
button,
input[type="range"] {
  width: 100%;
  border: 1px solid #d2dceb;
  background: #ffffff;
  color: #2d435e;
  border-radius: 9px;
  padding: 10px 11px;
  font-size: 15px;
}

button {
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  border-color: #a7c0e1;
  background: #f9fbff;
}

select:focus,
button:focus,
input[type="range"]:focus {
  outline: none;
  border-color: #8fb0df;
  box-shadow: 0 0 0 2px rgba(86, 132, 214, 0.18);
}

.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle-group button.active {
  background: #ecf3ff;
  border-color: #9bb4da;
}

.meta-box {
  margin-top: 12px;
  border: 1px solid #d9e3f0;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7faff, #f2f7ff);
  padding: 10px;
  color: #4c6585;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.replay-tools {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: 8px;
  align-items: center;
}

.replay-tools button {
  width: auto;
  min-width: 70px;
}

#playBtn {
  border-color: #9dcbb6;
  color: #205f47;
  background: linear-gradient(180deg, #f6fcf8, #edf8f2);
}

#pauseBtn {
  border-color: #e4c38f;
  color: #7f560f;
  background: linear-gradient(180deg, #fffaf1, #fff4e1);
}

#resetBtn {
  border-color: #dcb2b8;
  color: #8e3d48;
  background: linear-gradient(180deg, #fff8f9, #fff0f2);
}

.replay-tools select {
  width: 86px;
}

.turn-bar-wrap {
  margin: 12px 0 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

#turnInfo {
  color: #6a7f98;
  font-size: 14px;
  min-width: 90px;
  text-align: right;
}

.chat {
  border: 1px solid #dae3ef;
  border-radius: 12px;
  background:
    linear-gradient(180deg, #fdfefe 0%, #f9fcff 100%);
  min-height: 510px;
  max-height: 590px;
  overflow: auto;
  padding: 13px;
}

.msg {
  max-width: 84%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 15px;
  box-shadow: 0 1px 4px rgba(30, 48, 76, 0.035);
  animation: msgFadeIn 0.16s ease-out;
}

.msg .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.msg .role {
  display: inline-block;
  color: #7386a0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.24px;
}

.msg .time {
  color: #8ca0b8;
  font-size: 12px;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.avatar.user { background: #5f8fcd; }
.avatar.agent { background: #5ca081; }
.avatar.injection { background: #d18063; }
.avatar.system { background: #b08f4f; }

.msg.user {
  margin-left: auto;
  background: #eef4ff;
  border: 1px solid #d5e2f7;
}

.msg.agent {
  background: #f7f9fc;
  border: 1px solid #e0e7f0;
}

.msg.injection {
  background: #fff6ed;
  border: 1px solid #f0d7ba;
}

.msg.system {
  background: #f9f6ee;
  border: 1px solid #eadfc8;
}

.tool-call {
  margin-top: 8px;
  border: 1px solid #d7e2f2;
  border-radius: 8px;
  background: #f8fbff;
  overflow: hidden;
}

.tool-call summary {
  cursor: pointer;
  padding: 8px 10px;
  font-size: 13px;
  color: #5c7497;
  list-style: none;
}

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

.tool-call pre {
  margin: 0;
  padding: 8px 10px 10px;
  border-top: 1px solid #dce6f4;
  font-size: 12px;
  line-height: 1.45;
  color: #4f6584;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.fake-input {
  margin-top: 10px;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  background: #f9fbfe;
  padding: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.fake-input .mini {
  width: 26px;
  height: 26px;
  font-size: 13px;
}

.fake-input input {
  width: 100%;
  border: 1px solid #cfdbea;
  background: #ffffff;
  color: #6f8096;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.fake-input button {
  width: auto;
  min-width: 64px;
  opacity: 0.72;
}

.sub {
  margin: 0 0 10px;
  color: #7a8da3;
  font-size: 14px;
}

.files-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 11px;
}

.file-compare-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid #d4e0ef;
  background: #f8fbff;
  color: #607895;
}

.pill.before {
  border-color: #c0cfdf;
  background: #edf2f8;
}

.pill.after {
  border-color: #b6cdf0;
  background: #eef4fd;
}

.pill.blocked {
  border-color: #e0b9c1;
  background: #fff2f5;
}

.pill.kept {
  border-color: #b8dbc7;
  background: #f1fbf5;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #d2dcea;
  border-radius: 12px;
  background: #fcfdff;
  max-height: 380px;
  overflow: auto;
}

.file-list li {
  border-bottom: 1px solid #e4ebf3;
}

.file-list li.file-hidden {
  display: none;
}

.file-list li:last-child { border-bottom: none; }

.file-list button {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  line-height: 1.45;
}

.file-list button small {
  font-size: 12px;
}

.file-list button:hover {
  background: #f5f8fd;
}

.file-list button.active {
  background: #eaf2ff;
}

.file-list button.status-blocked {
  border-left: 3px solid #ca5e71;
}

.file-list button.status-kept {
  border-left: 3px solid #348d69;
}

.diff-view {
  margin: 0;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  background: #ffffff;
  min-height: 380px;
  max-height: 380px;
  overflow: auto;
  padding: 10px;
  color: #435c7c;
  font-size: 14px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.judge-list,
.harm-calc {
  display: grid;
  gap: 10px;
}

.harm-formula {
  border: 1px solid #dbe4ef;
  border-radius: 11px;
  background: linear-gradient(180deg, #f8fbff, #f2f7ff);
  padding: 10px;
  color: #5e7593;
  font-size: 14px;
  line-height: 1.5;
}

.harm-title {
  margin: 4px 0 0;
  font-size: 15px;
  color: #4a6384;
}

.harm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.harm-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  font-size: 14px;
}

.harm-table th,
.harm-table td {
  border-bottom: 1px solid #e6edf5;
  border-right: 1px solid #edf2f8;
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

.harm-table th:last-child,
.harm-table td:last-child {
  border-right: 0;
}

.harm-table thead th {
  background: #f6f9fd;
  color: #4a6383;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.harm-table tbody tr:nth-child(even) {
  background: #fbfdff;
}

.judge-item {
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.judge-item > summary {
  cursor: pointer;
  padding: 10px 12px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.judge-item > summary::-webkit-details-marker {
  display: none;
}

.judge-item.dangerous > summary {
  background: #fff6f8;
}

.judge-item.safe > summary {
  background: #f5fcf8;
}

.judge-content {
  padding: 10px 12px;
  border-top: 1px solid #dde6f0;
}

.risk-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 8px;
}

.risk-title {
  color: #7b8ea5;
  font-size: 13px;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid #d8e2f0;
  color: #6d85a2;
  background: #f7faff;
}

.risk-badge.authorization_drift {
  border-color: #d6c2f0;
  color: #6d4f9f;
  background: #f8f2ff;
}

.risk-badge.tool_use_escalation {
  border-color: #efc7b4;
  color: #915236;
  background: #fff4ee;
}

.risk-badge.unchecked_autonomy {
  border-color: #ecd7a8;
  color: #866215;
  background: #fff9ea;
}

.vote {
  margin-bottom: 10px;
  border: 1px solid #dbe5f1;
  border-radius: 9px;
  padding: 8px 9px;
  background: #fafcff;
}

.vote h4 {
  margin: 0 0 5px;
  font-size: 14px;
  color: #5b7392;
}

.vote .reason {
  color: #617a98;
  font-size: 14px;
  line-height: 1.45;
}

.vote ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.vote li {
  color: #6f87a3;
  font-size: 14px;
  line-height: 1.4;
}

.footer {
  color: #8ca0b7;
  font-size: 14px;
  padding: 0 14px 14px;
}

@keyframes msgFadeIn {
  from {
    transform: translateY(4px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1220px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-row: auto;
    position: static;
  }

  .replay, .files, .judge, .harm {
    grid-column: auto;
  }

  .files-layout {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
