:root {
  color-scheme: dark;
  --bg: #0a1119;
  --panel: rgba(18, 29, 42, 0.94);
  --text: #edf4fb;
  --muted: #9aabba;
  --subtle: #718397;
  --blue: #69a9ff;
  --green: #57d6a0;
  --cyan: #61d7d0;
  --amber: #ffc26d;
  --red: #ff8585;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 88% -10%, rgba(74, 130, 209, 0.2), transparent 28rem),
    radial-gradient(circle at -8% 46%, rgba(45, 124, 128, 0.08), transparent 24rem),
    var(--bg);
  letter-spacing: 0.002em;
}

button, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.screen-shell { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; }

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(146, 173, 200, 0.1);
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 35px;
  height: 35px;
  color: #c3e1ff;
  background: linear-gradient(145deg, rgba(84, 151, 242, 0.38), rgba(77, 101, 176, 0.2));
  border: 1px solid rgba(121, 176, 255, 0.35);
  border-radius: 11px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: -0.01em; }
.brand small { margin-top: 2px; color: var(--subtle); font-size: 10px; }
.header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.target-control { display: inline-flex; align-items: center; gap: 5px; color: var(--subtle); font-size: 10px; }
.target-control select { min-height: 26px; width: auto; padding: 3px 6px; color: #cde4ff; font-size: 10px; background: rgba(6, 14, 24, 0.58); border: 1px solid rgba(138, 165, 193, 0.2); border-radius: 6px; }
.status-badge, .source-state, .activity-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  background: rgba(113, 131, 151, 0.1);
  border: 1px solid rgba(113, 131, 151, 0.22);
  border-radius: 999px;
}
.status-badge.connected, .activity-state.active { color: #b6efd9; border-color: rgba(87, 214, 160, 0.28); background: rgba(87, 214, 160, 0.08); }
.status-badge.error, .activity-state.error { color: #ffc0bd; border-color: rgba(255, 133, 133, 0.3); background: rgba(255, 133, 133, 0.08); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); box-shadow: 0 0 0 3px rgba(113, 131, 151, 0.12); }
.status-badge.connected .status-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(87, 214, 160, 0.14); }
.status-badge.error .status-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 133, 133, 0.14); }
.back-link { color: var(--blue); font-size: 11px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.notice {
  margin: 14px 16px 0;
  padding: 10px 12px;
  color: #ffe1b7;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(125, 86, 31, 0.2);
  border: 1px solid rgba(255, 194, 109, 0.28);
  border-radius: 10px;
}
.notice.success { color: #c7f2df; background: rgba(45, 126, 100, 0.18); border-color: rgba(87, 214, 160, 0.3); }
.notice.error { color: #ffd0cd; background: rgba(125, 45, 49, 0.2); border-color: rgba(255, 133, 133, 0.32); }

.screen-main { display: grid; gap: 13px; padding: 16px 14px 34px; }
.card {
  min-width: 0;
  padding: 17px;
  background: linear-gradient(145deg, rgba(22, 36, 52, 0.94), rgba(14, 25, 38, 0.94));
  border: 1px solid rgba(152, 180, 207, 0.16);
  border-radius: 15px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.2);
}
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-heading.compact { align-items: center; }
.card-heading h1, .card-heading h2 { margin: 0; color: var(--text); letter-spacing: -0.025em; }
.card-heading h1 { font-size: 19px; line-height: 1.2; }
.card-heading h2 { font-size: 16px; line-height: 1.25; }
.card-heading p { max-width: 56ch; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.heading-icon { display: grid; place-items: center; width: 32px; height: 32px; color: var(--blue); background: rgba(105, 169, 255, 0.1); border: 1px solid rgba(105, 169, 255, 0.3); border-radius: 10px; }

.mode-state {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 17px;
  padding: 11px 12px;
  color: #c9d7e5;
  background: rgba(6, 14, 24, 0.42);
  border: 1px solid rgba(138, 165, 193, 0.15);
  border-radius: 10px;
}
.mode-state.enabled { color: #c7f2df; border-color: rgba(87, 214, 160, 0.28); background: rgba(45, 126, 100, 0.15); }
.mode-state.disabled { color: #ffd0cd; border-color: rgba(255, 133, 133, 0.26); background: rgba(125, 45, 49, 0.14); }
.state-icon { display: grid; flex: 0 0 auto; place-items: center; width: 24px; height: 24px; color: var(--cyan); font-size: 14px; background: rgba(97, 215, 208, 0.11); border-radius: 8px; }
.mode-state.disabled .state-icon { color: var(--red); background: rgba(255, 133, 133, 0.11); }
.mode-state strong, .mode-state small { display: block; }
.mode-state strong { font-size: 12px; }
.mode-state small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.mode-state.disabled small { color: #e7b7b5; }

.steps { display: grid; gap: 9px; margin-top: 15px; }
.step { display: flex; align-items: flex-start; gap: 9px; }
.step > span { display: grid; flex: 0 0 auto; place-items: center; width: 21px; height: 21px; color: #07111d; font-size: 11px; font-weight: 750; background: var(--blue); border-radius: 50%; }
.step p { margin: 1px 0 0; color: var(--muted); font-size: 11px; line-height: 1.42; }

.source-info { display: flex; align-items: center; gap: 9px; min-width: 0; margin-top: 15px; padding: 9px 10px; background: rgba(6, 14, 24, 0.38); border: 1px solid rgba(138, 165, 193, 0.13); border-radius: 9px; }
.source-icon { display: grid; flex: 0 0 auto; place-items: center; width: 29px; height: 29px; color: var(--cyan); background: rgba(97, 215, 208, 0.1); border-radius: 8px; }
.source-info strong, .source-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-info strong { color: #dbeafa; font-size: 12px; }
.source-info small { margin-top: 3px; color: var(--subtle); font-size: 10px; }
.video-wrap { position: relative; overflow: hidden; margin-top: 12px; background: #050b12; border: 1px solid rgba(105, 169, 255, 0.24); border-radius: 11px; }
.video-wrap video { display: block; width: 100%; max-height: min(58vh, 520px); object-fit: contain; background: #050b12; }
.video-badge { position: absolute; top: 8px; left: 8px; padding: 5px 7px; color: #dbeafa; font-size: 10px; background: rgba(5, 11, 18, 0.75); border: 1px solid rgba(146, 173, 200, 0.2); border-radius: 7px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 9px 13px; color: #dbeafa; font-size: 13px; font-weight: 650; background: rgba(35, 57, 80, 0.78); border: 1px solid rgba(124, 165, 207, 0.2); border-radius: 9px; transition: background 140ms ease, border-color 140ms ease, transform 140ms ease; }
.button:hover { background: rgba(48, 78, 109, 0.9); border-color: rgba(124, 181, 236, 0.4); }
.button:active { transform: translateY(1px); }
.button-primary { color: #07111d; background: linear-gradient(145deg, #75b0ff, #4e91fa); border-color: rgba(143, 192, 255, 0.55); }
.button-primary:hover { background: linear-gradient(145deg, #8abaff, #5f9eff); }
.button-secondary { color: #cde4ff; background: rgba(38, 75, 117, 0.55); border-color: rgba(105, 169, 255, 0.32); }
.field-hint { margin: 9px 1px 0; color: var(--subtle); font-size: 11px; line-height: 1.42; }

.activity-list { display: grid; gap: 0; margin: 14px 0 0; }
.activity-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid rgba(138, 165, 193, 0.1); }
.activity-list > div:last-child { border-bottom: 0; }
.activity-list dt { color: var(--subtle); font-size: 11px; }
.activity-list dd { max-width: 68%; margin: 0; overflow: hidden; color: #dbeafa; font-size: 12px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 560px) {
  .screen-header { padding-right: 22px; padding-left: 22px; }
  .screen-main { padding-right: 20px; padding-left: 20px; }
  .share-actions .button { flex: 1 1 220px; }
}

@media (max-width: 390px) {
  .screen-header { flex-wrap: wrap; align-items: flex-start; gap: 8px 14px; }
  .brand { flex: 1 1 100%; }
  .header-actions { flex: 1 1 100%; flex-direction: row; align-items: center; justify-content: space-between; min-width: 0; }
  .target-control { flex: 1 1 auto; justify-content: center; }
  .card { padding: 14px; }
  .share-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

[hidden] { display: none !important; }
