:root {
  --bulma-primary-h: 256deg;
  --bulma-primary-s: 72%;
  --bulma-primary-l: 58%;
  /* Bulma derives dark text for this hue, which lands at 3.5:1 on the primary
     background. White is 5.7:1 and clears WCAG AA. */
  --bulma-primary-invert-l: 100%;
  --bulma-link-h: 256deg;
  --bulma-link-s: 72%;
  --bulma-link-l: 58%;
  --bulma-family-primary: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bulma-family-code: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --bulma-radius: 0.5rem;
  --bulma-radius-large: 0.75rem;
  --app-sidebar-width: 15rem;
  --app-sidebar-bg: #16132b;
  --app-sidebar-fg: #c9c4e8;
  --app-sidebar-active: #2a2550;
  --app-surface: #f7f7fb;
  --app-border: #e7e6f0;
  --app-muted: #6b6883;
  --app-succeeded: #1f9d62;
  --app-failed: #d9384f;
  --app-running: #6d4ae6;
  --app-skipped: #9a98ad;
  --app-pending: #b3b1c4;
}

html { background: var(--app-surface); scroll-behavior: smooth; }
body { min-height: 100vh; }

@view-transition { navigation: auto; }

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--app-sidebar-width);
  flex-shrink: 0;
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1rem 0.75rem;
  z-index: 30;
  view-transition-name: sidebar;
}
.app-sidebar .brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.1rem; padding: .25rem .5rem 1rem; }
.app-sidebar .brand .brand-mark { border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.app-sidebar .menu-label { color: #8a84b5; font-size: .7rem; letter-spacing: .08em; margin: 1.25rem .5rem .5rem; }
.app-sidebar .menu-list a {
  color: var(--app-sidebar-fg);
  display: flex; align-items: center; gap: .6rem;
  border-radius: var(--bulma-radius);
  padding: .5rem .6rem;
  font-size: .925rem;
}
.app-sidebar .menu-list a:hover { background: var(--app-sidebar-active); color: #fff; }
.app-sidebar .menu-list a.is-active { background: var(--app-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #a78bfa; }
.app-sidebar .account-switcher { margin: 0 .25rem; }
.app-sidebar .account-switcher .button { width: 100%; justify-content: space-between; background: var(--app-sidebar-active); border: none; color: #fff; }
.app-sidebar .sidebar-footer { margin-top: auto; padding: .5rem; font-size: .8rem; color: #8a84b5; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.5rem; background: #fff; border-bottom: 1px solid var(--app-border);
  position: sticky; top: 0; z-index: 20;
}
.app-topbar .breadcrumb { margin: 0; font-size: .9rem; }
.app-content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.app-content.is-flush { max-width: none; }

.sidebar-toggle { display: none; }
@media (max-width: 1023px) {
  .app-sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .app-shell.sidebar-open .app-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar-toggle { display: inline-flex; }
}

.icon svg { width: 1.1em; height: 1.1em; }
.icon.is-large svg { width: 2em; height: 2em; }
svg.lucide { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header .title { margin-bottom: .25rem !important; }
.page-header .subtitle { color: var(--app-muted); font-size: .95rem; }

.card, .box { box-shadow: none; border: 1px solid var(--app-border); }
.card-header { box-shadow: none; border-bottom: 1px solid var(--app-border); }
.box.is-hoverable { transition: border-color .15s ease, transform .15s ease; }
.box.is-hoverable:hover { border-color: hsl(var(--bulma-primary-h), var(--bulma-primary-s), 80%); transform: translateY(-1px); }

.table { font-size: .925rem; }
.table td, .table th { vertical-align: middle; }
.table tbody tr { transition: background .3s ease; }

.stat { padding: 1.1rem 1.25rem; }
.stat .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat .stat-label { color: var(--app-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }

.status-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--app-pending); flex-shrink: 0; }
.status-succeeded .status-dot, .status-enabled .status-dot, .status-connected .status-dot, .status-dot.is-succeeded { background: var(--app-succeeded); }
.status-failed .status-dot, .status-failing .status-dot, .status-dot.is-failed { background: var(--app-failed); }
.status-draft .status-dot, .status-unverified .status-dot, .status-past .status-dot { background: #e0a100; }
.status-running .status-dot, .status-dot.is-running { background: var(--app-running); animation: pulse 1.2s ease-in-out infinite; }
.status-skipped .status-dot, .status-cancelled .status-dot { background: var(--app-skipped); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(109,74,230,.5); } 50% { box-shadow: 0 0 0 .35rem rgba(109,74,230,0); } }

.tag.is-status { gap: .4rem; font-weight: 600; text-transform: capitalize; }

pre.code, .code-block {
  background: #1b1830; color: #e6e3f8; border-radius: var(--bulma-radius);
  font-size: .8rem; line-height: 1.55; padding: 1rem 1.1rem; overflow: auto; max-height: 36rem;
}
pre.code.is-light { background: #f3f2f9; color: #2b2940; }
pre.code.json-view { max-height: 22rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline-step .column { min-width: 0; }

/* DAG */
.dag { position: relative; overflow-x: auto; padding: .5rem .25rem 1rem; }
.dag-levels { display: flex; gap: 2.25rem; align-items: flex-start; position: relative; z-index: 1; min-width: min-content; }
.dag-level { display: flex; flex-direction: column; gap: 1rem; min-width: 11.5rem; max-width: 16rem; }
.dag-trigger, .dag-node {
  background: #fff; border: 1px solid var(--app-border); border-radius: var(--bulma-radius-large);
  padding: .75rem .9rem; font-size: .875rem; position: relative;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.dag-node:hover { border-color: hsl(var(--bulma-primary-h), 70%, 75%); }
.dag-trigger { background: #f1edff; border-color: #d9d0ff; }
.dag-node .dag-kind, .dag-trigger .dag-kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); display: flex; align-items: center; gap: .35rem; }
.dag-node .dag-title { font-weight: 600; margin-top: .15rem; }
.dag-node .dag-detail { color: var(--app-muted); font-size: .78rem; margin-top: .2rem; word-break: break-word; }
.dag-node.status-running { border-color: var(--app-running); box-shadow: 0 0 0 3px rgba(109,74,230,.15); }
.dag-node.status-succeeded { border-color: rgba(31,157,98,.5); }
.dag-node.status-failed { border-color: var(--app-failed); box-shadow: 0 0 0 3px rgba(217,56,79,.12); }
.dag-node.status-skipped { opacity: .6; }
.dag-node .dag-condition { font-size: .72rem; color: #8a5a00; background: #fff6e0; border-radius: .3rem; padding: .1rem .35rem; display: inline-block; margin-top: .35rem; }
.dag-edges { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
.dag-edges path { fill: none; stroke: #cbc6e6; stroke-width: 1.5; }
.dag-edges path.is-conditional { stroke-dasharray: 4 4; }

/* Workflow workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 26rem; gap: 1.5rem; align-items: start; }
@media (max-width: 1215px) { .workspace { grid-template-columns: minmax(0, 1fr); } }
.assistant-panel { position: sticky; top: 4.5rem; height: calc(100vh - 6rem); display: flex; flex-direction: column; background: #fff; border: 1px solid var(--app-border); border-radius: var(--bulma-radius-large); overflow: hidden; }
.assistant-panel.is-standalone { position: static; height: calc(100vh - 10rem); }
.assistant-header { padding: .8rem 1rem; border-bottom: 1px solid var(--app-border); display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.assistant-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .85rem; }
.assistant-composer { border-top: 1px solid var(--app-border); padding: .75rem; background: #fcfcfe; }
.assistant-composer textarea { resize: none; min-height: 3.2rem; max-height: 12rem; }
.message { max-width: 92%; font-size: .9rem; line-height: 1.5; }
.message.is-user { align-self: flex-end; background: hsl(var(--bulma-primary-h), 72%, 58%); color: #fff; padding: .6rem .85rem; border-radius: 1rem 1rem .25rem 1rem; white-space: pre-wrap; }
.message.is-assistant { align-self: flex-start; }
.message.is-assistant .message-body-text { background: #f4f3fa; padding: .65rem .9rem; border-radius: 1rem 1rem 1rem .25rem; }
.message.is-assistant .stream-text:empty::after { content: "…"; animation: blink 1s steps(2) infinite; }
.message .content { font-size: .9rem; }
.message .content pre { font-size: .75rem; padding: .6rem; }
.message .content p:not(:last-child) { margin-bottom: .6rem; }
.message .tool-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.message .tool-chips .tag { font-size: .7rem; }
.stream-text { white-space: pre-wrap; }
.thinking-indicator { display: inline-flex; gap: .25rem; align-items: center; color: var(--app-muted); font-size: .85rem; }
.thinking-indicator span { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; animation: bounce 1.2s infinite ease-in-out; }
.thinking-indicator span:nth-child(2) { animation-delay: .15s; }
.thinking-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }

/* Run timeline */
.timeline-step { border: 1px solid var(--app-border); border-radius: var(--bulma-radius-large); background: #fff; margin-bottom: .75rem; }
.timeline-step > summary { list-style: none; cursor: pointer; padding: .8rem 1rem; display: flex; align-items: center; gap: .75rem; }
.timeline-step > summary::-webkit-details-marker { display: none; }
.timeline-step[open] > summary { border-bottom: 1px solid var(--app-border); }
.timeline-step .step-body { padding: 1rem; }
.timeline-step.status-running { border-color: var(--app-running); }
.timeline-step.status-failed { border-color: rgba(217,56,79,.5); }
.log-lines { font-family: var(--bulma-family-code); font-size: .75rem; background: #1b1830; color: #d7d3ef; border-radius: var(--bulma-radius); padding: .6rem .8rem; max-height: 16rem; overflow: auto; }
.log-lines:empty { display: none; }
.log-lines .log-time { color: #7d78a3; margin-right: .6rem; }
.stream-output { background: #f4f3fa; border-radius: var(--bulma-radius); padding: .6rem .8rem; font-size: .85rem; max-height: 16rem; overflow: auto; }
.stream-output:empty { display: none; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--app-muted); }
.empty-state .icon { color: #b8b0e8; margin-bottom: .75rem; }

.hero-prompt { background: linear-gradient(135deg, #221c49 0%, #3b2a8a 60%, #6d4ae6 100%); color: #fff; border-radius: var(--bulma-radius-large); padding: 2rem; }
.hero-prompt .title, .hero-prompt .subtitle { color: #fff; }
.hero-prompt textarea { border: none; }

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #3b2a8a 0, #16132b 55%); padding: 1.5rem; }
.auth-card { width: 100%; max-width: 26rem; }
.auth-brand { color: #fff; display: flex; align-items: center; gap: .6rem; justify-content: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }

.flash-stack { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: 24rem; }
.flash-stack .notification { box-shadow: 0 10px 30px rgba(22,19,43,.2); animation: slide-in .25s ease; }
@keyframes slide-in { from { transform: translateY(1rem); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-card { max-width: 40rem; width: calc(100% - 2rem); border-radius: var(--bulma-radius-large); }
.modal-card-head, .modal-card-foot { background: #fff; }
.modal-card-foot { justify-content: flex-end; gap: .5rem; }
.modal { animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

turbo-frame[busy] { opacity: .65; transition: opacity .2s; }
.turbo-progress-bar { height: 3px; background: #a78bfa; }

.is-mono { font-family: var(--bulma-family-code); }
.has-text-muted { color: var(--app-muted); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-2 { gap: .5rem; }
.token-reveal { word-break: break-all; }

.diff-view span { display: block; white-space: pre-wrap; padding: 0 .4rem; margin: 0 -.4rem; border-radius: .2rem; }
.diff-view .diff-added { background: #dcfce7; color: #166534; }
.diff-view .diff-removed { background: #fee2e2; color: #991b1b; }
.billing-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-radius: 0; padding: .6rem 1.5rem; font-size: .9rem; }
.status-trial .status-dot { background: #3b82f6; }
.status-paused .status-dot { background: var(--app-failed); }

.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.shot-card { display: block; overflow: hidden; color: inherit; }
.shot-cover { aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; background: var(--bulma-scheme-main-bis); color: #b8b0e8; overflow: hidden; }
.shot-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.shot-row { display: grid; grid-template-columns: repeat(var(--shot-columns, 1), minmax(0, 1fr)); gap: 1rem; align-items: start; }
.shot { margin: 0; overflow: hidden; }
.shot-caption { display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; min-width: 0; }
.shot-image { display: block; border-top: 1px solid var(--bulma-border-weak); }
.shot-image img { display: block; width: 100%; height: auto; }
@media (max-width: 768px) { .shot-row { grid-template-columns: minmax(0, 1fr); } }
