:root {
  --bg: #f3f1ec;
  --ink: #15171c;
  --muted: #717782;
  --soft: #9aa0aa;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --line: rgba(20, 24, 31, 0.1);
  --line-strong: rgba(20, 24, 31, 0.18);
  --charcoal: #171a22;
  --charcoal-2: #222633;
  --lime: #b9ff66;
  --mint: #35d6a1;
  --blue: #5d7cff;
  --amber: #f3b84b;
  --red: #e85d5d;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(32, 36, 44, 0.13);
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(185, 255, 102, 0.28), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(93, 124, 255, 0.16), transparent 24%),
    linear-gradient(180deg, #f8f6f0 0%, var(--bg) 46%, #eeece7 100%);
}

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

button {
  border: 0;
  cursor: pointer;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

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

.nav-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 24px;
  height: 76px;
  padding: 0 48px;
  border-bottom: 1px solid rgba(20, 24, 31, 0.08);
  background: rgba(248, 246, 240, 0.78);
  backdrop-filter: blur(22px);
}

.brand,
.top-nav,
.wallet-area,
.hero-actions,
.section-head,
.market-head,
.market-title,
.market-meta {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  font-size: 21px;
  font-weight: 850;
  color: var(--ink);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: cover;
}

.top-nav {
  justify-content: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
  width: fit-content;
  justify-self: center;
}

.top-nav button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.top-nav button:hover,
.top-nav button.active {
  color: var(--ink);
  background: var(--panel-solid);
  box-shadow: 0 8px 20px rgba(35, 39, 47, 0.08);
}

.wallet-area {
  justify-content: flex-end;
  gap: 10px;
}

.network-pill,
.wallet-pill,
.ca-pill,
.x-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.ca-pill {
  max-width: none;
  padding: 0 12px;
  border: 1px dashed rgba(20, 24, 31, 0.24);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.46);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.ca-pill:hover,
.ca-box button:hover {
  border-color: var(--charcoal);
  color: var(--ink);
  background: #fff;
}

.x-link {
  width: 38px;
  border: 1px solid #111;
  color: #fff;
  background: #000;
  font-size: 15px;
  font-weight: 900;
}

.x-link:hover {
  color: #000;
  background: #fff;
}

.network-pill {
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
}

.wallet-pill {
  max-width: 168px;
  overflow: hidden;
  padding: 0 15px;
  color: #f7f7f2;
  background: var(--charcoal);
  text-overflow: ellipsis;
}

.main-canvas {
  width: min(1420px, calc(100% - 72px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.toast {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 13px 10px 15px;
  border: 1px solid rgba(53, 214, 161, 0.28);
  border-radius: var(--radius);
  color: #11684f;
  background: rgba(53, 214, 161, 0.13);
  font-size: 13px;
  font-weight: 760;
}

.toast button {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #11684f;
  background: rgba(255, 255, 255, 0.56);
}

.page-hero {
  margin-bottom: 22px;
  padding: 44px 46px;
  border-radius: var(--radius);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(185, 255, 102, 0.22), transparent 36%),
    linear-gradient(150deg, #15171c 0%, #222633 100%);
  box-shadow: var(--shadow);
}

.eyebrow {
  width: fit-content;
  margin-bottom: 22px;
  padding: 7px 11px;
  border: 1px solid rgba(185, 255, 102, 0.24);
  border-radius: var(--radius);
  color: var(--lime);
  background: rgba(185, 255, 102, 0.08);
  font-size: 12px;
  font-weight: 820;
}

.page-hero h1 {
  max-width: 820px;
  font-size: clamp(38px, 4.4vw, 64px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 900;
}

.page-hero p {
  max-width: 620px;
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 17px;
  line-height: 1.7;
}

.primary-link,
.secondary-link,
.primary-button,
.ghost-button,
.rule-row button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 820;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-link,
.primary-button {
  padding: 0 18px;
  color: #11140f;
  background: var(--lime);
}

.secondary-link,
.ghost-button {
  padding: 0 16px;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.secondary-link {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.primary-link:hover,
.primary-button:hover,
.secondary-link:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(23, 26, 34, 0.12);
}

.status.is-active,
.status.is-active {
  padding: 6px 9px;
  border-radius: 6px;
  color: #176247;
  background: rgba(53, 214, 161, 0.16);
  font-size: 11px;
  text-transform: uppercase;
}

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

.metrics strong {
  display: block;
  font-size: 24px;
  letter-spacing: 0;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(480px, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.access-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(520px, 1.2fr);
  gap: 18px;
  align-items: stretch;
}

.surface {
  padding: 22px;
}

.section-head {
  gap: 13px;
  margin-bottom: 18px;
}

.section-head span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  color: var(--charcoal);
  background: var(--lime);
  font-size: 13px;
  font-weight: 860;
}

.section-head h2 {
  font-size: 19px;
  line-height: 1.1;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.section-head.compact {
  margin-bottom: 14px;
}

label {
  position: relative;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

textarea {
  min-height: 124px;
  resize: vertical;
  padding: 14px 15px;
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

textarea:focus,
input:focus {
  border-color: rgba(93, 124, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(93, 124, 255, 0.11);
  outline: 0;
}

#prompt-preview {
  min-height: 110px;
}

label small {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--soft);
  font-size: 11px;
}

.char-warn {
  color: var(--red) !important;
}

.field-label {
  margin: 15px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.type-card {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  text-align: left;
}

.type-card span {
  width: 29px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--charcoal);
  font-size: 10px;
  font-weight: 850;
}

.type-card strong {
  font-size: 12px;
  line-height: 1.2;
}

.type-card:hover,
.type-card.active {
  border-color: rgba(23, 26, 34, 0.24);
  color: var(--ink);
  background: #fff;
}

.type-card.active span {
  color: var(--charcoal);
  background: var(--lime);
}

.primary-button {
  border: 0;
}

.primary-button.wide {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
}

.primary-button.small,
.ghost-button {
  min-height: 36px;
  padding: 0 13px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.profile-panel {
  display: flex;
  flex-direction: column;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 17px;
}

.empty-state p {
  max-width: 240px;
  line-height: 1.45;
}

.agent-card-large {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--charcoal);
  color: #fff;
}

.agent-card-large span {
  color: var(--lime);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.agent-card-large h3 {
  margin: 4px 0 7px;
  font-size: 23px;
  line-height: 1.05;
}

.agent-card-large p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  line-height: 1.45;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.profile-facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.profile-facts span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.profile-facts strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.ca-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed rgba(20, 24, 31, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.ca-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.ca-box button {
  width: 100%;
  display: block;
  margin-top: 5px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  overflow-wrap: anywhere;
}

.cap-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.cap-list span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 720;
}

.side-stack {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.agent-symbol {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--charcoal);
  background: var(--lime);
  font-size: 18px;
  font-weight: 900;
}

.agent-symbol.small {
  width: 52px;
  height: 52px;
  align-self: start;
  font-size: 13px;
}

.access-panel {
  display: grid;
  gap: 9px;
}

.rule-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.rule-row b {
  font-size: 14px;
}

.rule-row span {
  color: var(--muted);
  font-size: 12px;
}

.rule-row i {
  padding: 5px 8px;
  border-radius: 6px;
  color: #176247;
  background: rgba(53, 214, 161, 0.16);
  font-size: 11px;
  font-style: normal;
  font-weight: 820;
}

.rule-row.pay i {
  display: none;
}

.rule-row button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--charcoal);
  background: var(--lime);
  font-size: 12px;
}

.chat-panel {
  min-height: 310px;
  display: flex;
  flex-direction: column;
}

.chat-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 180px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  text-align: center;
}

.chat-placeholder strong {
  color: var(--ink);
}

.chat-messages {
  flex: 1;
  min-height: 178px;
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 26, 34, 0.08);
  font-size: 13px;
  line-height: 1.45;
}

.chat-msg span {
  display: block;
  margin-bottom: 4px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.chat-msg.user {
  justify-self: end;
  color: #fff;
  background: var(--charcoal);
}

.chat-msg.agent {
  justify-self: start;
}

.chat-empty,
.chat-loading {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chat-input-row input {
  min-height: 42px;
  min-width: 0;
  padding: 0 13px;
}

.marketplace {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
}

.market-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.market-head span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.market-head h2 {
  margin-top: 4px;
  font-size: 28px;
}

.market-head b {
  padding: 8px 11px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

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

.market-card {
  min-height: 184px;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.market-title {
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.market-title h3 {
  font-size: 17px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.status {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--muted);
  background: rgba(20, 24, 31, 0.06);
  font-size: 11px;
  font-weight: 820;
}

.market-copy p {
  display: -webkit-box;
  overflow: hidden;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.market-meta {
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.market-meta span {
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--muted);
  background: rgba(20, 24, 31, 0.055);
  font-size: 11px;
  font-weight: 760;
}

.market-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.empty-market {
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.metrics div {
  padding: 18px;
}

.table-panel {
  margin-top: 18px;
}

.agent-table {
  display: grid;
  gap: 8px;
}

.agent-table div {
  display: grid;
  grid-template-columns: 34px minmax(180px, 1fr) 160px 110px 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.agent-table b {
  color: var(--soft);
}

.agent-table span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1220px) {
  .nav-bar {
    grid-template-columns: 1fr auto;
    height: auto;
    padding: 14px 24px;
  }

  .top-nav {
    grid-column: 1 / -1;
    justify-self: start;
    overflow-x: auto;
    max-width: 100%;
  }

  .studio-layout,
  .access-layout {
    grid-template-columns: 1fr;
  }

  .market-grid,
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(140deg, rgba(185, 255, 102, 0.2), transparent 26%),
      linear-gradient(180deg, #f8f6f0 0%, var(--bg) 100%);
  }

  .main-canvas {
    width: min(100% - 20px, 1420px);
    padding: 14px 0 28px;
  }

  .nav-bar {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px;
    align-items: start;
  }

  .brand {
    width: 100%;
    justify-content: flex-start;
    font-size: 18px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .wallet-area {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: 8px;
    justify-content: flex-start;
  }

  .ca-pill {
    grid-column: 1 / -1;
    max-width: 100%;
    height: auto;
    min-height: 40px;
    justify-content: flex-start;
    padding: 8px 10px;
    overflow-wrap: anywhere;
    white-space: normal;
    line-height: 1.35;
  }

  .network-pill,
  .wallet-pill {
    min-width: 0;
    min-height: 38px;
    font-size: 12px;
  }

  .wallet-pill {
    max-width: none;
  }

  .x-link {
    width: 38px;
    height: 38px;
  }

  .top-nav {
    width: 100%;
    justify-self: stretch;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
  }

  .top-nav::-webkit-scrollbar {
    display: none;
  }

  .top-nav button {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0 11px;
    font-size: 12px;
  }

  .page-hero {
    margin-bottom: 14px;
    padding: 24px 18px;
  }

  .page-hero h1 {
    font-size: 34px;
    line-height: 1.02;
  }

  .page-hero p {
    margin-top: 12px;
    font-size: 15px;
    line-height: 1.55;
  }

  .eyebrow {
    margin-bottom: 14px;
    font-size: 11px;
  }

  .surface,
  .marketplace {
    padding: 14px;
  }

  .studio-layout,
  .access-layout {
    gap: 12px;
  }

  .section-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .section-head span {
    width: 34px;
    height: 34px;
  }

  .section-head h2 {
    font-size: 17px;
  }

  .section-head p {
    font-size: 12px;
  }

  textarea {
    min-height: 116px;
    padding: 12px;
    font-size: 12px;
  }

  .type-grid,
  .profile-facts,
  .market-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .type-grid {
    gap: 7px;
  }

  .type-card {
    min-height: 52px;
    grid-template-columns: 34px 1fr;
    align-items: center;
  }

  .agent-card-large,
  .rule-row,
  .chat-input-row {
    grid-template-columns: 1fr;
  }

  .agent-symbol {
    width: 100%;
    height: 74px;
  }

  .agent-card-large h3 {
    font-size: 21px;
  }

  .ca-box button {
    font-size: 11px;
  }

  .rule-row {
    justify-items: start;
  }

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

  .chat-messages {
    min-height: 160px;
    max-height: 240px;
  }

  .chat-msg {
    max-width: 94%;
  }

  .marketplace {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .market-card {
    min-height: 0;
    padding: 14px;
    grid-template-columns: 48px 1fr;
  }

  .agent-symbol.small {
    width: 48px;
    height: 48px;
  }

  .market-head {
    align-items: flex-start;
  }

  .agent-table div {
    grid-template-columns: 28px 1fr;
  }

  .agent-table span {
    grid-column: 2;
  }
}

@media (max-width: 420px) {
  .main-canvas {
    width: min(100% - 14px, 1420px);
  }

  .page-hero h1 {
    font-size: 30px;
  }

  .wallet-area {
    grid-template-columns: 1fr 36px;
  }

  .network-pill,
  .wallet-pill,
  .x-link {
    min-height: 36px;
  }

  .top-nav button {
    padding: 0 9px;
  }

  .market-actions {
    grid-template-columns: 1fr;
  }
}
