/* CORVUS web — Cursor-like dark UI */
:root {
  --bg: #141414;
  --bg-elev: #181818;
  --panel: #1f1f1f;
  --panel-2: #252526;
  --panel-3: #2d2d2d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #3794ff;
  --accent-soft: rgba(55, 148, 255, 0.14);
  --accent-text: #e8e8e8;
  --text: #e4e4e4;
  --muted: #8a8a8a;
  --muted-2: #6e6e6e;
  --ok: #73c991;
  --warn: #cca700;
  --err: #f48771;
  --prod: #e39494;
  --font-ui: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: 'Cascadia Code', 'SF Mono', ui-monospace, Consolas, monospace;
  --radius: 8px;
  --radius-lg: 10px;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#root {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

a {
  color: var(--accent);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.62rem 0.72rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(55, 148, 255, 0.55);
  background: var(--panel-3);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0.55rem 0 0.28rem;
}

.hint,
.settings-help,
.settings-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.62rem 1rem;
  background: #e4e4e4;
  color: #141414;
}

.btn-primary:hover {
  background: #f0f0f0;
}

.btn-ghost {
  padding: 0.38rem 0.72rem;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--panel-2);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-text {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  font-size: 12px;
}

.btn-text:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn-text:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-send {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  color: var(--accent-text);
  font-size: 1rem;
  cursor: pointer;
}

.btn-send:hover {
  background: #353535;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-approve,
.btn-reject {
  appearance: none;
  border-radius: 6px;
  padding: 0.34rem 0.65rem;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-ui);
}

.btn-approve {
  background: rgba(115, 201, 145, 0.1);
  border-color: rgba(115, 201, 145, 0.28);
  color: var(--ok);
}

.btn-reject {
  background: rgba(244, 135, 113, 0.1);
  border-color: rgba(244, 135, 113, 0.28);
  color: var(--err);
}

/* Gate / auth */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--bg);
}

.gate-card {
  width: min(24rem, 100%);
  padding: 1.5rem 1.35rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 1.1rem;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 auto 0.75rem;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-text);
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.brand p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.tabs button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.tabs button.active {
  color: var(--text);
  background: var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.msg {
  margin-top: 0.75rem;
  font-size: 12px;
  line-height: 1.45;
}

.msg.err {
  color: var(--err);
}

.msg.ok {
  color: var(--ok);
}

.msg.info {
  color: var(--muted);
}

#qrWrap {
  display: none;
  text-align: center;
  margin: 0.75rem 0;
}

#qrBox {
  display: inline-block;
  background: #fff;
  padding: 12px;
  border-radius: var(--radius);
  min-width: 220px;
  min-height: 220px;
}

.secret {
  display: none;
  margin-top: 0.65rem;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
  line-height: 1.45;
  font-family: var(--font-mono);
}

.secret strong {
  color: var(--text);
}

/* App shell */
.app {
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  flex: 0 0 auto;
  z-index: 40;
}

.topbar-brand strong {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.topbar-brand span {
  display: block;
  margin-top: 0.1rem;
  font-size: 11px;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.nav button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.62rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
}

.nav button.active {
  color: var(--text);
  background: var(--panel-3);
}

.nav button:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-badge {
  display: inline-block;
  min-width: 1rem;
  padding: 0 0.3rem;
  margin-left: 0.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #141414;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

.layout {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layout-ops {
  flex: 1 1 0;
  min-height: 0;
}

.layout-page {
  padding: 1rem 1.1rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.view {
  display: none;
  min-height: 0;
}

.view.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}

.layout-page .view.active {
  display: block;
  flex: none;
  overflow-y: auto;
}

/* Ops / chat */
.ops-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.ops-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.65rem;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  flex: 0 0 auto;
}

.ops-toolbar-left {
  flex: 1 1 12rem;
  min-width: 0;
}

.ops-status {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 28rem;
}

.ops-status strong {
  color: var(--text);
  font-weight: 500;
}

.ops-status.working strong {
  color: var(--accent);
}

.ops-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  justify-content: flex-end;
  flex: 1 1 18rem;
  min-width: 0;
}

.pack-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pack-bar-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 6.5rem;
}

.pack-bar-value--prod {
  color: var(--prod);
}

.pack-isolation-note {
  margin: 0;
  flex: 1 1 100%;
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted-2);
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--panel);
}

.seg-sm .seg-btn {
  padding: 0.22rem 0.52rem;
  font-size: 10px;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.3rem 0.58rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.seg-btn.active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.seg-btn.seg-btn--locked {
  opacity: 0.45;
}

.mode-select {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.2rem;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  max-width: 100%;
  overflow-x: auto;
}

.mode-select-block {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  border: none;
  background: transparent;
}

.mode-chip {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-ui);
}

.mode-chip.active {
  color: var(--text);
  background: var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.mode-chip:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.chat {
  flex: 1 1 0;
  min-height: 8rem;
  overflow-y: auto;
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--bg);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 26rem;
  padding: 2rem 1rem;
}

.chat-empty-mark {
  font-size: 1.5rem;
  opacity: 0.25;
  margin-bottom: 0.45rem;
}

.chat-empty p {
  margin: 0 0 0.3rem;
  color: var(--text);
  font-size: 13px;
}

.chat-empty span {
  font-size: 12px;
}

.bubble {
  max-width: min(92%, 680px);
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-lg);
  line-height: 1.55;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user {
  align-self: flex-end;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
}

.bubble.bot {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
}

.bubble .who {
  display: block;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 0.28rem;
  font-family: var(--font-mono);
}

.bubble-meta {
  margin-top: 0.4rem;
  font-size: 10px;
  color: var(--muted-2);
  font-family: var(--font-mono);
}

.bubble-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.bubble-gallery img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
}

.live-card .live-dot {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  margin-right: 0.3rem;
  animation: pulse 1.4s ease-in-out infinite;
}

.live-now {
  font-size: 13px;
  margin: 0.3rem 0;
}

.live-meta {
  font-size: 11px;
  color: var(--muted);
}

.live-steps {
  margin: 0.45rem 0 0;
  padding-left: 1rem;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.live-steps li.fresh {
  color: var(--text);
}

.live-steps li.done {
  color: var(--ok);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.composer {
  padding: 0.55rem 0.85rem 0.75rem;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  flex: 0 0 auto;
}

.composer-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: end;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.55rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.composer-box textarea {
  min-height: 3.2rem;
  resize: vertical;
  border: none;
  background: transparent;
  padding: 0.15rem 0.25rem;
}

.composer-box textarea:focus {
  background: transparent;
  border: none;
  outline: none;
}

.composer-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding-top: 0.15rem;
  border-top: 1px solid var(--line);
}

.composer-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
}

.composer-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.btn-stop {
  appearance: none;
  border: 1px solid rgba(244, 135, 113, 0.55);
  background: rgba(244, 135, 113, 0.14);
  color: #ffb4a4;
  cursor: pointer;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-height: 2.4rem;
}

.btn-stop:hover:not(:disabled) {
  background: rgba(244, 135, 113, 0.28);
  color: #ffe0d8;
  border-color: rgba(244, 135, 113, 0.85);
}

.btn-stop:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-stop.is-hot {
  animation: corvus-stop-pulse 1.4s ease-in-out infinite;
}

@keyframes corvus-stop-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 135, 113, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(244, 135, 113, 0.18);
  }
}

.composer.is-busy .btn-send {
  display: none;
}

/* Pulse */
.pulse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.55rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--panel);
}

.stat .k {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 0.28rem;
}

.stat .v {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.stat .v.ok {
  color: var(--ok);
}

.stat .v.warn {
  color: var(--warn);
}

.stat .v.err {
  color: var(--err);
}

/* Deck */
.deck-shell,
.settings-shell {
  display: grid;
  gap: 0.85rem;
}

.deck-hero,
.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.deck-eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.deck-hero h2,
.settings-hero h2 {
  margin: 0.15rem 0;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0;
}

.deck-lead {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.5;
  font-size: 12px;
}

.deck-stage {
  display: grid;
  gap: 0.75rem;
}

.deck-packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.55rem;
}

.deck-pack {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  padding: 0.85rem;
  min-height: 9rem;
  background: var(--panel);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.deck-pack::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 1;
  pointer-events: none;
}

.deck-pack.test::before {
  background: linear-gradient(145deg, rgba(55, 148, 255, 0.08), transparent 55%);
}

.deck-pack.prod::before {
  background: linear-gradient(145deg, rgba(244, 135, 113, 0.1), transparent 55%);
}

.deck-pack > * {
  position: relative;
  z-index: 1;
}

.deck-pack:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--panel-2);
}

.deck-pack .mark {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
}

.deck-pack .label {
  margin-top: 0.3rem;
  font-weight: 600;
  font-size: 13px;
}

.deck-pack .blurb,
.deck-pack .path {
  margin-top: 0.28rem;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  font-family: var(--font-mono);
}

.pill {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(115, 201, 145, 0.3);
}

.pill.warn {
  color: var(--warn);
}

.deck-rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.deck-rail-k {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.deck-rail-v {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 12px;
}

.deck-crew-head h3 {
  margin: 0 0 0.2rem;
  font-size: 13px;
  font-weight: 600;
}

.deck-crew-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.deck-crew {
  display: grid;
  gap: 0.45rem;
}

.deck-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.deck-row.pending {
  border-color: rgba(204, 167, 0, 0.35);
}

.deck-row .name {
  font-weight: 600;
  font-size: 13px;
}

.deck-row .sub {
  margin-top: 0.15rem;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.deck-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.deck-actions--stack {
  flex-direction: column;
  align-items: flex-end;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.38rem;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.deck-toast,
.settings-toast {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  font-size: 12px;
}

.deck-toast.err,
.settings-toast.err {
  border-color: rgba(244, 135, 113, 0.35);
  color: var(--err);
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.55rem;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  background: var(--panel);
}

.settings-card h3 {
  margin: 0 0 0.55rem;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row span {
  color: var(--muted);
}

.settings-link {
  margin-top: 0.65rem;
}

/* PROD PIN modal */
.prod-pin-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

.prod-pin-card {
  width: min(100%, 22rem);
  padding: 1.25rem 1.15rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.prod-pin-card h3 {
  margin: 0.3rem 0 0.45rem;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
}

.prod-pin-card input {
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-family: var(--font-mono);
}

.prod-pin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.prod-pin-actions .btn-primary {
  flex: 1 1 auto;
  width: auto;
  margin-top: 0;
}

.pack-updates-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pack-updates-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #c97a2b;
  color: #141414;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(201, 122, 43, 0.25);
  animation: pack-alert-pulse 2.4s ease-in-out infinite;
}

.pack-updates-badge.hidden {
  display: none;
}

@keyframes pack-alert-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

.prod-update-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin: 0 0.65rem 0.45rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(201, 122, 43, 0.45);
  background: linear-gradient(90deg, rgba(201, 122, 43, 0.14), rgba(201, 122, 43, 0.04));
}

.prod-update-alert.hidden {
  display: none;
}

.prod-update-alert__seal {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #141414;
  background: #c97a2b;
}

.prod-update-alert__copy {
  flex: 1 1 12rem;
  min-width: 0;
}

.prod-update-alert__copy strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 0.12rem;
}

.prod-update-alert__copy p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.prod-update-alert.push-warning {
  border-color: rgba(255, 120, 90, 0.5);
  background: linear-gradient(90deg, rgba(180, 70, 50, 0.16), rgba(201, 122, 43, 0.05));
}

.prod-update-alert.push-warning .prod-update-alert__seal {
  background: #b44632;
}

.seg-btn.seg-btn--alert:not(.active) {
  box-shadow: inset 0 0 0 1px rgba(201, 122, 43, 0.55);
}

.pack-updates-card {
  width: min(100%, 32rem);
  max-height: min(85dvh, 34rem);
  display: flex;
  flex-direction: column;
}

.pack-updates-list {
  flex: 1 1 auto;
  min-height: 8rem;
  max-height: 22rem;
  overflow-y: auto;
  margin: 0.65rem 0 0.2rem;
  padding-right: 0.15rem;
}

.pack-update-row {
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.pack-update-row.push-warn {
  border-color: rgba(201, 122, 43, 0.55);
  background: rgba(201, 122, 43, 0.08);
}

.pack-update-row.fail {
  border-color: rgba(255, 120, 120, 0.35);
}

.pack-update-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 12px;
}

.pack-update-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
}

.pack-update-badge.test {
  color: #7ec8ff;
}

.pack-update-badge.prod {
  color: #ffb86b;
}

.pack-update-action {
  font-weight: 600;
  color: var(--text);
}

.pack-update-when {
  color: var(--muted);
  margin-left: auto;
  font-size: 11px;
}

.pack-update-who {
  margin-top: 0.25rem;
  font-size: 12px;
  color: var(--text);
}

.pack-update-detail {
  margin-top: 0.15rem;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.prod-pin-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  letter-spacing: 0.2em;
  color: var(--text);
}

.prod-pin-row {
  align-items: center;
}

/* Local preview (Vite localhost on office VPS) */
.layout-local {
  flex: 1 1 0;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.layout-local .view.active {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.local-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(115, 201, 145, 0.08), transparent 45%),
    var(--bg);
}

.local-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1c1c1c, #171717);
}

.local-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.local-badge {
  flex: 0 0 auto;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(115, 201, 145, 0.45);
  background: rgba(115, 201, 145, 0.12);
  color: #9fd9b0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.local-copy {
  min-width: 0;
}

.local-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.local-copy p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 12px;
}

.local-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.local-login-hint {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-right: 0.25rem;
}

.local-start-btn {
  padding: 0.4rem 0.75rem;
  font-size: 12px;
}

.local-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  background: #0b0b0b;
}

.local-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b0b0b;
}

.local-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.local-empty-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(115, 201, 145, 0.35);
  color: #9fd9b0;
  margin-bottom: 0.25rem;
}

.local-empty p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.local-empty span {
  max-width: 28rem;
  font-size: 12px;
  line-height: 1.45;
}

.local-empty .btn {
  margin-top: 0.55rem;
}

.local-shell.is-running .local-empty {
  display: none;
}

.local-shell.is-running .local-frame {
  display: block;
}

.local-shell.is-busy .local-start-btn,
.local-shell.is-busy #localRestartBtn {
  opacity: 0.6;
  pointer-events: none;
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
  }

  .nav {
    order: 3;
    width: 100%;
  }

  .ops-toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .pack-isolation-note {
    max-width: none;
  }

  .composer-box {
    grid-template-columns: 1fr;
  }

  .btn-send {
    width: 100%;
    height: 2.25rem;
  }

  .local-toolbar-right {
    width: 100%;
  }

  .local-login-hint {
    width: 100%;
  }
}

/* Powrót do Centrum Dowodzenia (hub) */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.hub-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius, 8px);
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: rgba(212, 175, 55, 0.08);
  color: #e8c96a;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.hub-back:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.65);
  color: #f5e6b0;
}

.hub-back-arrow {
  font-size: 14px;
  line-height: 1;
}

.hub-back--gate {
  margin-top: 0.85rem;
  justify-content: center;
  width: 100%;
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
}

@media (max-width: 720px) {
  .hub-back-label {
    display: none;
  }
  .hub-back {
    padding: 0.4rem 0.5rem;
  }
  .hub-back-arrow {
    font-size: 16px;
  }
}

/* Settings: zaawansowane domyślnie schowane */
.settings-advanced {
  grid-column: 1 / -1;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: var(--radius-lg, 12px);
  padding: 0.35rem 0.65rem 0.75rem;
  background: rgba(0,0,0,0.2);
}
.settings-advanced-summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.45rem 0.2rem;
  list-style: none;
}
.settings-advanced-summary::-webkit-details-marker { display: none; }
.settings-advanced[open] .settings-advanced-summary {
  color: #e8c96a;
  margin-bottom: 0.55rem;
}
.settings-advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

/* Agent: nie zaśmiecaj czatu ścianą własnego promptu */
.bubble.user.bubble--compact .bubble-body {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 2.9em;
}
.bubble.user.bubble--compact.is-expanded .bubble-body {
  display: block;
  -webkit-line-clamp: unset;
  max-height: none;
  overflow: visible;
}
.bubble-toggle {
  margin-top: 0.35rem;
  appearance: none;
  border: none;
  background: transparent;
  color: #cbb87a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.bubble.user {
  max-width: min(72%, 420px);
  opacity: 0.92;
}

.bubble.user.bubble--cmd {
  align-self: flex-end;
  max-width: min(56%, 360px);
  padding: 0.45rem 0.65rem;
  font-size: 12px;
  background: rgba(255,255,255,0.04);
}
.bubble.user.bubble--cmd .bubble-body {
  display: block;
  max-height: none;
  -webkit-line-clamp: unset;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble.user.bubble--cmd.is-expanded .bubble-body {
  white-space: pre-wrap;
  overflow: visible;
}
