/* =============================================
   DESIGN TOKENS: the signature Rare UI dark set
   (black surfaces, near-white text, teal accent,
   tight radii, short purposeful motion), same
   constants as the rest of the estate.
   ============================================= */
:root {
  --brand-x: #2dd4bf;
  --brand-x-dark: #5eead4;
  --brand-warn: #ffad1f;
  --brand-off: #737373;

  --bg: #000000;
  --bg-surface: #0e0e0e;
  --bg-muted: #171717;
  --bg-hover: #232323;
  --border: #444444;

  --text-primary: #e8e8e8;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.6);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-hover: 120ms;

  color-scheme: dark;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 700; letter-spacing: -0.02em; }

.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
code { font-family: ui-monospace, monospace; background: var(--bg-muted); padding: 1px 6px; border-radius: var(--radius-sm); font-size: 0.85em; }

/* Top bar */
.glass {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-mark { color: var(--brand-x); align-self: center; }
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-muted); font-size: 0.8rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chain-badge {
  font-size: 0.72rem;
  color: var(--brand-x);
  border: 1px solid color-mix(in srgb, var(--brand-x) 40%, transparent);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

/* Buttons, same spring feel as the estate */
.btn {
  font-weight: 600;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  padding: 9px 18px;
  font-size: 0.9rem;
  transition: transform var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease), box-shadow var(--dur-hover) var(--ease);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-x);
  color: #00110f;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-x-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-x) 35%, transparent);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-muted); }
.btn-small { padding: 5px 12px; font-size: 0.78rem; }
.btn-danger { background: transparent; border: 1px solid #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: rgba(127, 29, 29, 0.25); }

/* Inputs */
.input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.9rem;
  transition: border-color var(--dur-hover) var(--ease);
}
.input:focus { outline: none; border-color: var(--brand-x); }
.small-input { max-width: 260px; }

/* Layout */
.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
}
.panel h2 { font-size: 1.05rem; margin-bottom: 6px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.hero h1 { font-size: 1.6rem; margin-bottom: 12px; max-width: 22ch; }
.hero p { color: var(--text-secondary); max-width: 72ch; }
.hero-links { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.identity-row { display: flex; gap: 10px; margin: 12px 0; }
.identity-row .input { flex: 1; }
.identity-result { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.badge {
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: var(--radius-full);
  padding: 4px 12px;
}
.badge.is-held { color: #00110f; background: var(--brand-x); }
.badge.is-none { color: var(--text-secondary); border: 1px solid var(--border); }

/* Grant form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; }
.scope-row { display: flex; gap: 8px; flex-wrap: wrap; }
.scope-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--dur-hover) var(--ease);
}
.scope-chip.active { background: var(--brand-x); border-color: var(--brand-x); color: #00110f; font-weight: 700; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* Trails */
.trail-summary { font-size: 0.85rem; margin: 8px 0 14px; }
.grants-list { display: flex; flex-direction: column; gap: 14px; }
.grant-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: cardSlideIn 0.3s ease-out both;
}
.grant-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grant-id { font-weight: 700; }
.scope-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-x);
  border: 1px solid color-mix(in srgb, var(--brand-x) 35%, transparent);
  border-radius: var(--radius-full);
  padding: 2px 10px;
}
.state-tag { font-size: 0.72rem; font-weight: 700; border-radius: var(--radius-full); padding: 2px 10px; }
.state-tag.is-live { color: #00110f; background: var(--brand-x); }
.state-tag.is-revoked { color: #fca5a5; background: rgba(127, 29, 29, 0.3); }
.state-tag.is-expired { color: var(--brand-warn); border: 1px solid color-mix(in srgb, var(--brand-warn) 40%, transparent); }
.state-tag.is-exhausted { color: var(--text-muted); border: 1px solid var(--border); }
.grant-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 18px; font-size: 0.82rem; }
.grant-rows .k { color: var(--text-muted); }
.grant-rows .v { color: var(--text-primary); }
.cap-bar { height: 5px; background: var(--bg-hover); border-radius: var(--radius-full); overflow: hidden; }
.cap-bar > div { height: 100%; background: var(--brand-x); transition: width 0.3s var(--ease); }
.cap-bar.is-full > div { background: var(--brand-warn); }
.grant-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grant-actions .input { max-width: 130px; }
.trail-root { font-size: 0.75rem; color: var(--text-muted); word-break: break-all; }
.empty { color: var(--text-muted); padding: 18px 0; text-align: center; }

/* Status line */
.status-line {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 18px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  display: none;
  max-width: min(92vw, 640px);
}
.status-line.show { display: block; animation: cardSlideIn 0.25s ease-out both; }
.status-line.is-err { border-color: #7f1d1d; color: #fca5a5; }

.footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px 40px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}
.footer p { max-width: 70ch; margin: 0 auto; }

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
a { color: var(--brand-x); }
:focus-visible { outline: 2px solid var(--brand-x); outline-offset: 2px; }