:root {
  --navy: #0b1f33;
  --teal: #006d77;
  --teal-hover: #005860;
  --mist: #eff5fa;
  --surface: #ffffff;
  --border: #d5e2ee;
  --text-muted: #4b6177;
  --ok: #17633f;
  --ok-bg: #e7f6ee;
  --warn: #8a4b08;
  --warn-bg: #fef4e6;
  --err: #a92d38;
  --err-bg: #fdecef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--mist);
  color: var(--navy);
  line-height: 1.5;
}

.gate-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
}

.topbar {
  background: var(--navy);
  color: #ffffff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  text-decoration: none;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f27457;
  display: inline-block;
}

.brand-tag {
  background: var(--teal);
  color: #ffffff;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: #c5d6e6;
}

.topbar-link {
  color: #8ee3ea;
  text-decoration: none;
  font-weight: 600;
}

.topbar-link:hover {
  text-decoration: underline;
}

.container {
  max-width: 1040px;
  margin: 24px auto;
  padding: 0 20px 40px;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 10px rgba(11, 31, 51, 0.05);
  margin-bottom: 18px;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.role-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.role-card h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.role-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--teal);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--teal-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--navy);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--mist);
}

.btn-danger {
  background: var(--err);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: #8d232d;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--mist);
  color: var(--navy);
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-err {
  background: var(--err-bg);
  color: var(--err);
}

.pairing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  align-items: stretch;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--navy);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
}

.code-label {
  font-size: 0.78rem;
  color: #a9c3dc;
}

.code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.input-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  width: 150px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--navy);
}

.input-code-sm {
  width: 112px;
}

.input-code:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}

.video-stage {
  background: #061320;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #061320;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9cb7d1;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.banner {
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.banner-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #f5d4a6;
}

.banner-err {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid #f3bcc3;
}

.meter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.meter-bar-bg {
  flex: 1;
  max-width: 260px;
  height: 10px;
  background: #dce7f2;
  border-radius: 999px;
  overflow: hidden;
}

.meter-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width 0.08s linear;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat-item {
  background: var(--mist);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}

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

.log-box {
  background: #0b1f33;
  color: #cde0f2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  padding: 12px;
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 10px;
}
