/* ============================================================
   AI Call Center demo — iPhone-style UI
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --cell: #ffffff;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --bubble-in: #e9e9eb;
  --bar: rgba(249, 249, 249, 0.86);
  --banner: rgba(246, 246, 246, 0.82);
  --top: 54px;
  --bottom: 34px;
  --font: -apple-system, 'SF Pro Text', 'Inter', 'Noto Sans Thai', system-ui, 'Segoe UI', 'Leelawadee UI', sans-serif;
  --stage: #0b0b12;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-line: rgba(255, 255, 255, 0.1);
  --panel-text: #e9e9f1;
  --panel-dim: rgba(233, 233, 241, 0.55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --bg-grouped: #000000;
    --cell: #1c1c1e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --bubble-in: #26252a;
    --bar: rgba(22, 22, 24, 0.86);
    --banner: rgba(44, 44, 46, 0.82);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #000000;
  --bg-grouped: #000000;
  --cell: #1c1c1e;
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.65);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.36);
  --blue: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --bubble-in: #26252a;
  --bar: rgba(22, 22, 24, 0.86);
  --banner: rgba(44, 44, 46, 0.82);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(99, 102, 241, 0.25), transparent 60%),
    radial-gradient(800px 600px at 85% 90%, rgba(236, 72, 153, 0.18), transparent 60%),
    var(--stage);
  color: var(--label);
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; }

/* ------------------------------------------------------------ stage & device */
#stage {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 20px;
}
.device-wrap { flex: none; position: relative; }
.device {
  position: absolute;
  top: 0;
  left: 0;
  width: 414px;
  height: 868px;
  padding: 12px;
  border-radius: 66px;
  background: linear-gradient(145deg, #3a3a3e, #121214 40%, #2a2a2e);
  box-shadow:
    0 0 0 2px #4a4a50,
    0 0 0 3px #1b1b1d,
    0 40px 90px rgba(0, 0, 0, 0.55),
    inset 0 0 6px rgba(255, 255, 255, 0.15);
  transform-origin: top left;
}
.device .btn-side { position: absolute; width: 4px; background: #2c2c30; border-radius: 2px; }
.device .btn-action { left: -5px; top: 120px; height: 32px; }
.device .btn-vol-up { left: -5px; top: 180px; height: 62px; }
.device .btn-vol-down { left: -5px; top: 256px; height: 62px; }
.device .btn-power { right: -5px; top: 210px; height: 100px; }

.screen {
  position: relative;
  width: 390px;
  height: 844px;
  border-radius: 54px;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
  user-select: none;
}
.island {
  position: absolute;
  top: 11px;
  left: 50%;
  width: 124px;
  height: 36px;
  margin-left: -62px;
  background: #000;
  border-radius: 20px;
  z-index: 90;
  transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2), margin-left 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.island.call { width: 200px; margin-left: -100px; }
.island .island-l, .island .island-r { opacity: 0; transition: opacity 0.2s 0.15s; display: flex; align-items: center; gap: 5px; }
.island.call .island-l, .island.call .island-r { opacity: 1; }
.island .wave { display: flex; gap: 2px; align-items: center; height: 14px; }
.island .wave i { width: 3px; height: 4px; background: var(--green); border-radius: 2px; }
.island.talking .wave i { animation: wave 0.9s ease-in-out infinite; }
.island.talking .wave i:nth-child(2) { animation-delay: 0.15s; }
.island.talking .wave i:nth-child(3) { animation-delay: 0.3s; }
.island.talking .wave i:nth-child(4) { animation-delay: 0.45s; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 13px; } }

.statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 30px 0 46px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  z-index: 80;
  pointer-events: none;
  color: var(--label);
  transition: color 0.25s;
}
.statusbar.light { color: #fff; }
.statusbar .sb-right { display: flex; align-items: center; gap: 6px; }
.statusbar .battery { width: 27px; height: 13px; border: 1.3px solid currentColor; border-radius: 4px; padding: 1.5px; opacity: 0.95; position: relative; }
.statusbar .battery::after { content: ''; position: absolute; right: -4px; top: 3.5px; width: 2px; height: 4px; border-radius: 0 1px 1px 0; background: currentColor; opacity: 0.5; }
.statusbar .battery i { display: block; height: 100%; width: 78%; background: currentColor; border-radius: 2px; }

.homebar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 136px;
  height: 5px;
  margin-left: -68px;
  border-radius: 3px;
  background: var(--label);
  z-index: 85;
  cursor: pointer;
}
.homebar.light { background: #fff; }
.homebar::before { content: ''; position: absolute; inset: -16px -30px -10px; }
.homebar { transition: width 0.2s, margin-left 0.2s, transform 0.2s; }
.homebar:hover { width: 156px; margin-left: -78px; transform: translateY(-2px); }
.homebar.nudge { animation: nudge 1.1s ease-in-out 3; }
@keyframes nudge { 0%, 100% { transform: none; } 40% { transform: translateY(-7px); } }
.home-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottom) + 26px);
  transform: translateX(-50%);
  z-index: 86;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.78);
  padding: 8px 14px;
  border-radius: 99px;
  pointer-events: none;
  animation: hintIn 0.35s ease;
  transition: opacity 0.35s;
}
.home-hint::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: rgba(0, 0, 0, 0.78); }
.home-hint.out { opacity: 0; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 6px); } }
body.mobile .home-hint { bottom: 22px; }

/* ------------------------------------------------------------ mobile (no frame) */
body.mobile #stage { padding: 0; }
body.mobile .device-wrap { width: 100vw !important; height: 100dvh !important; }
body.mobile .device { position: static; width: 100%; height: 100%; padding: 0; border-radius: 0; box-shadow: none; background: none; transform: none !important; }
body.mobile .device .btn-side, body.mobile .island, body.mobile .statusbar { display: none; }
body.mobile .screen { width: 100%; height: 100%; border-radius: 0; }
body.mobile { --top: env(safe-area-inset-top, 20px); --bottom: max(env(safe-area-inset-bottom, 0px), 16px); }
body.mobile .homebar { bottom: 5px; }
body.mobile .inspector { display: none; }

/* ------------------------------------------------------------ apps & views */
.app { position: absolute; inset: 0; background: var(--bg); overflow: hidden; }
.app.opening { animation: appOpen 0.42s cubic-bezier(0.2, 0.85, 0.25, 1); }
.app.closing { animation: appClose 0.32s cubic-bezier(0.4, 0, 0.6, 1) forwards; }
@keyframes appOpen { from { transform: scale(0.2); opacity: 0; border-radius: 40px; } to { transform: none; opacity: 1; } }
@keyframes appClose { to { transform: scale(0.25); opacity: 0; border-radius: 60px; } }

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  padding-top: var(--top);
  scrollbar-width: none;
  transition: transform 0.42s cubic-bezier(0.2, 0.85, 0.25, 1), filter 0.42s;
}
.view::-webkit-scrollbar { display: none; }
.view.grouped { background: var(--bg-grouped); }
.view.with-tabs { padding-bottom: calc(50px + var(--bottom)); }
.view.enter { transform: translateX(100%); }
.view.behind { transform: translateX(-28%); filter: brightness(0.92); }
.view.leave { transform: translateX(100%); }

.navbar {
  position: sticky;
  top: calc(-1 * var(--top));
  margin-top: calc(-1 * var(--top));
  padding-top: var(--top);
  height: calc(44px + var(--top));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  z-index: 10;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.navbar.clear { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.navbar .nav-l { justify-self: start; padding-left: 8px; }
.navbar .nav-c { font-size: 17px; font-weight: 600; text-align: center; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .nav-r { justify-self: end; padding-right: 16px; color: var(--blue); font-size: 17px; }
.back { display: flex; align-items: center; gap: 2px; color: var(--blue); font-size: 17px; padding: 6px 4px; }
.back svg { width: 13px; height: 21px; margin-right: 4px; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.2px; padding: 2px 16px 8px; line-height: 1.25; }
.search {
  margin: 2px 16px 10px;
  height: 36px;
  border-radius: 10px;
  background: var(--fill);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--label-2);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input { border: 0; outline: 0; background: none; flex: 1; font-size: 17px; color: var(--label); min-width: 0; }
.search input::placeholder { color: var(--label-2); }

/* lists */
.list { background: var(--bg); }
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 16px;
  width: 100%;
  text-align: left;
  font-size: 17px;
}
.row:active { background: var(--fill); }
.row + .row::before { content: ''; position: absolute; top: 0; right: 0; left: var(--inset, 16px); border-top: 0.5px solid var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--label-2); font-size: 15px; margin-top: 1px; }
.row .meta { color: var(--label-2); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.row .chev { width: 8px; height: 13px; color: var(--label-3); flex: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.section-h { font-size: 15px; font-weight: 600; color: var(--label-2); padding: 6px 16px 4px; background: var(--bg); position: sticky; top: 44px; z-index: 2; }
.bold { font-weight: 600; }

.group { margin: 0 16px 22px; background: var(--cell); border-radius: 12px; overflow: hidden; }
.group .row { --inset: 16px; }
.group-h { font-size: 13px; color: var(--label-2); text-transform: uppercase; padding: 0 32px 6px; letter-spacing: 0.2px; }
.group-f { font-size: 13px; color: var(--label-2); padding: 6px 32px 0; margin-top: -16px; margin-bottom: 22px; line-height: 1.45; }

/* avatars */
.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(180deg, #a5abb8, #858994);
  overflow: hidden;
}
.avatar svg { width: 56%; height: 56%; }
.avatar.lg { width: 120px; height: 120px; font-size: 48px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }

/* tab bar */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(50px + var(--bottom));
  padding-bottom: var(--bottom);
  display: flex;
  z-index: 20;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--label-2); }
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--blue); }

/* ------------------------------------------------------------ contacts */
.my-card { display: flex; align-items: center; gap: 14px; padding: 6px 16px 14px; width: 100%; text-align: left; border-bottom: 0.5px solid var(--sep); }
.my-card .avatar { width: 58px; height: 58px; font-size: 22px; }
.my-card .nm { font-size: 20px; font-weight: 600; }
.my-card .sub { color: var(--label-2); font-size: 14px; }
.index-bar { position: absolute; right: 2px; top: 210px; display: flex; flex-direction: column; font-size: 11px; font-weight: 600; color: var(--blue); gap: 1px; z-index: 3; }
.demo-tip { margin: 14px 16px 6px; padding: 12px 14px; border-radius: 14px; background: var(--fill); font-size: 13.5px; color: var(--label-2); line-height: 1.5; }
.demo-tip b { color: var(--label); }

/* contact detail */
.contact-head { display: flex; flex-direction: column; align-items: center; padding: 6px 16px 18px; text-align: center; }
.contact-head .nm { font-size: 28px; font-weight: 600; margin-top: 12px; line-height: 1.25; }
.contact-head .cat { color: var(--label-2); font-size: 15px; margin-top: 2px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 16px 18px; }
.action { background: var(--cell); border-radius: 12px; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--blue); font-size: 12px; }
.action svg { width: 22px; height: 22px; }
.action:disabled { opacity: 0.4; }
.action:not(:disabled):active { opacity: 0.6; }
.field { padding: 9px 16px; position: relative; display: block; width: 100%; text-align: left; }
.field + .field::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.field .k { font-size: 14px; color: var(--label); }
.field .v { font-size: 17px; color: var(--label); margin-top: 1px; line-height: 1.35; }
.field .v.link { color: var(--blue); }
.hint-list { padding: 10px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: 15px; display: flex; gap: 8px; align-items: flex-start; line-height: 1.4; }
.hint::before { content: '“'; color: var(--blue); font-weight: 700; }

/* recents */
.seg { display: flex; margin: 0 auto; background: var(--fill); border-radius: 9px; padding: 2px; width: 180px; }
.seg span { flex: 1; text-align: center; font-size: 13px; font-weight: 600; padding: 5px 0; border-radius: 7px; }
.seg span.on { background: var(--cell); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.recent .ico { width: 14px; color: var(--label-2); }
.info-btn { color: var(--blue); width: 24px; height: 24px; flex: none; }
.empty { color: var(--label-2); text-align: center; padding: 120px 30px; font-size: 17px; line-height: 1.5; }
.empty .big { font-size: 22px; font-weight: 600; color: var(--label); margin-bottom: 6px; }

/* keypad */
.keypad { display: flex; flex-direction: column; align-items: center; padding-top: 40px; }
.dial-number { height: 56px; font-size: 38px; font-weight: 400; letter-spacing: 1px; text-align: center; padding: 0 30px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.dial-name { height: 22px; color: var(--blue); font-size: 15px; margin-bottom: 18px; }
.keys { display: grid; grid-template-columns: repeat(3, 78px); gap: 14px 26px; }
.key { width: 78px; height: 78px; border-radius: 50%; background: var(--fill); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.key:active { background: var(--fill-2); }
.key b { font-size: 34px; font-weight: 400; }
.key small { font-size: 9.5px; font-weight: 700; letter-spacing: 2px; margin-top: 3px; color: var(--label); }
.dial-actions { display: grid; grid-template-columns: repeat(3, 78px); gap: 0 26px; margin-top: 14px; align-items: center; }
.dial-call { width: 78px; height: 78px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; }
.dial-call svg { width: 34px; height: 34px; }
.dial-del { color: var(--label-2); justify-self: center; }
.dial-del svg { width: 30px; height: 30px; }

/* ------------------------------------------------------------ in-call screen */
.call {
  position: absolute;
  inset: 0;
  z-index: 70;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  animation: callIn 0.45s cubic-bezier(0.2, 0.85, 0.25, 1);
  background: #1c1c1e;
}
.call.leaving { animation: callOut 0.45s ease forwards; }
@keyframes callIn { from { opacity: 0; transform: scale(1.06); } }
@keyframes callOut { to { opacity: 0; transform: scale(0.96); } }
.call .poster { position: absolute; inset: -40px; filter: blur(42px) saturate(140%); opacity: 0.9; z-index: -2; }
.call::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.55)); }
.call .who { margin-top: calc(var(--top) + 48px); text-align: center; padding: 0 24px; }
.call .status { font-size: 17px; opacity: 0.78; min-height: 24px; font-variant-numeric: tabular-nums; }
.call .name { font-size: 34px; line-height: 1.25; margin-top: 4px; font-weight: 400; }
.call .avatar.call-av { width: 84px; height: 84px; margin: 22px auto 0; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); transition: transform 0.3s; }
.call .avatar.call-av.talking { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.35); } 50% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); } }
.call .grid { margin-top: auto; margin-bottom: calc(var(--bottom) + 36px); display: grid; grid-template-columns: repeat(3, 80px); gap: 24px 30px; }
.cbtn-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.cbtn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.cbtn svg { width: 34px; height: 34px; }
.cbtn:active { transform: scale(0.95); }
.cbtn.on { background: #fff; color: #1c1c1e; }
.cbtn:disabled { opacity: 0.45; }
.cbtn.end { background: #ff3b30; }
.cbtn.end svg { width: 38px; height: 38px; transform: rotate(135deg); }
.call .keypad-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding-top: calc(var(--top) + 110px); background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(6px); }
.call .keypad-overlay .key { background: rgba(255, 255, 255, 0.2); color: #fff; }
.call .keypad-overlay .key small { color: #fff; }
.call .keypad-overlay .typed { font-size: 32px; height: 46px; margin-bottom: 16px; letter-spacing: 2px; }
.call .keypad-overlay .hide { margin-top: 22px; font-size: 17px; }

/* ------------------------------------------------------------ notification banner */
#banners { position: absolute; top: calc(var(--top) + 2px); left: 8px; right: 8px; z-index: 95; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
body.mobile #banners { top: calc(var(--top) + 6px); }
.banner {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 24px;
  background: var(--banner);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22);
  transform: translateY(-160%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.3s;
  cursor: pointer;
  text-align: left;
  color: var(--label);
}
.banner.show { transform: none; opacity: 1; }
.banner .app-ic { width: 38px; height: 38px; border-radius: 9px; flex: none; }
.banner .b-body { flex: 1; min-width: 0; }
.banner .b-top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.banner .b-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner .b-top span { color: var(--label-2); font-size: 13px; flex: none; }
.banner .b-text { font-size: 15px; line-height: 1.35; margin-top: 1px; }

/* app icons */
.app-ic { display: flex; align-items: center; justify-content: center; color: #fff; border-radius: 22.5%; }
.app-ic svg { width: 62%; height: 62%; }
.ic-phone { background: linear-gradient(180deg, #5ef777, #1fc93b); }
.ic-messages { background: linear-gradient(180deg, #5ef777, #1fc93b); }
.ic-mail { background: linear-gradient(180deg, #2bb8ff, #1a6bf5); }
.ic-settings { background: linear-gradient(180deg, #b5b5bb, #85858b); }
.ic-crm { background: linear-gradient(180deg, #8b7bff, #5136e0); }

/* ------------------------------------------------------------ home screen */
.home {
  position: absolute;
  inset: 0;
  padding: calc(var(--top) + 14px) 22px 0;
  color: #fff;
  background:
    radial-gradient(120% 70% at 0% 0%, #ff7a59 0%, transparent 55%),
    radial-gradient(120% 70% at 100% 30%, #7c3aed 0%, transparent 60%),
    radial-gradient(100% 70% at 30% 100%, #0ea5e9 0%, transparent 60%),
    #1e1b4b;
}
.home .widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 26px; }
.widget { border-radius: 22px; height: 158px; padding: 14px 16px; background: rgba(255, 255, 255, 0.18); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); display: flex; flex-direction: column; text-align: left; }
.widget .w-k { font-size: 13px; font-weight: 600; opacity: 0.85; }
.widget .w-big { font-size: 46px; font-weight: 300; letter-spacing: -1px; margin-top: auto; line-height: 1; font-variant-numeric: tabular-nums; }
.widget .w-sub { font-size: 13px; opacity: 0.85; margin-top: 6px; }
.widget .w-text { font-size: 14px; line-height: 1.4; margin-top: 6px; }
.widget .w-btn { margin-top: auto; align-self: flex-start; background: #fff; color: #312e81; font-size: 13px; font-weight: 600; border-radius: 99px; padding: 6px 12px; }
.home .apps { display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 22px; justify-items: center; }
.home-app { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); position: relative; width: 74px; }
.home-app .app-ic { width: 62px; height: 62px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18); }
.home-app:active .app-ic { filter: brightness(0.8); }
.badge { position: absolute; top: -6px; right: 0; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ff3b30; color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; text-shadow: none; }
.home .dots { position: absolute; left: 0; right: 0; bottom: calc(var(--bottom) + 112px); display: flex; justify-content: center; gap: 8px; }
.home .dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
.home .dots i:first-child { background: #fff; }
.dock { position: absolute; left: 12px; right: 12px; bottom: calc(var(--bottom) + 8px); height: 94px; border-radius: 34px; background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); display: flex; justify-content: space-around; align-items: center; padding: 0 8px; }
.dock .home-app span { display: none; }

/* ------------------------------------------------------------ messages */
.msg-row .avatar { width: 46px; height: 46px; font-size: 17px; }
.msg-row .top { display: flex; justify-content: space-between; gap: 8px; }
.msg-row .top b { font-weight: 600; }
.msg-row .top span { color: var(--label-2); font-size: 15px; flex: none; display: flex; gap: 6px; align-items: center; }
.msg-row .prev { color: var(--label-2); font-size: 15px; line-height: 1.35; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); flex: none; margin-left: -6px; }
.unread-dot.off { background: transparent; }
.thread-head { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.thread-head .avatar { width: 40px; height: 40px; font-size: 15px; }
/* Views with a bottom bar (SMS thread, mail message): the bar sticks to the screen bottom while content scrolls */
.view.has-bar { display: flex; flex-direction: column; }
.view.has-bar > * { flex-shrink: 0; }
.thread { padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.thread .when { text-align: center; color: var(--label-2); font-size: 11px; margin: 12px 0 6px; }
.thread .when b { font-weight: 600; }
.bubble { align-self: flex-start; max-width: 78%; background: var(--bubble-in); padding: 8px 13px; border-radius: 19px; font-size: 16.5px; line-height: 1.38; white-space: pre-wrap; word-break: break-word; animation: pop 0.3s ease; }
.bubble a { color: var(--blue); text-decoration: underline; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.compose { position: sticky; bottom: 0; margin-top: auto; z-index: 5; padding: 8px 12px calc(var(--bottom) + 2px); background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; gap: 8px; align-items: center; color: var(--label-2); font-size: 13px; justify-content: center; text-align: center; }

/* ------------------------------------------------------------ mail */
.mail-row .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mail-row .top b { font-weight: 600; font-size: 17px; }
.mail-row .top span { color: var(--label-2); font-size: 15px; flex: none; display: flex; gap: 6px; align-items: center; }
.mail-row .subj { font-size: 15px; margin-top: 1px; }
.mail-row .prev { color: var(--label-2); font-size: 15px; line-height: 1.35; margin-top: 1px; }
.mail-head { padding: 6px 16px 12px; display: flex; gap: 12px; align-items: flex-start; border-bottom: 0.5px solid var(--sep); }
.mail-head .avatar { width: 42px; height: 42px; font-size: 16px; }
.mail-head .from { font-weight: 600; font-size: 17px; }
.mail-head .to, .mail-head .date { color: var(--label-2); font-size: 14px; }
.mail-subject { font-size: 21px; font-weight: 700; padding: 12px 16px 4px; line-height: 1.35; }
.mail-body { padding: 10px 14px 20px; }
.email-card { border-radius: 14px; overflow: hidden; background: #fff; color: #1f2937; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 6px 20px rgba(0, 0, 0, 0.06); border: 1px solid rgba(0, 0, 0, 0.06); }
.email-card .brand { padding: 16px 18px; color: #fff; font-weight: 700; font-size: 19px; letter-spacing: 0.3px; display: flex; flex-direction: column; gap: 2px; }
.email-card .brand small { font-weight: 500; font-size: 11.5px; opacity: 0.8; letter-spacing: 0; }
.email-card .ec-body { padding: 16px 18px 18px; }
.email-card h3 { margin: 0 0 8px; font-size: 18px; }
.email-card p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: #374151; }
.email-card table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0 12px; }
.email-card td { padding: 8px 0; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.email-card td:first-child { color: #6b7280; width: 38%; padding-right: 10px; }
.email-card td:last-child { font-weight: 600; }
.email-card .qr { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0 14px; font-size: 12px; color: #6b7280; }
.email-card .qr svg { width: 132px; height: 132px; }
.email-card ul { margin: 0 0 8px; padding-left: 18px; font-size: 13.5px; color: #4b5563; line-height: 1.55; }
.email-card .foot { font-size: 12px; color: #9ca3af; border-top: 1px solid #eef0f3; padding-top: 10px; margin-top: 6px; }
.mail-toolbar { position: sticky; bottom: 0; margin-top: auto; z-index: 5; height: calc(48px + var(--bottom)); padding: 0 26px var(--bottom); display: flex; justify-content: space-between; align-items: center; color: var(--blue); background: var(--bar); backdrop-filter: blur(20px); border-top: 0.5px solid var(--sep); }
.mail-toolbar svg { width: 24px; height: 24px; }

/* ------------------------------------------------------------ settings */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.profile-card .avatar { width: 60px; height: 60px; font-size: 22px; }
.profile-card .nm { font-size: 20px; font-weight: 500; }
.profile-card .sub { font-size: 13px; color: var(--label-2); }
.input-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 44px; position: relative; }
.input-row + .input-row::before, .group > * + .input-row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.input-row label { width: 96px; flex: none; font-size: 17px; }
.input-row input { flex: 1; border: 0; outline: 0; background: none; font-size: 17px; text-align: right; color: var(--label-2); min-width: 0; padding: 10px 0; }
.input-row input:focus { color: var(--label); }
.input-row .lbl { flex: 1; font-size: 17px; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background 0.2s; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1.2); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.danger { color: var(--red); justify-content: center; }
.settings-ic { width: 29px; height: 29px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.settings-ic svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------ inspector (desktop) */
.inspector {
  width: 420px;
  height: min(868px, calc(100dvh - 40px));
  flex: none;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(20px);
  color: var(--panel-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13.5px;
}
.inspector.hidden { display: none; }
.insp-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--panel-line); }
.insp-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.insp-title h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: 0.2px; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); color: var(--panel-dim); white-space: nowrap; }
.chip.live { background: rgba(48, 209, 88, 0.18); color: #4ade80; }
.chip.ring { background: rgba(255, 159, 10, 0.18); color: #fbbf24; }
.insp-sub { color: var(--panel-dim); margin-top: 4px; font-size: 12.5px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.metric { background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 8px 9px; min-width: 0; }
.metric b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric.cost b { color: #fcd34d; }
.metric span { color: var(--panel-dim); font-size: 11.5px; }
.insp-log { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.ev { display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; animation: fadeIn 0.25s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }
.ev .t { color: var(--panel-dim); font-size: 11px; width: 38px; flex: none; text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums; }
.ev .tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; padding: 2px 7px; border-radius: 6px; flex: none; margin-top: 1px; }
.ev .txt { flex: 1; min-width: 0; word-break: break-word; }
.ev.user .txt { background: rgba(10, 132, 255, 0.16); padding: 6px 10px; border-radius: 12px; }
.ev.agent .txt { background: rgba(255, 255, 255, 0.08); padding: 6px 10px; border-radius: 12px; }
.ev.interim .txt { opacity: 0.6; font-style: italic; }
.tag.user { background: rgba(10, 132, 255, 0.25); color: #7cc0ff; }
.tag.agent { background: rgba(255, 255, 255, 0.14); color: #fff; }
.tag.tool { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; }
.tag.hold { background: rgba(255, 159, 10, 0.22); color: #fcd34d; }
.tag.clip { background: rgba(45, 212, 191, 0.2); color: #5eead4; }
.tag.lat { background: rgba(48, 209, 88, 0.2); color: #86efac; }
.tag.sys { background: rgba(255, 255, 255, 0.08); color: var(--panel-dim); }
.tag.err { background: rgba(255, 69, 58, 0.25); color: #fca5a5; }
.ev details summary { cursor: pointer; list-style: none; }
.ev details summary::-webkit-details-marker { display: none; }
.ev pre { margin: 6px 0 0; padding: 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.3); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; font-family: ui-monospace, Consolas, monospace; color: #d1d5db; }
.insp-empty { color: var(--panel-dim); line-height: 1.7; padding: 8px 4px; }
.insp-empty ol { padding-left: 18px; margin: 8px 0; }
.insp-empty b { color: var(--panel-text); }
.insp-records { border-top: 1px solid var(--panel-line); padding: 12px 16px; max-height: 34%; overflow-y: auto; }
.insp-records h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--panel-dim); margin: 0 0 8px; }
.rec { background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; animation: fadeIn 0.3s; }
.rec .rec-top { display: flex; justify-content: space-between; font-weight: 700; }
.rec .rec-top span { color: #4ade80; font-size: 12px; }
.rec .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 6px; font-size: 12.5px; }
.rec .kv span:nth-child(odd) { color: var(--panel-dim); }
.insp-foot { border-top: 1px solid var(--panel-line); padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; color: var(--panel-dim); font-size: 12.5px; }
.insp-foot a { color: #a5b4fc; text-decoration: none; font-weight: 600; }
.panel-toggle { position: fixed; right: 14px; bottom: 14px; z-index: 5; font-size: 12px; color: var(--panel-dim); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 99px; padding: 6px 12px; }
body.mobile .panel-toggle { display: none; }

@media (max-width: 980px) {
  .inspector { display: none; }
  .panel-toggle { display: none; }
}
