*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%}
body{background:#EDE7DB;font-family:Inter,system-ui,sans-serif;display:flex;justify-content:center}
.app{width:100%;max-width:430px;min-height:100dvh;background:#FAF6EE;display:flex;flex-direction:column;position:relative;box-shadow:0 0 60px rgba(25,21,18,.15)}
.main{display:flex;flex-direction:column;flex:1;height:100dvh;min-height:0}
.hidden{display:none !important}
.banner{position:fixed;top:0;left:0;right:0;z-index:40;background:#7A3B22;color:#F6F1E5;font:600 13px Inter;padding:12px 18px;text-align:center}
.side{display:none}
.hd{padding:20px 24px 6px;display:flex;justify-content:space-between;align-items:center}
.wordmark{font:600 23px Fraunces,serif;color:#1E2B22}
.avatar{width:36px;height:36px;border-radius:50%;background:#EAE2D2;display:flex;align-items:center;justify-content:center;font:600 13px Inter;color:#4A4234}
.view{flex:1;padding:8px 22px 20px;overflow-y:auto}
/* card preview */
.mycard{margin:8px 0 0;background:linear-gradient(150deg,#22402F,#16281D 70%);border-radius:26px;padding:26px 24px;color:#F4EEE1;box-shadow:0 18px 30px -14px rgba(22,40,29,.5)}
.mycard.has-cover{padding-top:0}
.mc-cover{height:110px;background-size:cover;background-position:center;margin:0 -24px 18px;border-radius:26px 26px 0 0}
.mc-id{display:flex;gap:14px;align-items:center}
.mc-idt{min-width:0;flex:1}
.mc-name{font:600 23px Fraunces,serif;letter-spacing:.01em;overflow-wrap:anywhere;line-height:1.2}
.mc-role{font:500 12.5px Inter;color:#C9D4C5;margin-top:5px;overflow-wrap:anywhere}
.mc-logo{width:52px;height:52px;border-radius:14px;background:#E8C96B;display:flex;align-items:center;justify-content:center;font:700 17px Fraunces,serif;color:#22402F;flex-shrink:0}
.mc-photo{width:64px;height:64px;border-radius:50%;object-fit:cover;flex-shrink:0;border:3px solid rgba(244,238,225,.92)}
.mc-fields{margin-top:20px;display:grid;gap:9px;font:500 12.5px Inter;color:#DDE5D8}
.mc-fields i{font-style:normal;display:block;overflow-wrap:anywhere}
.mc-fields b{color:#9DB29E;font-weight:600;font-size:10px;letter-spacing:.1em;text-transform:uppercase;display:block;margin-bottom:1px}
.qrwrap{margin:16px 0 0;background:#fff;border-radius:22px;padding:18px;display:flex;flex-direction:column;align-items:center;gap:10px;box-shadow:0 12px 24px -14px rgba(25,21,18,.25)}
.qrwrap img{width:180px;height:180px}
.qrwrap p{font:500 12px Inter;color:#7A7160;text-align:center}
.btnrow{margin:16px 0 0;display:grid;gap:10px}
.btn{background:#1E2B22;color:#F6F1E5;border:0;border-radius:16px;padding:15px;text-align:center;font:600 14.5px Inter;cursor:pointer}
.btn.alt{background:#fff;color:#1E2B22;box-shadow:inset 0 0 0 1.5px #DED5C2}
.empty{padding:60px 10px;text-align:center}
.empty-title{font:600 22px Fraunces,serif;color:#1E2B22}
.empty-sub{font:500 13.5px Inter;color:#8A8069;margin:10px 0 22px;line-height:1.5}
/* form */
.secttl{padding:16px 2px 8px;font:600 12px Inter;color:#8A8069;letter-spacing:.09em;text-transform:uppercase}
.frm{display:grid;gap:10px}
.fld{display:block;background:#fff;border:1.5px solid #E7DFCB;border-radius:14px;padding:10px 14px}
.fld b{display:block;font:600 10.5px Inter;color:#A2967D;letter-spacing:.08em;text-transform:uppercase;margin-bottom:3px}
.fld input{border:0;outline:0;width:100%;font:500 14px Inter;color:#241F16;background:transparent}
.fld input[type=file]{font:500 12px Inter;color:#4A4234}
.swatches{display:flex;gap:10px;padding:4px 2px}
.sw{width:34px;height:34px;border-radius:50%;box-shadow:inset 0 0 0 2px rgba(255,255,255,.55);cursor:pointer;border:0}
.sw.on{outline:2.5px solid #1E2B22;outline-offset:2px}
.upprev{display:flex;align-items:center;gap:12px;padding:2px 4px}
.upprev img{height:46px;border-radius:10px;object-fit:cover}
.upprev img.wide{height:40px;width:120px}
.uprm{border:0;background:transparent;color:#B0583A;font:600 12px Inter;cursor:pointer}
/* scan */
.seg{display:flex;background:#EFE8D8;border-radius:14px;padding:4px;margin-top:10px}
.seg button{flex:1;border:0;background:transparent;font:600 13px Inter;color:#6B6252;padding:9px;border-radius:11px;cursor:pointer}
.seg button.on{background:#1E2B22;color:#F4EEE1}
.camwrap{margin-top:14px;background:#22261F;border-radius:22px;min-height:300px;position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center}
.camwrap video{width:100%;display:block;border-radius:22px}
.camhint{padding:34px 24px;text-align:center;width:100%}
.camhint p{font:500 13px Inter;color:#B9B2A0;line-height:1.5;margin-bottom:16px}
.statusline{padding:12px 4px;font:500 12.5px Inter;color:#8A8069;min-height:20px}
.qrother{margin-top:14px;background:#fff;border:1.5px solid #E7DFCB;border-radius:16px;padding:16px 18px}
.qrother b{font:600 14px Inter;color:#1E2B22}
.qrother p{font:500 12.5px Inter;color:#6B6252;margin-top:6px;overflow-wrap:anywhere}
/* contacts */
.search{width:100%;margin:10px 0 0;background:#fff;border:1.5px solid #E7DFCB;border-radius:14px;padding:12px 15px;font:500 13.5px Inter;color:#241F16;outline:0}
.chips{display:flex;gap:8px;padding:12px 0 2px;flex-wrap:wrap}
.chip{font:600 11.5px Inter;color:#6B6252;background:#EFE8D8;padding:7px 13px;border-radius:999px;border:0;cursor:pointer}
.chip.on{background:#1E2B22;color:#F4EEE1}
.cnt{padding:4px 2px;font:500 11.5px Inter;color:#8A8069}
.conflicts{margin:14px 0 4px;background:#FDF3E4;border:1.5px solid #EBD9B4;border-radius:16px;padding:12px 14px}
.conflicts .secttl{padding:0 0 6px}
.confrow{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:8px 0;border-top:1px solid #EBD9B4}
.confrow b{font:600 13px Inter;color:#4A4234;display:block}
.confrow span{font:500 11.5px Inter;color:#8A8069;display:block}
.confrow .confv{margin-top:3px;color:#6B6252}
.confbtns{display:flex;gap:6px;flex-shrink:0}
.clist{padding:8px 0;display:grid;gap:8px}
.crow{background:#fff;border-radius:16px;padding:12px 14px;display:flex;gap:12px;align-items:center;box-shadow:0 6px 14px -8px rgba(25,21,18,.14)}
.av{width:42px;height:42px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font:700 14px Inter;color:#fff;flex-shrink:0}
.av.sm{width:30px;height:30px;font-size:11px;margin-right:8px;vertical-align:middle}
.crow .nm{font:600 14px Inter;color:#221D15}
.crow .co{font:500 11.5px Inter;color:#8A8069;margin-top:1px}
.crow .ts{margin-left:auto;text-align:right}
.crow .ts b{display:block;font:600 11px Inter;color:#4A4234}
.src{font:600 10px Inter;padding:3px 8px;border-radius:999px;margin-top:4px;display:inline-block;white-space:nowrap}
.s-scanned{background:#E3EBE0;color:#2F4A34}
.s-qr{background:#F3E7C8;color:#7A5B1E}
.s-manual{background:#E4E3F0;color:#4A4670}
.cdel{border:0;background:transparent;color:#C9BFA9;font-size:15px;cursor:pointer;padding:4px}
.csave{border:0;background:transparent;color:#6B7F6E;font-size:15px;cursor:pointer;padding:4px}
.cempty{text-align:center;font:500 13px Inter;color:#8A8069;padding:40px 10px}
.ctable{display:none}
.backup{margin-top:26px;background:#F3EDDF;border-radius:18px;padding:18px 20px}
.backup b{font:600 14px Inter;color:#1E2B22}
.backup p{font:500 12.5px Inter;color:#7A7160;line-height:1.55;margin-top:6px}
/* tabbar */
.tabbar{display:flex;justify-content:space-around;padding:12px 10px calc(14px + env(safe-area-inset-bottom,0px));background:#fff;border-top:1px solid #EFE8D9;flex-shrink:0}
.tab{border:0;background:transparent;font:600 11px Inter;color:#A79D8A;text-align:center;cursor:pointer;padding:2px 14px}
.tab.on{color:#1E2B22}
.tab .ic{display:block;font-size:15px;margin-bottom:3px}
/* sheet */
.sheetbg{position:fixed;inset:0;background:rgba(20,24,18,.45);display:flex;align-items:flex-end;justify-content:center;z-index:30}
.sheet{background:#FAF6EE;border-radius:26px 26px 0 0;width:100%;max-width:430px;padding:22px 22px 28px;max-height:88dvh;overflow-y:auto}
.sheet h4{font:600 17px Fraunces,serif;color:#1E2B22}
.scardimg{width:100%;max-height:130px;object-fit:contain;border-radius:12px;background:#EFE8D8;margin:6px 0;cursor:zoom-in}
.imgviewer{position:fixed;inset:0;z-index:60;background:#14120E;overflow:auto;touch-action:pan-x pan-y pinch-zoom;display:flex;align-items:flex-start;justify-content:center}
.imgviewer img{min-width:100%;width:auto;max-width:none}
.ivclose{position:fixed;top:14px;right:14px;z-index:61;background:#F6F1E5;color:#1E2B22;border:0;border-radius:999px;padding:10px 18px;font:600 13px Inter;cursor:pointer}
.fwarn{background:#FDF3E4;border:1px solid #EBD9B4;border-radius:10px;padding:8px 10px;font:500 12px Inter;color:#7A5B22;margin:6px 0}
.sheet .sub{font:500 11.5px Inter;color:#8A8069;margin:4px 0 14px}
/* ---------- desktop ---------- */
@media (min-width:900px){
  body{padding:28px 0}
  .app{max-width:1080px;flex-direction:row;border-radius:24px;min-height:calc(100dvh - 56px);overflow:hidden}
  .side{display:flex;flex-direction:column;gap:6px;width:230px;flex-shrink:0;background:#FBF8F1;border-right:1px solid #EDE5D3;padding:26px 18px}
  .side .wordmark{margin-bottom:20px;padding:0 10px}
  .nav{border:0;background:transparent;text-align:left;font:600 13.5px Inter;color:#6B6252;padding:11px 13px;border-radius:12px;cursor:pointer}
  .nav.on{background:#1E2B22;color:#F4EEE1}
  .side-foot{margin-top:auto;font:500 11.5px Inter;color:#A79D8A;padding:0 10px}
  .hd{display:none}
  .tabbar{display:none}
  .main{min-height:auto;height:auto}
  .view{padding:30px 38px}
  #cardMain{display:grid;grid-template-columns:minmax(320px,1fr) 280px;gap:26px;align-items:start}
  #cardMain .mycard{margin-top:0}
  #cardMain .qrsid{margin-top:0}
  #cardMain .qrwrap{margin-top:0}
  #cardEdit{max-width:560px}
  .clist{display:none}
  .ctable{display:table;width:100%;border-collapse:separate;border-spacing:0 8px;margin-top:8px}
  .ctable th{font:600 11px Inter;color:#A2967D;text-transform:uppercase;letter-spacing:.08em;text-align:left;padding:0 14px 2px}
  .ctable td{background:#fff;padding:12px 14px;font:500 13px Inter;color:#241F16}
  .ctable td:first-child{border-radius:12px 0 0 12px;font-weight:600}
  .ctable td:last-child{border-radius:0 12px 12px 0}
  .ctop{display:grid;grid-template-columns:1fr auto;gap:14px;align-items:center}
  .ctop .search{margin:0}
  .ctop .cnt{grid-column:1/-1}
  .camwrap{max-width:640px}
  #view-scan .btnrow,#view-scan .statusline,#view-scan .qrother,#view-scan .seg{max-width:640px}
  #view-contacts>.btnrow{display:flex;gap:12px;max-width:640px}
  .backup{max-width:640px}
  .conflicts{max-width:640px}
  .confrow{flex-direction:row;justify-content:space-between;align-items:center}
  .backup .btnrow{display:flex;gap:12px}
  .sheetbg{align-items:center}
  .sheet{border-radius:26px}
}
@media (min-width:900px){
  .ctable td:nth-child(5){white-space:nowrap}
  .ctable td:nth-child(1){white-space:nowrap}
}

/* sign-in */
.signin{max-width:340px;margin:14vh auto 0;padding:0 8px;text-align:center}
.si-logo{font:800 30px Fraunces,serif;color:#1E2B22;letter-spacing:-.5px}
.si-sub{color:#5A5346;font:500 13.5px/1.55 Inter;margin:12px 0 22px}
.si-status{min-height:20px;margin-top:12px;font:500 13px/1.5 Inter;color:#5A5346}
.si-status.err{color:#A33B2E}
.signin .frm{text-align:left}

/* signed-out: hide navigation; authed-only controls */
body.signedout .tabbar, body.signedout aside .nav, body.signedout .side-foot{display:none}
body.authed .authed-only{display:block}
