:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #62706a;
  --quiet: #8b9691;
  --line: #dce4df;
  --line-strong: #c9d4ce;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --canvas: #eef2ef;
  --green: #186c55;
  --green-bright: #21a477;
  --green-soft: #e7f5ef;
  --blue: #3b68c8;
  --blue-soft: #eaf0fc;
  --amber: #b87517;
  --amber-soft: #fff4df;
  --red: #b5413b;
  --red-soft: #fdecea;
  --shadow: 0 18px 50px rgba(27, 49, 40, 0.07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 1180px; min-height: 720px; background: #f1f4f2; color: var(--ink); }

body { height: 100vh; overflow: hidden; font-size: 14px; }

button, textarea, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 66px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: relative;
  z-index: 10;
}

.brand-block, .header-actions, .header-context, .sim-title-row, .section-title-row, .event-heading, .code-heading {
  display: flex;
  align-items: center;
}

.brand-block { gap: 11px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: #163d31; display: flex; align-items: end; justify-content: center; gap: 3px; padding: 8px; }
.brand-mark span { width: 4px; border-radius: 4px; background: #7ee0b9; }
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; }
.brand-name { font-size: 16px; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; }
.brand-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }

.header-context { gap: 9px; padding: 8px 13px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.context-label { color: var(--muted); }
.header-context strong { font-size: 13px; font-weight: 650; }
.header-actions { justify-content: end; gap: 10px; }

.mode-badge, .run-badge, .small-status, .source-tag, .scenario-id {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
}
.mode-badge { gap: 7px; padding: 7px 10px; background: var(--green-soft); color: var(--green); border: 1px solid #c9e8dc; font-size: 12px; font-weight: 700; }
.mode-badge.mode-remote { color: #3157a0; background: var(--blue-soft); border-color: #cfdbf5; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(33, 164, 119, .12); }

.workspace {
  height: calc(100vh - 66px);
  padding: 14px;
  display: grid;
  grid-template-columns: 318px minmax(510px, 1fr) 342px;
  gap: 14px;
}

.panel, .center-column { min-width: 0; min-height: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { min-height: 72px; padding: 16px 17px 13px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h1, .panel-heading h2, .simulation-header h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -0.025em; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.small-status { padding: 5px 8px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); font-size: 12px; }
.small-status.success { color: var(--green); background: var(--green-soft); border-color: #c9e8dc; }
.small-status.error { color: var(--red); background: var(--red-soft); border-color: #f4c9c4; }

.left-panel { display: flex; flex-direction: column; }
.left-scroll, .right-scroll { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #c8d2cc transparent; }
.left-scroll { padding: 13px 16px 18px; }
.task-summary { margin-bottom: 11px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
.task-row { min-height: 24px; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; align-items: center; font-size: 12px; }
.task-row span { color: var(--muted); }
.task-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.seed-card { margin-bottom: 13px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.seed-card img { display: block; width: 100%; height: 104px; object-fit: cover; object-position: center 55%; background: #dce4df; }
.seed-copy { padding: 9px 10px 10px; }
.seed-copy > div:first-child { display: flex; align-items: center; gap: 7px; }
.seed-copy strong { font-size: 13px; }
.seed-copy p { margin: 6px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.evidence-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 3px 6px; border-radius: 5px; font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.evidence-badge.real { color: #245291; background: #eaf0fc; }
.evidence-badge.synthetic { color: #89591d; background: #fff1d9; }
.delta-row { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
textarea { width: 100%; resize: vertical; min-height: 108px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: #fbfcfb; outline: none; line-height: 1.58; font-size: 13px; transition: border .16s, box-shadow .16s; }
textarea:focus, input:focus { border-color: #69aa91; box-shadow: 0 0 0 3px rgba(33, 164, 119, .1); }
.example-row { display: flex; gap: 7px; margin: 9px 0 11px; }
.example-chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 5px 8px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.example-chip:hover { border-color: #8dbca9; color: var(--green); }

.button { min-height: 35px; padding: 8px 13px; border-radius: 9px; border: 1px solid transparent; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { background: #163d31; color: white; }
.button-primary:hover:not(:disabled) { background: #215544; }
.button-secondary { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: #8dbca9; background: var(--green-soft); }
.button-wide { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.error-box { margin-top: 10px; padding: 9px 10px; border-radius: 8px; background: var(--red-soft); border: 1px solid #f4c9c4; color: #8f332d; line-height: 1.45; font-size: 12px; }

.section-block { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.section-title-row { justify-content: space-between; margin-bottom: 11px; }
.section-title-row h2 { margin: 0; font-size: 14px; }
.source-tag { padding: 4px 7px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); font-size: 12px; font-weight: 650; }
.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.parameter-field { min-width: 0; }
.parameter-field > span:first-child { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
.input-with-unit { height: 36px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfb; overflow: hidden; }
.input-with-unit:focus-within { border-color: #69aa91; box-shadow: 0 0 0 3px rgba(33, 164, 119, .1); }
.input-with-unit input { width: 100%; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0 8px; background: transparent; font-weight: 700; }
.input-with-unit b { padding-right: 7px; color: var(--quiet); font-size: 13px; font-weight: 650; }
.policy-row { margin-top: 10px; padding: 9px 10px; display: grid; grid-template-columns: 1fr auto auto; gap: 7px; align-items: center; border-radius: 8px; background: var(--green-soft); color: var(--green); font-size: 13px; }
.policy-row > span:first-child { color: #497265; }
.lock-icon { padding: 2px 5px; border-radius: 5px; background: rgba(255,255,255,.7); font-size: 12px; font-weight: 700; }

.tool-plan { margin: 0; padding: 0; list-style: none; }
.tool-plan li { min-height: 34px; display: grid; grid-template-columns: 21px 1fr auto; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; position: relative; }
.tool-plan li:not(:last-child)::after { content: ""; position: absolute; left: 9px; top: 27px; bottom: -7px; width: 1px; background: var(--line); }
.plan-index { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); border: 1px solid var(--line); color: var(--quiet); font-size: 12px; z-index: 1; }
.tool-plan li.completed .plan-index { background: var(--green); border-color: var(--green); color: white; }
.tool-plan li.blocked .plan-index { background: var(--red); border-color: var(--red); color: white; }
.tool-plan li.active .plan-index { background: var(--amber-soft); border-color: #f0ca8d; color: var(--amber); }
.plan-owner { color: var(--quiet); font-size: 12px; text-transform: uppercase; }

.center-column { display: grid; grid-template-rows: auto minmax(310px, 1fr) auto auto 118px; gap: 10px; }
.simulation-header { min-height: 64px; padding: 0 2px 2px; display: flex; align-items: center; justify-content: space-between; }
.sim-title-row { gap: 9px; }
.execution-disclosure { margin-top: 4px; color: var(--muted); font-size: 13px; }
.run-badge { padding: 4px 7px; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.status-ready { color: var(--blue); background: var(--blue-soft); }
.status-running { color: var(--amber); background: var(--amber-soft); }
.status-paused { color: #74589c; background: #f1eafb; }
.status-passed { color: var(--green); background: var(--green-soft); }
.status-failed, .status-blocked { color: var(--red); background: var(--red-soft); }
.simulation-controls { display: flex; gap: 7px; }
.icon-button { height: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 13px; }
.icon-button.run-control { color: white; background: #163d31; border-color: #163d31; }
.icon-button.batch-control { color: #3157a0; background: var(--blue-soft); border-color: #cfdbf5; font-weight: 700; }
.play-icon { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid currentColor; }
.pause-icon { width: 8px; height: 10px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.reset-icon { font-size: 17px; line-height: 1; }

.canvas-card { min-height: 0; position: relative; overflow: hidden; background: var(--canvas); border: 1px solid var(--line-strong); border-radius: 15px; box-shadow: inset 0 1px rgba(255,255,255,.7); }
#simulation-canvas { display: block; width: 100%; height: 100%; min-height: 310px; }
.canvas-legend { position: absolute; left: 14px; top: 12px; display: flex; gap: 12px; padding: 6px 8px; background: rgba(255,255,255,.87); border: 1px solid rgba(211,221,215,.9); border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 750; backdrop-filter: blur(6px); }
.canvas-legend span { display: flex; align-items: center; gap: 4px; }
.canvas-legend i { width: 14px; height: 6px; border-radius: 3px 5px 5px 3px; }
.canvas-legend .legend-zone { width: 8px; height: 8px; border-radius: 2px; }
.legend-ego { background: #2fa982; }
.legend-actor { background: #3f66bb; }
.legend-zone { background: #db8b2e; }
.sim-clock { position: absolute; right: 14px; top: 12px; text-align: right; padding: 6px 8px; background: rgba(20,37,31,.84); border-radius: 8px; color: white; backdrop-filter: blur(6px); }
.sim-clock strong { display: block; font-variant-numeric: tabular-nums; font-size: 14px; }
.sim-clock span { color: #bcd1c8; font-size: 12px; }
.runner-profile { position: absolute; left: 14px; top: 50px; display: grid; grid-template-columns: auto auto; gap: 1px 7px; align-items: center; padding: 7px 9px; border-radius: 8px; border: 1px solid rgba(244, 201, 196, .95); background: rgba(253, 236, 234, .92); color: #8f332d; backdrop-filter: blur(6px); }
.runner-profile span { grid-column: 1 / -1; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.runner-profile strong, .runner-profile b { font-size: 12px; }
.runner-profile b { font-weight: 800; }
.runner-profile.ready { color: var(--green); border-color: #c9e8dc; background: rgba(231, 245, 239, .92); }

.timeline-row { display: grid; grid-template-columns: 28px 1fr 32px; gap: 7px; align-items: center; color: var(--quiet); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline-track { height: 4px; border-radius: 99px; background: #d8e0dc; overflow: hidden; }
.timeline-progress { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #31a47e, #69c6a5); transition: width .08s linear; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.metric-card { min-width: 0; padding: 10px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 7px 24px rgba(27,49,40,.04); }
.metric-card > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-card strong { font-size: 18px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metric-card small { margin-left: 3px; color: var(--quiet); font-size: 12px; }
.metric-accent { border-color: #bfe2d5; background: linear-gradient(135deg, #f1faf6, #fff); }
.metric-accent strong { color: var(--green); }

.event-card { min-height: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.event-heading { justify-content: space-between; margin-bottom: 8px; }
.event-heading h3 { margin: 0; font-size: 13px; }
.event-heading span { color: var(--quiet); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.event-list { height: 72px; overflow: auto; display: flex; flex-direction: column; gap: 5px; }
.event-item { display: grid; grid-template-columns: 42px 8px 1fr auto; gap: 7px; align-items: center; color: var(--muted); font-size: 12px; }
.event-time { color: var(--quiet); font-variant-numeric: tabular-nums; }
.event-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green-bright); }
.event-item.collision .event-dot { background: var(--red); }
.event-item b { color: var(--ink); font-size: 13px; font-weight: 650; }
.event-item em { color: var(--quiet); font-style: normal; font-size: 12px; }
.empty-event { height: 100%; display: grid; place-items: center; color: var(--quiet); font-size: 12px; }

.right-panel { display: flex; flex-direction: column; }
.right-heading { align-items: flex-start; }
.scenario-id { max-width: 145px; padding: 5px 7px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.tabs { min-height: 42px; padding: 6px 10px 0; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.tab-button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.tab-button.active { color: var(--green); border-bottom-color: var(--green); }
.right-scroll { flex: 1; padding: 14px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.object-card { padding: 11px; margin-bottom: 9px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
.object-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.object-card-header h3 { margin: 0; font-size: 12px; }
.object-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.property-list { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; font-size: 12px; }
.property-list dt { color: var(--muted); }
.property-list dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.provenance-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.provenance-chip { padding: 4px 6px; border-radius: 6px; background: var(--blue-soft); color: #3c5e9d; font-size: 12px; }
.code-heading { justify-content: space-between; margin-bottom: 9px; font-size: 12px; font-weight: 650; }
.code-block { margin: 0; padding: 12px; min-height: 460px; overflow: auto; border-radius: 10px; background: #15231e; color: #d7e9e1; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
.batch-content { display: flex; flex-direction: column; gap: 7px; }
.batch-row { padding: 9px 10px; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; }
.batch-index { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 800; }
.batch-copy { min-width: 0; }
.batch-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.batch-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.batch-status { padding: 4px 6px; border-radius: 6px; color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 800; }
.batch-status.passed { color: var(--green); background: var(--green-soft); }
.batch-status.failed, .batch-status.blocked { color: var(--red); background: var(--red-soft); }
.dsl-details { margin-top: 10px; }
.dsl-details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.dsl-details[open] summary { margin-bottom: 8px; }
.dsl-details .code-block { min-height: 220px; max-height: 320px; }
.gate-summary { padding: 12px; margin-bottom: 10px; border-radius: 10px; background: var(--green-soft); color: var(--green); }
.gate-summary.blocked { background: var(--red-soft); color: var(--red); }
.gate-summary strong { display: block; margin-bottom: 4px; font-size: 14px; }
.gate-summary span { font-size: 12px; }
.gate-list { display: flex; flex-direction: column; gap: 8px; }
.gate-item { padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.gate-item-header { display: grid; grid-template-columns: 18px 1fr auto; gap: 7px; align-items: center; }
.gate-check { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.gate-item.blocked .gate-check { background: var(--red-soft); color: var(--red); }
.gate-item h3 { margin: 0; font-size: 12px; }
.gate-item-header span:last-child { color: var(--quiet); font-size: 12px; text-transform: uppercase; }
.gate-errors { margin: 8px 0 0 25px; padding: 0; color: var(--red); font-size: 12px; line-height: 1.45; }
.artifact-hero { padding: 14px; margin-bottom: 10px; border-radius: 11px; background: #15231e; color: white; }
.artifact-hero .artifact-mark { width: 34px; height: 34px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 9px; background: #285b49; color: #8ce4c1; font-weight: 800; }
.artifact-hero strong { display: block; margin-bottom: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.artifact-hero span { color: #a9beb5; font-size: 12px; }
.artifact-row { padding: 9px 0; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); font-size: 12px; }
.artifact-row span { color: var(--muted); }
.artifact-row strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.artifact-note { margin-top: 11px; padding: 9px; border-radius: 8px; background: var(--amber-soft); color: #7c571f; line-height: 1.5; font-size: 12px; }
.result-action { margin-top: 12px; }
.empty-state { padding: 36px 14px; text-align: center; color: var(--quiet); font-size: 12px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 14px; border-radius: 9px; background: #15231e; color: white; box-shadow: 0 15px 45px rgba(20,35,30,.25); font-size: 12px; }

/* PC operational copy remains readable; reserve 12px for IDs, units and provenance. */
.task-row,
.seed-copy p,
.delta-row,
.event-item,
.empty-event,
.object-card-header h3,
.property-list,
.batch-copy span,
.dsl-details summary,
.gate-summary span,
.gate-item h3,
.gate-errors,
.artifact-row,
.artifact-note,
.empty-state,
.toast { font-size: 13px; }

@media (min-width: 1700px) {
  .workspace { grid-template-columns: 350px minmax(650px, 1fr) 390px; padding: 16px 20px; gap: 16px; }
  .center-column { grid-template-rows: auto minmax(360px, 1fr) auto auto 124px; }
  .metric-card { padding: 12px 13px; }
  .metric-card strong { font-size: 21px; }
}

@media (max-height: 820px) {
  .workspace { padding-top: 10px; padding-bottom: 10px; }
  .center-column { grid-template-rows: auto minmax(280px, 1fr) auto auto 100px; gap: 7px; }
  #simulation-canvas { min-height: 280px; }
  .metric-card { padding-top: 8px; padding-bottom: 8px; }
  .event-list { height: 56px; }
}
