/* CamLink — shared styles. Mobile-first, dark only. */

:root {
  --midnight: #0A0E1A;
  --surface: #121829;
  --surface-2: #1B2238;
  --border: #263050;
  --cyan: #22D3EE;
  --violet: #8B5CF6;
  --text: #E8ECF8;
  --muted: #94A3B8;
  --live: #EF4444;
  --ok: #22C55E;

  --radius: 14px;
  --tap: 44px;
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--midnight);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  padding-left: var(--sa-left);
  padding-right: var(--sa-right);
}

h1, h2, h3, .brand, .mono-big {
  font-family: "Space Grotesk", Inter, -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; line-height: 1.25; margin: 0 0 10px; }
h3 { font-size: 17px; line-height: 1.3; margin: 0 0 8px; }

p { margin: 0 0 12px; }

a { color: var(--cyan); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + var(--sa-top)) 16px calc(28px + var(--sa-bottom));
}
.wrap-wide { max-width: 900px; }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  margin-bottom: 18px;
}
.brand {
  font-size: 20px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  flex: 0 0 auto;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.card-2 { background: var(--surface-2); }

/* Buttons */
button, .btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 11px 18px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  border-color: transparent;
  color: #07101D;
  font-weight: 600;
}
.btn-danger { border-color: #5A2230; color: #FCA5A5; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: 14px; border-radius: 9px; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--midnight);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: #5C6782; }
.field { margin: 0 0 12px; }

/* Text helpers */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spread { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* Messages */
.msg {
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.msg-error { border-color: #5A2230; background: #2A1420; color: #FCA5A5; }
.msg-ok { border-color: #1E4634; background: #10261C; color: #86EFAC; }

/* Pills / badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill-live { color: #FECACA; border-color: #5A2230; background: #2A1420; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
}
.badge-owner { color: #A5F3FC; border-color: #164E5B; }
.badge-shared { color: #DDD6FE; border-color: #3C2E66; }

/* Dots */
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  display: inline-block;
}
.dot-on { background: var(--ok); }
.dot-off { background: #475569; }
.dot-live { background: var(--live); animation: camlink-pulse 1.4s ease-out infinite; }

@keyframes camlink-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70%  { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .dot-live { animation: none; }
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 10px;
}
.list-tight > li { padding: 10px 12px; margin-bottom: 8px; }

/* Table (admin) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Video */
.video-shell {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 180px;
}
/* Fallback for browsers without aspect-ratio */
@supports not (aspect-ratio: 16 / 9) {
  .video-shell { height: 56.25vw; min-height: 180px; }
}
.video-shell video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}
.video-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 14px;
  color: var(--muted);
  background: rgba(10, 14, 26, 0.72);
}

/* Stats panel */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.stat {
  flex: 1 1 44%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.stat-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-v { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Modal */
.modal-back {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 8, 15, 0.82);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 16px;
  padding-bottom: calc(16px + var(--sa-bottom));
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  width: 100%;
  max-width: 420px;
  margin: auto 0 0;
}
@media (min-width: 560px) {
  .modal-back { align-items: center; }
  .modal { margin: auto; }
}

/* Pair code */
.paircode {
  font-family: "Space Grotesk", ui-monospace, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
  word-break: break-all;
  color: var(--cyan);
  margin: 10px 0;
}
.qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  width: 232px;
  max-width: 100%;
}
.qr-box canvas, .qr-box img, .qr-box svg { display: block; width: 100%; height: auto; }

/* Dim overlay (camera) */
.dim {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + var(--sa-bottom));
}
.dim .dim-hint { color: #1d2433; font-size: 12px; }

/* Footer */
.foot {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* Landing hero */
.hero { padding: 10px 0 4px; }
.hero h1 { font-size: 32px; }
.hero .lede { font-size: 17px; color: var(--muted); }
.features { list-style: none; margin: 16px 0 0; padding: 0; }
.features li {
  position: relative;
  padding: 0 0 0 22px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 15px;
}
.features li::before {
  content: "";
  position: absolute;
  left: 2px; top: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button { flex: 1 1 0; }
.tabs button[aria-selected="true"] { border-color: var(--cyan); color: var(--cyan); }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  display: inline-block;
  animation: camlink-spin 0.8s linear infinite;
}
@keyframes camlink-spin { to { transform: rotate(360deg); } }
