:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #1f2430;
  --ink-2: #6b7280;
  --ink-3: #9aa1ac;
  --line: #e8eaf0;
  --accent: #6c5ce7;
  --accent-weak: #eef0ff;
  --consumer: #2f80ed;
  --consumer-weak: #eaf2fe;
  --provider: #f2994a;
  --provider-weak: #fdf1e6;
  --appact: #6c5ce7;
  --appact-weak: #efeaff;
  --ok: #17a673;
  --danger: #e5484d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.05), 0 8px 24px rgba(20, 24, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win, even over class rules that set display (flex/grid). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* ---- hero ---- */
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.hero p { color: var(--ink-2); margin: 0; font-size: 15px; }

/* ---- selectors row ---- */
.selectors {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.lane { display: flex; flex-direction: column; gap: 8px; flex: 1 1 220px; min-width: 200px; }
.lane-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3); }
.lane-label.accent { color: var(--accent); text-align: center; }

.app-select {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  min-height: 56px;
}
.app-select.appact { border-color: var(--appact-weak); background: linear-gradient(0deg, #fff, #fff); cursor: default; justify-content: center; }
.app-select .chev { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.app-name { font-weight: 600; font-size: 14px; }
.app-sub { font-size: 11px; color: var(--ink-3); }
.app-meta { display: flex; flex-direction: column; line-height: 1.25; }

.avatar {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex: none;
}
.appact-avatar { background: var(--appact); }

.connector-dash {
  flex: 0 0 44px;
  height: 2px;
  margin-bottom: 26px;
  background-image: linear-gradient(90deg, var(--ink-3) 45%, transparent 0);
  background-size: 10px 2px;
  opacity: 0.5;
}

.connect-btn {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.06s ease, opacity 0.15s ease;
}
.connect-btn:hover { transform: translateY(-1px); }
.connect-btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* ---- dropdown menu ---- */
.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
  overflow: hidden;
}
.menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.menu-item:hover { background: var(--accent-weak); }

/* ---- result banner ---- */
.result-banner {
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.result-banner.ok { background: #e8f7f0; color: #0f7a53; border: 1px solid #bfe9d6; }
.result-banner.blocked { background: #fdeceb; color: #b42318; border: 1px solid #f6cecb; }

/* ---- panels ---- */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panels:has(.wide) { grid-template-columns: 1fr; }
.panel.wide { max-width: 720px; margin: 0 auto; width: 100%; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 260px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-flow { display: flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 13px; }
.panel-title { font-weight: 700; font-size: 14px; }
.panel-sub { font-size: 12px; color: var(--ink-3); }
.live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); font-weight: 600; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(23,166,115,0.18); }

.thread { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 82%; animation: pop 0.22s ease; }
.msg.left { align-self: flex-start; align-items: flex-start; }
.msg.right { align-self: flex-end; align-items: flex-end; }
.msg-who { font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.msg-bubble {
  background: #f1f3f8; color: var(--ink);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45;
}
.msg.right .msg-bubble { background: var(--appact-weak); }
.msg.who-consumer .msg-who { color: var(--consumer); }
.msg.who-provider .msg-who { color: var(--provider); }
.msg.who-appact .msg-who { color: var(--appact); }
.msg.who-consumer .msg-bubble { background: var(--consumer-weak); }
.msg.who-provider .msg-bubble { background: var(--provider-weak); }
.msg.who-appact .msg-bubble { background: var(--appact-weak); }
.msg-time { font-size: 10px; color: var(--ink-3); }

.data-block { margin-top: 8px; }
.data-block .data-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.data-block ul, .data-block ol { margin: 0; padding-left: 18px; }
.data-block li { font-size: 12px; margin: 2px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--ink-2); }

.typing { display: inline-flex; gap: 3px; padding: 8px 10px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1s infinite; }
.typing i:nth-child(2){ animation-delay: 0.2s; } .typing i:nth-child(3){ animation-delay: 0.4s; }

.composer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.composer input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13px; color: var(--ink-2); background: #fbfbfe; }
.composer .send { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; border: none; display: inline-flex; align-items: center; justify-content: center; }

/* ---- contract card ---- */
.contract-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-top: 6px;
}
.contract-card h2 { margin: 0 0 4px; font-size: 18px; }
.contract-meta { color: var(--ink-2); font-size: 13px; margin-bottom: 16px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: #fafbff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--ink-3); letter-spacing: 0.03em; }
.stat.ok .v { color: var(--ok); }

table.caps { width: 100%; border-collapse: collapse; font-size: 13px; }
table.caps th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: 11px; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.caps td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.caps td code { background: #f1f3f8; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.badge-val { color: var(--ok); font-size: 11px; font-weight: 700; }
.badge-doc { color: var(--ink-3); font-size: 11px; font-weight: 600; }

.sig-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.sig { background: #fafbff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.sig .role { font-size: 11px; color: var(--ink-3); }
.sig .key { font-size: 12px; font-weight: 600; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); word-break: break-all; }

/* ---- connector kit download ---- */
.kit {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: linear-gradient(120deg, #f4f2ff 0%, #eef4ff 100%);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; margin-bottom: 22px;
}
.kit-info { max-width: 640px; }
.kit-info h2 { margin: 0 0 4px; font-size: 18px; }
.kit-info p { margin: 0 0 10px; color: var(--ink-2); font-size: 13.5px; }
.kit-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 12.5px; line-height: 1.7; }
.kit-list code { background: #ffffffAA; border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; font-size: 12px; }
.kit-btn {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; text-align: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
  padding: 16px 26px; border-radius: 12px; box-shadow: 0 6px 18px rgba(108, 92, 231, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kit-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(108, 92, 231, 0.45); }
.kit-btn-icon { font-size: 20px; }
.kit-btn-sub { font-size: 10.5px; font-weight: 500; opacity: 0.85; }

/* ---- register your app ---- */
.register { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.register-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer; padding: 16px 22px; font-size: 15px; font-weight: 700; color: var(--ink);
}
.register-chev { transition: transform 0.15s ease; color: var(--ink-3); }
.register.open .register-chev { transform: rotate(180deg); }
.register-body { padding: 0 22px 20px; }
.register-note { color: var(--ink-2); font-size: 13px; margin: 0 0 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 10px 0 5px; }
.reg-textarea, .reg-input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 13px;
  font-family: ui-monospace, Menlo, monospace; background: #fbfcfe; color: var(--ink);
}
.reg-textarea { min-height: 180px; resize: vertical; }
.register-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.register-btn { background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 9px; }
.register-btn:disabled { opacity: 0.6; cursor: default; }
.register-result { font-size: 13px; }
.register-result.ok { color: var(--ok); }
.register-result.err { color: var(--danger); }

/* ---- live badge + provider login ---- */
.app-name-row { display: flex; align-items: center; gap: 8px; }
.live-badge { color: var(--ok); font-size: 10px; font-weight: 700; letter-spacing: 0.02em; }
.login-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f2fbf7; border: 1px solid #cdeede; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
}
.login-hint { font-size: 12.5px; color: var(--ink-2); flex: 1 1 260px; }
.login-input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13px; background: #fff; }

/* ---- discovery card ---- */
.discovery-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin-bottom: 16px; }
.discovery-card h3 { margin: 0 0 8px; font-size: 15px; }
.discovery-steps { margin: 6px 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; line-height: 1.8; }

/* ---- authorization / credential provisioning ---- */
.authorize { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.authorize h3 { margin: 0 0 6px; font-size: 15px; }
.auth-note { color: var(--ink-2); font-size: 12.5px; line-height: 1.5; margin: 6px 0; }
.auth-note code { background: #f1f3f8; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.auth-btn {
  margin-top: 8px; background: var(--provider); color: #fff; border: none; cursor: pointer;
  font-weight: 700; font-size: 14px; padding: 11px 18px; border-radius: 10px;
}
.auth-btn:disabled { opacity: 0.6; cursor: default; }
.minted { margin-top: 14px; background: #f2fbf7; border: 1px solid #cdeede; border-radius: 12px; padding: 14px 16px; animation: pop 0.25s ease; }
.minted-title { font-weight: 800; font-size: 14px; color: var(--ok); margin-bottom: 4px; }
.key-reveal { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.raw-key {
  flex: 1; background: #0f1424; color: #6ee7b7; font-family: ui-monospace, Menlo, monospace;
  font-size: 13px; padding: 10px 12px; border-radius: 8px; word-break: break-all;
}
.copy-btn { background: var(--ink); color: #fff; border: none; cursor: pointer; font-weight: 600; padding: 9px 14px; border-radius: 8px; font-size: 13px; }
.revoke-btn { background: transparent; color: var(--danger); border: 1px solid #f3c3c5; cursor: pointer; font-weight: 600; padding: 4px 12px; border-radius: 7px; font-size: 12px; }
.revoke-btn:disabled { opacity: 0.5; cursor: default; }

.foot { margin-top: 26px; text-align: center; color: var(--ink-3); font-size: 12px; }
.foot code { background: #eef0f6; padding: 1px 6px; border-radius: 6px; }

@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%,100%{ opacity: 0.3; } 50%{ opacity: 1; } }

@media (max-width: 820px) {
  .panels { grid-template-columns: 1fr; }
  .connector-dash { display: none; }
  .selectors { flex-direction: column; align-items: stretch; }
  .connect-btn { width: 100%; }
  .kit { flex-direction: column; align-items: stretch; text-align: center; }
  .kit-btn { align-self: center; }
}

/* ---- Account auth gate ------------------------------------------------------------------------ */
.auth-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--appact-weak), var(--bg));
  z-index: 50;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}
.auth-title { font-size: 22px; margin: 0 0 6px; }
.auth-sub { color: var(--ink-2); font-size: 14px; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-row { display: flex; gap: 12px; }
.auth-row > label { flex: 1; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.auth-form .hint { font-weight: 400; color: var(--ink-3); }
.auth-form input,
.auth-form textarea {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  outline: none;
  resize: vertical;
}
.auth-form input:focus,
.auth-form textarea:focus { border-color: var(--accent); background: #fff; }
.auth-btn-primary {
  margin-top: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.auth-btn-primary:hover { filter: brightness(1.05); }
.auth-btn-primary:disabled { opacity: 0.6; cursor: default; }
.auth-error {
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 13px;
}
.auth-switch { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---- Account bar ----------------------------------------------------------------------------- */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.logout-btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 560px) {
  .auth-row { flex-direction: column; gap: 12px; }
}

/* ---- Steps (how it works) -------------------------------------------------------------------- */
.steps {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.steps-head h2 { margin: 0 0 4px; font-size: 18px; }
.steps-head p { margin: 0 0 18px; color: var(--ink-2); font-size: 13.5px; }
.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.step {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 14px 14px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}
.step-body h3 { margin: 0 0 5px; font-size: 14px; }
.step-body p { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; }
.step-body code { font-size: 11.5px; background: var(--accent-weak); padding: 1px 4px; border-radius: 4px; }

@media (max-width: 900px) {
  .steps-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .steps-list { grid-template-columns: 1fr; }
}

/* ---- Kit prompt (copy for code agent) -------------------------------------------------------- */
.kit-prompt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.kit-prompt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.kit-prompt-head h2 { margin: 0 0 4px; font-size: 17px; }
.kit-prompt-note { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 60ch; }
.copy-prompt-btn {
  flex: none;
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.copy-prompt-btn:hover { filter: brightness(1.05); }
.copy-prompt-btn.copied { background: var(--ok); }
.kit-prompt-box {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f1220;
  color: #d7dbe8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}
.kit-prompt-box:focus { border-color: var(--accent); }

/* Recommended MCP panel emphasis */
.mcp-config { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak), var(--shadow); }
.reco {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.alt-tag {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.mcp-foot { margin-top: 12px; font-style: italic; opacity: 0.85; }

@media (max-width: 560px) {
  .kit-prompt-head { flex-direction: column; }
  .copy-prompt-btn { align-self: flex-start; }
}
