:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #4c8dff;
  --accent-2: #0d7a3f;
  --warn: #d9a441;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  display: flex;
  flex-direction: column;
}
button {
  cursor: pointer;
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  transition: 0.15s;
}
button:hover {
  border-color: var(--accent);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover {
  filter: brightness(1.08);
}
button.ghost {
  background: transparent;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
input,
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  margin-top: 5px;
}
textarea {
  resize: vertical;
}
label {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}
label input,
label textarea,
label select {
  color: var(--text);
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.spacer {
  flex: 1;
}

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
}
.project-title {
  color: var(--muted);
  font-size: 14px;
}
.update-banner {
  background: rgba(217, 164, 65, 0.15);
  color: var(--warn);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.update-banner button {
  padding: 3px 8px;
  margin-left: 6px;
}

/* Views */
.view {
  flex: 1;
  overflow: auto;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.center {
  max-width: 520px;
  margin: 60px auto;
  text-align: center;
}
.checks {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 20px auto;
  max-width: 360px;
}
.checks li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.checks li {
  flex-direction: column;
  align-items: stretch;
}
.checks li > span:first-of-type,
.checks li > span {
}
.checks .fix {
  margin: 6px 0 2px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.checks .fix code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12.5px;
  color: var(--text);
  user-select: all;
}
.checks .fix a {
  color: var(--accent);
  font-size: 12.5px;
  text-decoration: none;
}
.checks .note {
  margin: 2px 0 0 26px;
  font-size: 12px;
}
.log {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
  color: var(--muted);
}

/* Start view */
.start-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 22px;
  max-width: 1100px;
  margin: 0 auto;
}
.chips {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text);
}
.chip input {
  width: auto;
  margin: 0;
}
.project-list,
.vault-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.project-list li {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
.project-list li:hover {
  border-color: var(--accent);
}
.project-list .badge {
  color: var(--muted);
  font-size: 12px;
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 42%) 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.chat-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.phase-strip {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.phase-strip .step {
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.phase-strip .step.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.phase-strip .step.done {
  color: var(--accent-2);
  border-color: var(--accent-2);
}
.chat-log {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  padding: 11px 13px;
  border-radius: 10px;
  max-width: 92%;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.msg.kiro {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.msg.sys {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.act {
  align-self: flex-start;
  max-width: 92%;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  gap: 7px;
}
.act .ic {
  flex: none;
}
.act .tt {
  font-family: ui-monospace, Menlo, monospace;
}
.act .st {
  color: var(--accent-2);
  font-weight: 700;
}
.act .st.fail {
  color: #d9534f;
}
.act.thought {
  color: var(--muted);
  font-style: italic;
  border-style: dashed;
}
.act.sub {
  color: var(--warn);
  border-color: var(--warn);
}
.act.plan {
  display: block;
  color: var(--text);
  line-height: 1.6;
}
.act.mode {
  color: var(--accent);
}
.act.sub .sub-open {
  color: var(--warn);
  text-decoration: underline;
  cursor: pointer;
}
.act.sub .sub-open:hover {
  color: #f0c674;
}
.sub-drawer {
  width: 720px;
  max-width: 94vw;
  height: 84vh;
  display: flex;
  flex-direction: column;
}
.sub-brief {
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  max-height: 72px;
  overflow: auto;
}
.sub-feed {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-feed .sf {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.sub-feed .think {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-style: italic;
  border: 1px dashed var(--border);
}
.sub-feed .asst {
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.sub-feed .prompt {
  background: rgba(76, 141, 255, 0.08);
  color: var(--text);
}
.sub-feed .tool {
  background: rgba(13, 122, 63, 0.1);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.sub-feed .tool .in {
  color: var(--muted);
}
.sub-feed .res {
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.gate {
  background: rgba(76, 141, 255, 0.12);
  border-top: 1px solid var(--accent);
  padding: 12px 14px;
}
.gate-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.working {
  padding: 6px 14px;
  color: var(--warn);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.spin {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--warn);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.chat-input textarea {
  flex: 1;
}
.agent-log-wrap {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}
.agent-log-wrap summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

/* Mocks pane */
.mocks-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.mocks-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.counter {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}
#workView {
  overflow: hidden;
}
.mock-grid {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-content: start;
}
.mock-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.mock-card .thumb {
  position: relative;
  background: #fff;
  height: 190px;
  overflow: hidden;
  cursor: pointer;
}
.mock-card .thumb iframe {
  border: 0;
  transform-origin: top left;
  pointer-events: none;
}
.mock-card .thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  color: var(--muted);
}
.mock-card .meta {
  padding: 9px 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.mock-card .plat {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.s-pending {
  background: #4b5261;
}
.s-generating {
  background: var(--warn);
  animation: pulse 1s infinite;
}
.s-ready {
  background: var(--accent-2);
}
.s-error {
  background: #d9534f;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: 520px;
  max-width: 92vw;
}
.modal-card.lb {
  width: 90vw;
  height: 88vh;
  display: flex;
  flex-direction: column;
}
.lb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.lb-frame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
/* Mobile mocks: show in a phone-shaped frame (390x844 ratio), not stretched to fill. */
#lightbox.lb-mobile .modal-card.lb {
  width: auto;
  height: auto;
  max-width: 96vw;
  max-height: 94vh;
}
#lightbox.lb-mobile .lb-frame {
  flex: none;
  align-self: center;
  height: 82vh;
  width: calc(82vh * 490 / 844);
  max-width: 94vw;
  border-radius: 20px;
}
.vault-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  margin: 14px 0;
}
.vault-form input {
  margin: 0;
}
.vault-list li {
  display: flex;
  justify-content: space-between;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
h1,
h2 {
  margin-top: 0;
}

/* Usage meter (web) — small informational counter in the top bar */
.usage-meter {
  font-size: 12px;
  color: var(--muted, #8a8f98);
  margin-right: 8px;
  white-space: nowrap;
}
