:root {
  --ink: #f4f1e8;
  --muted: #a9b7ad;
  --line: rgba(226, 238, 228, .12);
  --panel: rgba(14, 29, 25, .78);
  --panel-strong: rgba(16, 35, 29, .94);
  --green: #5de3a5;
  --green-dark: #174f3c;
  --gold: #e2ba6b;
  --danger: #ff8b87;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #07130f; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 13% 15%, rgba(19, 113, 76, .2), transparent 29rem),
    linear-gradient(145deg, #081711 0%, #0c1c17 52%, #07110e 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.ambient { position: fixed; border-radius: 999px; filter: blur(100px); pointer-events: none; opacity: .18; }
.ambient-one { width: 24rem; height: 24rem; background: #1fc47c; top: 12%; left: -14rem; }
.ambient-two { width: 21rem; height: 21rem; background: #d8a94e; right: -13rem; bottom: 4%; }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; letter-spacing: .08em; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(93, 227, 165, .42); border-radius: 12px; background: rgba(93, 227, 165, .08); color: var(--green); font: 700 12px Georgia, serif; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.connection { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(7, 17, 14, .5); color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #87928c; box-shadow: 0 0 0 4px rgba(135, 146, 140, .1); }
.connection[data-state="ready"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(93, 227, 165, .1); }
.connection[data-state="ready"] { color: var(--green); }
.connection[data-state="error"] .status-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 139, 135, .1); }
.connection[data-state="error"] { color: var(--danger); }

.shell { position: relative; z-index: 1; width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 72px; }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 48px; margin-bottom: 42px; }
.eyebrow, .step { margin: 0 0 9px; color: var(--green); font-size: 10px; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
h1 { max-width: 720px; margin: 0; font: 500 clamp(40px, 6.5vw, 74px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.hero-copy { max-width: 650px; margin: 20px 0 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.authority-card { display: grid; grid-template-columns: auto auto; gap: 10px 22px; min-width: 230px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(7, 17, 14, .44); box-shadow: var(--shadow); }
.authority-card span { color: var(--muted); font-size: 11px; }
.authority-card strong { text-align: right; font-size: 11px; font-weight: 650; }

.grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 18px; align-items: start; }
.left-column, .right-column { display: grid; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 20px; padding: 24px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0; font: 500 23px/1.1 Georgia, serif; }
.hint { margin: -9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.token-row, .auth-actions { display: flex; align-items: end; gap: 12px; }
.grow { flex: 1; }
.field-grid { display: grid; gap: 12px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.action-fields { grid-template-columns: .55fr .9fr 1.35fr 1fr; }
.field { display: grid; gap: 7px; }
.field span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 11px; outline: none; padding: 0 13px; color: var(--ink); background: rgba(2, 11, 8, .52); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: rgba(93, 227, 165, .62); box-shadow: 0 0 0 3px rgba(93, 227, 165, .1); }
input:disabled { opacity: .45; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.primary-button, .secondary-button, .quiet-button { border-radius: 11px; font-weight: 720; transition: transform .15s, filter .15s, border-color .15s; }
.primary-button { min-height: 44px; border: 0; padding: 0 18px; background: var(--green); color: #052017; box-shadow: 0 8px 24px rgba(93, 227, 165, .12); }
.secondary-button { min-height: 39px; border: 1px solid rgba(93, 227, 165, .27); padding: 0 14px; background: rgba(93, 227, 165, .07); color: var(--green); }
.quiet-button { border: 0; padding: 5px; color: var(--muted); background: transparent; font-size: 11px; }
button:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.sequence, .timestamp { color: var(--muted); font-size: 11px; }
.sequence strong { margin-left: 5px; color: var(--gold); font-size: 14px; }
.action-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.action-footer p { margin: 0; color: var(--muted); font-size: 11px; }
.action-button { min-width: 160px; }
.action-button span { margin-left: 12px; font-size: 17px; }

.observation-panel { background: linear-gradient(145deg, rgba(23, 79, 60, .44), rgba(14, 29, 25, .9)); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; margin: 0 -6px 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.metrics div { padding: 14px; background: var(--panel-strong); }
.metrics span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.metrics strong { color: var(--gold); font: 500 22px Georgia, serif; }
.result-box { display: grid; place-items: center; min-height: 220px; border: 1px dashed rgba(226, 238, 228, .15); border-radius: 15px; padding: 28px; text-align: center; }
.result-box strong { margin-top: 15px; font: 500 17px Georgia, serif; }
.result-box span { margin-top: -14px; color: var(--muted); font-size: 11px; }
.card-stack { position: relative; width: 62px; height: 48px; }
.card-stack i { position: absolute; top: 0; left: 18px; width: 31px; height: 43px; border: 1px solid rgba(93, 227, 165, .45); border-radius: 5px; background: #102c22; transform: rotate(0); }
.card-stack i:first-child { transform: translateX(-13px) rotate(-12deg); }
.card-stack i:last-child { transform: translateX(13px) rotate(12deg); }
.json-view { max-height: 320px; overflow: auto; margin: 0; border: 1px solid var(--line); border-radius: 13px; padding: 16px; color: #c7e7d6; background: rgba(2, 9, 7, .62); font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.hidden { display: none; }
.activity-panel { min-height: 232px; }
.activity-list { display: grid; gap: 11px; max-height: 330px; overflow: auto; margin: 0; padding: 0; list-style: none; }
.activity-list li { display: grid; grid-template-columns: 9px 1fr auto; gap: 10px; align-items: start; padding: 11px 0; border-bottom: 1px solid rgba(226, 238, 228, .07); }
.activity-list li::before { content: ""; width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--green); }
.activity-list li.error::before { background: var(--danger); }
.activity-list strong { display: block; font-size: 11px; }
.activity-list span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.activity-list time { color: var(--muted); font-size: 9px; }
.activity-list .empty-activity { display: block; color: var(--muted); font-size: 11px; border: 0; }
.activity-list .empty-activity::before { display: none; }
.toast { position: fixed; z-index: 5; right: 22px; bottom: 22px; max-width: min(390px, calc(100% - 44px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #17382d; box-shadow: var(--shadow); color: var(--ink); font-size: 12px; transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255, 139, 135, .38); background: #44231f; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .authority-card { width: min(100%, 360px); }
  .grid { grid-template-columns: 1fr; }
  .right-column { grid-row: 1; }
}
@media (max-width: 620px) {
  .topbar, .shell { width: min(100% - 24px, 1180px); }
  .topbar { padding: 16px 0; }
  .shell { padding-top: 36px; }
  .brand small { display: none; }
  .hero { gap: 24px; margin-bottom: 28px; }
  h1 { font-size: 42px; }
  .panel { padding: 19px; border-radius: 16px; }
  .panel-heading { align-items: flex-start; }
  .token-row, .auth-actions { align-items: stretch; flex-direction: column; }
  .field-grid.three, .action-fields { grid-template-columns: 1fr 1fr; }
  .action-footer { align-items: stretch; flex-direction: column; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 410px) {
  .field-grid.three, .action-fields { grid-template-columns: 1fr; }
  .connection { padding: 8px; }
  #connectionText { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
