:root {
  --bg: #0d0f0e;
  --panel: #121513;
  --panel-2: #171a18;
  --panel-3: #1d211e;
  --line: rgba(238, 245, 239, 0.09);
  --line-strong: rgba(238, 245, 239, 0.16);
  --text: #edf2ee;
  --muted: #8f9992;
  --faint: #5f6862;
  --green: #90e3ad;
  --green-strong: #39ca74;
  --green-deep: #153923;
  --orange: #f4bc72;
  --red: #ff8a84;
  --blue: #8ab9ff;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 68% -20%, rgba(59, 151, 91, 0.12), transparent 38%),
    var(--bg);
}

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

.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line);
  background: rgba(13, 16, 14, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 22px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e8f5ec;
  box-shadow: 0 5px 18px rgba(79, 214, 126, 0.13);
}

.brand-mark svg { width: 21px; fill: #122017; }
.brand-mark .brand-hole { fill: #e8f5ec; }
.brand strong { display: block; font-size: 14px; letter-spacing: .01em; }
.brand span { color: var(--muted); font-size: 11px; }

.new-session {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-2);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: .18s ease;
}

.new-session:hover { background: var(--panel-3); border-color: rgba(144, 227, 173, .35); }
.new-session span { color: var(--green); font-size: 18px; line-height: 1; }

.sidebar-section { margin-top: 28px; }
.section-label {
  margin: 0 8px 8px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.session-row {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 10px 11px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}

.session-row.active { color: var(--text); background: rgba(255, 255, 255, .045); }
.session-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.session-row.active .session-dot { background: var(--green-strong); box-shadow: 0 0 0 4px rgba(57, 202, 116, .1); }
.sidebar-spacer { flex: 1; }

.safety-card {
  padding: 13px;
  border: 1px solid rgba(110, 205, 140, .15);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(47, 112, 67, .13), rgba(20, 24, 21, .65));
}

.safety-title { display: flex; align-items: center; gap: 7px; color: #bceecb; font-size: 11px; font-weight: 700; }
.safety-title svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.safety-card p { margin: 8px 0 10px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.safety-card code { display: block; overflow: hidden; color: #7f9185; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

.topbar {
  height: 82px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 15, 14, .58);
  backdrop-filter: blur(14px);
}

.eyebrow { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.topbar h1 { margin: 5px 0 0; font-size: 17px; line-height: 1; font-weight: 650; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mode-badge { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--faint); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.mode-badge.mock { color: var(--orange); border-color: rgba(244, 188, 114, .2); background: rgba(244, 188, 114, .06); }

.connection { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.connection span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.connection.online span { background: var(--green-strong); box-shadow: 0 0 0 4px rgba(57, 202, 116, .08); }
.connection.error span { background: var(--red); }
.connection b { font-weight: 600; }

.timeline {
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 36px max(28px, calc((100% - 820px) / 2)) 80px;
  scrollbar-width: thin;
  scrollbar-color: #313632 transparent;
}

.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px 0 70px; text-align: center; }
.welcome-orbit { width: 92px; height: 92px; display: grid; place-items: center; border: 1px solid rgba(119, 215, 151, .08); border-radius: 50%; background: radial-gradient(circle, rgba(66, 169, 102, .13), transparent 65%); }
.welcome-core { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid rgba(163, 236, 187, .18); border-radius: 16px; background: linear-gradient(145deg, #1e2e23, #141a16); box-shadow: 0 14px 38px rgba(0,0,0,.3); transform: rotate(-3deg); }
.welcome-core svg { width: 28px; fill: #b8edc8; }
.welcome-core .welcome-hole { fill: #182219; }
.welcome-kicker { margin: 21px 0 8px; color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .2em; }
.welcome h2 { margin: 0; font-size: clamp(26px, 4vw, 38px); font-weight: 590; letter-spacing: -.045em; }
.welcome-copy { max-width: 480px; margin: 14px auto 23px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggestions button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); color: #a6afa9; font-size: 11px; cursor: pointer; transition: .18s ease; }
.suggestions button:hover { border-color: rgba(144,227,173,.3); color: var(--text); background: rgba(144,227,173,.05); transform: translateY(-1px); }

.message { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 11px; margin-bottom: 24px; animation: rise .24s ease; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.avatar { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; margin-top: 1px; background: #e6f4eb; color: #142219; font-weight: 800; font-size: 10px; }
.message-body { min-width: 0; width: 100%; }
.message-meta { display: flex; align-items: center; gap: 7px; height: 21px; margin-bottom: 5px; color: var(--faint); font-size: 10px; }
.message-meta strong { color: #bec7c1; font-size: 11px; }
.message-text { color: #dce3de; font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.message.user .message-body { width: auto; max-width: min(76%, 650px); }
.message.user .message-text { padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; background: var(--panel-2); color: #e7ece8; }
.cursor::after { content: ""; display: inline-block; width: 5px; height: 14px; margin-left: 3px; vertical-align: -2px; border-radius: 1px; background: var(--green); animation: blink .85s steps(2) infinite; }

.activity { margin: 4px 0 24px 39px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(20, 23, 21, .75); animation: rise .22s ease; }
.activity summary { list-style: none; padding: 11px 13px; display: flex; align-items: center; gap: 9px; cursor: pointer; color: #bbc4be; font-size: 11px; user-select: none; }
.activity summary::-webkit-details-marker { display: none; }
.activity summary::after { content: "⌄"; margin-left: auto; color: var(--faint); transition: transform .18s; }
.activity[open] summary::after { transform: rotate(180deg); }
.activity-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: rgba(144, 227, 173, .08); color: var(--green); font: 700 10px/1 ui-monospace, monospace; }
.activity-status { margin-left: 3px; color: var(--faint); }
.activity-content { margin: 0; padding: 12px 14px 14px; border-top: 1px solid var(--line); color: #96a19a; background: #101210; font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; }

.plan-card { margin: 4px 0 24px 39px; padding: 13px 15px; border-left: 2px solid #4b9d68; background: linear-gradient(90deg, rgba(61, 124, 82, .09), transparent); }
.plan-title { margin: 0 0 9px; color: #aab5ae; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.plan-list { display: grid; gap: 7px; }
.plan-item { display: grid; grid-template-columns: 14px 1fr; gap: 8px; color: #8e9992; font-size: 11px; line-height: 1.45; }
.plan-item span:first-child { color: var(--faint); }
.plan-item.completed { color: #718078; text-decoration: line-through; text-decoration-color: #3d4841; }
.plan-item.inProgress { color: #d1dad4; }
.plan-item.inProgress span:first-child { color: var(--green); }

.approval { margin: 4px 0 24px 39px; padding: 15px; border: 1px solid rgba(244, 188, 114, .25); border-radius: 12px; background: linear-gradient(135deg, rgba(78, 56, 28, .22), rgba(26, 24, 20, .88)); box-shadow: 0 12px 34px rgba(0,0,0,.15); }
.approval h3 { margin: 0 0 7px; color: #f1c991; font-size: 12px; }
.approval p { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.approval code { display: block; padding: 10px; border-radius: 8px; color: #d7d0c5; background: rgba(0,0,0,.25); font: 10px/1.55 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; }
.approval-actions { display: flex; gap: 7px; margin-top: 12px; }
.approval-actions button { border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 11px; background: rgba(255,255,255,.04); cursor: pointer; font-size: 10px; font-weight: 650; }
.approval-actions .approve { border-color: rgba(107,215,142,.3); background: rgba(69,154,95,.17); color: #b7efca; }
.approval-actions .cancel { color: var(--red); }
.approval.resolved { opacity: .55; pointer-events: none; }

.result-banner { margin: 4px 0 24px 39px; display: flex; align-items: center; gap: 9px; color: #839087; font-size: 10px; }
.result-banner span { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid rgba(107,215,142,.22); border-radius: 50%; color: var(--green); }
.result-banner.failed span { border-color: rgba(255,138,132,.25); color: var(--red); }

.artifact-card { margin: 4px 0 26px 39px; padding: 14px; border: 1px solid rgba(138,185,255,.2); border-radius: 13px; background: linear-gradient(135deg, rgba(49,83,126,.16), rgba(20,23,21,.9)); animation: rise .24s ease; }
.artifact-heading { margin-bottom: 10px; color: #b9d3fa; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.artifact-list { display: grid; gap: 8px; }
.artifact-link { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: rgba(255,255,255,.025); text-decoration: none; transition: .18s ease; }
.artifact-link:hover { border-color: rgba(138,185,255,.35); background: rgba(138,185,255,.07); transform: translateY(-1px); }
.artifact-icon { width: 30px; height: 30px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; color: #cde0ff; background: rgba(93,142,211,.18); font-size: 11px; font-weight: 800; }
.artifact-details { min-width: 0; display: grid; gap: 3px; }
.artifact-details strong { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.artifact-details small { color: var(--muted); font-size: 9px; }

.composer-wrap { position: relative; z-index: 3; padding: 0 max(28px, calc((100% - 820px) / 2)) 18px; background: linear-gradient(0deg, var(--bg) 74%, transparent); }
.run-state { position: absolute; top: -28px; left: max(28px, calc((100% - 820px) / 2)); display: flex; align-items: center; gap: 8px; color: #849088; font-size: 10px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(95, 218, 136, .4); animation: pulse 1.7s infinite; }
.composer { border: 1px solid var(--line-strong); border-radius: var(--radius); background: rgba(23, 26, 24, .97); box-shadow: 0 18px 50px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.025); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(144,227,173,.28); box-shadow: 0 18px 50px rgba(0,0,0,.32), 0 0 0 3px rgba(74,182,110,.045); }
.composer textarea { display: block; width: 100%; max-height: 160px; resize: none; border: 0; outline: 0; padding: 15px 16px 8px; color: var(--text); background: transparent; font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: #626b65; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px 15px; }
.composer-hint { color: #56605a; font-size: 9px; }
.key { color: #747e77; }
.divider { margin: 0 3px; }
.composer-actions { display: flex; align-items: center; gap: 7px; }
.send { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: #dff2e5; color: #142018; cursor: pointer; transition: .18s ease; }
.send:hover { transform: translateY(-1px); background: #f0fff5; }
.send:disabled { cursor: not-allowed; opacity: .35; transform: none; }
.send svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stop { height: 32px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,138,132,.18); border-radius: 9px; background: rgba(123,53,49,.08); color: #d99691; font-size: 10px; cursor: pointer; }
.stop span { width: 7px; height: 7px; border-radius: 1px; background: currentColor; }
.footer-note { margin: 8px 0 0; color: #4e5651; text-align: center; font-size: 9px; }
.hidden { display: none !important; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 380px; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #202421; color: #d5ddd7; box-shadow: 0 18px 46px rgba(0,0,0,.4); font-size: 11px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,138,132,.24); color: #ffc0bc; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(95,218,136,0); } 100% { box-shadow: 0 0 0 0 rgba(95,218,136,0); } }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { height: 70px; padding: 0 18px; }
  .topbar h1 { font-size: 15px; }
  .timeline { padding: 26px 16px 70px; }
  .composer-wrap { padding: 0 12px 12px; }
  .run-state { left: 16px; }
  .composer-hint { display: none; }
  .composer-bottom { justify-content: flex-end; }
  .message.user .message-body { max-width: 90%; }
  .activity, .plan-card, .approval, .result-banner, .artifact-card { margin-left: 0; }
  .mode-badge { display: none; }
}
