/* JARVIS phone app */
html, body { height: 100%; overflow: hidden; }
body { user-select: none; -webkit-user-select: none; }
input, .bubble { user-select: text; -webkit-user-select: text; }

.screen-full { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: calc(24px + var(--safe-top)) 28px calc(24px + var(--safe-bottom)); text-align: center; }
.screen-full h1 { margin: 6px 0 0; font-size: 24px; }

#shell { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 18px 10px; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px currentColor; }
.status-chip.online { color: var(--text); }
.status-chip.online .dot { background: var(--green); color: var(--green); }
.status-chip.asleep .dot { background: var(--amber); color: var(--amber); }
.status-chip.offline .dot { background: var(--red); color: var(--red); }

/* views */
.views { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 18px 24px;
  opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }
.view.active { opacity: 1; pointer-events: auto; transform: none; }
.view-title { font-size: 30px; letter-spacing: -.02em; margin: 6px 2px 16px; }
.section-label { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 26px 4px 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }

/* home */
.view[data-view="home"] { display: flex; flex-direction: column; align-items: center; padding-top: 4px; }
.greeting { font-size: 22px; font-weight: 650; margin: 8px 0 22px; color: var(--text); text-align: center; }
#orb { width: 220px; height: 220px; margin: 6px 0 0; }
#orb .ring2 { inset: 30px; }
#orb .core { inset: 82px; }
#orb:active .core { transform: scale(.92); }
.orb-label { margin: 18px 0 0; color: var(--muted); font-size: 15px; font-weight: 550; min-height: 22px; }
.live { width: 100%; max-width: 520px; margin: 18px 0 0; padding: 14px 16px; border-radius: 16px; background: var(--panel);
  border: 1px solid var(--line); font-size: 17px; line-height: 1.5; max-height: 30vh; overflow-y: auto; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 14px; max-width: 520px; }
.chip-btn { padding: 9px 14px; border-radius: 999px; font-size: 14px; color: var(--text); background: rgba(255,255,255,.04);
  border: 1px solid var(--line); transition: background .2s, transform .1s; }
.chip-btn:active { transform: scale(.96); background: var(--cyan-soft); }

/* composer */
.composer { display: flex; gap: 8px; width: 100%; max-width: 520px; margin-top: auto; align-items: center; }
.composer .field { flex: 1; border-radius: 999px; min-height: 50px; }
.composer .send, .icon-btn { width: 50px; height: 50px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 19px; }
.composer .send { background: var(--cyan); color: #00131a; box-shadow: 0 6px 20px rgba(0, 229, 255, .3); }
.icon-btn { background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.icon-btn.recording { background: rgba(255, 92, 122, .16); border-color: rgba(255, 92, 122, .5); animation: pulse 1s infinite; }
.composer.sticky { position: sticky; bottom: 0; padding: 10px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }

/* chat */
.view[data-view="chat"] { display: flex; flex-direction: column; padding-bottom: 8px; }
.feed { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 8px 0 12px; }
.empty { margin: auto; text-align: center; color: var(--dim); padding: 40px 20px; }
.bubble { max-width: 84%; padding: 11px 15px; border-radius: 20px; font-size: 16px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
  animation: pop .18s ease; }
.bubble.me { align-self: flex-end; background: var(--cyan); color: #00131a; border-end-end-radius: 6px; }
.bubble.jarvis { align-self: flex-start; background: var(--panel-solid); border: 1px solid var(--line); border-end-start-radius: 6px; }
.bubble.sys { align-self: center; background: none; color: var(--dim); font-size: 13px; padding: 2px 8px; }
.bubble .time { display: block; font-size: 11px; opacity: .55; margin-top: 4px; }
.typing { align-self: flex-start; display: flex; gap: 5px; padding: 14px 16px; border-radius: 20px; background: var(--panel-solid); border: 1px solid var(--line); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* devices */
.device { padding: 18px; }
.device-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.device-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--cyan-soft); border: 1px solid var(--line-strong); }
.device-name { font-weight: 700; font-size: 17px; }
.device-sub { color: var(--muted); font-size: 13px; }
.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ctl { min-height: 64px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); font-size: 12px; color: var(--muted); transition: transform .1s, background .2s; }
.ctl b { font-size: 21px; color: var(--text); font-weight: 500; line-height: 1; }
.ctl:active { transform: scale(.95); background: var(--cyan-soft); }
.ctl.busy { opacity: .5; }
.apps { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 2px; scrollbar-width: none; }
.apps::-webkit-scrollbar { display: none; }
.apps .chip-btn { flex: none; white-space: nowrap; }
.soon { padding: 16px 18px; display: flex; align-items: center; gap: 14px; opacity: .6; }
.soon .device-icon { filter: grayscale(.6); }
.badge { white-space: nowrap; flex: none; margin-inline-start: auto; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--amber);
  border: 1px solid rgba(255, 181, 71, .4); border-radius: 999px; padding: 3px 8px; }

/* files */
.upload { display: flex; align-items: center; gap: 16px; padding: 18px; border-style: dashed; border-color: var(--line-strong); cursor: pointer; }
.upload-icon { width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 22px; color: var(--cyan); background: var(--cyan-soft); }
.file { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.file-ic { font-size: 24px; width: 34px; text-align: center; flex: none; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--muted); font-size: 12px; }
.file-actions { display: flex; gap: 6px; }
.mini { min-height: 38px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 650; background: var(--cyan-soft); color: var(--cyan); border: 1px solid var(--line); }
.bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.06); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--cyan); transition: width .2s; }

/* settings */
.group { padding: 6px 16px; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 0; }
.group > .row + .row, .member + .member { border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; padding: 0 0 12px; }
.inline-form .field { flex: 1; }
.toggle input { display: none; }
.switch { width: 50px; height: 30px; flex: none; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .switch { background: var(--green); }
.toggle input:checked + .switch::after { transform: translateX(20px); }
.member { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.member-meta { flex: 1; min-width: 0; }
.member-name { font-weight: 600; }
.member-sub { font-size: 12px; color: var(--muted); }
#unpair { margin: 22px 0 10px; }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + var(--safe-bottom));
  background: rgba(3, 7, 15, .86); border-top: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--dim); }
.tab .ti { font-size: 20px; filter: grayscale(1) opacity(.6); transition: filter .2s; }
.tab.active { color: var(--cyan); }
.tab.active .ti { filter: none; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; animation: fade .2s; }
.sheet-panel { width: 100%; border-radius: 26px 26px 0 0; padding: 10px 20px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px;
  background: var(--panel-solid); animation: up .25s ease; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin: 0 auto 4px; }
.sheet h3 { margin: 0; text-align: center; }
.dpad { display: grid; grid-template-columns: repeat(3, 76px); grid-template-rows: repeat(3, 76px); gap: 8px; justify-content: center; }
.dp { border-radius: 20px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 22px; }
.dp:active { background: var(--cyan-soft); }
.dp.up { grid-column: 2; } .dp.left { grid-column: 1; grid-row: 2; } .dp.ok { grid-column: 2; grid-row: 2; font-weight: 800; color: var(--cyan); }
.dp.right { grid-column: 3; grid-row: 2; } .dp.down { grid-column: 2; grid-row: 3; }
.remote-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.remote-row .btn { min-height: 48px; padding: 0 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* confirmation */
#confirm { z-index: 25; }
.confirm-panel { border-top: 2px solid var(--amber); }
.confirm-badge { align-self: center; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber); background: rgba(255, 181, 71, .1); border: 1px solid rgba(255, 181, 71, .4); border-radius: 999px; padding: 5px 12px; margin-top: 6px; }
.confirm-detail { margin: 0; white-space: pre-wrap; color: var(--muted); max-height: 38vh; overflow-y: auto; line-height: 1.5; }
#confirm h3 { font-size: 20px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 30; transform: translate(-50%, 20px); opacity: 0;
  max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 550;
  background: #102235; border: 1px solid var(--line-strong); box-shadow: 0 10px 40px rgba(0,0,0,.5); transition: all .25s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 92, 122, .5); }

@media (min-width: 700px) { .view { padding-left: calc(50% - 300px); padding-right: calc(50% - 300px); } }

/* briefing */
.briefing { width: 100%; max-width: 520px; position: relative; padding: 14px 18px 12px; margin: -8px 0 16px; text-align: start; }
.briefing h3 { margin: 0 0 6px; font-size: 16px; color: var(--cyan); }
.briefing ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 14px; line-height: 1.4; color: var(--text); }
.briefing li:first-child { color: var(--muted); font-size: 13px; }
.briefing-close { position: absolute; top: 8px; inset-inline-end: 10px; width: 30px; height: 30px; border-radius: 50%; color: var(--dim); font-size: 14px; }

/* house */
.section-label.first { margin-top: 4px; }
.whos-home { margin: -8px 4px 14px; }
.scene-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.scene-btn { min-height: 58px; border-radius: 16px; padding: 10px 14px; text-align: start; font-weight: 650; font-size: 15px;
  background: linear-gradient(135deg, rgba(0,229,255,.12), rgba(255,255,255,.03)); border: 1px solid var(--line-strong); transition: transform .1s; }
.scene-btn small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.scene-btn:active { transform: scale(.97); }
.scene-btn.busy { opacity: .5; }
.top-pad { padding-top: 12px; }
.shop-item { display: flex; align-items: center; gap: 12px; min-height: 50px; border-top: 1px solid var(--line); }
.shop-check { width: 26px; height: 26px; flex: none; border-radius: 8px; border: 2px solid var(--line-strong); }
.shop-check:active, .shop-check.on { background: var(--green); border-color: var(--green); }
.shop-text { flex: 1; min-width: 0; }
.shop-by { font-size: 11px; color: var(--dim); }
.sched-item { display: flex; align-items: center; gap: 12px; min-height: 54px; }
.sched-item + .sched-item { border-top: 1px solid var(--line); }
.sched-meta { flex: 1; min-width: 0; }

/* printer */
.printer { padding: 14px 16px; margin-bottom: 12px; }
.printer-head { display: flex; align-items: center; gap: 12px; }
.printer-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--cyan-soft); flex: none; }
.printer-meta { flex: 1; min-width: 0; }
.ink { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.ink:empty { display: none; }
.ink-col { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.ink-bar { width: 100%; height: 44px; border-radius: 8px; background: rgba(255,255,255,.06); position: relative; overflow: hidden; border: 1px solid var(--line); }
.ink-bar > i { position: absolute; left: 0; right: 0; bottom: 0; }
.ink-col.low { color: var(--red); font-weight: 700; }

/* announcement */
#announce { z-index: 26; }
.announce-panel { border-top: 2px solid var(--cyan); }
.announce-badge { align-self: center; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan);
  background: var(--cyan-soft); border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px; margin-top: 6px; }
.announce-text { margin: 4px 0; font-size: 22px; font-weight: 650; line-height: 1.4; text-align: center; white-space: pre-wrap; word-wrap: break-word; }

/* alert */
.alert-screen { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: calc(24px + var(--safe-top)) 26px calc(24px + var(--safe-bottom)); text-align: center; color: #fff;
  background: radial-gradient(circle at 50% 30%, #b3001b, #4a0010 70%); animation: alarm 1.2s ease-in-out infinite alternate; }
.alert-icon { font-size: 64px; }
.alert-screen h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.alert-desc { margin: 0; font-size: 20px; font-weight: 650; line-height: 1.4; }
.alert-places { margin: 0; font-size: 15px; opacity: .85; max-height: 22vh; overflow-y: auto; }
.alert-note { margin: 8px 0 0; font-size: 12px; opacity: .7; }
.alert-btn { max-width: 360px; margin-top: 10px; background: #fff; color: #7a0014; font-weight: 800; }
.alert-screen.ended { background: radial-gradient(circle at 50% 30%, #0f6b3a, #062b18 70%); animation: none; }
@keyframes alarm { from { filter: brightness(1); } to { filter: brightness(1.25); } }

/* add a phone */
#add-phone { margin-top: 4px; }
.pair-qr { width: 220px; height: 220px; align-self: center; border-radius: 16px; background: #fff; padding: 8px; image-rendering: pixelated; }
.pair-key { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; color: var(--cyan); }

.play-form { padding: 12px 0 0; }

/* right-to-left (Hebrew) */
html[dir="rtl"] .switch::after { left: auto; right: 3px; }
html[dir="rtl"] .toggle input:checked + .switch::after { transform: translateX(-20px); }
html[dir="rtl"] .composer .send { transform: scaleX(-1); }
html[dir="rtl"] body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Arial Hebrew", Arial, sans-serif; }
.lang-switch { display: inline-flex; flex: none; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.lang-btn { padding: 8px 14px; font-size: 14px; font-weight: 650; color: var(--muted); background: transparent; }
.lang-btn.active { background: var(--cyan); color: #00131a; }
/* an empty dir="auto" field would lay a Hebrew placeholder out left-to-right */
html[dir="rtl"] input[dir="auto"]:placeholder-shown { direction: rtl; }
