/* ============================================================
   Exif Inspector — styles
   Mobile-first PWA. Dark by default, light via prefers-color-scheme.
   ============================================================ */

:root {
  --bg:        #0f1020;
  --bg-2:      #171933;
  --surface:   #1c1f3d;
  --surface-2: #242850;
  --line:      #2f3363;
  --text:      #eef0ff;
  --text-dim:  #a6abd6;
  --text-mute: #6f76a8;
  --brand:     #a78bfa;
  --brand-2:   #f472b6;
  --accent:    #7c3aed;
  --good:      #34d399;
  --grad:      linear-gradient(135deg, #6d28d9 0%, #7c3aed 45%, #db2777 100%);
  --shadow:    0 10px 40px rgba(0,0,0,.45);
  --radius:    20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f4f2fb;
    --bg-2:      #ffffff;
    --surface:   #ffffff;
    --surface-2: #f2eefc;
    --line:      #e6e0f4;
    --text:      #1a1533;
    --text-dim:  #5b5578;
    --text-mute: #938db3;
    --brand:     #7c3aed;
    --brand-2:   #db2777;
    --accent:    #7c3aed;
    --shadow:    0 10px 40px rgba(80,40,160,.16);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

/* The [hidden] attribute must always win over a class's display value
   (author rules otherwise beat the UA [hidden]{display:none}). */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Soft aurora backdrop */
body::before {
  content: "";
  position: fixed;
  inset: -30% -30% auto -30%;
  height: 70vh;
  background:
    radial-gradient(60% 55% at 25% 20%, rgba(124,58,237,.38), transparent 70%),
    radial-gradient(55% 50% at 85% 10%, rgba(219,39,119,.30), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--safe-b) + 32px);
  min-height: 100dvh;
}

/* ---------------- top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 4px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { border-radius: 8px; box-shadow: 0 3px 12px rgba(124,58,237,.4); }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 1.05rem; }
.icon-ghost {
  display: grid; place-items: center;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-dim); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-ghost:hover { background: var(--surface); color: var(--text); }

/* ---------------- stage ---------------- */
.stage { padding-top: 10px; }

/* ---------------- intro ---------------- */
.intro { text-align: center; padding: 4vh 6px 0; animation: rise .5s ease both; }
.intro-art {
  position: relative; width: 150px; height: 150px; margin: 0 auto 26px;
  display: grid; place-items: center;
}
.intro-icon {
  width: 104px; height: 104px; border-radius: 30px;
  display: grid; place-items: center; color: #fff;
  background: var(--grad);
  box-shadow: 0 12px 34px rgba(124,58,237,.5);
  position: relative; z-index: 2;
}
.ripple {
  position: absolute; inset: 0; margin: auto; border-radius: 40px;
  border: 2px solid var(--brand); opacity: 0;
  animation: ripple 3s ease-out infinite;
}
.ripple.r1 { width: 104px; height: 104px; }
.ripple.r2 { width: 104px; height: 104px; animation-delay: 1s; }
.ripple.r3 { width: 104px; height: 104px; animation-delay: 2s; }
@keyframes ripple {
  0%   { transform: scale(1);   opacity: .5; }
  100% { transform: scale(2.1); opacity: 0; }
}

.intro-title { font-size: 1.9rem; line-height: 1.12; font-weight: 850; letter-spacing: -.03em; margin: 0 0 12px; }
.intro-sub { color: var(--text-dim); font-size: 1rem; line-height: 1.5; max-width: 30rem; margin: 0 auto 26px; }

.cta-row { display: flex; flex-direction: column; gap: 12px; max-width: 22rem; margin: 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 16px; padding: 15px 22px;
  font-size: 1.02rem; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s, background .2s, border-color .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary { color: #fff; background: var(--grad); box-shadow: 0 8px 24px rgba(124,58,237,.45); }
.btn-primary:hover { box-shadow: 0 10px 30px rgba(124,58,237,.6); }
.btn-ghost {
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn.full { width: 100%; margin-top: 8px; }

.privacy-note {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text-mute); font-size: .84rem; margin-top: 22px;
}
.privacy-note svg { color: var(--good); }

/* ---------------- result ---------------- */
.result { animation: rise .45s ease both; }

.preview-wrap {
  position: relative; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--surface);
  margin-bottom: 18px;
}
.preview {
  display: block; width: 100%; max-height: 46vh; object-fit: cover;
  background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 24px 24px;
}
.fab-new {
  position: absolute; right: 14px; bottom: 14px;
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: var(--grad); color: #fff; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(124,58,237,.55);
  transition: transform .12s;
}
.fab-new:active { transform: scale(.9) rotate(90deg); }

/* ---------------- identity fingerprint ---------------- */
.fp { margin-bottom: 14px; }
.fp-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 16px 16px 6px;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(124,58,237,.35), transparent 60%),
    radial-gradient(120% 100% at 100% 0%, rgba(219,39,119,.30), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  animation: rise .45s ease both;
}
.fp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.fp-ico {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; color: #fff; background: var(--grad);
}
.fp-label { font-weight: 750; font-size: 1.02rem; }
.fp-note { color: var(--text-mute); font-size: .76rem; margin-top: 1px; }

.fp-phrase {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.28rem; font-weight: 800; letter-spacing: -.01em;
  line-height: 1.25; word-break: break-word;
  color: transparent; background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.fp-hex {
  font-family: ui-monospace, Menlo, monospace; font-size: .72rem;
  color: var(--text-mute); word-break: break-all; margin-top: 6px; line-height: 1.4;
}

.fp-meter { margin: 14px 0 4px; }
.fp-meter-bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.fp-meter-bar span {
  display: block; height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, #34d399, #fbbf24, #f472b6);
  transition: width .7s cubic-bezier(.2,.8,.2,1);
}
.fp-meter-label { font-size: .78rem; color: var(--text-dim); margin-top: 7px; font-weight: 600; }

.fp-caveat { font-size: .8rem; color: var(--text-dim); line-height: 1.45; margin-top: 10px; }

.fp-groups { margin-top: 6px; }
.fp-group { padding: 12px 0; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.fp-group-name {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--brand); font-weight: 750; margin-bottom: 8px;
}
.fp-photo .fp-group-name { color: var(--good); }
.fp-device .fp-group-name { color: var(--brand-2); }
.fp-excluded .fp-group-name { color: var(--text-mute); }
.fp-viewer .fp-group-name { color: var(--brand-2); }
.fp-excluded-note { font-size: .78rem; color: var(--text-mute); line-height: 1.45; }
.fp-empty { font-size: .82rem; color: var(--text-mute); }
.fp-row { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; align-items: baseline; }
.fp-row .fk { color: var(--text-dim); font-size: .82rem; flex: none; max-width: 42%; }
.fp-row .fv { color: var(--text); font-size: .82rem; font-weight: 600; text-align: right; word-break: break-word; }
.fp-row .fv.mono { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; }

.fp-details { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.fp-details summary {
  cursor: pointer; padding: 12px 0 4px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--brand-2); font-weight: 750; list-style: none;
}
.fp-details summary::-webkit-details-marker { display: none; }
.fp-details summary::before { content: '▸ '; }
.fp-details[open] summary::before { content: '▾ '; }
.fp-details summary em { text-transform: none; letter-spacing: 0; color: var(--text-mute); font-style: italic; font-weight: 600; }
.fp-details .fp-group { border-top: 0; padding-top: 4px; }

/* ---------------- cards ---------------- */
.cards { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: rise .5s ease both;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px;
}
.card-ico {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; color: #fff;
  background: var(--grad);
}
.card-ico svg { width: 20px; height: 20px; }
.card-title { font-weight: 750; font-size: 1.02rem; }
.card-sub { color: var(--text-mute); font-size: .8rem; margin-top: 1px; }

.rows { border-top: 1px solid var(--line); }
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 16px;
}
.row + .row { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.row .k { color: var(--text-dim); font-size: .88rem; flex: none; max-width: 46%; }
.row .v { color: var(--text); font-weight: 650; font-size: .92rem; text-align: right; word-break: break-word; }
.row .v.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86rem; }

/* collapsible "all other fields" card */
.card-head.clickable { cursor: pointer; user-select: none; }
.chev { color: var(--text-mute); transition: transform .2s ease; flex: none; }
.card.collapsible .rows { display: none; }
.card.collapsible.open .rows { display: block; }
.card.collapsible.open .chev { transform: rotate(180deg); }

/* highlight strip for the marquee stats (exposure) */
.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); border-top: 1px solid var(--line);
}
.stat {
  background: var(--surface); padding: 13px 8px; text-align: center;
}
.stat .sv { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.stat .sk { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); margin-top: 3px; }

/* ---------------- map card ---------------- */
.map-card .card-head { padding-bottom: 12px; }
#map {
  width: 100%; height: 240px;
  background: var(--surface-2);
}
.map-actions {
  display: flex; gap: 10px; padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.map-actions a {
  flex: 1; text-align: center; text-decoration: none;
  padding: 10px; border-radius: 12px; font-size: .85rem; font-weight: 700;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
}
.map-actions a:active { transform: scale(.97); }
.leaflet-container { font: inherit; border-radius: 0; }
.coords-line {
  padding: 10px 16px 0; font-size: .82rem; color: var(--text-dim);
  font-family: ui-monospace, Menlo, monospace;
}

/* ---------------- no data ---------------- */
.nodata { text-align: center; padding: 8vh 20px; animation: rise .4s ease both; }
.nodata-icon {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 22px;
  display: grid; place-items: center; color: var(--text-mute);
  background: var(--surface); border: 1px solid var(--line);
}
.nodata h2 { font-size: 1.3rem; margin: 0 0 8px; }
.nodata p { color: var(--text-dim); line-height: 1.5; max-width: 26rem; margin: 0 auto 22px; }

/* ---------------- about sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5,5,20,.55); backdrop-filter: blur(3px); animation: fade .25s ease both; }
.sheet-panel {
  position: relative; width: 100%; max-width: 640px;
  background: var(--bg-2); border-radius: 26px 26px 0 0;
  padding: 12px 22px calc(var(--safe-b) + 26px);
  box-shadow: 0 -10px 50px rgba(0,0,0,.5);
  animation: slideUp .3s cubic-bezier(.2,.8,.2,1) both;
  max-height: 88dvh; overflow-y: auto;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
.sheet-panel h2 { margin: 0 0 12px; font-size: 1.3rem; }
.sheet-panel p { color: var(--text-dim); line-height: 1.55; margin: 0 0 12px; }
.about-list { list-style: none; padding: 0; margin: 6px 0 16px; display: flex; flex-direction: column; gap: 10px; }
.about-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; font-size: .92rem; }
.fineprint { color: var(--text-mute); font-size: .78rem; }

/* ---------------- QR / share block (in About sheet) ---------------- */
.qr-block { text-align: center; margin: 6px 0 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.qr-title { font-size: .95rem; margin: 0 0 14px; color: var(--text); font-weight: 700; }
.qr {
  width: 200px; max-width: 62vw; aspect-ratio: 1; margin: 0 auto 12px;
  background: #fff; border-radius: 16px; padding: 12px;
  box-shadow: 0 8px 26px rgba(0,0,0,.25); display: grid; place-items: center;
}
.qr svg, .qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.qr-url { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; color: var(--text-dim); word-break: break-all; margin-bottom: 12px; }

/* ---------------- update toast ---------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 18px); z-index: 70;
  display: flex; align-items: center; gap: 10px;
  width: calc(100% - 32px); max-width: 480px;
  padding: 12px 12px 12px 16px; border-radius: 16px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  animation: toastIn .35s cubic-bezier(.2,.8,.2,1) both;
}
.toast > svg { color: var(--brand); flex: none; }
.toast-text { flex: 1; font-size: .92rem; font-weight: 600; }
.toast-btn {
  flex: none; border: 0; border-radius: 11px; padding: 9px 16px;
  font-weight: 750; font-size: .9rem; cursor: pointer;
  color: #fff; background: var(--grad); font-family: inherit;
}
.toast-btn:active { transform: scale(.96); }
.toast-x {
  flex: none; border: 0; background: transparent; color: var(--text-mute);
  font-size: 1.4rem; line-height: 1; width: 30px; height: 30px; cursor: pointer;
  border-radius: 8px;
}
.toast-x:hover { background: var(--surface); color: var(--text); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- loader ---------------- */
.loader {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(6px);
}
.loader p { color: var(--text-dim); font-weight: 600; }
.loader-lens {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}

/* ---------------- anims ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* stagger cards */
.card:nth-child(1){animation-delay:.02s}
.card:nth-child(2){animation-delay:.07s}
.card:nth-child(3){animation-delay:.12s}
.card:nth-child(4){animation-delay:.17s}
.card:nth-child(5){animation-delay:.22s}
.card:nth-child(6){animation-delay:.27s}

@media (min-width: 560px) {
  .intro-title { font-size: 2.2rem; }
}
