/* Startrail SDK playground — page styles.
   The SDK's login modal is NOT styled here: it renders in a Shadow DOM and is
   themed through customUi.theme (section 2) or --startrail-modal-* variables. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --border: #dde2e8;
  --border-strong: #c7cdd6;
  --text: #16191d;
  --muted: #626b77;
  --accent: #4a156c;
  --accent-contrast: #ffffff;
  --accent-weak: #f3ecf9;
  --ok: #007f5f; --ok-bg: #e8f8f1;
  --warn: #9a6100; --warn-bg: #fff6e0;
  --err: #d0263b; --err-bg: #fdecef;
  --info: #0c70b8; --info-bg: #eaf4fd;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --topbar-h: 52px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116; --panel: #161a21; --panel-2: #1d222b; --border: #2a313c; --border-strong: #3a4350;
    --text: #e7eaee; --muted: #98a2b3; --accent: #c9a6e6; --accent-contrast: #1b1020; --accent-weak: #2a2136;
    --ok: #4ade80; --ok-bg: #10241a; --warn: #fbbf24; --warn-bg: #2a2410; --err: #f87171; --err-bg: #2a1514; --info: #7cc0f5; --info-bg: #12263a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116; --panel: #161a21; --panel-2: #1d222b; --border: #2a313c; --border-strong: #3a4350;
  --text: #e7eaee; --muted: #98a2b3; --accent: #c9a6e6; --accent-contrast: #1b1020; --accent-weak: #2a2136;
  --ok: #4ade80; --ok-bg: #10241a; --warn: #fbbf24; --warn-bg: #2a2410; --err: #f87171; --err-bg: #2a1514; --info: #7cc0f5; --info-bg: #12263a;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body { margin: 0; font-family: var(--sans); font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--accent-weak); padding: 1px 5px; border-radius: 4px; }
pre.code { margin: 0; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.code-scroll { max-height: 240px; overflow: auto; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.hint { color: var(--muted); font-size: 12.5px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 6px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.skip-link:focus { top: 8px; }
abbr[title] { text-decoration: none; color: var(--err); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; min-height: var(--topbar-h); padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.status-item { display: inline-flex; align-items: center; gap: 6px; }
.status b { color: var(--text); font-weight: 600; }
.status .link { font-weight: 600; }
.status .link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.status-busy { color: var(--warn); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--warn); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-control { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.topbar-control select { width: auto; padding: 3px 6px; font-size: 12px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); font-size: 11px; font-weight: 700; }
.count-error { background: var(--err-bg); color: var(--err); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr) 400px; gap: 0; align-items: start; }
.nav { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--panel); }
.nav ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a[aria-current="true"] { background: var(--accent-weak); color: var(--accent); }
.step-no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 700; flex: none; }
.nav a[aria-current="true"] .step-no, .section-head .step-no { background: var(--accent); color: var(--accent-contrast); }
.nav-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.nav-foot a { color: var(--muted); text-decoration: none; }
.nav-foot a:hover { color: var(--text); }
main { min-width: 0; padding: 24px 28px 80px; display: flex; flex-direction: column; gap: 40px; }

/* ---------- sections ---------- */
.section { scroll-margin-top: calc(var(--topbar-h) + 12px); display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; flex-direction: column; gap: 6px; max-width: 900px; }
.section-head h2 { display: flex; align-items: center; gap: 10px; }
.section-head p { color: var(--muted); }
.group-title { margin-top: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.hero { display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
.hero p { color: var(--muted); font-size: 15px; }
.lifecycle { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.lifecycle li { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.lifecycle li span { color: var(--muted); font-size: 12.5px; }
.lifecycle li b { font-size: 14px; }
.checklist-card { max-width: 900px; display: flex; flex-direction: column; gap: 12px; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.checklist li.done { color: var(--text); }
.check-mark { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.checklist li.done .check-mark { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 3px var(--panel); }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-actions { display: inline-flex; gap: 6px; }
.card-actions button { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }
.snippet-card { position: sticky; top: calc(var(--topbar-h) + 12px); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 12px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* ---------- method cards ---------- */
.method { display: flex; flex-direction: column; gap: 10px; }
.method-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.method-head h3 { font-family: var(--mono); font-size: 14px; }
.doc-link { margin-left: auto; font-size: 12px; color: var(--muted); text-decoration: none; }
.doc-link:hover { color: var(--accent); }
.summary { color: var(--muted); font-size: 13px; }
.summary em { color: var(--warn); font-style: normal; }
.method-form { display: flex; flex-direction: column; gap: 10px; }
.method-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.uses { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.uses-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); font: inherit; font-size: 11.5px; color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip-key { color: var(--muted); }
.chip-value { font-family: var(--mono); }
.chip-empty .chip-value { color: var(--err); }
.code-details > summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.code-details > pre { margin-top: 6px; }
.result { display: flex; flex-direction: column; gap: 6px; }
.result:empty { display: none; }
.result-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.result-message { color: var(--err); font-weight: 600; }
.result-pre { max-height: 280px; overflow: auto; }

/* ---------- badges + pills ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.badge-auth { background: var(--accent-weak); color: var(--accent); }
.badge-read { background: var(--info-bg); color: var(--info); }
.badge-offline { background: var(--panel-2); color: var(--muted); }
.badge-write { background: var(--warn-bg); color: var(--warn); }
.badge-deprecated { background: var(--err-bg); color: var(--err); }
.badge-new { background: var(--ok-bg); color: var(--ok); text-transform: uppercase; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-running { background: var(--warn-bg); color: var(--warn); }
.pill-running::before { content: ''; width: 10px; height: 10px; border: 2px solid var(--warn); border-top-color: transparent; border-radius: 50%; animation: spin 0.9s linear infinite; }
.pill-success { background: var(--ok-bg); color: var(--ok); }
.pill-false { background: var(--warn-bg); color: var(--warn); }
.pill-error { background: var(--err-bg); color: var(--err); }
.pill-info { background: var(--info-bg); color: var(--info); }

/* ---------- forms ---------- */
fieldset { margin: 0; padding: 10px 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 0; }
legend { padding: 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-actions { display: inline-flex; gap: 10px; font-size: 12px; }
.field-help { font-size: 11.5px; color: var(--muted); }
.field-error { font-size: 11.5px; color: var(--err); font-weight: 600; }
input:not([type="checkbox"]):not([type="color"]):not([type="range"]), select, textarea {
  font: inherit; font-size: 13px; color: var(--text); width: 100%; min-width: 0; padding: 7px 9px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
textarea { font-family: var(--mono); font-size: 12px; line-height: 1.45; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
[aria-invalid="true"] { border-color: var(--err) !important; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
input[type="color"] { width: 36px; height: 34px; padding: 2px; flex: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.color-pair { display: flex; gap: 6px; align-items: center; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.checks-row { align-items: center; }
details > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
details > .grid { margin-top: 10px; }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
button { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); cursor: pointer; transition: border-color 0.12s, background 0.12s; }
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
button.ghost { background: transparent; }
button.link { padding: 0; border: 0; background: none; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.presets-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
[data-preset][aria-pressed="true"] { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.provider { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; }
.provider span { font-size: 11.5px; font-weight: 500; color: var(--muted); }

/* ---------- scenarios ---------- */
.stepper { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stepper li { display: flex; align-items: center; gap: 10px; }
.stepper li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.stepper li[data-status="done"]::before { background: var(--ok); }
.stepper li[data-status="fail"]::before { background: var(--err); }
.callout { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin: 8px 0; }
.callout-muted { background: var(--panel-2); color: var(--muted); }
.callout-success { background: var(--ok-bg); color: var(--ok); }
.callout-error { background: var(--err-bg); color: var(--err); }
.storage-details { margin-top: 10px; }
.storage-details pre { margin-top: 8px; font-size: 11.5px; }

/* ---------- activity ---------- */
.activity { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--panel); }
.activity-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.activity-head select { width: auto; padding: 3px 6px; font-size: 12px; }
.activity-head button { padding: 4px 8px; font-size: 12px; }
.activity-close { display: none; }
.spacer { flex: 1; }
.activity-list { flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.activity-list .empty { padding: 24px 12px; color: var(--muted); text-align: center; }
.entry { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--panel-2); }
.entry > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; cursor: pointer; list-style: none; }
.entry > summary::-webkit-details-marker { display: none; }
.entry-label { font-weight: 600; flex: 1; min-width: 120px; }
.entry-meta { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.entry pre { margin: 0 8px 8px; padding: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.entry-note { margin: 0 8px 4px; font-size: 12px; color: var(--muted); }
.entry-success { border-left-color: var(--ok); }
.entry-false { border-left-color: var(--warn); }
.entry-error { border-left-color: var(--err); }
.entry-running { border-left-color: var(--warn); }
.entry-info { border-left-color: var(--border-strong); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); font-size: 13px; animation: toast-in 0.2s ease-out; }
.toast-success { border-left: 3px solid var(--ok); }
.toast-warn { border-left: 3px solid var(--warn); }
.toast-error { border-left: 3px solid var(--err); }
.toast-info { border-left: 3px solid var(--info); }
.toast-close { margin-left: auto; padding: 0 4px; border: 0; background: none; font-size: 16px; line-height: 1; color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- responsive ---------- */
.activity-toggle { display: none; }
@media (max-width: 1280px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .activity-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .activity { position: fixed; inset: var(--topbar-h) 0 0 auto; width: min(460px, 100vw); transform: translateX(100%); transition: transform 0.2s ease-out; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15); z-index: 30; }
  body.activity-open .activity { transform: none; }
  .activity-close { display: inline-block; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: var(--topbar-h); height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); z-index: 10; }
  .nav ol { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .nav-foot { display: none; }
  main { padding: 16px 16px 72px; gap: 32px; }
  .two-col { grid-template-columns: 1fr; }
  .snippet-card { position: static; }
  .status { display: none; }
  h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner, .pill-running::before { animation-duration: 2s; }
  .toast { animation: none; }
  .activity { transition: none; }
  button { transition: none; }
}
