/* ============================================================
   COMPONENTS - Reusable UI components
   ============================================================ */

/* Buttons */
.btn-ico {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label2);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.btn-ico:hover { background: var(--fill2); color: var(--label); }
.btn-ico:active { background: var(--fill2); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: background var(--transition-fast);
}
.btn-primary:hover { background: #0062cc; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--fill);
  color: var(--label);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: background var(--transition-fast);
}
.btn-secondary:hover { background: var(--fill2); }

.btn-ghost {
  background: transparent;
  color: var(--tint);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background var(--transition-fast);
}
.btn-ghost:hover { background: var(--fill); }

/* Avatar */
.av {
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  background-size: cover;
  background-position: center;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.av.sq { border-radius: 38%; }
.av.av-default,
.n-avatar.av-default {
  --avd-top: #a9acb9;
  --avd-bot: #868a9b;
  background: linear-gradient(180deg, var(--avd-top), var(--avd-bot));
}
.av-default > svg {
  display: block;
  width: 100%;
  height: 100%;
}
@media (prefers-color-scheme: dark) {
  .av.av-default,
  .n-avatar.av-default {
    --avd-top: #555266;
    --avd-bot: #2e264b;
  }
}
.av.grp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  place-items: stretch;
  gap: 1.5px;
  padding: 0;
  background: var(--bg);
}
.av.grp i { display: block; }

/* Icons */
.ico {
  width: 62px;
  height: 62px;
  border-radius: 14.5px;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}
.ico svg { width: 100%; height: 100%; }

.ico-label {
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.cal-ico {
  background: #fff;
  color: #000;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.cal-ico em { font-style: normal; color: #ff3b30; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-top: -2px; }
.cal-ico b { font-size: 31px; font-weight: 300; line-height: 1; }

/* Badge */
.badge {
  position: absolute;
  top: -6px;
  right: 0;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: grid;
  place-items: center;
  padding: 0 7px;
  z-index: 2;
  animation: pop 0.35s;
}
.app-ico .badge {
  /* Sit on the icon's top-right corner, overlapping it (iOS style).
     .app-ico is position: relative with no overflow clipping, so the
     badge can extend past the icon corner without being cut off. */
  position: absolute;
  top: -9px;
  right: -8px;
}

/* Navigation Bar */
.nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  padding-top: 50px;
  transition: background var(--transition-fast);
  border-bottom: 0.5px solid transparent;
}
.nav.scrolled, .nav.solid {
  background: var(--bar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom-color: var(--sep);
}

.nav-row {
  height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 8px;
}

.nav-l { display: flex; justify-content: flex-start; min-width: 0; }
.nav-r { display: flex; justify-content: flex-end; gap: 16px; padding-right: 8px; color: var(--tint); align-items: center; }
.nav-t {
  font-size: 17px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
  text-align: center;
  max-width: 210px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav.scrolled .nav-t, .nav.solid .nav-t { opacity: 1; }

.back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--tint);
  font-size: 17px;
  height: 44px;
  padding: 0 6px;
  white-space: nowrap;
}
.back svg { width: 12px; height: 21px; }

.icon-btn {
  color: var(--tint);
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 44px;
}
.icon-btn svg { width: 23px; height: 23px; }

/* Scroll Area */
.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 94px;
  padding-bottom: 40px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }

.has-tabs .scroll { padding-bottom: 110px; }

/* Large Title */
.large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  padding: 0 16px;
  line-height: 1.15;
}

/* Search Bar */
.search {
  margin: 0 16px 12px;
  height: 36px;
  border-radius: 10px;
  background: var(--fill);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--label2);
  font-size: 17px;
}
.search svg { width: 16px; height: 16px; }

/* Section Header */
.section-h {
  font-size: 13px;
  color: var(--label2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 18px 32px 6px;
}

/* Group / List */
.group { margin: 0 16px; background: var(--cell); border-radius: 12px; overflow: hidden; }
.view.grouped, .view.grouped .scroll { background: var(--bg2); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 0 0 0 16px;
  position: relative;
  min-height: 44px;
}
.row:active { background: var(--fill); }

.row-main { flex: 1; min-width: 0; padding: 10px 16px 10px 0; border-bottom: 0.5px solid var(--sep); align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.row:last-child .row-main { border-bottom: 0; }

.row-top { display: flex; align-items: baseline; gap: 6px; }
.row-top b { font-weight: 600; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { color: var(--label2); font-size: 15px; white-space: nowrap; }
.row-sub { color: var(--label2); font-size: 15px; line-height: 1.3; }

.two { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.chev { width: 8px; height: 13px; color: var(--label3); flex: none; }

.unread { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); flex: none; margin-left: -6px; margin-right: -4px; }
.unread.off { background: transparent; }

/* Switch Toggle */
.switch { width: 51px; height: 31px; border-radius: 16px; background: var(--fill2); position: relative; flex: none; transition: background 0.25s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.25s cubic-bezier(0.3, 0.8, 0.3, 1); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(20px); }

/* Tab Bar */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 84px;
  display: flex;
  justify-content: space-around;
  padding: 6px 6px 0;
  background: var(--bar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--sep);
  z-index: 7;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--label2); width: 70px; position: relative; }
.tab svg { width: 27px; height: 27px; }
.tab.on { color: var(--tint); }
.tab .tb { position: absolute; top: -3px; left: 44px; background: #ff3b30; color: #fff; font-size: 11px; font-weight: 600; border-radius: 9px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; }

.tab-host { position: absolute; inset: 0; }

/* Segmented Control */
.seg { display: flex; margin: 0 auto; background: var(--fill); border-radius: 9px; padding: 2px; width: 190px; }
.seg button { flex: 1; font-size: 13px; font-weight: 500; height: 28px; border-radius: 7px; }
.seg button.on { background: var(--cell); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); font-weight: 600; }

/* Call Direction */
.call-dir { width: 16px; color: var(--label2); flex: none; margin-left: -4px; }
.call-dir svg { width: 14px; height: 14px; }

/* Missed Call */
.missed b { color: var(--red); }

/* Info Button */
.info { color: var(--tint); width: 24px; height: 24px; flex: none; }

/* Dial Number Display */
.dial-num { height: 56px; font-size: 36px; font-weight: 400; letter-spacing: 0.02em; margin-bottom: 24px; text-align: center; font-variant-numeric: tabular-nums; }

/* Green Call Button */
.green-call { width: 78px; height: 78px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin-top: 18px; }
.green-call svg { width: 34px; height: 34px; }

/* Voicemail */
.vm { display: block; width: 100%; text-align: left; }
.vm-detail { padding: 4px 16px 14px 16px; }
.vm-bar { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.vm-bar button { width: 30px; height: 30px; border-radius: 50%; background: var(--tint); color: #fff; display: grid; place-items: center; }
.vm-bar button svg { width: 12px; height: 12px; }
.prog { flex: 1; height: 4px; border-radius: 2px; background: var(--fill2); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--label2); }
.vm-text { font-size: 15px; line-height: 1.4; }
.vm-text .lbl { display: block; font-size: 12px; color: var(--label2); margin-bottom: 3px; }

/* Contact Card */
.contact-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 16px 18px; }
.contact-card h2 { margin: 4px 0 0; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.cc-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin-top: 8px; }
.cc-actions button { background: var(--cell); border-radius: 12px; padding: 9px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--tint); font-size: 11.5px; }
.cc-actions svg { width: 22px; height: 22px; }

/* Field Row */
.field-row { padding: 10px 16px; border-bottom: 0.5px solid var(--sep); }
.field-row:last-child { border-bottom: 0; }
.field-row small { display: block; font-size: 13px; color: var(--label); }
.field-row span { color: var(--tint); font-size: 17px; }

/* Empty State */
.empty { padding: 16px; color: var(--label2); font-size: 15px; text-align: center; }

/* Chips */
.chip { align-self: flex-start; text-align: left; font-size: 15px; padding: 9px 14px; border-radius: 18px; border: 1.5px solid var(--kn-accent); color: var(--kn-accent); background: transparent; line-height: 1.3; max-width: 100%; animation: bubIn 0.35s both; }
.chip:active { background: var(--kn-accent); color: #fff; }

/* Chip variants */
.chip.chip-pl { border-color: #ff6b81; color: #e0284a; }

/* Playlist bubble in chat */
.tbub.pl { display: flex; flex-direction: column; padding: 0; overflow: hidden; width: 220px; text-align: left; background: #1c1c22 !important; color: #fff !important; border-radius: 18px; }
.pl-cv { display: block; width: 100%; aspect-ratio: 1/1; background-size: cover; background-position: center; }
.pl-t { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.pl-t small { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #ff6b81; }
.pl-t small svg { width: 12px; height: 12px; }
.pl-t b { font-size: 17px; font-weight: 700; }
.pl-t span { font-size: 13px; opacity: 0.7; }
.pl-t em { font-style: normal; font-size: 13px; font-weight: 600; color: #ff6b81; margin-top: 6px; }

/* Message Links */
.tlink { display: inline-flex; align-items: center; gap: 7px; margin-top: 5px; padding: 5px 11px 5px 5px; border-radius: 14px; background: var(--fill, #efeff4); color: var(--label); font-size: 13px; font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); align-self: flex-start; }
.tm.me .tlink { align-self: flex-end; }
.tlink .tl-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 12px; overflow: hidden; }
.tlink .tl-ico svg { width: 14px; height: 14px; }
.b-row.lk { margin: 2px 0 8px; }
.b-row.lk.me { justify-content: flex-end; }

/* Headers & Footers */
.bt-h { padding: 22px 32px 7px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--label2, #8e8e93); }
.bt-foot { padding: 8px 32px; font-size: 13px; line-height: 1.35; color: var(--label2, #8e8e93); }

/* Deleted message */
.tbub.del { background: transparent !important; color: var(--label2, #8e8e93) !important; border: 1px dashed var(--sep, #c6c6c8); font-style: italic; }
.tbub.del svg { width: 13px; height: 13px; vertical-align: -2px; }

/* Language list */
.lang-list .saved { font-style: normal; font-size: 11px; opacity: 0.7; margin-left: auto; margin-right: 8px; }
.restart-all { margin-top: 6px; font-size: 14px; color: rgba(255, 255, 255, 0.85); padding: 8px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.12); }
.set-ico { font-weight: 700; color: #fff; }

/* Round buttons */
.round { width: 50px; height: 50px; border-radius: 50%; background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: grid; place-items: center; color: #fff; transition: background 0.2s, color 0.2s; }
.round svg { width: 22px; height: 22px; }
.round.on { background: #fff; color: #000; }

/* Swipe hint */
.swipe-hint { font-size: 14px; font-weight: 500; opacity: 0.8; animation: hint 2.4s ease-in-out infinite; }

/* Passcode */
#pass { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; opacity: 0; transform: translateY(40px); pointer-events: none; transition: opacity 420ms cubic-bezier(0.2, 0.9, 0.25, 1), transform 420ms cubic-bezier(0.2, 0.9, 0.25, 1); z-index: 10; }
.phone[data-ctx="pass"] #pass { opacity: 1; transform: translateY(0); pointer-events: auto; }
.pass-title { margin-top: 118px; font-size: 20px; font-weight: 500; }
.dots { display: flex; gap: 22px; margin-top: 22px; height: 14px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.4px solid #fff; transition: background 0.12s; }
.dots i.on { background: #fff; }
.dots.shake { animation: shake 0.45s; }
.pass-hint { margin-top: 16px; font-size: 13.5px; opacity: 0.85; max-width: 260px; text-align: center; line-height: 1.35; min-height: 36px; }
.keypad { display: grid; grid-template-columns: repeat(3, 80px); gap: 15px 26px; margin-top: 22px; }
.key { width: 80px; height: 80px; border-radius: 50%; background: rgba(255, 255, 255, 0.17); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; transition: background 0.25s; }
.key:active { background: rgba(255, 255, 255, 0.55); transition: none; }
.key b { font-size: 36px; font-weight: 400; line-height: 1; }
.key small { font-size: 10px; font-weight: 600; letter-spacing: 0.18em; margin-top: 2px; }
.key.zero { grid-column: 2; }
.pass-foot { margin-top: auto; width: 100%; display: flex; justify-content: space-between; padding: 0 50px 52px; font-size: 16px; }

/* Home screen widgets */
#home { opacity: 0; pointer-events: none; transform: scale(1.12); transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.35s; position: absolute; inset: 0; transform-origin: 50% 0; }
.phone[data-ctx="home"] #home, .phone[data-ctx="app"] #home { opacity: 1; pointer-events: auto; transform: none; }
.phone[data-ctx="app"] #home { transform: scale(0.94); transition-duration: 0.45s; }

.widgets { position: absolute; top: clamp(44px, 7vh, 66px); left: 26px; right: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.widget { height: clamp(130px, 18vh, 160px); width: 100%; border-radius: 22px; padding: 14px 15px; text-align: left; display: flex; flex-direction: column; color: #fff; }
.w-weather { background: linear-gradient(180deg, #3174d3, #7fb8f2); padding-top: 12px; padding-bottom: 12px; }
.w-weather.night { background: linear-gradient(180deg, #0d1433, #34467d); }
.w-weather .city { font-size: 15px; font-weight: 600; display: flex; gap: 4px; align-items: center; }
.w-weather .city svg { width: 11px; height: 11px; }
.w-weather .deg { font-size: 44px; font-weight: 300; line-height: 1.05; }
.w-weather .cond { margin-top: auto; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.w-weather .wx-wico { width: 16px; height: 16px; flex: none; }
.w-weather .hl { display: block; text-align: left; font-size: 13px; opacity: 0.85; }
.w-cal { background: #fff; color: #000; }
.w-cal .wd { color: #ff3b30; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.w-cal .dn { font-size: 34px; font-weight: 400; line-height: 1; }
.w-cal .wev { margin-top: auto; border-left: 3px solid #af52de; padding-left: 7px; font-size: 12.5px; line-height: 1.25; }
.w-cal .wev b { display: block; font-weight: 600; }
.w-cal .wev span { color: #8e8e93; }
.w-label { display: block; font-size: 12px; text-align: center; margin-top: 4px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }

.grid { position: absolute; top: clamp(210px, 28vh, 270px); left: 16px; right: 16px; display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 22px; justify-items: center; }
.app-ico { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; transition: transform 0.15s; position: relative; }
.app-ico:active { transform: scale(0.9); }

.spot { position: absolute; bottom: clamp(115px, 15vh, 130px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; padding: 6px 13px; border-radius: 16px; background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); font-size: 13px; font-weight: 500; }
.spot svg { width: 13px; height: 13px; }

.dock { position: absolute; bottom: clamp(12px, 3vh, 20px); left: 12px; right: 12px; height: 94px; border-radius: 34px; background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(30px) saturate(150%); -webkit-backdrop-filter: blur(30px) saturate(150%); display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; justify-items: center; padding: 0 6px; }
.dock .ico-label { display: none; }

/* Apps container */
#apps { z-index: 40; overflow: hidden; background: var(--bg); color: var(--label); }
#apps.open { animation: appIn 0.46s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
#apps.closing { animation: appOut 0.32s cubic-bezier(0.4, 0, 0.8, 0.4) both; }
@keyframes appIn { from { transform: scale(0.13); opacity: 0; border-radius: 60px; } to { transform: none; opacity: 1; border-radius: 0; } }
@keyframes appOut { to { transform: scale(0.13); opacity: 0; border-radius: 60px; } }

/* View */
.view { position: absolute; inset: 0; z-index: 0; background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
.view.push-in { animation: pushIn 0.42s cubic-bezier(0.2, 0.9, 0.25, 1) both; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12); }
.view.push-under { animation: pushUnder 0.42s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
.view.pop-out { animation: popOut 0.34s cubic-bezier(0.3, 0.7, 0.3, 1) both; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12); }
.view.pop-reveal { animation: popReveal 0.34s cubic-bezier(0.3, 0.7, 0.3, 1) both; }
.view.sheet-in { animation: sheetIn 0.45s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
.view.sheet-out { animation: sheetOut 0.32s ease-in both; }
@keyframes pushIn { from { transform: translateX(100%); } }
@keyframes pushUnder { to { transform: translateX(-28%); filter: brightness(0.92); } }
@keyframes popOut { to { transform: translateX(100%); } }
@keyframes popReveal { from { transform: translateX(-28%); } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }