:root {
  color-scheme: light;
  --ink: #1f2528;
  --muted: #667073;
  --line: #d8dfdc;
  --panel: #ffffff;
  --soft: #f4f7f5;
  --wash: #eaf2ee;
  --green: #167052;
  --green-2: #0c5d47;
  --blue: #1b5f9c;
  --red: #a13a31;
  --amber: #996713;
  --shadow: 0 18px 50px rgba(31, 37, 40, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 245, 0.93);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

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

.brand-copy strong,
.panel-title strong,
.identity-name {
  display: block;
}

.brand-copy span,
.panel-title span,
.micro,
.field-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  min-width: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button.secondary {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
}

.button.warn {
  background: var(--red);
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

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

.button:focus-visible,
.chip:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(27, 95, 156, 0.25);
  outline-offset: 2px;
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 20px;
  width: min(1240px, calc(100% - 32px));
  margin: 22px auto 40px;
}

.setup-main,
.dashboard-grid,
.page-band {
  width: min(1240px, calc(100% - 32px));
  margin: 22px auto 40px;
}

.panel,
.card,
.identity-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.identity-card {
  position: sticky;
  top: 86px;
  overflow: hidden;
}

.portrait {
  display: grid;
  min-height: 180px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(22, 112, 82, 0.16), transparent 45%),
    linear-gradient(30deg, rgba(27, 95, 156, 0.16), transparent 50%),
    #e6efea;
}

.portrait-device {
  align-self: end;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(31, 37, 40, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 18px 45px rgba(31, 37, 40, 0.12);
}

.portrait-screen {
  min-height: 114px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  padding: 14px;
}

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.signal-dot,
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.avatar-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 22px;
  font-weight: 800;
}

.identity-body {
  padding: 18px;
}

.identity-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.meta-row span:first-child {
  color: var(--muted);
}

.meta-row strong {
  overflow-wrap: anywhere;
  text-align: right;
}

.stepper {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.step-pill.active {
  border-color: rgba(22, 112, 82, 0.4);
  background: var(--wash);
  color: var(--ink);
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.toggle-grid,
.ledger-grid,
.approval-grid,
.stat-grid,
.connector-grid {
  display: grid;
  gap: 10px;
}

.toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-card,
.ledger-row,
.approval-row,
.stat-card,
.log-row,
.connector-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.toggle-card {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.toggle-card strong,
.ledger-row strong,
.approval-row strong,
.stat-card strong,
.connector-card strong {
  display: block;
}

.connector-header {
  margin-top: 20px;
}

.connector-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.connector-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 96px;
  padding: 12px;
}

.connector-card .button {
  grid-column: 1 / -1;
  justify-self: start;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #cfd8d5;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 160ms ease;
}

.switch.on {
  background: var(--green);
}

.switch.on::after {
  transform: translateX(20px);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.segment {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(31, 37, 40, 0.08);
}

.ledger-row,
.approval-row,
.log-row {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.ledger-top,
.approval-top,
.log-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--green-2);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.blue {
  background: #e7f0f9;
  color: var(--blue);
}

.badge.amber {
  background: #fbf1d9;
  color: var(--amber);
}

.badge.red {
  background: #fae6e3;
  color: var(--red);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  min-height: 520px;
}

.chat-feed {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 3px;
}

.message {
  max-width: 92%;
  border-radius: 16px;
  padding: 10px 12px;
  line-height: 1.4;
}

.message.agent {
  justify-self: start;
  background: var(--wash);
}

.message.user {
  justify-self: end;
  background: var(--ink);
  color: white;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.chat-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

.setup-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.5fr);
  gap: 18px;
}

.dashboard-stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

.stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  padding: 12px;
}

.stat-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.task-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: start;
}

.task-composer textarea {
  min-height: 88px;
}

.task-actions {
  display: grid;
  gap: 8px;
}

.payment-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border-radius: 14px;
  background: #202725;
  color: white;
}

.magic-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
}

.magic-panel h2 {
  margin: 8px 0 4px;
  font-size: 20px;
  line-height: 1.1;
}

.runtime-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.runtime-panel strong {
  display: block;
  margin-top: 6px;
}

.runtime-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.runtime-options span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.magic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(22, 112, 82, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-2);
}

.notice.error {
  border-color: rgba(161, 58, 49, 0.25);
  color: var(--red);
}

.payment-card .micro {
  color: rgba(255, 255, 255, 0.72);
}

.card-number {
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 800;
  letter-spacing: 0;
}

.range-row {
  display: grid;
  gap: 8px;
}

input[type="range"] {
  min-height: auto;
  padding: 0;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.applet-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.applet-panel {
  display: grid;
  gap: 18px;
  width: min(640px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.applet-panel h1 {
  margin: 8px 0 4px;
  font-size: 30px;
  line-height: 1.08;
}

.applet-rows {
  margin-top: 14px;
}

@media (max-width: 980px) {
  .setup-layout,
  .workspace,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .identity-card {
    position: static;
  }

  .chat-panel {
    min-height: 420px;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions .button {
    flex: 1 1 auto;
  }

  .runtime-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .toggle-grid,
  .stat-grid,
  .connector-grid,
  .task-composer {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-entry {
    grid-template-columns: 1fr;
  }
}
