:root {
  color-scheme: light;
  --ink: #15201b;
  --muted: #657169;
  --paper: #f4f6f1;
  --card: rgba(255, 255, 255, 0.94);
  --line: #d8ddd6;
  --forest: #123f31;
  --forest-dark: #0b2f24;
  --blue: #4d78ef;
  --green: #2fa36b;
  --orange: #e88935;
  --danger: #b43d34;
  --shadow: 0 18px 44px rgba(27, 47, 38, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% -8%, rgba(150, 216, 180, 0.3), transparent 32rem),
    linear-gradient(180deg, #fafbf7 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }

.page-width {
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
}

.eyebrow, .section-kicker, .strategy-label {
  margin-bottom: 8px;
  color: var(--forest);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.home-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 64px 0 34px;
}

.home-hero h1, .role-hero h1 {
  margin-bottom: 15px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(42px, 5vw, 72px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
}

.subtitle {
  max-width: 800px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.relay-badge, .tab-badge {
  border: 1px solid rgba(18, 63, 49, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  padding: 16px 20px;
  backdrop-filter: blur(12px);
}

.relay-badge span, .relay-badge small, .tab-badge span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.relay-badge strong { display: block; margin: 6px 0; font-size: 14px; }
.tab-badge { min-width: 150px; }
.tab-badge strong { display: block; margin-top: 6px; color: var(--forest); font-family: "Cascadia Code", Consolas, monospace; font-size: 21px; letter-spacing: 0.13em; }

.home-main, .experiment-main { display: grid; gap: 24px; }

.panel, .experiment-card, .pair-switcher {
  border: 1px solid rgba(30, 53, 44, 0.12);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel { padding: 26px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading h2, .experiment-card h2 { margin-bottom: 0; font-size: 23px; letter-spacing: -0.025em; }

.config-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.55fr 0.55fr;
  gap: 15px;
  margin-top: 24px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: #fbfcfa;
  color: var(--ink);
  padding: 0 13px;
}

input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(18, 63, 49, 0.1); }

.toolbar, .page-actions, .pair-links { display: flex; align-items: center; gap: 10px; }
.toolbar { margin-top: 18px; }

.primary-button, .secondary-button {
  min-height: 42px;
  border-radius: 11px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button { border: 1px solid var(--forest); background: var(--forest); color: white; }
.primary-button:hover:not(:disabled) { background: var(--forest-dark); }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary-button:hover:not(:disabled) { border-color: #a8b1aa; background: #f7f9f6; }

.status-pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.status-neutral { background: #edf0ec; color: #617068; }
.status-running { background: #e7edff; color: #3159c3; }
.status-success { background: #e3f4e9; color: #23794e; }
.status-error { background: #f9e7e5; color: var(--danger); }

.security-note { margin: 15px 0 0; color: #765c36; font-size: 12px; line-height: 1.6; }

.experiment-list { display: grid; gap: 18px; }
.experiment-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(520px, 0.95fr); gap: 28px; padding: 28px; overflow: hidden; position: relative; }
.experiment-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; }
.experiment-blue::before { background: var(--blue); }
.experiment-green::before { background: var(--green); }
.experiment-orange::before { background: var(--orange); }
.experiment-copy p:last-child { max-width: 700px; margin: 14px 0 0; color: var(--muted); line-height: 1.7; }

.route-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.route-pair a { display: flex; min-width: 0; flex-direction: column; justify-content: center; border: 1px solid var(--line); border-radius: 16px; background: #f9faf7; padding: 16px; text-decoration: none; transition: transform 140ms ease, border-color 140ms ease; }
.route-pair a:hover { border-color: var(--forest); transform: translateY(-2px); }
.route-pair span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; }
.route-pair code { overflow: hidden; margin: 8px 0 12px; color: var(--forest); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.route-pair b { font-size: 13px; }

.instructions-panel { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 30px; }
.instructions-panel ol { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 28px; margin: 0; color: var(--muted); line-height: 1.6; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  border-bottom: 1px solid rgba(30, 53, 44, 0.12);
  background: rgba(250, 251, 247, 0.9);
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  backdrop-filter: blur(16px);
}
.brand { color: var(--forest); font-weight: 900; letter-spacing: 0.08em; text-decoration: none; text-transform: uppercase; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a { border-radius: 999px; color: var(--muted); padding: 8px 12px; font-size: 13px; font-weight: 750; text-decoration: none; }
.topbar nav a:hover { background: #e9eee9; color: var(--forest); }

.experiment-main { padding-top: 34px; }
.role-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; border-radius: 26px; padding: 34px; }
.role-hero h1 { font-size: clamp(38px, 4.4vw, 64px); }
.role-hero-blue { background: linear-gradient(135deg, #eaf0ff, #f9fbff); }
.role-hero-green { background: linear-gradient(135deg, #e2f4e9, #f9fcfa); }
.role-hero-orange { background: linear-gradient(135deg, #fbeada, #fffaf5); }
.route-label { display: inline-block; margin-top: 18px; border-radius: 9px; background: rgba(255,255,255,.75); padding: 7px 10px; color: var(--forest); }

.pair-switcher { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; }
.pair-switcher span { display: block; color: var(--muted); font-size: 11px; }
.pair-switcher strong { font-size: 14px; }
.pair-links a { border-radius: 10px; padding: 9px 13px; color: var(--muted); font-size: 13px; font-weight: 800; text-decoration: none; }
.pair-links a.active { background: var(--forest); color: white; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 0.85fr); gap: 18px; }
.query-settings { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 14px; margin-top: 22px; }
.query-settings.hidden { display: none; }
.secret-field { position: relative; }
.secret-field input { padding-right: 65px; }
.text-button { position: absolute; top: 6px; right: 7px; height: 32px; border: 0; background: transparent; color: var(--forest); font-size: 13px; font-weight: 800; }

.request-summary { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 17px; }
.request-summary span { border-radius: 999px; background: #eff2ed; color: #526159; padding: 8px 11px; font-size: 12px; font-weight: 750; }
.page-actions { flex-wrap: wrap; margin-top: 18px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; margin: 22px 0 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.metric { min-width: 0; background: #fbfcfa; padding: 12px; }
.metric dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.metric dd { overflow: hidden; margin: 0; font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

details { border-top: 1px solid var(--line); padding-top: 14px; }
summary { color: var(--forest); cursor: pointer; font-size: 13px; font-weight: 800; }
pre { max-height: 300px; overflow: auto; margin: 12px 0 0; border-radius: 12px; background: #101713; color: #d7e7df; padding: 14px; font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

.table-wrap { overflow: auto; margin-top: 20px; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 13px; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #f1f4ef; color: var(--muted); font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { color: var(--muted); padding: 26px; text-align: center; }
.table-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; }

.logs { max-height: 430px; overflow: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 16px; background: #111814; color: #dce8e2; padding: 9px 0; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.log-entry { display: grid; grid-template-columns: 110px 80px 88px 1fr; gap: 12px; margin: 0; border-bottom: 1px solid rgba(255,255,255,.045); padding: 7px 16px; line-height: 1.55; }
.log-time, .log-elapsed { color: #8fa69a; }
.log-type { color: #8fb8ff; font-weight: 850; }
.log-success .log-type { color: #85d8a9; }
.log-error .log-type, .log-error .log-message { color: #ff9b91; }
.empty-log { margin: 0; padding: 20px; color: #82958b; text-align: center; }
.text-action { border: 0; background: transparent; color: var(--forest); font-weight: 800; }

footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; padding: 28px 0 42px; color: var(--muted); font-size: 12px; }
code { color: var(--forest); }

@media (max-width: 1050px) {
  .home-hero, .role-hero { align-items: stretch; flex-direction: column; }
  .experiment-card, .workspace-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr 1fr; }
  .relay-badge, .tab-badge { width: fit-content; }
}

@media (max-width: 680px) {
  .page-width { width: calc(100% - 24px); }
  .home-hero { padding-top: 38px; }
  .config-grid, .route-pair, .instructions-panel, .instructions-panel ol, .query-settings { grid-template-columns: 1fr; }
  .experiment-card { padding: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 8px; padding-block: 12px; }
  .topbar nav { width: 100%; overflow-x: auto; }
  .pair-switcher { align-items: stretch; flex-direction: column; }
  .pair-links { align-items: stretch; flex-direction: column; }
  .log-entry { grid-template-columns: 1fr; gap: 2px; }
}
