:root { color-scheme: dark; --accent: #1f9d8f; --bg: #0b0d0e; --card: #1a1d1f; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 600px; height: 600px; overflow: hidden; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: #fff; user-select: none;
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 8px; }
.hidden { display: none !important; }

/* focus ring for D-pad */
.focusable { outline: none; }
.focusable:focus { box-shadow: 0 0 0 3px var(--accent); border-radius: 10px; }

/* ===================== HEADER ===================== */
.header {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; flex: none;
}
.header-title { font-size: 22px; font-weight: 700; flex: 1; }
.cam-mark { font-size: 24px; }
.hdr-btn, .vb-btn {
  background: #26292b; color: #fff; border: none; border-radius: 10px;
  font-size: 20px; padding: 8px 12px; cursor: pointer; min-width: 44px;
}

/* ===================== AUTH ===================== */
.auth-wrap { margin: auto; width: 100%; max-width: 440px; text-align: center; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.brand-name { font-size: 30px; font-weight: 800; }
.auth-hint { color: #aab; font-size: 14px; line-height: 1.5; margin: 6px 0; }
.auth-url { color: var(--accent); font-weight: 700; }
.code-display { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.code-cell {
  width: 44px; height: 56px; line-height: 56px; font-size: 32px; font-weight: 700;
  background: #15191b; border-radius: 10px; color: #fff; font-variant-numeric: tabular-nums;
}
.code-cell.filled { background: #20262a; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 0 auto; }
.key {
  background: #20262a; color: #fff; border: none; border-radius: 12px;
  font-size: 26px; padding: 14px 0; cursor: pointer;
}
.key-alt { background: #2c2222; }
.key-go { background: var(--accent); font-weight: 700; }
.auth-status { margin-top: 12px; color: #f5d76e; font-size: 14px; min-height: 18px; }
.auth-status.ok { color: var(--accent); }

/* ===================== CAMERA LIST ===================== */
.content { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.list-container { display: flex; flex-direction: column; gap: 12px; }
.ccard {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border: none; border-radius: 14px; padding: 16px 18px;
  color: #fff; cursor: pointer; width: 100%;
}
.ccard.offline { opacity: .5; }
.ccard-ic { font-size: 30px; }
.ccard-body { flex: 1; min-width: 0; }
.ccard-name { font-size: 20px; font-weight: 700; }
.ccard-sub { font-size: 13px; color: #9aa; margin-top: 2px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.on { background: #36d399; } .dot.off { background: #888; }
.ccard-arrow { font-size: 22px; color: #778; }

/* ===================== VIEWER ===================== */
#viewer { padding: 0; }
.media { position: relative; flex: 1; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-el { width: 100%; height: 100%; object-fit: contain; background: #000; }
.media-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #aab; font-size: 16px; text-align: center; padding: 0 24px; }
.viewer-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px; background: #0b0d0e; }
.vb-mode { background: var(--accent); font-weight: 700; font-size: 16px; min-width: 70px; }
.vb-btn { font-size: 18px; }
.vb-name { margin-left: auto; font-size: 14px; color: #9aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ===================== STATES / SPINNER ===================== */
.state { position: absolute; inset: 70px 8px 8px; display: flex; align-items: center; justify-content: center; color: #9aa; font-size: 16px; text-align: center; padding: 0 24px; }
.spinner { width: 44px; height: 44px; border: 4px solid #2a2d31; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOAST ===================== */
.toast {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%) translateY(20px);
  background: #1c1e21; color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 520px; text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #3a1416; } .toast.success { background: #14331f; }
