/* ===== Bottom sheet / modal ===== */
.overlay{
  position:absolute; inset:0; z-index:100;
  background:var(--overlay-scrim);
  display:flex; align-items:flex-end; justify-content:center;
  opacity:0; pointer-events:none;
  transition:opacity .25s;
}
.overlay.show{opacity:1; pointer-events:auto;}
.overlay.center{align-items:center;}
.sheet{
  width:100%; background:var(--sheet-bg);
  border-radius:20px 20px 0 0;
  padding:10px 16px calc(16px + env(safe-area-inset-bottom,0px));
  transform:translateY(100%);
  transition:transform .3s cubic-bezier(.32,.72,0,1);
  max-height:82%; overflow-y:auto;
}
.overlay.show .sheet{transform:translateY(0);}
.sheet-grabber{width:36px;height:5px;background:var(--text-faint);opacity:.4;border-radius:3px;margin:4px auto 12px;}
.sheet-title{font-size:16px;font-weight:700;text-align:center;margin-bottom:14px;color:var(--text-main);}
.card-modal{
  width:min(340px,88%); background:var(--card-bg); border-radius:16px; padding:18px;
  transform:scale(.9); opacity:0; transition:all .22s;
}
.overlay.show .card-modal{transform:scale(1); opacity:1;}

.attach-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:14px 6px; padding:4px 0 8px;}
.attach-item{display:flex;flex-direction:column;align-items:center;gap:6px;background:none;border:none;color:var(--text-main);font-size:12px;}
.attach-icon-circle{width:54px;height:54px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;}

.field-label{font-size:12.5px;color:var(--text-sub);margin:14px 0 6px;font-weight:600;text-transform:uppercase;letter-spacing:.3px;}
.field-label:first-child{margin-top:0;}
.text-field{
  width:100%; background:var(--composer-field); border:1px solid var(--input-border);
  border-radius:10px; padding:11px 12px; font-size:16px; color:var(--text-main); outline:none;
}
.text-field:focus{border-color:var(--accent);}
.select-field{
  width:100%; background:var(--composer-field); border:1px solid var(--input-border);
  border-radius:10px; padding:11px 12px; font-size:16px; color:var(--text-main); outline:none;
}
.btn-row{display:flex;gap:10px;margin-top:18px;}
.btn{
  flex:1; padding:12px; border-radius:10px; border:none; font-size:15.5px; font-weight:600;
  display:flex;align-items:center;justify-content:center;gap:6px;
}
.btn-primary{background:var(--accent); color:#fff;}
.btn-secondary{background:rgba(120,120,128,.16); color:var(--text-main);}
.btn-danger{background:none;color:var(--danger);}
.btn:active{opacity:.75;}
.btn-full{width:100%;}

.option-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:6px 0 4px;}
.option-tile{
  border:2px solid transparent; border-radius:12px; overflow:hidden; background:var(--composer-field);
  padding:0; position:relative;
}
.option-tile img{width:100%;height:80px;object-fit:cover;display:block;}
.option-tile.selected{border-color:var(--accent);}
.option-tile .ot-check{position:absolute;top:6px;right:6px;width:20px;height:20px;border-radius:50%;background:var(--accent);color:#fff;display:none;align-items:center;justify-content:center;}
.option-tile.selected .ot-check{display:flex;}

.context-menu{
  position:absolute; background:var(--card-bg); border-radius:13px; overflow:hidden;
  box-shadow:0 8px 30px rgba(0,0,0,.35); min-width:180px; z-index:110;
}
.context-menu-item{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:12px 16px; font-size:15.5px; color:var(--text-main); border-bottom:.5px solid var(--divider);
}
.context-menu-item:last-child{border-bottom:none;}
.context-menu-item.danger{color:var(--danger);}

.status-radio-row{display:flex;align-items:center;justify-content:space-between;padding:11px 2px;border-bottom:.5px solid var(--divider);}
.status-radio-row:last-child{border-bottom:none;}
.radio-dot{width:20px;height:20px;border-radius:50%;border:2px solid var(--input-border);display:flex;align-items:center;justify-content:center;}
.radio-dot.checked{border-color:var(--accent);}
.radio-dot.checked::after{content:"";width:11px;height:11px;border-radius:50%;background:var(--accent);}

/* ===== Settings / list screens ===== */
.settings-group{margin:20px 0 0;}
.settings-group-label{font-size:12.5px;color:var(--text-sub);padding:0 16px 6px;text-transform:uppercase;letter-spacing:.3px;}
.settings-card{background:var(--card-bg); margin:0 16px; border-radius:10px; overflow:hidden;}
.settings-item{
  display:flex;align-items:center;gap:12px;padding:12px 14px;min-height:46px;
  border-bottom:.5px solid var(--divider);
}
.settings-item:last-child{border-bottom:none;}
.settings-item .si-label{flex:1;font-size:16px;color:var(--text-main);}
.settings-item .si-sub{font-size:13px;color:var(--text-sub);}
.settings-item .si-icon{width:29px;height:29px;border-radius:7px;display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0;}
.chevron{color:var(--text-faint);}

.switch{position:relative; width:51px;height:31px;border-radius:16px; background:var(--input-border); flex-shrink:0;}
.switch.on{background:var(--wa-green);}
.switch-knob{position:absolute; top:2px;left:2px; width:27px;height:27px;border-radius:50%;background:#fff; box-shadow:0 2px 4px rgba(0,0,0,.25); transition:left .18s;}
.switch.on .switch-knob{left:22px;}

.profile-header{display:flex;flex-direction:column;align-items:center;padding:22px 16px 10px;gap:10px;}
.avatar-edit-wrap{position:relative;}
.avatar-edit-badge{position:absolute;bottom:2px;right:2px;width:28px;height:28px;border-radius:50%;background:var(--accent);border:2px solid var(--card-bg);display:flex;align-items:center;justify-content:center;color:#fff;}

/* select member rows */
.member-row{display:flex;align-items:center;gap:12px;padding:9px 16px;}
.member-row .mr-check{width:24px;height:24px;border-radius:50%;border:2px solid var(--input-border);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.member-row .mr-check.checked{background:var(--accent);border-color:var(--accent);color:#fff;}
.section-index-letter{padding:4px 16px;font-size:13px;font-weight:700;color:var(--accent);}

/* Story */
.story-ring{padding:2px;border-radius:50%;background:#ccc;}
.story-ring.unseen{background:linear-gradient(135deg,#25D366,#128c7e);}
.story-ring.seen{background:#8696a0; opacity:.5;}
.story-ring.me{background:none;}
.updates-add-badge{position:absolute; bottom:-2px; right:-2px; width:20px;height:20px;border-radius:50%;background:var(--wa-green);border:2px solid var(--bg-app);display:flex;align-items:center;justify-content:center;color:#fff;}

#story-viewer{position:absolute;inset:0;background:#000;z-index:200;display:none;flex-direction:column;}
#story-viewer.show{display:flex;}
.story-progress-wrap{display:flex;gap:4px;padding:8px 8px 0;padding-top:calc(8px + 47px);}
.story-progress-seg{flex:1;height:2.5px;background:rgba(255,255,255,.35);border-radius:2px;overflow:hidden;}
.story-progress-fill{height:100%;width:0%;background:#fff;}
.story-progress-fill.done{width:100%!important;transition:none;}
.story-progress-fill.animating{transition:width linear;}
.story-header{display:flex;align-items:center;gap:10px;padding:10px 14px;color:#fff;}
.story-header .sh-name{font-weight:600;font-size:14.5px;}
.story-header .sh-time{font-size:13px;opacity:.75;}
.story-media-wrap{flex:1;display:flex;align-items:center;justify-content:center;position:relative;overflow:hidden;}
.story-media-wrap img{max-width:100%;max-height:100%;object-fit:contain;}
.story-tap-zone{position:absolute;top:0;bottom:0;width:35%;z-index:5;}
.story-caption{position:absolute;bottom:30px;left:0;right:0;text-align:center;color:#fff;font-size:15px;padding:0 20px;text-shadow:0 1px 4px rgba(0,0,0,.6);}

.toast{
  position:absolute; top:60px; left:50%; transform:translateX(-50%) translateY(-10px);
  background:rgba(30,30,30,.92); color:#fff; padding:9px 16px; border-radius:10px; font-size:14px;
  opacity:0; pointer-events:none; transition:all .25s; z-index:300; white-space:nowrap;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

.hidden{display:none!important;}
::-webkit-scrollbar{display:none;}

.color-swatch-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:10px;margin:8px 0;}
.color-swatch{aspect-ratio:1;border-radius:12px;border:2px solid transparent;position:relative;}
.color-swatch.selected{border-color:var(--accent);}
.color-swatch.selected::after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;text-shadow:0 1px 3px rgba(0,0,0,.4);}

/* ===== Yappy refinement pass ===== */
button{cursor:pointer;}
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid color-mix(in srgb,var(--link) 72%, transparent);outline-offset:2px;}
.chat-header-info .avatar{width:38px;height:38px;font-size:14px;}
.chat-header-info .avatar svg{width:20px;height:20px;}
.msg-row .group-sender-avatar{width:27px;height:27px;margin-right:8px;align-self:flex-end;flex-shrink:0;margin-bottom:2px;}
.msg-row .group-sender-avatar>.avatar{width:27px;height:27px;font-size:10px;}
.bubble-meta-inline{transform:translateY(6px);line-height:1;}
.bubble{padding-bottom:7px;}
.sender-chip-wrap{display:none!important;}
.composer-icon-btn,.send-btn{min-width:44px;min-height:44px;}
.nav-btn{min-width:44px;min-height:44px;}
.attach-item{min-height:84px;border-radius:14px;}
.attach-item:active{background:rgba(120,120,128,.12);}
.attach-sender-row{display:flex;align-items:center;gap:10px;padding:8px 4px 14px;margin-bottom:8px;border-bottom:.5px solid var(--divider);}
.attach-sender-row .attach-sender-copy{flex:1;min-width:0;}
.attach-sender-row strong{display:block;font-size:14px;}
.attach-sender-row span{display:block;font-size:12px;color:var(--text-sub);margin-top:1px;}
.profile-name-edit{background:none;border:0;color:var(--text-main);font-size:20px;font-weight:700;padding:6px 12px;border-radius:10px;}
.profile-name-edit:active{background:rgba(120,120,128,.12);}
.map-caption{display:block;font-size:11px;padding:6px 4px;color:var(--text-sub);text-align:center;}
.option-tile.map-option img{height:92px;}
.pending-clock{display:inline-flex;color:var(--bubble-meta);margin-left:3px;}
.pending-clock svg{width:12px;height:12px;}
:root[data-theme="dark"] .navbar,:root[data-theme="dark"] #tabbar,:root[data-theme="dark"] .composer{box-shadow:none;}
:root[data-theme="dark"] .searchbar{background:#1c1c1e;}
:root[data-theme="dark"] .settings-card{background:#1c1c1e;}
:root[data-theme="dark"] .sheet{background:#1c1c1e;}
:root[data-theme="dark"] .card-modal{background:#2c2c2e;}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}
