:root {
  color-scheme: dark;
  --bg-canvas: #080d17;
  --bg-surface: #0f172a;
  --bg-elevated: #17233b;
  --border-subtle: rgba(148, 163, 184, 0.22);
  --border-strong: rgba(52, 211, 153, 0.48);
  --text-primary: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-emerald: #34d399;
  --accent-emerald-ink: #052e16;
  --accent-gold: #facc15;
  --accent-gold-ink: #1e293b;
  --accent-sky: #38bdf8;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-border: #f87171;
  --danger-text: #fecaca;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --max-width: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 18% 8%, rgba(52, 211, 153, 0.12), transparent 42%),
    radial-gradient(circle at 86% 14%, rgba(56, 189, 248, 0.12), transparent 40%),
    var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-emerald);
}

:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 2px;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.container {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

.topbar {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(8, 13, 23, 0.88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-sky));
  color: var(--accent-emerald-ink);
  font-weight: 800;
  font-size: 0.95rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-size: 0.92rem;
  font-weight: 600;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  border-color: var(--accent-emerald);
  background: rgba(52, 211, 153, 0.12);
}

.hero {
  padding-block: clamp(2rem, 5vw, 3.6rem) 1.5rem;
}

.hero-eyebrow {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.42);
  color: var(--accent-gold);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
}

.hero h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.65rem, 3.8vw, 2.7rem);
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.hero-lead {
  color: var(--text-muted);
  max-width: 68ch;
  margin: 0 0 1.4rem;
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-emerald);
  color: var(--accent-emerald-ink);
}

.btn-gold {
  background: var(--accent-gold);
  color: var(--accent-gold-ink);
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-block {
  width: 100%;
}

.section {
  padding-block: 1.6rem 2.4rem;
}

.section-header {
  margin-bottom: 1.2rem;
}

.section-header h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

.section-header p {
  margin: 0;
  color: var(--text-muted);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card.is-unlocked {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-sky);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.card-tagline {
  margin: 0;
  color: var(--accent-gold);
  font-weight: 600;
  font-size: 0.96rem;
}

.card-list {
  margin: 0;
  padding-inline-start: 1.2rem;
  color: var(--text-muted);
  display: grid;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.card-actions {
  margin-top: auto;
  display: grid;
  gap: 0.55rem;
}

.unlock-status {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(52, 211, 153, 0.11);
  border: 1px solid rgba(52, 211, 153, 0.36);
  color: #a7f3d0;
  font-size: 0.9rem;
}

/* Hộp Bản Dùng Thử Tương tác trên Web */
.sandbox-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.tab-btn {
  min-height: 48px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: var(--accent-emerald);
  color: var(--accent-emerald-ink);
  border-color: var(--accent-emerald);
}

.sandbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.metric-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-emerald);
  margin: 0.2rem 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.field label {
  font-weight: 600;
  font-size: 0.96rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.86rem;
}

input[type="email"],
input[type="text"],
input[type="number"] {
  font: inherit;
  font-size: max(1rem, 1em);
  min-height: 48px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.42);
  background: #0b1220;
  color: var(--text-primary);
  width: 100%;
}

:is(input:user-invalid, input.user-invalid-fallback) {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.error-msg {
  display: none;
  color: var(--danger-text);
  font-size: 0.88rem;
  margin-top: 0.25rem;
}

:is(input:user-invalid, input.user-invalid-fallback) ~ .error-msg,
.error-msg.is-visible {
  display: block;
}

fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin: 0 0 1rem;
}

legend {
  padding-inline: 0.4rem;
  font-weight: 700;
  font-size: 0.94rem;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
}

.radio-row input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-emerald);
}

/* Native Modal Dialog theo chuẩn hiện đại */
dialog:modal {
  overscroll-behavior: contain;
  margin: auto;
  width: min(100% - 1.5rem, 560px);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.icon-close {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.step-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  margin-bottom: 0.8rem;
}

.step-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--accent-gold);
}

.code-block {
  background: #050911;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e2e8f0;
  margin: 0.6rem 0 0.9rem;
}

.logic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.footer {
  border-top: 1px solid var(--border-subtle);
  padding-block: 1.6rem 2.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.disclosure-box {
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.32);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: #fef08a;
  font-size: 0.92rem;
}
