:root {
  /* Spacing scale (8/12/16/24 as primary) */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;

  /* Radius scale */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 20px;

  /* Shadow scale (clean + consistent) */
  --shadow-1: 0 8px 18px -14px rgba(15, 23, 42, 0.18);
  --shadow-2: 0 18px 44px -30px rgba(15, 23, 42, 0.18);
  --shadow-3: 0 28px 70px -44px rgba(15, 23, 42, 0.22);

  --bg: #f6f7fb;
  --gradient: radial-gradient(120% 120% at 50% -15%, rgba(112,142,255,0.22) 0%, rgba(255,255,255,0.97) 60%, #eef2ff 100%);
  --surface: rgba(255,255,255,0.94);
  --surface-strong: rgba(255,255,255,0.96);
  --border: rgba(195,206,235,0.45);
  --border-soft: rgba(195,206,235,0.28);
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --accent-3: #0ea5e9;
  --danger: #f97316;
  --success: #22c55e;
  --warning: #fbbf24;
  --text-primary: #101830;
  --text-secondary: #3b4764;
  --text-muted: #74809f;
  /* Back-compat tokens */
  --shadow: var(--shadow-3);
  --shadow-soft: var(--shadow-2);
  --input-height: 72px;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--gradient);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  letter-spacing: 0.01em;
}

h1, h2, h3 {
  line-height: 1.15;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-3); color: var(--text-secondary); }


header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255,255,255,0.94);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) 0;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(18px);
  transition: padding 0.25s ease;
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.brand-link:hover { transform: translateY(-1px); }

.brand-link img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
}

.logo-text {
  background: linear-gradient(135deg, #0ea5e9, #2563eb 55%, #3730a3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.06em;
}

.user-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-status .user-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.24);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.user-status .user-name i { color: var(--accent); }

.user-status a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  background: rgba(250,252,255,0.84);
  border: 1px solid rgba(207,217,236,0.52);
  color: var(--text-secondary);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.user-status a:hover {
  transform: translateY(-2px);
  border-color: rgba(99,102,241,0.24);
  background: rgba(99,102,241,0.12);
  color: var(--text-primary);
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(207,217,236,0.6);
  background: rgba(252,253,255,0.85);
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.toggle-pill:hover {
  transform: translateY(-2px);
  border-color: rgba(99,102,241,0.24);
  background: rgba(99,102,241,0.12);
  color: var(--text-primary);
}

.toggle-pill i { color: var(--accent-2); }

main {
  flex: 1 1 auto;
  width: calc(100% - 3rem);
  max-width: 1080px;
  margin: var(--space-4) auto var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-3);
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--accent-3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.62rem 1.25rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(45,212,191,0.9), rgba(59,130,246,0.86));
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-2);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-3);
}

.btn[disabled],
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.78rem 1.45rem;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-2);
}

.btn-primary i { font-size: 1rem; }

.ghost-btn {
  border: 1px solid rgba(207,217,236,0.75);
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius-md);
  padding: 0.62rem 1.15rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  color: var(--text-primary);
}

.card {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-1);
}

.status-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.status-text.error { color: #dc2626; }

.muted {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.pill-btn {
  border: 1px solid rgba(14,165,233,0.28);
  background: rgba(14,165,233,0.08);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
}

.pill-btn.copy {
  border-color: rgba(99,102,241,0.28);
  background: rgba(99,102,241,0.08);
}

.pill-btn.secondary {
  border-color: rgba(16,185,129,0.32);
  background: rgba(16,185,129,0.08);
}

.sample-btn {
  border: 1px solid rgba(14,165,233,0.22);
  background: rgba(16,185,129,0.08);
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.badge-soft {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(14,165,233,0.12);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.92rem;
}

.feed-table {
  width: 100%;
  border-collapse: collapse;
}

.feed-table th,
.feed-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.feed-table th {
  background: rgba(14,165,233,0.12);
  font-weight: 700;
}

.feed-table td:first-child,
.feed-table th:first-child {
  text-align: center;
  white-space: nowrap;
  width: 68px;
}

.ref-table {
  border: 1px solid rgba(14,165,233,0.2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.error { color: #dc3545; margin-top: 1rem; font-weight: 500; }

:where(
    a,
    button,
    input,
    textarea,
    select,
    summary,
    [role="button"],
    [tabindex]:not([tabindex="-1"])
  ):focus-visible {
  outline: 2px solid rgba(14, 165, 233, 0.65);
  outline-offset: 3px;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
}

.toast-message {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(192, 203, 236, 0.5);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-2);
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  width: 22px;
  text-align: center;
  filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.18));
}

.toast-text {
  line-height: 1.35;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.toast-action {
  appearance: none;
  border: 1px solid rgba(14, 165, 233, 0.32);
  background: rgba(14, 165, 233, 0.12);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.toast-action:hover {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(14, 165, 233, 0.18);
}

.toast-message.success {
  border-color: rgba(16, 185, 129, 0.45);
}
.toast-message.warning {
  border-color: rgba(251, 191, 36, 0.55);
}
.toast-message.error {
  border-color: rgba(248, 113, 113, 0.6);
}

@media (max-width: 768px) {
  header { padding: var(--space-2) 0; }
  .header-container { padding: 0 var(--space-3); }
  .brand { font-size: 1.25rem; }
  .brand-link img { width: 34px; height: 34px; }
  .user-status { gap: var(--space-2); }
  .user-status .user-name,
  .user-status a,
  .toggle-pill { padding: 0.32rem 0.7rem; font-size: 0.85rem; }
  main { width: calc(100% - 1.4rem); margin: var(--space-3) auto var(--space-4); padding: var(--space-4); border-radius: var(--radius-lg); }
  .btn { font-size: 0.9rem; padding: 0.55rem 1rem; }
}
