:root {
  --text: #181a20;
  --muted: #737985;
  --line: #e8e9ed;
  --soft: #f5f6f8;
  --blue: #2f73ff;
  --blue-dark: #173a7a;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: #fbfbfc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 30px;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}
.brand, .nav, .top-actions { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 24px; font-weight: 850; letter-spacing: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(145deg, #f0f1f4, #ffffff);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.top-actions { gap: 10px; }
.status-pill, .user-button, .ghost-button, .secondary-button, .icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
.status-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.status-pill.ok { color: #047857; border-color: #bbf7d0; background: #f0fdf4; }
.status-pill.error { color: #b42318; border-color: #fecaca; background: #fff7f7; }
.user-button, .ghost-button, .secondary-button, .primary-button {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 850;
}
.user-button.has-key { border-color: #bbf7d0; background: #f0fdf4; color: #047857; }
.ghost-button { color: var(--muted); }
.secondary-button { color: #4b5563; }
.primary-button {
  border: 0;
  background: #111;
  color: #fff;
}
.primary-button:disabled { opacity: 0.55; cursor: not-allowed; }
.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.home {
  min-height: calc(100vh - 68px);
  display: flex;
  justify-content: center;
  padding: 8vh 20px 48px;
}
.hero {
  width: min(100%, 1060px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.logo-lockup {
  display: flex;
  align-items: baseline;
  justify-content: center;
  color: var(--blue-dark);
  font-size: clamp(58px, 9.5vw, 104px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
  overflow: hidden;
  padding: 0 0.05em 0.1em;
}
.logo-lockup .logo-char {
  display: inline-block;
  will-change: transform, opacity;
  animation: logoCharSweep 7.2s cubic-bezier(.2,.8,.2,1) infinite;
  animation-delay: calc(var(--i) * 90ms);
}
.logo-lockup .logo-number {
  color: var(--blue);
  font: inherit;
}
@keyframes logoCharSweep {
  0%, 52%, 100% { transform: translateX(0); opacity: 1; }
  60% { transform: translateX(0.42em); opacity: 0; }
  61% { transform: translateX(-0.42em); opacity: 0; }
  72% { transform: translateX(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-lockup .logo-char {
    animation: none;
  }
}
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 32px 0 20px;
}
.mode-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 850;
}
.mode-tabs button.selected {
  border-color: #111;
  background: #111;
  color: #fff;
}
.capability-grid {
  width: min(100%, 880px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 30px 0 20px;
}
.capability-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  justify-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  padding: 16px;
  text-align: left;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.capability-card:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 115, 255, 0.42);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
}
.capability-card.selected {
  border-color: #111;
  box-shadow: inset 0 0 0 1px #111, 0 16px 38px rgba(15, 23, 42, 0.08);
}
.capability-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}
.capability-card strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}
.capability-card small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}
.card-index {
  min-width: 32px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 900;
}
.capability-card.selected .card-index {
  background: #111;
  color: #fff;
}
.prompt-bar {
  width: min(100%, 760px);
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr 56px;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 24px;
  border: 1px solid #dfe2e7;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}
.prompt-bar textarea {
  width: 100%;
  max-height: 150px;
  min-height: 32px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1.45;
  padding: 0;
}
.prompt-bar textarea::placeholder { color: #a5abb6; }
.prompt-bar button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: #0b0b0c;
  color: #fff;
}
.prompt-bar button:disabled { opacity: 0.55; cursor: not-allowed; }
.key-dialog {
  width: min(92vw, 480px);
  border: 0;
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}
.key-dialog::backdrop {
  background: rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(4px);
}
.key-panel {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: #fff;
}
.key-head,
.key-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}
h2 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}
.key-panel label {
  font-size: 14px;
  font-weight: 850;
}
.key-panel input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  padding: 0 14px;
  color: var(--text);
}
.key-panel input:focus {
  border-color: rgba(47, 115, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(47, 115, 255, 0.1);
}
.key-message {
  min-height: 20px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.key-message.ok { color: #157347; }
.key-message.error { color: #b42318; }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .status-pill { display: none; }
  .home { padding-top: 7vh; }
  .capability-grid {
    grid-template-columns: 1fr;
    width: min(100%, 460px);
  }
  .prompt-bar {
    grid-template-columns: 1fr 50px;
    min-height: 66px;
    padding-left: 18px;
  }
  .prompt-bar textarea { font-size: 17px; }
  .prompt-bar button { width: 50px; height: 50px; }
}
