/* Cynact — new design prototype.
   Style taken from the reference: soft pastel background blobs, frosted white
   cards with large radii, deep navy-violet type, Cynact-blue highlights, thin
   outline icons, pill buttons. Mobile first; iPad/desktop = two panes. */

:root {
  --ink: #2f2b62;            /* headings */
  --ink-2: #4b4878;          /* body */
  --muted: #9a97b6;          /* secondary text, idle icons */
  --line: #eeeaf5;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --card-soft: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 40px -18px rgba(60, 100, 180, 0.28);
  --shadow-sm: 0 8px 22px -12px rgba(60, 100, 180, 0.30);
  --brand: #3c82f5;          /* Cynact logo blue */

  --coral: #ff7f7a;
  --peach: #ffae7a;
  --pink: #e874b4;
  --violet: #a46be2;
  --blue: #6f8ff0;
  --amber: #f5a54a;
  /* highlights = Cynact logo blue */
  --grad: linear-gradient(135deg, #6aa6ff 0%, #3c82f5 55%, #2f6be0 100%);
  --grad-violet: linear-gradient(135deg, #6aa6ff 0%, #3c82f5 100%);
  --brand-soft: #e3eeff;

  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 18px;
  --pill: 999px;

  --bg-base: #edf2fb;
  --tab-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--ink-2);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg-base); }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }
svg.lucide { stroke-width: 1.7; }

/* ---------- background blobs ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background:
  linear-gradient(160deg, #e8f0fd 0%, #eef3fb 45%, #e4eefb 100%); }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .75; }
.b1 { width: 70vw; height: 70vw; max-width: 620px; max-height: 620px; left: -20vw; top: -12vw; background: #bcd5fb; }
.b2 { width: 60vw; height: 60vw; max-width: 520px; max-height: 520px; right: -22vw; top: 30vh; background: #cfd8fd; }
.b3 { width: 70vw; height: 70vw; max-width: 600px; max-height: 600px; left: 10vw; bottom: -30vw; background: #c6e6fa; }

/* ---------- layout ---------- */
.app { position: relative; z-index: 1; min-height: 100dvh; }
.pane { padding: 28px 20px calc(var(--tab-h) + var(--safe-b) + 28px); }

/* phone: one pane at a time */
@media (max-width: 767px) {
  .app[data-view="home"]   .pane-detail { display: none; }
  .app[data-view="detail"] .pane-home   { display: none; }
}

/* ---------- headings ---------- */
.eyebrow { font-size: 15px; font-weight: 500; color: var(--muted); }
.title { font-size: 32px; font-weight: 700; color: var(--ink); letter-spacing: -0.3px; }
.section-title { font-size: 22px; font-weight: 700; color: var(--ink); }

/* ---------- home header ---------- */
.home-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.home-top .logo { height: 26px; width: auto; display: block; }
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; box-shadow: var(--shadow-sm); flex: none; }

/* status chips under the title (alarm / temperature / doors) */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.chip { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 14px; border-radius: 22px; min-width: 0;
  background: var(--card); box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); text-align: left; }
.chip .c-ico { flex: none; display: grid; }
.chip .lucide { width: 20px; height: 20px; }
.chip .txt { display: flex; flex-direction: column; min-width: 0; }
.chip b { font-weight: 700; color: var(--ink); font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip small { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:active { transform: scale(.97); }

/* ---------- category icon grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cat { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  aspect-ratio: 1 / 0.88; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: transform .15s ease, box-shadow .2s ease; }
.cat:active { transform: scale(.96); }
.cat .ico { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; }
.cat .ico .lucide { width: 24px; height: 24px; }
.cat .label { font-size: 14px; font-weight: 600; color: var(--ink); }
.cat .badge { position: absolute; top: 10px; right: 10px; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--pill);
  font-size: 12px; font-weight: 700; color: #fff; background: var(--grad); display: grid; place-items: center; }
.cat[aria-current="true"] { box-shadow: 0 0 0 2px #8fb8fb, var(--shadow); }

/* every category icon uses Cynact blue */
.tint-amber, .tint-coral, .tint-pink, .tint-violet, .tint-blue { background: var(--brand-soft); color: var(--brand); }

/* ---------- rooms ---------- */
.floor-chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px 18px; padding: 2px 20px 6px; scrollbar-width: none; }
.floor-chips::-webkit-scrollbar { display: none; }
.floor-chips .pill { flex: none; height: 36px; padding: 0 16px; }
.room-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.room-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 14px 16px; border-radius: var(--r-lg); cursor: pointer;
  background: var(--card); box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform .15s ease, box-shadow .2s ease; outline: none; }
.room-tile:active { transform: scale(.97); }
.room-tile:focus-visible, .room-tile[aria-current="true"] { box-shadow: 0 0 0 2px #8fb8fb, var(--shadow); }
.room-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.room-top .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.room-top .ico .lucide { width: 22px; height: 22px; }
.room-top .round { width: 36px; height: 36px; }
.room-name { font-weight: 700; font-size: 16px; color: var(--ink); line-height: 1.2; }
.room-sub { font-size: 13px; font-weight: 500; color: var(--muted); }
.room-group { margin-bottom: 22px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ink-2); margin: 0 0 10px 4px; }
.group-title .lucide { width: 18px; height: 18px; color: var(--brand); }
.room-group .cams { grid-template-columns: 1fr; }

/* ---------- detail header ---------- */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.back { width: 44px; height: 44px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; color: var(--ink); flex: none; }
.back .lucide { width: 22px; height: 22px; }
.detail-sub { margin: 4px 0 22px; color: var(--muted); font-weight: 500; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* outline pills like "UI Design" / "Prototype" */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 18px; border-radius: var(--pill);
  border: 1.5px solid #d5e3fb; background: rgba(255,255,255,.6); font-size: 14px; font-weight: 600; color: var(--brand); }
.pill.coral { color: var(--ink-2); border-color: #e3e6f0; }
.pill.solid { border: 0; color: #fff; background: var(--grad); box-shadow: var(--shadow-sm); }
.pill .lucide { width: 16px; height: 16px; }
.pill:active { transform: scale(.97); }

/* ---------- device list ---------- */
.list { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px 14px 14px; border-radius: var(--r-lg);
  background: var(--card); box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.row .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: #f4f1f9; color: var(--muted); transition: background .2s, color .2s; }
.row .ico .lucide { width: 22px; height: 22px; }
.row.is-on .ico { background: var(--brand-soft); color: var(--brand); }
.row .meta { flex: 1; min-width: 0; text-align: left; }
.row .name { font-weight: 700; color: var(--ink); font-size: 16px; line-height: 1.25; }
.row .sub { font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.row .sub .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.row .end { display: flex; align-items: center; gap: 6px; flex: none; }
.row .end .round { width: 36px; height: 36px; }
@media (max-width: 380px) { .row { gap: 10px; padding: 12px; } .row .ico { width: 38px; height: 38px; } }

/* switch */
.switch { width: 52px; height: 30px; border-radius: var(--pill); background: #e9e5f2; position: relative; transition: background .25s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(80, 60, 130, .25); transition: transform .25s cubic-bezier(.3,.7,.4,1.2); }
.switch[aria-checked="true"] { background: var(--grad); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* small round control buttons */
.round { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #f4f1f9; color: var(--ink-2); }
.round .lucide { width: 18px; height: 18px; }
.round.active { background: var(--grad); color: #fff; box-shadow: var(--shadow-sm); }
.round:active { transform: scale(.94); }

/* climate */
.temp { font-size: 22px; font-weight: 700; color: var(--ink); min-width: 52px; text-align: center; }
.temp small { font-size: 13px; color: var(--muted); font-weight: 600; }

/* status text on the right */
.state { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: var(--pill); background: #f4f1f9; color: var(--ink-2); white-space: nowrap; }
.state.good { background: #e8f6ef; color: #3a9a6c; }
.state.warn { background: #fff0e6; color: #e07a3e; }

/* cameras */
.cams { display: grid; grid-template-columns: 1fr; gap: 14px; }
.cam { border-radius: var(--r-lg); overflow: hidden; background: var(--card); box-shadow: var(--shadow-sm); text-align: left; }
.cam .frame { aspect-ratio: 16 / 9; position: relative; }
.cam .frame .lucide { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; color: rgba(255,255,255,.85); }
.cam .live { position: absolute; top: 12px; left: 12px; font-size: 12px; font-weight: 700; color: #fff; padding: 4px 10px;
  border-radius: var(--pill); background: rgba(47, 43, 98, .35); backdrop-filter: blur(6px); }
.cam .live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff6b7a; margin-right: 6px; vertical-align: 1px; }
.cam .cap { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.hue-peach { background: linear-gradient(135deg, #ffb59a, #ff8f9f); }
.hue-lilac { background: linear-gradient(135deg, #cfa8f2, #f19ccc); }
.hue-sky   { background: linear-gradient(135deg, #a9c0f6, #d4a9ef); }
.hue-rose  { background: linear-gradient(135deg, #f6a7c6, #ffc79b); }

/* scenes */
.scenes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.scene { padding: 18px; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-sm); text-align: left;
  display: flex; flex-direction: column; gap: 14px; min-height: 120px; justify-content: space-between; transition: transform .15s; }
.scene .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.scene .name { font-weight: 700; color: var(--ink); }
.scene.ran { background: var(--grad); }
.scene.ran .name { color: #fff; }
.scene.ran .ico { background: rgba(255,255,255,.25); color: #fff; }
.scene:active { transform: scale(.97); }

/* alarm hero */
.alarm { padding: 26px 22px; border-radius: var(--r-xl); background: var(--card); box-shadow: var(--shadow); text-align: center; }
.alarm .ring { width: 120px; height: 120px; margin: 4px auto 16px; border-radius: 50%; display: grid; place-items: center; background: #f4f1f9; color: var(--muted); }
.alarm .ring .lucide { width: 48px; height: 48px; }
.alarm.armed .ring { background: var(--grad); color: #fff; box-shadow: 0 16px 34px -14px rgba(60, 130, 245, .7); }
.alarm .big { font-size: 24px; font-weight: 700; color: var(--ink); }
.alarm .choices { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* empty / coming soon */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-weight: 500; }
.empty .lucide { width: 40px; height: 40px; margin-bottom: 10px; color: #cfc8e4; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); height: var(--tab-h);
  border-radius: 28px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  display: flex; align-items: center; justify-content: space-around; padding: 0 8px; }
.tab { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: var(--muted); position: relative; }
.tab .lucide { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--brand); }
.tab[aria-current="page"]::after { content: ''; position: absolute; bottom: 4px; width: 18px; height: 3px; border-radius: 3px; background: var(--grad-violet); }
.tab .dot { position: absolute; top: 10px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(47, 43, 98, .18); backdrop-filter: blur(3px); }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow: auto;
  padding: 14px 22px calc(28px + var(--safe-b)); border-radius: 32px 32px 0 0; background: #fff; box-shadow: 0 -20px 60px -20px rgba(80,60,130,.35);
  animation: up .28s cubic-bezier(.2,.8,.3,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 5px; background: #e6e1f0; margin: 0 auto 18px; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet .close { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink); }
.sheet .sub { color: var(--muted); font-weight: 500; margin-bottom: 22px; }
.slider-wrap { margin: 10px 0 24px; }
.slider-label { display: flex; justify-content: space-between; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: 10px; outline: none;
  background: linear-gradient(90deg, #6aa6ff, #3c82f5) 0/var(--p, 50%) 100% no-repeat, #e8edf6; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 3px 10px rgba(80,60,130,.3); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 3px 10px rgba(80,60,130,.3); }
.dial { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 18px 0 26px; }
.dial .val { font-size: 64px; font-weight: 700; color: var(--ink); line-height: 1; }
.dial .val sup { font-size: 24px; color: var(--muted); }
.dial .round { width: 56px; height: 56px; }
.seg { display: flex; gap: 8px; background: #f4f1f9; padding: 5px; border-radius: var(--pill); }
.seg button { flex: 1; height: 40px; border-radius: var(--pill); font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.big-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big-actions button { height: 64px; border-radius: var(--r-md); background: #f4f1f9; font-weight: 700; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; }
.big-actions button.active { background: var(--grad); color: #fff; }
.big-actions .lucide { width: 22px; height: 22px; }

/* toast */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tab-h) + 30px + var(--safe-b)); transform: translateX(-50%);
  padding: 12px 20px; border-radius: var(--pill); background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); animation: fade .2s ease; white-space: nowrap; }

@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0; transform: translate(-50%, 8px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* ======================================================================
   iPad / desktop: icon rail on the left, home (categories) + devices side
   by side. Desktop is the iPad layout, centred with a max width.
   ====================================================================== */
@media (min-width: 768px) {
  :root { --tab-h: 0px; }
  .app { display: grid; grid-template-columns: 96px minmax(320px, 400px) 1fr; gap: 0 24px;
    max-width: 1280px; margin: 0 auto; padding: 24px; min-height: 100dvh; }
  .tabbar { position: sticky; top: 24px; left: auto; right: auto; bottom: auto; height: calc(100dvh - 48px);
    flex-direction: column; justify-content: flex-start; gap: 14px; padding: 26px 0; border-radius: var(--r-xl); }
  .tab[aria-current="page"]::after { bottom: auto; left: 2px; width: 3px; height: 18px; }
  .tabbar .brand { width: 48px; height: 48px; margin-bottom: 18px; display: block; }
  .tabbar .brand img { width: 100%; height: 100%; display: block; }
  .home-top .logo { display: none; }
  .home-top { justify-content: flex-end; margin-bottom: -40px; }
  .pane { padding: 34px 28px; border-radius: var(--r-xl); }
  .pane-home { background: var(--card-soft); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); align-self: start;
    position: sticky; top: 24px; max-height: calc(100dvh - 48px); overflow: auto; }
  .pane-detail { background: rgba(255,255,255,.72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); min-height: calc(100dvh - 48px); }
  .back { display: none; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .cams { grid-template-columns: repeat(2, 1fr); }
  .floor-chips { margin: 0 0 18px; padding: 2px 0 6px; flex-wrap: wrap; }
  .scenes { grid-template-columns: repeat(3, 1fr); }
  .list { grid-template-columns: 1fr; }
  .title { font-size: 34px; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: 440px; transform: translate(-50%, 50%); border-radius: 32px; animation: none; }
  .sheet .grab { display: none; }
  .toast { bottom: 30px; }
}
@media (min-width: 1100px) {
  .list { grid-template-columns: repeat(2, 1fr); }
  .cams { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) { .tabbar .brand { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
