/* Telefonos kijelző-kezelő — ugyanaz a vizuális nyelv, mint a csengő-távirányítóé (remote.css),
   türkiz fejléccel, hogy a kezdőképernyőn és használat közben is elkülönüljön. */
:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --border: #E2E5EA; --ink: #131826; --muted: #6B7280;
  --accent: #22D3AA; --accent-ink: #04342C; --brand: #0E7C6B; --danger: #C0263B; --danger-bg: #FBE7EA;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0F131B; --surface: #181D28; --border: #2A3140; --ink: #EEF1F6; --muted: #8C95A5; --danger-bg: #3B1220; --danger: #F87171; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 16px; }
body { padding-bottom: env(safe-area-inset-bottom); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { color: var(--danger); margin: 0 0 0.6rem; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem; background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.logo { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: #F0FDFA; flex-shrink: 0; }
.title { font-weight: 800; font-size: 1.1rem; }
.sub { font-size: 0.72rem; color: #CCFBF1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.top-right { display: flex; align-items: center; gap: 0.4rem; }
.pill { font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.6rem; border-radius: 999px; background: rgba(0,0,0,0.25); white-space: nowrap; }
.pill.ok { color: #A7F3D0; }
.pill.off { color: #FECACA; }
.icon-btn { background: none; border: none; color: inherit; font-size: 1.5rem; padding: 0.2rem 0.5rem; cursor: pointer; }

.menu { position: fixed; right: 0.6rem; top: calc(3.6rem + env(safe-area-inset-top)); z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.25); min-width: 240px; overflow: hidden; }
.menu-user { padding: 0.8rem 1rem; font-weight: 700; border-bottom: 1px solid var(--border); }
.menu-item { display: block; width: 100%; text-align: left; padding: 0.85rem 1rem; background: none; border: none; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.menu-item.danger { color: var(--danger); }

.wrap { padding: 0.8rem; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.8rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.card h1 { margin: 0 0 0.3rem; font-size: 1.4rem; }
.card h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.row.between { justify-content: space-between; margin-top: 0; }
.row.two > * { flex: 1; }
.grow { flex: 1; min-width: 0; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.7rem; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
.field-label { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.35rem; }
input, select, textarea {
  font: inherit; font-size: 16px; padding: 0.7rem 0.75rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); width: 100%;
}
textarea { resize: vertical; margin-top: 0.6rem; }
label.check input { width: auto; }
select.filter { width: auto; padding: 0.4rem 0.6rem; font-size: 0.9rem; }

.btn { font: inherit; font-weight: 600; padding: 0.75rem 0.9rem; border-radius: 12px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--ink); min-height: 48px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { font-size: 1.05rem; min-height: 54px; }
.btn.wide { width: 100%; margin-top: 0.6rem; }
.small-btn { min-height: 38px; padding: 0.4rem 0.75rem; font-size: 0.88rem; }
body.viewer .btn, body.viewer .upload-btn, body.viewer .switch, body.viewer .mini-switch, body.viewer .media-card { pointer-events: none; opacity: 0.5; }

.banner { border-radius: var(--radius); padding: 0.8rem 1rem; font-size: 0.92rem; }
.banner.warn { background: #FEF3C7; color: #78350F; }

/* Feltöltés */
.upload-btn {
  flex-direction: row; align-items: center; gap: 0.9rem; margin: 0; padding: 1rem; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
}
.upload-btn:active { transform: scale(0.98); }
.upload-btn .upload-ico { font-size: 2rem; }
.upload-btn strong { display: block; font-size: 1.1rem; }

/* Vész-sáv */
#emergency-card.em-on { border-color: #DC2626; box-shadow: 0 0 0 2px rgba(220,38,38,0.25); }

/* Kapcsolók */
.switch { position: relative; display: inline-block; width: 3.8rem; height: 2.2rem; flex-shrink: 0; margin: 0; }
.switch input, .mini-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.track { position: absolute; inset: 0; border-radius: 999px; background: #9CA3AF; transition: background 0.2s; }
.track::after { content: ''; position: absolute; top: 0.22rem; left: 0.22rem; width: 1.76rem; height: 1.76rem; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + .track { background: #DC2626; }
.switch input:checked + .track::after { transform: translateX(1.6rem); }
.mini-switch { position: relative; flex-direction: column; align-items: center; gap: 0.15rem; margin: 0; font-size: 0.7rem; color: var(--muted); }
.mini-switch .track { position: relative; display: block; width: 2.8rem; height: 1.6rem; }
.mini-switch .track::after { width: 1.2rem; height: 1.2rem; top: 0.2rem; left: 0.2rem; }
.mini-switch input:checked + .track { background: #10B981; }
.mini-switch input:checked + .track::after { transform: translateX(1.2rem); }

/* Kijelzők */
.list { display: flex; flex-direction: column; }
.screen-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 0.7rem; padding: 0.75rem 0; border-top: 1px solid var(--border); align-items: center; }
.screen-row:first-child { border-top: none; }
.screen-actions { grid-column: 1 / -1; display: flex; gap: 0.5rem; }
.screen-actions .btn { flex: 1; }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.4rem; }
.dot.on { background: #10B981; }
.dot.off { background: #EF4444; }

/* Média-rács */
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
@media (min-width: 560px) { .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.media-card { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.media-card:active { transform: scale(0.98); }
.media-card.st-off, .media-card.st-expired { opacity: 0.55; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #0B0E14; display: grid; place-items: center; overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.big { aspect-ratio: 16 / 9; border-radius: 10px; }
.type-badge { position: absolute; left: 0.35rem; bottom: 0.35rem; background: rgba(0,0,0,0.65); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 6px; }
.type-badge.yt { background: #DC2626; }
.pdf { color: #fff; font-size: 2rem; display: flex; flex-direction: column; align-items: center; }
.pdf span { font-size: 0.75rem; }
.media-info { padding: 0.5rem 0.6rem 0.6rem; min-width: 0; }
.media-title { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-weight: 700; }
.s-live { color: #059669; }
.s-scheduled { color: #2563EB; }
.s-off, .s-expired { color: var(--muted); }

/* Alsó lap */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; padding: 0.6rem 1rem calc(1rem + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; box-shadow: 0 -10px 30px rgba(0,0,0,0.3);
}
.sheet-handle { width: 2.6rem; height: 0.3rem; border-radius: 999px; background: var(--border); margin: 0 auto 0.6rem; }
.sheet h2 { margin: 0 0 0.6rem; }
.sheet-preview { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.sheet-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.sheet-preview .thumb.big { width: 100%; }
.file-chip { padding: 0.4rem 0.6rem; border-radius: 8px; background: var(--bg); font-size: 0.8rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-checks { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.8rem; }
.screen-check { flex-direction: row; align-items: center; gap: 0.6rem; margin: 0; padding: 0.55rem 0.2rem; font-weight: 500; border-bottom: 1px solid var(--border); }
.screen-check input { width: 1.3rem; height: 1.3rem; }
.dates { margin-bottom: 0.8rem; }
.dates summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
.dates .row { align-items: flex-start; }
.progress { position: relative; height: 2rem; border-radius: 10px; background: var(--bg); overflow: hidden; margin-bottom: 0.6rem; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width 0.2s; }
.progress .ptext { position: relative; display: block; text-align: center; line-height: 2rem; font-size: 0.85rem; font-weight: 600; }

/* Élő előnézet */
.preview { position: fixed; inset: 0; z-index: 40; background: #05070B; color: #fff; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 1rem; }
.preview-stage { position: relative; width: 100%; overflow: hidden; }
.preview-stage iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: #000; }

.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: #131826; color: #fff; padding: 0.75rem 1.1rem; border-radius: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3); max-width: calc(100vw - 2rem);
}
.toast.ok { background: #065F46; }
.toast.err { background: #991B1B; }
/* Vissza a főmenübe (közös telepített app — iPhone-on nincs "vissza" gomb) */
.home-btn { color: #fff; text-decoration: none; font-size: 2rem; line-height: 1; padding: 0 0.35rem 0.15rem 0; margin-right: 0.1rem; }
.top { justify-content: flex-start; }
.top .top-right { margin-left: auto; }
