:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  background: #171717;
  color: #f5f5f4;
  --canvas: #171717;
  --surface: #242424;
  --surface-raised: #2a2a2a;
  --surface-deep: #1d1d1d;
  --line: #454545;
  --line-soft: #353535;
  --text: #f5f5f4;
  --muted: #a1a1aa;
  --quiet: #71717a;
  --accent: #ff7a45;
  --danger: #fb7f7f;
  --composer-height: 168px;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid rgba(255, 122, 69, .82); outline-offset: 2px; }

.shell { width: min(100%, 940px); min-height: 100vh; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 30px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 15px; font-weight: 720; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 9px; color: var(--accent); background: #202020; font-size: 16px; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--quiet); font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #6b7280; }
.connection.online { color: #bdbdbd; }
.connection.online .dot { background: #5dd39e; box-shadow: 0 0 0 4px rgba(93, 211, 158, .1); }
.connection.warning .dot { background: #f5bc61; }

.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 760; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; color: var(--text); font-size: clamp(28px, 8vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin: 0; color: var(--text); font-size: 21px; line-height: 1.2; letter-spacing: -.03em; }
.lede { max-width: 620px; margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 32px 0 13px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.panel, .project-card, .session-row, .message-card, .tool-card { border: 1px solid var(--line-soft); background: var(--surface); }
.panel { padding: 20px; border-radius: 20px; }
.project-list, .session-list, .conversation { display: grid; gap: 10px; }
.github-connection { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 16px; padding: 16px 18px; }
.github-connection strong { display: block; font-size: 15px; }
.github-connection .eyebrow { margin-bottom: 5px; }
.github-connection .small-note { max-width: 560px; }
.project-card { width: 100%; padding: 18px; border-radius: 15px; color: inherit; text-align: left; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.project-card:hover, .project-card:focus-visible { border-color: #5a5a5a; background: #2b2b2b; transform: translateY(-1px); outline: none; }
.project-summary { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.45; }
.session-row { overflow: hidden; border-radius: 15px; transition: border-color .16s ease, background .16s ease; }
.session-row.is-archived { opacity: .72; }
.session-open { width: 100%; border: 0; padding: 17px 18px; color: inherit; background: transparent; text-align: left; }
.session-open:hover, .session-open:focus-visible { background: #2b2b2b; outline: none; }
.session-row:focus-within { border-color: #5b5b5b; }
.row-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-title { font-size: 16px; font-weight: 700; letter-spacing: -.018em; }
.row-meta { margin-top: 7px; color: var(--muted); font-size: 13px; }
.chevron { color: var(--accent); font-size: 22px; line-height: 1; }
.session-statuses { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.archive-tag { display: inline-flex; align-items: center; padding: 4px 7px; border: 1px solid rgba(245, 188, 97, .34); border-radius: 999px; color: #f7ca80; font-size: 11px; font-weight: 700; }
.session-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 14px 13px; border-top: 1px solid var(--line-soft); }
.session-action { border: 1px solid #4a4a4a; border-radius: 9px; padding: 7px 9px; color: #dedede; background: #202020; font-size: 12px; font-weight: 680; }
.session-action:hover, .session-action:focus-visible { border-color: #797979; background: #292929; outline: none; }
.session-action:disabled { cursor: not-allowed; opacity: .45; }
.danger-text { color: #ffaaa5; }
.session-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 13px; }
.session-search { min-width: 0; padding: 10px 12px; }
.archive-filter { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.archive-filter input { accent-color: var(--accent); }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid #4b4b4b; border-radius: 999px; color: #c6c6c6; font-size: 10px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.status.running { border-color: rgba(93, 211, 158, .46); color: #8ee2b9; }
.status.error, .status.failed, .status.cancelled { border-color: rgba(251, 127, 127, .48); color: #ffaaa5; }
.status.succeeded, .status.idle { color: #d0d0d0; }

.action { border: 0; border-radius: 11px; padding: 11px 14px; color: #171717; background: #f0f0ed; font-weight: 760; transition: opacity .16s ease, transform .16s ease, background .16s ease; }
.action:hover { background: #fff; transform: translateY(-1px); }
.action:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.action.secondary { border: 1px solid #4d4d4d; color: #e1e1e1; background: transparent; }
.action.secondary:hover { background: #2d2d2d; }
.action.danger { color: #ffe9e6; background: #8a3b3b; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 9px; }
@media (max-width: 560px) { .github-connection { align-items: flex-start; flex-direction: column; } }

.auth { max-width: 500px; margin: clamp(35px, 12vh, 110px) auto 0; }
.auth h1 { overflow-wrap: anywhere; font-size: clamp(32px, 8vw, 44px); }
.field-label { display: block; margin: 22px 0 8px; color: #e7e7e7; font-size: 13px; font-weight: 680; }
.input, .composer textarea, .run-select select { width: 100%; border: 1px solid #484848; border-radius: 12px; outline: none; color: var(--text); background: var(--surface-deep); padding: 12px 13px; }
.input:focus, .composer textarea:focus, .run-select select:focus { border-color: rgba(255, 122, 69, .82); box-shadow: 0 0 0 3px rgba(255, 122, 69, .12); }
.small-note { margin: 10px 0 0; color: var(--quiet); font-size: 12px; line-height: 1.5; }
.form-error, .notice { margin-top: 13px; color: #ffaaa5; font-size: 13px; line-height: 1.45; }
.notice { color: #c8c8c8; }
.mode-notice { margin: 13px 0 0; padding: 10px 12px; border: 1px solid rgba(245, 188, 97, .3); border-radius: 12px; color: #f4cd91; background: rgba(124, 85, 28, .16); font-size: 13px; line-height: 1.5; }

.back { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; color: var(--muted); background: transparent; font-weight: 650; }
.back:hover { color: var(--text); }
.empty { padding: 26px 18px; border: 1px dashed #4a4a4a; border-radius: 14px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.55; }
.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: end center; padding: 18px; background: rgba(0, 0, 0, .66); backdrop-filter: blur(4px); }
.session-dialog, .project-dialog { width: min(100%, 520px); padding: 22px; border-color: #555; box-shadow: 0 24px 60px rgba(0, 0, 0, .46); }
.session-dialog .lede { margin-top: 12px; }
.project-dialog .input { display: block; }
.project-description { min-height: 92px; resize: vertical; }
.project-binding { margin: 12px 0 0; color: #c5c5c5; font-size: 13px; }
.project-description-copy { margin-top: 12px; }

.conversation-head { position: sticky; top: 0; z-index: 2; margin: 0 -4px; padding: 6px 4px 14px; background: linear-gradient(var(--canvas) 78%, transparent); }
.conversation-head .row-main { align-items: flex-start; }
.conversation { padding-bottom: calc(var(--composer-height) + 18px); }
.message-card { padding: 14px 15px; border-radius: 16px; }
.message-card.user { border-color: #4c4b49; background: #2c2a28; }
.message-card.assistant { background: #232323; }
.message-label { margin-bottom: 7px; color: var(--accent); font-size: 11px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.message-card.user .message-label { color: #d3d0cb; }
.message-text { color: #f1f1ef; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.58; }
.message-body { color: #eeeeec; overflow-wrap: anywhere; font-size: 14px; line-height: 1.62; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre, .markdown-body table, .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 0 0 13px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { color: #fafaf9; line-height: 1.25; letter-spacing: -.02em; }
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 19px; }
.markdown-body h3 { font-size: 17px; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 15px; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.markdown-body li + li { margin-top: 5px; }
.markdown-body blockquote { padding: 2px 0 2px 12px; border-left: 3px solid rgba(255, 122, 69, .65); color: #c5c5c3; }
.markdown-body a { color: #ff9d78; text-decoration: underline; text-underline-offset: 2px; }
.markdown-body code { padding: 2px 5px; border-radius: 5px; color: #fff0e9; background: #191919; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .91em; }
.markdown-body .markdown-code { max-width: 100%; padding: 12px 13px; border: 1px solid #404040; border-radius: 10px; overflow: auto; background: #181818; }
.markdown-body .markdown-code code { display: block; padding: 0; color: #e5e5e5; white-space: pre; background: transparent; font-size: 12px; line-height: 1.55; }
.markdown-body hr { margin: 18px 0; border: 0; border-top: 1px solid #414141; }
.markdown-table-wrap { max-width: 100%; margin-bottom: 13px; overflow-x: auto; }
.markdown-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.markdown-body th, .markdown-body td { min-width: 90px; padding: 7px 9px; border: 1px solid #454545; text-align: left; vertical-align: top; }
.markdown-body th { color: #efefed; background: #2d2d2d; font-weight: 700; }
.markdown-image-placeholder { color: var(--muted); font-style: italic; }
.message-body.is-collapsed { position: relative; max-height: 360px; overflow: hidden; }
.message-body.is-collapsed::after { position: absolute; right: 0; bottom: 0; left: 0; height: 90px; background: linear-gradient(transparent, #232323); content: ""; pointer-events: none; }
.message-toggle { display: block; margin: 11px 0 0; padding: 0; border: 0; color: #ff9d78; background: transparent; font-size: 13px; font-weight: 700; }
.message-toggle:hover, .message-toggle:focus-visible { color: #ffd2c1; text-decoration: underline; text-underline-offset: 3px; outline: none; }
.tool-list { display: grid; gap: 7px; margin: 0 0 4px; }
.tool-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 11px; }
.tool-card span { color: #ddddda; font-size: 13px; }
.tool-card small { color: var(--muted); font-size: 11px; }
.media-card { width: min(100%, 640px); margin: 9px 0 5px; overflow: hidden; scroll-margin-block-end: calc(var(--composer-height) + 18px); border: 1px solid #454545; border-radius: 14px; background: #1e1e1e; }
.media-card.is-collapsed { display: flex; align-items: center; gap: 9px; min-height: 76px; padding: 8px; }
.media-compact { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; border: 0; padding: 0; color: inherit; background: transparent; text-align: left; }
.media-compact:hover .media-compact-copy strong, .media-compact:focus-visible .media-compact-copy strong { color: #ffd2c1; }
.media-thumbnail { display: grid; place-items: center; flex: 0 0 auto; width: 58px; height: 58px; border: 1px solid #505050; border-radius: 10px; color: #f5f5f4; background: linear-gradient(145deg, #383838, #202020); font-size: 18px; }
.media-thumbnail-video { color: #ffc0aa; background: linear-gradient(145deg, #603327, #251f1e); }
.media-thumbnail-image { color: #b8dbff; background: linear-gradient(145deg, #2b4356, #1e252b); }
.media-compact-copy { display: grid; min-width: 0; gap: 4px; }
.media-compact-copy strong { overflow: hidden; color: #eeeeec; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.media-compact-copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.media-expand, .media-collapse, .media-open, .media-retry { flex: 0 0 auto; border: 0; padding: 4px 0; color: #ff9d78; background: transparent; font-size: 12px; font-weight: 700; }
.media-expand:hover, .media-expand:focus-visible, .media-collapse:hover, .media-collapse:focus-visible, .media-open:hover, .media-open:focus-visible, .media-retry:hover, .media-retry:focus-visible { color: #ffd2c1; text-decoration: underline; text-underline-offset: 3px; outline: none; }
.media-card-head, .media-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; }
.media-card-head { border-bottom: 1px solid #383838; color: var(--accent); font-size: 11px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.media-card-head small { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: normal; text-transform: none; }
.media-preview { display: grid; min-height: 116px; max-height: min(48svh, 440px); place-items: center; overflow: hidden; padding: 10px; background: #151515; }
.media-image, .media-player { display: block; max-width: 100%; max-height: min(48svh, 440px); border-radius: 9px; }
.media-image { object-fit: contain; }
.media-player { width: auto; height: auto; background: #080808; }
.media-loading { padding: 28px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.media-loading.media-error { display: grid; gap: 9px; justify-items: center; color: #ffaaa5; }
.media-card-footer strong { min-width: 0; overflow: hidden; color: #eeeeec; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.media-open:disabled { color: #777; }
.media-viewer { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(0, 0, 0, .78); backdrop-filter: blur(7px); }
.media-viewer-dialog { display: grid; width: min(100%, 980px); max-height: calc(100svh - 36px); overflow: hidden; border: 1px solid #5a5a5a; border-radius: 18px; background: #1b1b1b; box-shadow: 0 28px 72px rgba(0, 0, 0, .56); }
.media-viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-bottom: 1px solid #3d3d3d; }
.media-viewer-head > div { display: grid; min-width: 0; gap: 3px; }
.media-viewer-head strong { overflow: hidden; color: #f2f2ef; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.media-viewer-kicker { color: var(--accent); font-size: 10px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.media-viewer-close { display: grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border: 1px solid #535353; border-radius: 9px; color: #f2f2ef; background: #292929; font-size: 23px; line-height: 1; }
.media-viewer-close:hover, .media-viewer-close:focus-visible { border-color: #787878; background: #363636; outline: none; }
.media-viewer-stage { display: grid; min-height: 0; place-items: center; overflow: auto; padding: 14px; background: #101010; }
.media-viewer-media { max-width: 100%; max-height: calc(100svh - 132px); border-radius: 10px; }

.composer-wrap { position: fixed; right: 0; bottom: 0; left: 0; z-index: 3; padding: 22px max(18px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: linear-gradient(transparent, var(--canvas) 30%); }
.composer { width: min(calc(100% - 36px), 900px); margin: 0 auto; overflow: hidden; border: 1px solid #484848; border-radius: 24px; background: var(--surface); box-shadow: 0 16px 50px rgba(0, 0, 0, .34); }
.composer-settings { padding: 15px; border-bottom: 1px solid var(--line-soft); background: #202020; }
.composer-settings[hidden] { display: none; }
.composer-settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 0 0 13px; color: var(--muted); font-size: 12px; }
.composer-settings-head > div { display: grid; gap: 3px; }
.composer-settings-head strong { color: #e6e6e4; font-size: 14px; }
.composer-kicker { color: var(--accent); font-size: 10px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.run-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.run-select { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 720; letter-spacing: .04em; }
.run-select.repo-select { grid-column: span 3; }
.run-select select { min-width: 0; padding: 9px 10px; color: #ededeb; font-size: 13px; letter-spacing: normal; }
.run-select select:disabled { cursor: not-allowed; opacity: .5; }
.composer-input { display: grid; gap: 2px; padding: 7px 9px 8px 14px; }
.composer textarea { min-height: 62px; max-height: 164px; border: 0; padding: 9px 2px 4px; background: transparent; box-shadow: none; resize: none; font-size: 16px; line-height: 1.45; }
.composer textarea::placeholder { color: #898989; }
.composer textarea:focus { box-shadow: none; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.composer-settings-toggle { display: flex; align-items: center; gap: 7px; min-width: 0; border: 0; padding: 7px 6px; color: #d8d8d6; background: transparent; font-size: 13px; font-weight: 650; text-align: left; }
.composer-settings-toggle:hover { color: var(--text); }
.composer-settings-toggle:disabled { cursor: not-allowed; opacity: .5; }
.control-icon { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #505050; border-radius: 7px; color: var(--accent); font-size: 13px; line-height: 1; }
.composer-summary { overflow: hidden; color: var(--quiet); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.send { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; min-width: 42px; border-radius: 50%; padding: 0; font-size: 25px; font-weight: 450; line-height: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.boot { display: grid; place-content: center; min-height: 90vh; gap: 12px; color: var(--muted); text-align: center; }
.pulse { width: 12px; height: 12px; margin: 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(255, 122, 69, .45); animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 11px rgba(255, 122, 69, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 122, 69, 0); } }

@media (min-width: 720px) {
  .shell { padding-right: 28px; padding-left: 28px; }
  .project-list { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 25px; }
  .modal-backdrop { place-items: center; }
}

@media (max-width: 560px) {
  .topbar { margin-bottom: 22px; }
  .connection { font-size: 11px; }
  .composer-wrap { padding-top: 16px; }
  .composer { width: min(calc(100% - 24px), 900px); border-radius: 21px; }
  .run-controls { grid-template-columns: 1fr; }
  .run-select.repo-select { grid-column: auto; }
  .composer-summary { display: none; }
  .media-card { width: 100%; }
  .media-preview { max-height: min(46svh, 390px); }
  .media-image, .media-player { max-height: min(46svh, 390px); }
  .media-viewer { padding: 10px; }
  .media-viewer-dialog { max-height: calc(100svh - 20px); border-radius: 14px; }
  .media-viewer-media { max-height: calc(100svh - 112px); }
}

@media (max-width: 440px) {
  .shell { padding-right: 14px; padding-left: 14px; }
  .session-toolbar { align-items: stretch; flex-direction: column; }
  .archive-filter { padding-left: 2px; }
  .composer-settings-head > span { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
