/* scs studio — production stylesheet. Theme via CSS custom properties;
   [data-theme="dark"] overrides. See DESIGN.md for tokens. */

:root {
  --bg: #ffffff; --fg: #1f2328; --muted: #656d76;
  --surface: #f6f8fa; --border: #d0d7de;
  --accent: #0969da; --active: #1a7f37; --danger: #cf222e;
  --node-active: #dafbe1;
  --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
[data-theme="dark"] {
  --bg: #0d1117; --fg: #e6edf3; --muted: #8b949e;
  --surface: #161b22; --border: #30363d;
  --accent: #2f81f7; --active: #3fb950; --danger: #f85149;
  --node-active: #0f2417;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--fg);
}
/* simulator pages get a full-height, non-scrolling app shell */
body.sim { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* header bar */
header.bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex: 0 0 auto;
}
header.bar .title { font-weight: 600; font-size: 1rem; }
header.bar .machine { color: var(--muted); font-family: ui-monospace, monospace; }
header.bar .spacer { flex: 1; }
header.bar .badge {
  font-size: .7rem; padding: .1rem .45rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em;
}
header.bar .badge.running { color: var(--active); border-color: var(--active); }
header.bar .badge.done { color: var(--accent); border-color: var(--accent); }
header.bar .badge.disconnected { color: var(--danger); border-color: var(--danger); }

button, .btn {
  font: inherit; font-size: .85rem; cursor: pointer;
  padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg);
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { padding: .35rem .5rem; }

/* layout */
main.layout { flex: 1; display: flex; min-height: 0; }
.graph-pane {
  flex: 1.6; min-width: 0; position: relative; overflow: hidden;
  background: var(--bg); border-right: 1px solid var(--border);
}
.graph-pane .mermaid-host {
  position: absolute; inset: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.graph-pane .mermaid-host svg { max-width: none; cursor: grab; }
.graph-pane .zoom-hint {
  position: absolute; bottom: .5rem; left: .6rem; font-size: .7rem;
  color: var(--muted); background: var(--surface); padding: .1rem .4rem;
  border-radius: 4px; border: 1px solid var(--border);
}

.inspector {
  flex: 1; min-width: 300px; max-width: 460px; overflow-y: auto;
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: 1rem;
}
.inspector h2 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 .35rem;
}
.inspector .panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem .7rem; }
#state-path { font-family: ui-monospace, monospace; font-size: .82rem; word-break: break-all; }

#event-btns { display: flex; flex-wrap: wrap; gap: .35rem; }
.evt-btn {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  font-family: ui-monospace, monospace; font-size: .78rem;
}

#context {
  margin: 0; font-family: ui-monospace, monospace; font-size: .78rem;
  white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto;
}
#context .hit { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 2px; }
.filter-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.filter-row input { flex: 1; padding: .3rem .45rem; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--fg); font: inherit; font-size: .8rem; }

/* timeline */
#timeline { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto;
  font-family: ui-monospace, monospace; font-size: .76rem; }
#timeline li { padding: .25rem .4rem; border-radius: 5px; cursor: pointer;
  display: flex; justify-content: space-between; gap: .5rem; }
#timeline li:hover { background: var(--surface); }
#timeline li .ev { color: var(--accent); }
#timeline li .arrow { color: var(--muted); }

/* toasts */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex;
  flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: .5rem .75rem;
  box-shadow: var(--shadow); font-size: .82rem; max-width: 340px;
  animation: toast-in .15s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--active); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* index + static /m pages */
.index-wrap { padding: 2rem; max-width: 80ch; margin: 0 auto; }
table { border-collapse: collapse; width: 100%; }
td, th { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
pre.diagram, pre.sidebar {
  background: var(--surface); color: var(--fg); padding: 1rem; border-radius: var(--radius);
  overflow: auto; font-family: ui-monospace, monospace; font-size: .82rem; line-height: 1.4;
  border: 1px solid var(--border);
}
.index-wrap form { margin: 1rem 0; padding: .75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.index-wrap input { padding: .3rem; font: inherit; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--fg); }

/* responsive: stack panes */
@media (max-width: 760px) {
  main.layout { flex-direction: column; }
  .graph-pane { border-right: none; border-bottom: 1px solid var(--border); min-height: 45vh; }
  .inspector { max-width: none; }
}
