/* הודעות לטלוויזיות — כחול לילה של חדר בקרה, כתום בטיחות של אחזקה */
:root {
  --ground: #f3f5f9;
  --surface: #ffffff;
  --ink: #13203a;
  --ink-soft: #5a6679;
  --line: #d8dee8;
  --accent: #ff7a1a;
  --accent-ink: #1a0e00;
  --navy: #13203a;
  --danger: #c9303b;
  --ok: #1f9d63;
  --chip: #e9edf4;
  --radius: 14px;
  --f: "Rubik", "Heebo", "Arial Hebrew", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c1322; --surface: #151f33; --ink: #e8edf6; --ink-soft: #9aa6ba; --line: #26324a;
    --chip: #1d2a42; --navy: #0a1120;
  }
}
:root[data-theme="dark"] {
  --ground: #0c1322; --surface: #151f33; --ink: #e8edf6; --ink-soft: #9aa6ba; --line: #26324a;
  --chip: #1d2a42; --navy: #0a1120;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--f); font-size: 16px; }
body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* סרגל עליון */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--navy); color: #fff;
}
.bar h1 { margin: 0; font-size: 18px; font-weight: 500; flex: 1; letter-spacing: .01em; }
.bar h1 b { color: var(--accent); font-weight: 700; }
.bar .who { font-size: 13px; opacity: .8; }
.bar button { background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff; border-radius: 10px; padding: 7px 11px; font-size: 14px; }

.wrap { max-width: 720px; margin: 0 auto; padding-inline: 16px; padding-block: 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.section-title { font-size: 13px; letter-spacing: .06em; color: var(--ink-soft); margin: 4px 2px -6px; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 500; background: var(--chip); color: var(--ink); min-height: 46px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }

.fab {
  position: fixed; inset-inline-start: 50%; transform: translateX(50%); bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30; box-shadow: 0 10px 30px rgba(255,122,26,.45); padding: 14px 26px; font-size: 17px;
}

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=number], select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); min-height: 46px; width: 100%;
}

/* כניסה */
.login { min-height: 100vh; display: grid; place-items: center; padding-inline: 16px; background: radial-gradient(1200px 600px at 50% -10%, #22365c 0, var(--navy) 60%); }
.login form { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 26px 22px; display: flex; flex-direction: column; gap: 14px; }
.login h2 { margin: 0; font-size: 24px; }
.login p { margin: 0 0 6px; color: var(--ink-soft); font-size: 14px; }
.tv-glyph { width: 56px; height: 36px; border: 5px solid var(--accent); border-radius: 8px; position: relative; margin-bottom: 6px; }
.tv-glyph::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; color: var(--accent); font-size: 18px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* רשימת הודעות */
.msg { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: start; }
.thumb { width: 132px; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; }
.msg .meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg .targets { font-size: 14px; color: var(--ink-soft); overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--chip); width: fit-content; }
.pill.live { background: #ffe7d4; color: #8a3a00; }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
.pill.gone { color: var(--ink-soft); }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .pill.live::before { animation: none; } }
.msg .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .actions .btn { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; }

/* עורך */
.toolbar {
  position: sticky; top: 56px; z-index: 15; display: flex; gap: 6px; overflow-x: auto; padding: 8px; margin: 0 -2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tb { flex: none; min-width: 42px; height: 42px; border-radius: 9px; border: 1px solid transparent; background: var(--chip); display: grid; place-items: center; font-size: 17px; padding: 0 8px; }
.tb.on { border-color: var(--accent); background: #ffe7d4; color: #6b2d00; }
.tb select { border: 0; background: transparent; min-height: 0; padding: 0; width: auto; font-size: 14px; }
.tb input[type=color] { width: 26px; height: 26px; padding: 0; border: 0; background: none; }
.tb-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }

.ed-box { width: 100%; aspect-ratio: 1536 / 864; border-radius: 10px; position: relative; overflow: hidden; background: #0f1b2d; border: 5px solid var(--accent); }
.ed-inner {
  position: absolute; top: 0; right: 0; width: 1508px; height: 740px; display: flex; flex-direction: column; justify-content: center;
  padding: 56px 72px; font-size: 64px; line-height: 1.25; text-align: center; outline: none; overflow: auto; overflow-wrap: anywhere;
  transform-origin: top right;
}
.ed-inner:empty::before { content: attr(data-placeholder); opacity: .45; }
.ed-foot { position: absolute; left: 0; right: 0; bottom: 0; height: 13%; display: grid; place-items: center; font-size: 12px; font-weight: 500; }

.swatches { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.swatch { flex: none; width: 64px; border-radius: 10px; border: 2px solid transparent; padding: 0; overflow: hidden; background: none; }
.swatch.on { border-color: var(--accent); }
.swatch span { display: block; height: 34px; border: 5px solid; border-radius: 8px; }
.swatch small { display: block; font-size: 11px; padding: 3px 0; color: var(--ink-soft); }
.custom-colors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.custom-colors label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.custom-colors input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 2px; }

.targets-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; background: var(--surface); font-size: 15px; }
.tchip input { width: 18px; height: 18px; accent-color: var(--accent); }
.tchip.all { font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #aab3c2; }
.dot.on { background: var(--ok); }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--ground) 30%); padding: 18px 0 calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.sticky-actions .btn { flex: 1; }

/* תצוגה מקדימה */
.preview { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; }
.preview .stage-box { flex: 1; position: relative; }
.preview .pv-bar { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #0a0f19; }
.preview .pv-bar .btn { flex: 1; }
.preview .hint { color: #9aa6ba; font-size: 13px; text-align: center; padding-top: calc(8px + env(safe-area-inset-top)); }

/* אדמין */
.tabs { display: flex; gap: 6px; background: var(--chip); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 10px; font-weight: 500; color: var(--ink-soft); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .name { font-weight: 500; }
.list-item .sub { font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item.off { opacity: .55; }
.keybox { font-family: ui-monospace, Consolas, monospace; background: var(--chip); border-radius: 8px; padding: 10px; direction: ltr; text-align: left; overflow-wrap: anywhere; font-size: 13px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }

#toast {
  position: fixed; inset-inline: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 200; margin: 0 auto; max-width: 480px;
  background: var(--navy); color: #fff; border-radius: 12px; padding: 13px 16px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
#toast.bad { background: var(--danger); }

/* כפתור התקנה (מופיע רק כש-Chrome מאפשר התקנה ועוד לא הותקן) */
.btn.install { background: transparent; border: 1.5px dashed var(--accent); color: var(--ink); width: 100%; }
.btn.install::before { content: "⬇  "; color: var(--accent); font-weight: 700; }

/* עריכה במסך מלא: העורך ממלא את המסך (לסובב את הטלפון), הסרגל נשאר מעליו */
body.ed-full { overflow: hidden; }
body.ed-full .toolbar { position: fixed; top: 0; inset-inline: 0; z-index: 96; border-radius: 0; margin: 0; }
.ed-box.full { position: fixed; z-index: 95; inset-inline: 0; top: 58px; bottom: 0; width: 100%; aspect-ratio: auto; border-radius: 0; border-width: 8px; }
.ed-box.full .ed-inner { right: 50%; margin-right: -754px; transform-origin: top center; }

/* מסך שליחה: שורת היסטוריה אחת ובחירת טלוויזיה (14.9.2026) */
.history-row { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--surface); border: 1px solid var(--line); text-align: start; }
.history-row span:first-child { font-weight: 500; }
.history-row .hist-info { flex: 1; color: var(--ink-soft); font-size: 14px; font-weight: 400; }
.target-field { font-size: 15px; color: var(--ink); font-weight: 500; }
.target-field select { font-size: 17px; font-weight: 500; border-width: 2px; }
.emoji-pop { position: sticky; top: 118px; z-index: 16; display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; max-height: 200px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.emo { font-size: 26px; height: 44px; border: 0; background: transparent; border-radius: 8px; }
.emo:active { background: var(--chip); }
