:root {
  --bg: #080b12;
  --panel: #111722;
  --panel-2: #0d1521;
  --line: #2a3a50;
  --ink: #f3f6fb;
  --muted: #9aaabd;
  --gold: #e8c47c;
  --blue: #8eb8ff;
  --green: #71e0a0;
  --red: #ff8d88;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100dvh; }
button { font: inherit; }

.app { width: min(1060px, 100%); min-height: 100dvh; margin: 0 auto; padding: calc(22px + var(--safe-top)) 16px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.app-header, .section-heading, .meter-row, .activity-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: .68rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.45rem, 3.2vw, 2.1rem); letter-spacing: -.03em; }
h2 { margin-bottom: 5px; font-size: clamp(1.05rem, 2.1vw, 1.35rem); }
.subtitle, .muted, .privacy-note, .footer-note, .two-tab-card span { color: var(--muted); line-height: 1.45; }
.subtitle { margin: 0; font-size: .86rem; }
.secure-badge, .active-badge, .record-badge, .gallery-count { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .65rem; font-weight: 900; letter-spacing: .08em; white-space: nowrap; }
.secure-badge.good, .active-badge.good, .record-badge.good { border-color: rgba(113, 224, 160, .55); color: var(--green); }
.secure-badge.warn, .active-badge.warn, .record-badge.warn { border-color: rgba(232, 196, 124, .55); color: var(--gold); }
.secure-badge.bad, .active-badge.bad, .record-badge.bad { border-color: rgba(255, 141, 136, .55); color: var(--red); }
.record-badge.recording { border-color: rgba(255, 141, 136, .7); background: rgba(90, 21, 24, .35); color: var(--red); }

.bridge-card, .two-tab-card { border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(21, 30, 45, .98), rgba(13, 18, 28, .98)); box-shadow: 0 18px 55px rgba(0,0,0,.2); }
.bridge-card { padding: 15px; }
.section-heading { align-items: flex-start; }
.section-heading h2 { margin-top: 0; }
.section-heading .muted { max-width: 720px; margin-bottom: 0; font-size: .78rem; }
.gallery-heading { align-items: center; }
.gallery-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.gallery-tools .button { flex: 0 1 auto; }

.preview { position: relative; min-height: min(50vw, 470px); margin-top: 14px; overflow: hidden; border: 1px solid #30445f; border-radius: 13px; background: #03070c; }
.preview video { display: block; width: 100%; height: 100%; min-height: min(50vw, 470px); object-fit: contain; background: #02050a; }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; padding: 20px; color: var(--muted); font-size: .8rem; text-align: center; }
.preview-mark, .gallery-mark { display: grid; place-items: center; border: 1px solid rgba(232,196,124,.6); border-radius: 50%; color: var(--gold); font-weight: 900; letter-spacing: .08em; }
.preview-mark { width: 66px; height: 66px; font-size: .8rem; }
.on-air, .frame-count { position: absolute; top: 10px; padding: 5px 8px; border-radius: 999px; font-size: .65rem; font-weight: 900; letter-spacing: .07em; }
.on-air { left: 10px; border: 1px solid rgba(113,224,160,.65); background: rgba(2,18,10,.86); color: var(--green); }
.frame-count { right: 10px; border: 1px solid #3e5775; background: rgba(3,8,14,.86); color: var(--blue); }

.primary-actions, .record-actions, .gallery-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.button { flex: 1 1 150px; min-height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: #111925; color: var(--ink); cursor: pointer; font-size: .72rem; font-weight: 900; letter-spacing: .045em; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover:not(:disabled) { border-color: var(--gold); background: #182437; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { border-color: var(--gold); background: var(--gold); color: #111; }
.button.primary:hover:not(:disabled) { background: #f0d18e; }
.button.send { border-color: var(--blue); color: #d6e5ff; }
.button.queued { border-color: rgba(113,224,160,.65); color: var(--green); }
.button.danger { border-color: rgba(255,141,136,.65); color: var(--red); }
.button.small { flex: 0 1 auto; min-height: 36px; padding: 0 12px; font-size: .67rem; }
.button:disabled { opacity: .4; cursor: not-allowed; }
.button:focus-visible, .text-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.record-card { border-color: rgba(232,196,124,.45); }
.record-actions { margin-top: 15px; }
.record-actions .button { flex-basis: 210px; }
.meter-row { align-items: center; margin-top: 12px; padding: 10px 11px; border: 1px solid #26384f; border-radius: 10px; background: rgba(7, 14, 24, .7); color: var(--muted); font-size: .73rem; }
.meter-row strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: .76rem; }
.meter { flex: 0 0 min(260px, 35%); height: 7px; overflow: hidden; border-radius: 999px; background: #223047; }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--gold)); transition: width .2s ease; }
.bridge-status { min-height: 40px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.bridge-status.good { border-color: rgba(113,224,160,.45); color: var(--green); }
.bridge-status.warn { border-color: rgba(232,196,124,.45); color: var(--gold); }
.bridge-status.bad { border-color: rgba(255,141,136,.45); color: var(--red); }

.gallery-empty { display: grid; place-items: center; align-content: center; gap: 7px; min-height: 145px; margin-top: 13px; padding: 18px; border: 1px dashed #3b526e; border-radius: 12px; color: var(--muted); font-size: .76rem; text-align: center; }
.gallery-mark { width: 48px; height: 48px; font-size: .7rem; }
.gallery-empty strong { color: var(--ink); font-size: .82rem; }
.gallery-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 10px; margin-top: 13px; }
.gallery-item { display: grid; gap: 9px; padding: 9px; border: 1px solid #30445f; border-radius: 12px; background: rgba(7,14,24,.72); }
.gallery-item.queued { border-color: rgba(142,184,255,.8); box-shadow: 0 0 0 1px rgba(142,184,255,.18); }
.gallery-item.sent { border-color: rgba(113,224,160,.55); }
.gallery-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid #26384f; border-radius: 8px; background: #03070c; }
.gallery-meta { display: grid; gap: 3px; }
.gallery-meta strong { color: var(--ink); font-size: .78rem; }
.gallery-meta span { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.gallery-actions { margin-top: 1px; }
.gallery-actions .button { flex-basis: 120px; }

.activity { border: 1px solid #26384f; border-radius: 10px; background: rgba(7,14,24,.7); }
.activity-heading { align-items: center; padding: 10px 11px 7px; color: var(--ink); font-size: .76rem; }
.text-button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: .7rem; font-weight: 800; }
.activity-log { max-height: 130px; overflow: auto; padding: 0 11px 10px; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.activity-log p { margin: 4px 0; }
.activity-log p strong { color: var(--gold); }
.privacy-note { margin: 0; font-size: .7rem; }

.two-tab-card { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; overflow: hidden; background: var(--line); }
.two-tab-card > div { display: grid; gap: 3px; padding: 13px 14px; background: var(--panel-2); }
.two-tab-card strong { font-size: .82rem; }
.two-tab-card span { font-size: .7rem; }
.two-tab-card .tab-number { color: var(--gold); font-size: .64rem; font-weight: 900; letter-spacing: .12em; }
.footer-note { font-size: .68rem; text-align: center; }
.hidden { display: none !important; }

@media (max-width: 650px) {
  .app-header, .section-heading { flex-direction: column; gap: 10px; }
  .secure-badge, .active-badge, .record-badge, .gallery-count { align-self: flex-start; }
  .gallery-tools { justify-content: flex-start; }
  .meter-row { align-items: stretch; flex-direction: column; }
  .meter { flex-basis: auto; width: 100%; }
  .two-tab-card { grid-template-columns: 1fr; }
}
