:root {
  --og: rgba(255, 119, 61, 0.25);
  --tf-gold: #e8c547;
  --tf-gold-dim: rgba(232, 197, 71, 0.35);
  --tf-surface: #0c0c0f;
  --tf-line: rgba(255, 255, 255, 0.12);
}

.page-apply {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #e8e8e8;
}

.page-apply #main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Non-desktop gate (enforced in apply.js) */
.apply-app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.apply-app-shell[hidden] {
  display: none !important;
}

.apply-desktop-gate[hidden] {
  display: none !important;
}

.apply-desktop-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(64px, 10vh, 120px) 20px 80px;
  text-align: center;
  min-height: min(80vh, 800px);
}

.apply-desktop-gate-inner {
  max-width: 520px;
  margin: 0 auto;
}

.apply-desktop-gate-title {
  margin: 0 0 16px;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
}

.apply-desktop-gate-text,
.apply-desktop-gate-hint {
  margin: 0 0 14px;
  color: #9a9a9a;
  font-size: 0.98rem;
  line-height: 1.6;
}

.apply-desktop-gate-hint {
  color: #666;
  font-size: 0.88rem;
  margin-bottom: 28px;
}

.apply-desktop-gate-cta {
  text-decoration: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Landing */
.apply-landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(96px, 14vh, 150px) 20px 80px;
  min-height: min(72vh, 720px);
  animation: applyFadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.apply-landing.hidden {
  display: none;
}

.apply-landing-inner {
  max-width: 560px;
  text-align: center;
}

.apply-landing-title {
  margin: 0 0 16px;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.1;
}

.apply-landing-lead {
  margin: 0 0 28px;
  color: #9a9a9a;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  line-height: 1.65;
}

.apply-landing-gate {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(232, 197, 71, 0.35);
  background: rgba(232, 197, 71, 0.08);
  color: #e8d089;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: left;
}

.apply-landing-gate.err {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
}

.btn-continue-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 36px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  color: #0a0a0a;
  background: linear-gradient(180deg, var(--tf-gold), var(--nav-gold-dark));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 12px 40px rgba(232, 197, 71, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-continue-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 16px 48px rgba(232, 197, 71, 0.32);
}

.apply-landing-hint {
  margin: 18px 0 0;
  font-size: 0.8rem;
  color: #555;
}

.kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78em;
  font-weight: 700;
  color: #888;
}

/* Flow */
.apply-main {
  flex: 1;
  padding: 20px 0 100px;
}

.apply-flow.hidden {
  display: none;
}

.tf-wrap {
  width: min(720px, 92vw);
  margin: 0 auto;
  padding: 8px 0 0;
  position: relative;
  animation: applyFadeUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

.tf-bar-wrap {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.tf-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tf-gold), var(--primary));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.tf-progress {
  text-align: right;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tf-gold);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
}

.tf-form {
  position: relative;
  min-height: min(58vh, 560px);
}

.tf-panels {
  position: relative;
}

.step-panel {
  animation: applyStepIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.step-panel.hidden {
  display: none;
}

.tf-q {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3.8vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.15;
}

.tf-arrow {
  color: var(--tf-gold);
  margin-right: 6px;
  font-weight: 400;
}

.tf-sub {
  margin: 0 0 22px;
  color: #7a7a7a;
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 52ch;
}

.tf-sub strong {
  color: #c4c4c4;
}

.tf-fan-msg {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ccc;
  font-size: 0.95rem;
}

.tf-enter-hint {
  margin-top: 20px;
  font-size: 0.78rem;
  color: #444;
}

.tf-msg {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 0.88rem;
}

.tf-msg.err {
  color: #ff6b6b;
}

.tf-msg.ok {
  color: #5eead4;
}

/* Choices */
.tf-choice-grid {
  display: grid;
  gap: 12px;
}

.tf-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 18px 18px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--tf-surface);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.tf-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.tf-card-check input,
.tf-pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tf-card-check:has(:checked),
.tf-pick:has(:checked) {
  border-color: var(--tf-gold);
  background: rgba(232, 197, 71, 0.06);
  box-shadow: 0 0 0 1px var(--tf-gold-dim);
}

.tf-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: #bbb;
}

.tf-pick:has(:checked) .tf-key {
  background: var(--tf-gold);
  color: #111;
}

.tf-card-body {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #ccc;
}

.tf-card-body a {
  color: var(--primary);
}

.conditional-group {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

/* Inputs */
.tf-fields {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.tf-line {
  display: block;
}

.tf-line-lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 6px;
}

.tf-line input,
textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--tf-gold-dim);
  border-radius: 0;
  padding: 10px 0;
  font: inherit;
  font-size: 1.15rem;
  color: #fff;
  outline: none;
  transition: border-color 0.2s ease;
}

.tf-line input:focus,
textarea:focus {
  border-bottom-color: var(--tf-gold);
}

textarea {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 120px;
  resize: vertical;
}

textarea:focus {
  border-color: rgba(232, 197, 71, 0.45);
}

/* Speed test */
.speed-shell {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #0f0f12, #0a0a0c);
  padding: 28px 22px;
  text-align: center;
}

.speed-start {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  color: #111;
  background: linear-gradient(180deg, var(--tf-gold), var(--nav-gold-dark));
}

.speed-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.speed-start.hidden {
  display: none;
}

.speed-wifi {
  font-size: 1.1rem;
}

.speed-running.hidden {
  display: none;
}

.speed-wait {
  color: var(--tf-gold);
  font-size: 0.88rem;
  margin: 0 0 18px;
}

.speed-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.speed-m {
  padding: 12px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.speed-lbl {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: #666;
  margin-bottom: 6px;
}

.speed-ping {
  color: var(--tf-gold);
  font-size: 1.35rem;
}

.speed-down {
  color: #38bdf8;
  font-size: 1.35rem;
}

.speed-up {
  color: #4ade80;
  font-size: 1.35rem;
}

.speed-bar-outer {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.speed-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tf-gold), #38bdf8);
  transition: width 0.2s linear;
}

/* Typing */
.typing-shell {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0a0a0c;
  padding: 16px 16px 18px;
}

.typing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.typing-timer {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.72rem;
  color: #888;
}

.typing-timer strong {
  font-size: 1.4rem;
  font-weight: 800;
  color: #f87171;
  font-variant-numeric: tabular-nums;
}

.typing-retry {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
  font-size: 0.8rem;
  cursor: pointer;
}

.typing-retry.hidden {
  display: none;
}

.typing-passage {
  min-height: 4.5em;
  padding: 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 1.05rem;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: #6b7280;
  margin-bottom: 12px;
}

.typing-passage .w-ok {
  color: #4ade80;
}

.typing-passage .w-bad {
  color: #f87171;
  text-decoration: underline;
}

.typing-passage .w-cur {
  background: rgba(232, 197, 71, 0.25);
  color: #fde68a;
  border-radius: 4px;
  padding: 0 2px;
}

.typing-passage .w-cur .c-ok {
  color: #86efac;
}

.typing-passage .w-cur .c-bad {
  color: #fca5a5;
  text-decoration: underline;
}

.typing-passage .w-cur .c-pend {
  color: #fde68a;
}

.typing-passage .w-cur .c-overflow {
  color: #f87171;
  text-decoration: underline;
}

.typing-passage .w-pend {
  color: #4b5563;
}

.typing-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--tf-gold-dim);
  background: transparent;
  padding: 10px 0;
  font-size: 1.1rem;
  color: #fff;
  outline: none;
}

.typing-input:focus {
  border-bottom-color: var(--tf-gold);
}

.typing-hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: #555;
}

.typing-live {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.typing-live-item {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
}

.typing-live-item span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a7a7a;
}

.typing-live-item strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
  color: #f1f5f9;
}

.typing-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.88rem;
}

.typing-result.pass {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.06);
  color: #86efac;
}

.typing-result.fail {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.06);
  color: #fca5a5;
}

/* Drop */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 180px;
  padding: 24px;
  border-radius: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover,
.drop-zone.drag {
  border-color: rgba(232, 197, 71, 0.45);
  background: rgba(232, 197, 71, 0.04);
}

.drop-zone.has-file {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.06);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.drop-icon {
  font-size: 1.5rem;
  opacity: 0.7;
}

.drop-title {
  font-weight: 700;
  color: #ddd;
}

.drop-meta {
  font-size: 0.8rem;
  color: #666;
}

.video-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #050506;
  margin-bottom: 14px;
}

.video-embed-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Footer bar */
.tf-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 20px 22px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.92) 35%);
  z-index: 40;
  pointer-events: none;
}

.tf-footer-inner {
  pointer-events: all;
  width: min(720px, 92vw);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.tf-btn {
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.2s ease;
}

.tf-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.tf-btn-back {
  background: transparent;
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.tf-btn-back:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
}

.tf-btn-next {
  background: linear-gradient(180deg, var(--tf-gold), var(--nav-gold-dark));
  color: #111;
  box-shadow: 0 4px 20px rgba(232, 197, 71, 0.2);
}

.tf-btn-next:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(232, 197, 71, 0.28);
}

.apply-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.apply-footer .container {
  padding: 16px 0 22px;
  color: #555;
  font-size: 13px;
}

.apply-footer a {
  color: #888;
}

@keyframes applyFadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes applyStepIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 768px) {
  .speed-metrics {
    grid-template-columns: 1fr;
  }

  .tf-footer-inner {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .tf-btn {
    width: 100%;
    justify-content: center;
  }

  .typing-live {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step-panel,
  .apply-landing,
  .tf-wrap {
    animation: none !important;
  }

  .tf-btn:hover:not(:disabled) {
    transform: none;
  }
}
