:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #151515;
  --muted: #6f6f6f;
  --border: #dddddd;
  --soft: #f7f7f5;
  --gold: #c49a18;
  --gold-dark: #9f7d11;
  --error: #c63d32;
  --ok: #1b8a45;
  --app-header-h: 52px;
  --app-footer-h: 40px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}
button, input, textarea { font: inherit; }
a { color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Shared status */
.backend-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9a9a9a; }
.status-dot.checking { background: #9a9a9a; }
.status-dot.connected { background: var(--ok); }
.status-dot.unavailable { background: var(--error); }

/* Chat-first landing page */
.interview-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 23%, rgba(196, 154, 24, 0.14), transparent 34rem),
    #fff;
}
.interview-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 10;
  height: var(--app-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.7rem;
  background: #f7f1df;
}
.interview-main {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: var(--app-header-h) 1.25rem 0;
}
.interview-shell {
  width: min(820px, 100%);
  min-height: calc(100vh - var(--app-header-h) - var(--app-footer-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(2.5rem, 6vh, 4.5rem) 0 2.5rem;
  transition: padding 300ms ease;
}
body.workspace .interview-shell {
  height: calc(100vh - var(--app-header-h) - var(--app-footer-h));
  min-height: 0;
  padding-top: clamp(2rem, 5vh, 4rem);
  padding-bottom: 1.25rem;
}
.interview-logo {
  width: min(590px, 82vw);
  height: auto;
  display: block;
  margin: 0 auto calc(clamp(2.25rem, 6vh, 4.5rem) - 1.25rem);
  transition: width 300ms ease, margin 300ms ease;
}
body.workspace .interview-logo {
  width: min(300px, 52vw);
  margin: 0 auto 1rem;
}
.conversation {
  width: min(720px, 100%);
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
  scrollbar-width: none;
}
.conversation::-webkit-scrollbar {
  display: none;
}
body.workspace .conversation {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1 1 auto;
  max-height: none;
}
.message {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
/* Text + metadata form one vertical content column beside the icon
   (OCME-024C): the metadata stays directly beneath the text, not
   beneath the icon row. */
.message-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}
.user-message .message-column {
  align-items: flex-end;
  /* The column is a flex item with default flex-grow 0, so it never grows
     beyond its content max-width — the body's max-width: 88% would resolve
     against a narrow column and the lane stays empty. Let it fill the lane
     so the bubble can expand left up to its 88% cap. */
  flex-grow: 1;
}
.message-mark-wrap {
  position: relative;
  flex: 0 0 34px;
}
.message-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: help;
}
.message-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* OCME-024D: the assistant icon sits on the same visual floor as the message
   text. The mark's margin-box bottom aligns with the column bottom (metadata
   bottom); the offset equals the metadata stack below the text
   (10px * line-height 1.5 + 1px margin), placing the icon's bottom exactly at
   the text block's bottom for any line count. Metadata stays below the line. */
.assistant-message .message-mark-wrap,
.assistant-message .message-mark {
  align-self: flex-end;
  margin-bottom: calc(10px * 1.5 + 1px);
}
.process-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 12px);
  z-index: 20;
  width: min(340px, calc(100vw - 3rem));
  padding: 1rem 1.05rem;
  border: 1px solid #e5dcc1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.13);
  color: var(--fg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  pointer-events: none;
}
.process-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 11px;
  width: 10px;
  height: 10px;
  border-left: 1px solid #e5dcc1;
  border-top: 1px solid #e5dcc1;
  background: #fff;
  transform: rotate(45deg);
}
.message-mark-wrap:hover .process-popover,
.message-mark-wrap:focus-within .process-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.process-popover strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}
.process-popover p {
  margin: 0;
  color: #555;
  font-size: 0.86rem;
  line-height: 1.55;
}
.message-body {
  max-width: 620px;
  padding: 0.15rem 0;
}
.message-body p { margin: 0; font-size: 1.05rem; }
.user-message { justify-content: flex-end; }
.user-message .message-body {
  background: var(--soft);
  border: 1px solid #ececea;
  border-radius: 16px 16px 4px 16px;
  padding: 0.8rem 1rem;
  max-width: 88%;
}
/* Long unbroken user content (URLs, paths, hashes, IDs) must wrap inside
   the bubble instead of escaping or clipping; ordinary prose still wraps
   at spaces. */
.user-message .message-body p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Quiet per-message metadata (OCME-024): timestamp + copy control.
   Secondary system text that almost disappears until hovered/focused. */
.message-metadata {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 400;
  color: #6b6b68;
  opacity: 0.5;
  transition: opacity 120ms ease;
}
.message-metadata:hover,
.message-metadata:focus-within {
  opacity: 1;
}
.copy-message {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 10px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}
.copy-message:focus-visible {
  outline: 1px solid #c9a227;
  outline-offset: 2px;
}
.copy-message.copied {
  color: #1a7f37;
}
.chat-composer {
  width: min(720px, 100%);
  border: 1px solid #d7d7d4;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.07);
  overflow: visible;
}
.chat-composer textarea {
  width: 100%;
  min-height: 92px;
  max-height: 240px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  padding: 1rem 1.1rem 0.45rem;
  color: var(--fg);
  background: transparent;
  border-radius: 18px 18px 0 0;
  transition: min-height 160ms ease;
}
.chat-composer textarea::placeholder { color: #9a9a9a; }
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.65rem 0.65rem 1rem;
  border-radius: 0 0 18px 18px;
}
.shortcut-hint {
  color: #a2a2a0;
  font-size: 0.78rem;
  white-space: nowrap;
  user-select: none;
}
.manual-link-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.manual-link {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}
.manual-link:hover { color: var(--fg); text-decoration: underline; }
.manual-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 30;
  width: max-content;
  max-width: min(240px, calc(100vw - 3rem));
  padding: 0.55rem 0.75rem;
  border: 1px solid #e5dcc1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  color: var(--fg);
  font-size: 0.82rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  pointer-events: none;
}
.manual-popover::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid #e5dcc1;
  border-bottom: 1px solid #e5dcc1;
  background: #fff;
  transform: rotate(45deg);
}
.manual-link-wrap:hover .manual-popover,
.manual-link-wrap:focus-within .manual-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.send-button {
  border: 0;
  border-radius: 999px;
  background: #171717;
  color: #fff;
  padding: 0.62rem 1rem;
  cursor: pointer;
}
.send-button:hover { background: #000; }
.interview-note {
  width: min(720px, 100%);
  margin: 0.85rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
}

/* Manual planning page */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.brand-link { display: block; text-decoration: none; }
.compact-logo {
  display: block;
  width: min(320px, 58vw);
  height: auto;
}
.manual-main { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.manual-heading { margin-bottom: 1.5rem; }
.manual-heading h1 { margin: 0.6rem 0 0.2rem; font-size: 1.65rem; }
.manual-heading p { margin: 0; color: var(--muted); }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; color: var(--fg); }
.panel {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.checkbox-field { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-field label { margin-bottom: 0; }
input[type="text"], input[type="number"], .manual-page textarea {
  width: 100%;
  padding: 0.58rem 0.65rem;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.manual-page textarea { resize: vertical; }
.manual-page button {
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 7px;
  background: #171717;
  color: #fff;
  cursor: pointer;
}
.manual-page button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.state-region {
  font-weight: 700;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
  margin-bottom: 1.25rem;
}
dl { margin: 0.5rem 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
dt { font-weight: 600; color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.receipt-list { padding-left: 1.5rem; display: grid; gap: 0.75rem; }
.receipt-list li { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; background: #fff; }
details { margin-top: 1rem; }
details pre {
  max-height: 24rem;
  overflow: auto;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Header controls (Connected status + Settings gear) */
.header-controls {
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 1vw, 0.85rem);
  min-width: 0;
}
.settings-gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #555;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.settings-gear img {
  width: 36px;
  height: 36px;
  display: block;
}
.settings-gear:hover { background: transparent; }

/* Compact account control: circular Google avatar + green status dot */
.account-wrap {
  position: relative;
  display: inline-flex;
}
.account-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #d7d7d4;
  border-radius: 50%;
  background: #fff;
  padding: 0;
  cursor: pointer;
  overflow: visible;
}
.account-avatar:hover { border-color: #b9b9b4; }
.account-avatar:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.account-avatar-photo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #e9e7df;
}
.account-avatar.no-photo .account-avatar-photo { display: none; }
.account-avatar.no-photo::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e9e7df;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23777777'%3E%3Cpath d='M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm0 2c-4 0-8 2-8 5v1h16v-1c0-3-4-5-8-5Z'/%3E%3C/svg%3E");
  background-size: 16px 16px;
  background-position: center;
  background-repeat: no-repeat;
}
.account-status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #22c55e;
  display: none;
}
.account-avatar.authenticated .account-status-dot { display: block; }

/* Account menu popover */
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #d7d7d4;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.5rem;
  z-index: 60;
}
.account-menu-header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem 0.6rem;
  border-bottom: 1px solid #eeece4;
  margin-bottom: 0.4rem;
}
.account-menu-name {
  font-weight: 600;
  color: #171717;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-email {
  font-size: 0.8rem;
  color: #777;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-signout {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #c0392b;
  font-size: 0.9rem;
  cursor: pointer;
}
.account-menu-signout:hover { background: #fdf0ee; }
.account-menu-signout:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Execution reopen pill — appears only after execution has started (OCME-011) */
/* Build status indicator (footer right) — simple status treatment like
   Connected: no pill, no border, no background, no padding. */
.build-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 0.88rem;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
}
.build-meter:hover { background: transparent; }
.build-meter[hidden] { display: none; }
.reopen-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9a9a96;
}
.build-meter.idle .reopen-dot { background: #9a9a96; }
.build-meter.running .reopen-dot { background: #7fb8e6; }
.build-meter.completed .reopen-dot { background: #1a7f37; }
.build-meter.failed .reopen-dot { background: #b3261e; }

/* Compact application footer — operational status chrome */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 10;
  height: var(--app-footer-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1.7rem;
  background: transparent;
}
/* Field glow from the footer's top edge, UPWARD into the workspace
   only — the glow is the entire field-to-chrome transition. Maximum
   gold alpha = 0.14 — the exact center-field value. Fades smoothly to
   transparent; never washes over footer controls. */
.footer-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  justify-self: start;
}
.footer-center {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  justify-self: center;
  position: relative;
}
.footer-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  justify-self: end;
}

/* Centered credit pill — remaining paid build time + direct purchase
   entry into Stripe Checkout */
.credit-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 0.9rem;
  border: 1px solid rgba(196, 154, 24, 0.5);
  border-radius: 17px;
  background: rgba(196, 154, 24, 0.12);
  color: #171717;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.credit-pill:hover { background: rgba(196, 154, 24, 0.22); color: #171717; }
.credit-pill:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.credit-pill[hidden] { display: none; }
.credit-pill.zero { color: rgba(23, 23, 23, 0.7); }

/* Modal overlay — sits above the Build Terminal so it can open over it */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(20, 20, 18, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

/* The author display rule above must not defeat the hidden attribute's
   display:none, or overlays stay visible forever and trap the user. */
.modal-overlay[hidden] { display: none; }

/* Scroll lock while a modal is open; removed when the modal closes. */
body.modal-open { overflow: hidden; }

/* BuildPrint Viewer */
.buildprint-viewer {
  width: min(880px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2dfd4;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.buildprint-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #ececea;
}
.buildprint-viewer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.viewer-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #777;
  padding: 0.2rem 0.4rem;
}
.viewer-close:hover { color: #171717; }
.buildprint-viewer-header h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}
.buildprint-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: #f4f2ea;
  color: #8a6d1f;
  border: 1px solid #e5dcc1;
}
.buildprint-badge.approved {
  background: #eaf6ec;
  color: #1a7f37;
  border-color: #cfe8d3;
}
.buildprint-document {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.4rem 1.6rem 1.6rem;
  min-height: 0;
}
.buildprint-document h3 {
  margin: 1.4rem 0 0.45rem;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a6d1f;
}
.buildprint-document h3:first-child { margin-top: 0; }
.buildprint-repository {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  margin-bottom: 1.1rem;
  padding: 0.55rem 0.7rem;
  background: #faf8f0;
  border: 1px solid #ece5cf;
  border-radius: 8px;
  font-size: 0.92rem;
}
.buildprint-repository-label {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #8a6d1f;
}
.buildprint-document ul {
  margin: 0;
  padding-left: 1.15rem;
}
.buildprint-document li {
  margin: 0.25rem 0;
  font-size: 1rem;
  line-height: 1.55;
  color: #222;
}
.buildprint-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid #ececea;
  flex-wrap: wrap;
}
.primary-action {
  border: 0;
  border-radius: 999px;
  background: #171717;
  color: #fff;
  padding: 0.62rem 1.15rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.primary-action:hover { background: #000; }
.secondary-action {
  border: 1px solid #d7d7d4;
  border-radius: 999px;
  background: #fff;
  color: #333;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.secondary-action:hover { background: #f4f2ea; }

/* Settings panel */
.settings-panel {
  width: min(480px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2dfd4;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.3rem;
  border-bottom: 1px solid #ececea;
}
.settings-header h2 { margin: 0; font-size: 1.15rem; }
.settings-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #777;
  padding: 0.2rem 0.4rem;
}
.settings-close:hover { color: #171717; }
.settings-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.6rem 1.3rem 1.2rem;
  min-height: 0;
}
.settings-section {
  padding: 1rem 0;
  border-bottom: 1px solid #f0efea;
}
.settings-section:last-child { border-bottom: 0; }
.settings-section h3 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a6d1f;
}
.settings-section label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0.7rem 0 0.25rem;
}
.settings-section input[type="text"],
.settings-section input[type="password"],
.settings-section select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #d7d7d4;
  border-radius: 8px;
}
.settings-field { margin-top: 0.4rem; }
.settings-note {
  margin: 0.6rem 0 0;
  color: #9a9a98;
  font-size: 0.78rem;
  line-height: 1.5;
}
.builder-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.builder-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #e2dfd4;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  margin: 0;
}
.builder-option:has(input:checked) {
  border-color: #c9a227;
  background: #fdfaf0;
}
.settings-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.3rem;
  border-top: 1px solid #ececea;
}

/* BuildPrint link inside chat messages (OCME-011) */
.buildprint-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #8a6d1f;
  text-decoration: underline;
  cursor: pointer;
}
.buildprint-link:hover { color: #c9a227; }

/* Interview question progress (OCME-020) — small, secondary, above the
   question text; built from protocol metadata, never part of the message. */
.question-progress {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a6d1f;
  margin: 0 0 0.3rem;
}

/* Build Terminal (OCME-011) — execution-status surface, not theater */
.terminal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 12, 10, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.terminal-overlay[hidden] { display: none; }
.build-terminal {
  width: min(720px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #101010;
  color: #e8e6df;
  border: 1px solid #2c2c2a;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.build-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid #262624;
}
.build-terminal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: #d9c069;
}
.build-terminal-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.terminal-control {
  border: 1px solid #3a3a36;
  background: #181816;
  color: #d6d3c9;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.terminal-control:hover { background: #232320; }
.build-terminal-body {
  padding: 1rem 1.2rem 1.2rem;
  overflow-y: auto;
  min-height: 0;
}
.terminal-row {
  display: flex;
  gap: 0.8rem;
  margin: 0.35rem 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.terminal-row-label {
  color: #8f8d84;
  min-width: 8.5rem;
}
.terminal-row-value {
  color: #e8e6df;
  word-break: break-word;
}
.terminal-status-starting { color: #d9c069; }
.terminal-status-running { color: #7fb8e6; }
.terminal-status-completed { color: #7fd69a; }
.terminal-status-failed { color: #f0857d; }
.terminal-detail {
  margin-top: 0.6rem;
  padding: 0.6rem 0.7rem;
  background: #181816;
  border-radius: 8px;
  color: #c9c6bb;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #c9a227;
  text-decoration: underline;
  cursor: pointer;
}
.terminal-link:hover { color: #e0b83a; }

/* BUILD INTELLIGENCE section hierarchy (OCME-REPAIR) */
.terminal-section {
  margin-bottom: 1rem;
}
.terminal-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8f8d84;
  margin: 0 0 0.6rem;
  padding: 0 0.1rem;
}
.terminal-divider {
  border-top: 1px solid #262624;
  margin: 1.25rem 0;
}
.terminal-agent-activity .terminal-log-entry {
  color: #d9d3c4;
}
.terminal-agent-activity .terminal-log-head {
  color: #6e6c62;
}
.terminal-agent-activity .terminal-log-message {
  color: #c9c6bb;
}

@media (max-width: 900px) {
  .interview-header { padding: 0 1rem; }
  .app-footer { padding: 0 1rem; }
  .header-controls { gap: 0.5rem; }
  .build-time-button, .buildprint-cta, .credit-pill { padding: 0 0.6rem; }
}

@media (max-width: 640px) {
  .interview-header { height: auto; min-height: var(--app-header-h); padding: 0.4rem 1rem; }
  .header-controls { flex-wrap: wrap; }
  .backend-status #status-text { display: none; }
  .interview-shell { padding-top: 4.25rem; }
  body.workspace .interview-shell { padding-top: 1.5rem; }
  .interview-logo { width: min(500px, 88vw); margin-bottom: 0.75rem; }
  body.workspace .interview-logo { width: min(260px, 64vw); margin-bottom: 0.75rem; }
  .message-body p { font-size: 1rem; }
  .process-popover { left: -4px; }
  .manual-popover { white-space: normal; width: 190px; }
  .interview-note { padding: 0 0.5rem; }
  .composer-footer { flex-wrap: wrap; }
  .shortcut-hint { order: 3; width: 100%; text-align: center; margin-top: 0.2rem; }
  .app-header { padding: 0.8rem 1rem; }
  .manual-main { padding: 1.25rem 0.75rem 3rem; }
  dl { grid-template-columns: 1fr; gap: 0.1rem 0; }
  dd { margin-bottom: 0.5rem; }
}

/* Build-time purchase control */
.build-time-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 0.9rem;
  border: 1px solid #d7d7d4;
  border-radius: 17px;
  background: #fff;
  color: #555;
  font-size: 0.82rem;
  cursor: pointer;
}
.build-time-button:hover { background: #f4f2ea; color: #171717; }
.build-time-button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Purchase-required state inside the BUILD INTELLIGENCE terminal */
.terminal-purchase {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eeece4;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.terminal-purchase-message {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  color: #555;
}
.terminal-purchase-note {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: #777;
}
/* Terminal purchase CTA — same gold-family surface/border as the
   main-page Credit control, with BRIGHT gold text (#c9a227, the
   terminal's link gold) that reads clearly against the dark terminal.
   Horizontally centered within the purchase section. */
#terminal-buy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 0.9rem;
  border: 1px solid rgba(196, 154, 24, 0.5);
  border-radius: 17px;
  background: rgba(196, 154, 24, 0.12);
  color: #c9a227;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}
#terminal-buy-button:hover {
  background: rgba(196, 154, 24, 0.22);
}

/* Terminal event log (planning mode) + resize handle + drag affordance */
.terminal-log {
  overflow-y: auto;
  max-height: 100%;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.25rem 0;
}
.terminal-log-entry { margin-bottom: 0.6rem; }
.terminal-log-head { color: #888; }
.terminal-log-message { color: #333; }
.build-terminal { touch-action: none; }
.build-terminal-header { cursor: move; }
.terminal-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.25) 50%);
}

/* Header-left permanent BuildPrint control (availability, not recovery) */
.header-left {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}
.buildprint-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 0.9rem;
  border: 1px solid #d7d7d4;
  border-radius: 17px;
  background: #fff;
  color: #555;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.buildprint-cta:hover:not(:disabled) { background: #f4f2ea; color: #171717; }
.buildprint-cta:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.buildprint-cta:disabled {
  background: #f5f5f3;
  border-color: #e2e2de;
  color: #9a9a96;
  cursor: default;
}

.bp-warn { color: var(--gold-dark); font-weight: 600; }

/* OCME-051: HACKASS Pro Settings modal */
.hackass-settings-pro {
  width: 520px;
  max-width: 92vw;
  max-height: 86vh;
  background: #fdfbf6;
  border: 1px solid #e8e2d0;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px 14px;
  border-bottom: 1px solid #ede8d8;
}
.settings-head h2 {
  font-family: "Fraunces", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.icon-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
}
.icon-close:hover {
  opacity: 1;
}
.durable-card {
  background: white;
  border: 1px solid #efe9d6;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.durable-kicker {
  font-family: "Fraunces", serif;
  color: #b9972f;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}
.durable-desc {
  font-size: 13px;
  color: #6b5f4a;
  line-height: 1.45;
  margin: 0 0 12px 0;
}
.workspace-status-line {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff8e1;
  border: 1px dashed #e6d8a8;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workspace-status-line.ready {
  background: #111;
  color: #f5e6b8;
  border-style: solid;
  border-color: #111;
}
.drive-actions {
  margin-bottom: 10px;
}
.btn-ghost {
  border: 1px solid #111;
  background: white;
  color: #111;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover {
  background: #111;
  color: white;
}
.folder-list {
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #eee6d0;
  border-radius: 10px;
  background: #fcfaf3;
  margin: 8px 0;
}
.folder-list:empty {
  display: none;
}
.folder-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: none;
  border-bottom: 1px solid #f0e9d3;
  background: transparent;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-pick:last-child {
  border-bottom: none;
}
.folder-pick::before {
  content: "📁";
  opacity: 0.8;
}
.folder-pick:hover {
  background: #f7f1df;
}
.folder-pick.selected {
  background: #111;
  color: #f5e6b8;
}
.folder-pick.selected::before {
  content: "✓";
}
.new-folder-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.new-folder-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e0d8c0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  background: #fdfbf6;
}
.btn-dark {
  background: #111;
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-dark:hover {
  background: #000;
}
.verify-details {
  margin-top: 12px;
  font-size: 11.5px;
  color: #8a7d64;
}
.verify-details summary {
  cursor: pointer;
}
.settings-foot {
  padding: 14px 22px;
  border-top: 1px solid #ede8d8;
  display: flex;
  justify-content: flex-end;
  background: #fdfbf6;
}
.btn-done {
  background: #111;
  color: white;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn-done:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* OCME-057: Multi-BuildPrint Drawer */
.bp-drawer {
  border-bottom: 1px solid #ede8d8;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.bp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #fdfbf6;
  border: 1px solid #efe9d6;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.bp-item:hover {
  background: #f7f1df;
}
.bp-item.active {
  background: #111;
  color: #f5e6b8;
  border-color: #111;
}
.bp-item .bp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.bp-item .bp-dot.DRAFT { background: #eab308; }
.bp-item .bp-dot.APPROVED { background: #22c55e; }
.bp-item .bp-dot.RUNNING { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.bp-item .bp-dot.FAILED { background: #ef4444; }
.bp-item .bp-dot.CANCELLED { background: #9ca3af; }
.bp-item .bp-stop-btn {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  color: inherit;
}
.bp-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.bp-trash-btn {
  background: transparent;
  border: none;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.bp-trash-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}
.bp-item.active .bp-trash-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
