:root {
  --bg: #0a0a0c;
  --surface: #141418;
  --surface-hover: #1c1c22;
  --border: #2a2a32;
  --border-glow: rgba(249, 115, 22, 0.35);
  --text: #f5f5f7;
  --muted: #9ca3af;
  --accent: #f97316;
  --accent-dim: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.25);
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    linear-gradient(rgba(249, 115, 22, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249, 115, 22, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.logo-phoenix {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(249, 115, 22, 0.35));
}

.logo-header {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  object-position: left center;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  background: linear-gradient(135deg, #fbbf24, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.icon-btn:hover {
  border-color: var(--border-glow);
  color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Main card */
.main-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.06), 0 8px 32px rgba(0, 0, 0, 0.4);
  flex: 1;
}

.card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.card-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Platform selector */
.platform-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

/* Platform selector continued */
.platform-select-wrap {
  flex: 1;
  min-width: 160px;
}

.platform-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.platform-select:focus {
  outline: none;
  border-color: var(--accent);
}

.platform-hint {
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1 1 100%;
}

@media (min-width: 400px) {
  .platform-hint {
    flex: 1 1 auto;
    text-align: right;
  }
}

/* Install section */
.install-section {
  margin-top: 16px;
  margin-bottom: 20px;
}

.section-header {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(234, 88, 12, 0.08));
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.install-steps {
  font-size: 0.88rem;
  color: var(--muted);
  padding-left: 0;
  line-height: 1.6;
  list-style: none;
}

.install-steps li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  padding-left: 0;
}

.install-steps li::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 4px;
  background: no-repeat center / contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f97316' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12l7 7 7-7'/%3E%3C/svg%3E");
  opacity: 0.9;
}

/* средний пункт — стрелка вправо */
.install-steps-rest li:not(.install-step-highlight)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f97316' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 5l7 7-7 7'/%3E%3C/svg%3E");
}

.install-steps li.install-step-highlight::before {
  display: none;
}

.store-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 4px;
  padding-left: 22px;
}

.install-guide-block {
  margin-top: 16px;
}

.install-guide-hint {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 4px;
}

.install-steps li.install-step-highlight {
  color: var(--text);
  font-weight: 500;
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 8px;
  padding: 8px 10px 8px 8px;
  margin-top: 2px;
}

.install-steps:not(.install-steps-rest) {
  margin-bottom: 0;
}

.install-steps-rest {
  margin-top: 12px;
  margin-bottom: 0;
}

.install-steps li:last-child {
  margin-bottom: 0;
}

.store-btn {
  flex: 1 1 calc(50% - 5px);
  min-width: 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.store-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.store-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* Hero CTA */
.tv-connect-hint {
  margin-top: 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  text-align: left;
}

.btn-activate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 18px 20px;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  box-shadow: 0 4px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.1s, box-shadow 0.15s;
}

.btn-activate:hover {
  box-shadow: 0 6px 32px rgba(249, 115, 22, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-activate:active {
  transform: scale(0.98);
}

.btn-activate-sm {
  padding: 14px 16px;
  font-size: 0.95rem;
}

/* Step 3 */
.step-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.connect-hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  text-align: left;
}

.connect-success {
  margin-top: 16px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text);
  font-weight: 500;
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 8px;
}

.connect-success p + p {
  margin-top: 8px;
}

.connect-hint strong {
  color: var(--text);
  font-weight: 600;
}

.connect-footnote {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  opacity: 0.9;
}

.happ-guide {
  position: relative;
  margin-top: 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0d1117;
}

.happ-guide-img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

.happ-guide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.happ-highlight-server {
  position: absolute;
  top: 58.2%;
  left: 3.5%;
  width: 93%;
  height: 11.2%;
  border: 2px solid rgba(249, 115, 22, 0.85);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(249, 115, 22, 0.25),
    0 0 20px rgba(249, 115, 22, 0.35),
    inset 0 0 24px rgba(249, 115, 22, 0.08);
}

.happ-highlight-server::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 5px;
  background: linear-gradient(180deg, #fbbf24, var(--accent));
  border-radius: 10px 0 0 10px;
  box-shadow: 0 0 10px var(--accent);
}

.happ-label {
  position: absolute;
  font-size: clamp(0.62rem, 2.6vw, 0.76rem);
  font-weight: 600;
  line-height: 1.25;
  color: #fff;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.95), rgba(234, 88, 12, 0.95));
  padding: 5px 9px;
  border-radius: 8px;
  box-shadow: 0 2px 14px rgba(249, 115, 22, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.happ-label-server {
  top: 70.5%;
  left: 4%;
  max-width: 62%;
}

.happ-label-power {
  top: 24%;
  left: 61%;
  max-width: 36%;
}

/* QR modal */
.modal-qr {
  max-width: 380px;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
}

.qr-wrap canvas {
  display: block;
}

.link-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.45;
}

/* Footer */
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 20px;
}

.footer-note a {
  color: var(--accent);
  text-decoration: none;
}

.footer-note a:hover {
  text-decoration: underline;
}

/* Error state */
.error-card {
  text-align: center;
  padding: 32px 20px;
}

.error-card h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: #ef4444;
}

.error-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 0 40px var(--accent-glow);
}

.modal h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.modal p {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 12px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--border-glow);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.hidden {
  display: none !important;
}
