/* tvEasyCopy sender.
   An instrument, not a dashboard: near-black ground, one signal-green accent,
   monospace wherever the content is machine text (URLs, pairing codes).
   No external fonts, no dependencies - character comes from spacing,
   tracking and restraint. */

:root {
  color-scheme: dark light;

  --bg: #08090b;
  --bg-glow: #0e1014;
  --surface: #101216;
  --surface-raised: #161920;
  --line: #22262e;
  --line-strong: #2d323c;

  --text: #f2f4f7;
  --muted: #8a92a0;
  --faint: #5d646f;

  --accent: #3ddc84;
  --accent-ink: #04140b;
  --accent-dim: #1f6b42;

  --ok: #3ddc84;
  --warn: #e8b04b;
  --err: #ff6b5e;

  --radius: 12px;
  --radius-lg: 18px;

  --font-sans: 'Helvetica Neue', Helvetica, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f6;
    --bg-glow: #ffffff;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --line: #e3e6ea;
    --line-strong: #d2d7de;

    --text: #0e1013;
    --muted: #666f7d;
    --faint: #8d96a3;

    --accent: #0c8c4d;
    --accent-ink: #ffffff;
    --accent-dim: #a9e3c3;

    --ok: #0c8c4d;
    --warn: #8a6100;
    --err: #c42f22;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: clamp(28px, 7vh, 72px) 20px 64px;
  background:
    radial-gradient(90rem 42rem at 50% -14rem, var(--bg-glow) 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.card {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
}

/* ---------- header ---------- */

.head {
  margin-bottom: clamp(28px, 5vh, 44px);
}

h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.035em;
}

h1::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  flex: none;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

h2 {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- form ---------- */

.field {
  display: block;
  margin-bottom: 18px;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.input::placeholder {
  color: var(--faint);
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-raised);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

select.input {
  font-family: var(--font-sans);
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% + 1px),
    calc(100% - 15px) calc(50% + 1px);
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.input-code {
  height: 64px;
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-align: center;
  text-indent: 0.22em; /* balances the trailing letter-spacing */
}

/* ---------- buttons ---------- */

.btn {
  height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease),
    transform 0.08s var(--ease);
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

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

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

.btn-primary {
  height: 56px;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.005em;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn-primary:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 88%, white);
  box-shadow: 0 6px 22px -10px var(--accent);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn-wide {
  display: block;
  width: 100%;
}

.btn-quiet {
  height: auto;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

.btn-quiet:hover {
  background: none;
  color: var(--text);
  text-decoration-color: currentColor;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.btn-icon:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  min-height: 24px;
}

/* ---------- status text ---------- */

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  text-align: right;
}

.status:not(:empty) {
  animation: status-in 0.22s var(--ease);
}

.status-ok {
  color: var(--ok);
}

.status-warn {
  color: var(--warn);
}

.status-err {
  color: var(--err);
}

.status-big {
  margin-bottom: 26px;
  font-size: 17px;
  text-align: center;
}

@keyframes status-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}

.hint {
  color: var(--muted);
  font-size: 13.5px;
}

code {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
}

.rule {
  margin: 34px 0 26px;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---------- empty state ---------- */

/* The first thing a new user sees, so it carries the whole setup story:
   what it will look like, what to type where, and one button. */
.empty {
  padding: clamp(28px, 6vw, 40px) clamp(20px, 5vw, 32px) clamp(24px, 5vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.empty-art {
  display: block;
  width: min(180px, 52%);
  height: auto;
  margin: 0 auto 22px;
  overflow: visible;
}

.art-screen {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 3;
}

.art-stand {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 3;
  stroke-linecap: round;
}

.art-beam {
  fill: var(--accent);
}

.art-wave {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.35;
  transform-origin: 60px 35px;
  animation: ripple 3.2s var(--ease) infinite;
}

.art-wave-2 {
  opacity: 0.18;
  animation-delay: 0.6s;
}

@keyframes ripple {
  0% {
    transform: scale(0.55);
    opacity: 0;
  }
  35% {
    opacity: 0.35;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

.empty-title {
  margin: 0 0 24px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}

.steps {
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
}

.steps li {
  position: relative;
  padding: 0 0 18px 38px;
  counter-increment: step;
}

.steps li:last-child {
  padding-bottom: 0;
}

/* The numbers double as the connecting line down the list. */
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--bg-glow);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.steps li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 11.5px;
  top: 28px;
  bottom: 10px;
  width: 1px;
  background: var(--line);
}

.step-text {
  display: block;
  padding-top: 2px;
  color: var(--muted);
  font-size: 14.5px;
}

.address {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
}

.address code {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-glow);
  font-size: 13.5px;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
}

.btn-copy {
  flex: none;
  height: auto;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- devices ---------- */

.device-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s var(--ease);
}

.device-row:hover {
  border-color: var(--line-strong);
}

.device-row .name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.presence {
  flex: none;
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.presence-online {
  color: var(--ok);
}

.device-actions {
  flex: none;
  display: flex;
  gap: 14px;
}

.device-actions .btn-quiet {
  font-size: 13px;
}

/* ---------- add TV modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 5, 7, 0.66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s var(--ease);
}

.modal-card {
  width: 100%;
  max-width: 400px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-glow);
  box-shadow: 0 32px 70px -30px rgba(0, 0, 0, 0.8);
  animation: pop-in 0.22s var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}

.modal-card .hint {
  margin: 0 0 18px;
}

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.or::before,
.or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.scan-video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  object-fit: cover;
}

#pair-status {
  margin-top: 14px;
  text-align: center;
}

/* ---------- pair page ---------- */

.pair-page {
  padding: 40px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.pair-page .btn-primary {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- entrance ---------- */

.head,
#empty,
#sender {
  animation: rise 0.4s var(--ease) both;
}

#empty,
#sender {
  animation-delay: 0.06s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

/* On a tall desktop window the panel sits centred rather than clinging to
   the top edge. Phones keep the top alignment so the keyboard has room. */
@media (min-width: 561px) and (min-height: 700px) {
  body {
    display: flex;
    align-items: center;
    padding-top: 40px;
    padding-bottom: 40px;
  }
}

/* ---------- phones ---------- */

@media (max-width: 560px) {
  body {
    padding: 26px 16px 48px;
  }

  .device-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .device-row .name {
    flex-basis: calc(100% - 90px);
  }

  .device-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 18px;
  }

  /* The modal becomes a sheet: thumbs live at the bottom of a phone. */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: none;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    animation: sheet-up 0.24s var(--ease);
  }

  .row {
    align-items: flex-start;
  }

  .address {
    flex-direction: column;
    gap: 6px;
  }

  .btn-copy {
    height: 40px;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

[hidden] {
  display: none !important;
}

/* ---------- lock screen ---------- */

.card-narrow {
  max-width: 380px;
}

.lock {
  padding: 26px 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  animation: rise 0.4s var(--ease) both;
  animation-delay: 0.06s;
}

.lock .field {
  margin-bottom: 16px;
}

.status-centred {
  margin-top: 14px;
  text-align: center;
}

.signout {
  margin: 28px 0 0;
  text-align: center;
}

.signout .btn-quiet {
  font-size: 13px;
  color: var(--faint);
}
