/* =====================================================================
   Storefit — full-screen App Store image sizer.
   Inherits Pidugu brand tokens (--ink, --bg, --serif…) from /styles.css.
   ===================================================================== */

.is-hidden { display: none !important; }
[hidden] { display: none !important; }

/* The app owns the viewport — no page scroll, no marketing chrome. */
.sf-body { overflow: hidden; }
.sf-shell {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}

/* ---------------- Top bar ---------------- */
.sf-bar {
  flex: none;
  display: flex; align-items: center; gap: clamp(12px, 3vw, 26px);
  padding: 11px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 246, 242, 0.82);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
}
.sf-brand { flex: none; }
.sf-brand .mark { height: 30px; }
.sf-brand .name { font-size: 20px; }
.sf-crumb {
  margin-left: 10px; padding-left: 11px;
  border-left: 1px solid var(--border-strong);
  font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--slate);
}
@media (max-width: 560px) { .sf-crumb { display: none; } .sf-brand .name { display: none; } }

/* Mode switch */
.sf-modes {
  display: inline-flex; gap: 4px; padding: 4px; margin: 0 auto 0 4px;
  background: rgba(15, 27, 46, 0.05); border: 1px solid var(--border); border-radius: 12px;
}
.sf-mode {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 15px; border-radius: 9px;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.sf-mode svg { width: 17px; height: 17px; }
.sf-mode:hover { color: var(--ink); }
.sf-mode.is-active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-soft); border: 1px solid var(--border); }

.sf-bar__right { flex: none; display: flex; align-items: center; gap: 8px; }
.sf-ghostbtn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 14px; font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background 0.18s ease, border-color 0.18s ease;
}
.sf-ghostbtn:hover { background: rgba(15, 27, 46, 0.05); border-color: var(--border-strong); }
.sf-ghostbtn svg { width: 16px; height: 16px; color: var(--slate); }
.sf-ghostbtn--icon { padding: 8px; }
@media (max-width: 460px) { #sf-about-btn { display: none; } }

/* ---------------- Main panels ---------------- */
.sf-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sf-main[hidden] { display: none; }

/* Toolbar (anchors the popovers) */
.sf-toolbar {
  flex: none; position: relative; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sf-tool-group { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sf-tool-label { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); flex: none; }
.sf-tool-spacer { flex: 1 1 auto; }
.sf-orient-wrap { flex: none; }

.sf-pop-trigger {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 13px; font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.sf-pop-trigger:hover { background: rgba(15, 27, 46, 0.04); }
.sf-pop-trigger b { color: var(--slate); font-variant-numeric: tabular-nums; }
.sf-pop-trigger.is-open { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(15, 27, 46, 0.08); }
.sf-caret { width: 15px; height: 15px; color: var(--faint); transition: transform 0.2s ease; }
.sf-pop-trigger.is-open .sf-caret { transform: rotate(180deg); }
.sf-swatch { width: 15px; height: 15px; border-radius: 5px; background: var(--sw); border: 1px solid var(--border-strong); }

/* Popovers */
.sf-pop {
  position: absolute; top: calc(100% + 8px); z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 16px;
  width: min(380px, calc(100vw - 28px));
  animation: sf-pop-in 0.16s ease;
}
.sf-pop[hidden] { display: none; }
@keyframes sf-pop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sf-pop__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sf-pop__title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.sf-quick { display: flex; gap: 12px; }
.sf-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: var(--slate);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong);
}
.sf-link:hover { color: var(--ink); }

/* Size list */
.sf-sizes { display: flex; flex-direction: column; gap: 7px; max-height: min(56vh, 420px); overflow-y: auto; padding-right: 2px; }
.sf-size {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.sf-size:hover { border-color: var(--border-strong); }
.sf-size.is-on { border-color: rgba(15, 27, 46, 0.5); background: rgba(15, 27, 46, 0.035); box-shadow: var(--shadow-soft); }
.sf-size__box { width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--bg); display: grid; place-items: center; transition: background 0.15s ease, border-color 0.15s ease; }
.sf-size__box svg { width: 13px; height: 13px; color: var(--bg); opacity: 0; transition: opacity 0.15s ease; }
.sf-size.is-on .sf-size__box { background: var(--ink); border-color: var(--ink); }
.sf-size.is-on .sf-size__box svg { opacity: 1; }
.sf-size__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sf-size__name { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); line-height: 1.35; }
.sf-size__dim { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.sf-badge2 { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: none; }
.sf-badge2.req { color: var(--bg); background: var(--ink); }
.sf-badge2.rec { color: var(--slate); background: rgba(58, 74, 99, 0.12); border: 1px solid rgba(58, 74, 99, 0.26); }

/* Option rows */
.sf-pop--opts { display: flex; flex-direction: column; gap: 13px; }
.sf-opt { display: flex; align-items: center; gap: 14px; }
.sf-opt__label { width: 84px; flex: none; font-size: 13px; font-weight: 600; color: var(--muted); }
.sf-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 4px; }

.sf-seg { display: inline-flex; gap: 4px; padding: 4px; background: rgba(15, 27, 46, 0.045); border: 1px solid var(--border); border-radius: 11px; }
.sf-seg--wrap { display: flex; flex-wrap: wrap; }
.sf-seg button { border: 0; background: transparent; cursor: pointer; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); padding: 7px 12px; border-radius: 8px; white-space: nowrap; transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease; }
.sf-seg button:hover { color: var(--ink); }
.sf-seg button.is-active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-soft); }
.sf-seg--mini button { padding: 6px 11px; font-size: 12.5px; }

.sf-bg { display: inline-flex; gap: 8px; align-items: center; }
.sf-bg button { width: 28px; height: 28px; border-radius: 9px; cursor: pointer; background: var(--sw); border: 1px solid var(--border-strong); transition: box-shadow 0.15s ease, transform 0.12s ease; }
.sf-bg button:hover { transform: translateY(-1px); }
.sf-bg button.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.sf-bg__custom { width: 28px; height: 28px; border-radius: 9px; overflow: hidden; cursor: pointer; border: 1px solid var(--border-strong); position: relative; background: conic-gradient(from 0deg, #ff5d5d, #ffd24d, #4ad991, #4db8ff, #b06bff, #ff5d5d); }
.sf-bg__custom input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); opacity: 0; cursor: pointer; }

.sf-range { display: flex; align-items: center; gap: 12px; flex: 1; }
.sf-range input[type=range] { flex: 1; accent-color: var(--ink); }
.sf-range output { font-size: 13px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; width: 30px; text-align: right; }

/* ---------------- Surface ---------------- */
.sf-surface { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: clamp(16px, 3vw, 30px); }

.sf-empty { flex: 1; display: grid; place-items: center; min-height: 240px; }
.sf-drop {
  position: relative; width: min(640px, 100%);
  border: 1.5px dashed var(--border-strong); border-radius: 22px; background: var(--surface);
  padding: clamp(34px, 7vh, 72px) 28px; text-align: center; cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}
.sf-drop:hover, .sf-drop:focus-visible { border-color: var(--ink); background: rgba(15, 27, 46, 0.025); outline: none; }
.sf-surface.is-drag .sf-drop { border-color: var(--ink); background: rgba(15, 27, 46, 0.05); }
.sf-surface.is-drag { outline: 2px dashed var(--border-strong); outline-offset: -10px; border-radius: 12px; }
.sf-drop__icon { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--border); box-shadow: var(--shadow-soft); color: var(--ink); }
.sf-drop__icon svg { width: 27px; height: 27px; }
.sf-drop__title { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.sf-drop__hint { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.sf-drop__browse { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.sf-drop--icon { padding: 22px; min-height: 260px; display: grid; place-items: center; }
.sf-master { position: absolute; inset: 16px; border-radius: 16px; overflow: hidden; display: grid; place-items: center; background: repeating-conic-gradient(rgba(15, 27, 46, 0.05) 0% 25%, transparent 0% 50%) 50% / 22px 22px; }
.sf-master img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow); }

/* Source thumbnails strip */
.sf-sources { flex: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 11px; }
.sf-src { position: relative; border-radius: 13px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); aspect-ratio: 1; box-shadow: var(--shadow-soft); }
.sf-src img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sf-src__x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 7px; border: 0; cursor: pointer; display: grid; place-items: center; background: rgba(15, 27, 46, 0.78); color: #fff; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.18s ease; }
.sf-src:hover .sf-src__x { opacity: 1; }
.sf-src__x svg { width: 13px; height: 13px; }
.sf-add { border: 1.5px dashed var(--border-strong); background: var(--surface); border-radius: 13px; aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; color: var(--slate); transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease; }
.sf-add:hover { border-color: var(--ink); color: var(--ink); background: rgba(15, 27, 46, 0.03); }
.sf-add svg { width: 22px; height: 22px; }

/* ---------------- Results ---------------- */
.sf-results-wrap { flex: none; }
.sf-results-head { margin-bottom: 16px; }
.sf-results-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--ink); }
.sf-results-sub { margin-top: 3px; font-size: 13px; color: var(--muted); }

.sf-group { margin-bottom: 22px; }
.sf-group:last-child { margin-bottom: 0; }
.sf-group__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.sf-group__name { font-size: 14px; font-weight: 700; color: var(--ink); }
.sf-group__dim { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sf-group__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

.sf-out { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-soft); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.sf-out:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.sf-out__pic { height: 150px; display: grid; place-items: center; padding: 10px; background: rgba(15, 27, 46, 0.045); }
.sf-out__pic img { max-width: 100%; max-height: 100%; box-shadow: 0 4px 14px -6px rgba(15, 27, 46, 0.4); display: block; }
.sf-out__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; border-top: 1px solid var(--border); }
.sf-out__info { min-width: 0; }
.sf-out__dim { font-size: 11.5px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.sf-out__sz { font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-out__dl { width: 30px; height: 30px; flex: none; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); cursor: pointer; display: grid; place-items: center; transition: background 0.18s ease, border-color 0.18s ease; }
.sf-out__dl:hover { background: rgba(15, 27, 46, 0.06); border-color: var(--border-strong); }
.sf-out__dl svg { width: 15px; height: 15px; }

.sf-results--icons { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.sf-ic { text-align: center; }
.sf-ic img { display: block; border-radius: 18%; box-shadow: var(--shadow-soft); background: #fff; }
.sf-ic span { display: block; margin-top: 7px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------- Action bar ---------------- */
.sf-actionbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(14px, 3vw, 28px); border-top: 1px solid var(--border);
  background: rgba(247, 246, 242, 0.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.sf-status { font-size: 13.5px; color: var(--muted); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-status.is-busy { color: var(--slate); }
.sf-status.is-done { color: var(--ink); font-weight: 600; }
.sf-status.is-err { color: #A23B2E; font-weight: 600; }
.sf-actionbar__btns { display: flex; gap: 10px; flex: none; }
.sf-run svg { width: 18px; height: 18px; }
.sf-run[disabled] { opacity: 0.45; cursor: default; filter: none; }
.sf-zip svg { width: 16px; height: 16px; }

/* ---------------- About modal ---------------- */
.sf-about { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(15, 27, 46, 0.42); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: sf-fade 0.2s ease; }
.sf-about[hidden] { display: none; }
@keyframes sf-fade { from { opacity: 0; } to { opacity: 1; } }
.sf-about__card { position: relative; width: min(540px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: clamp(28px, 4vw, 40px); box-shadow: var(--shadow); }
.sf-about__x { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--slate); cursor: pointer; display: grid; place-items: center; transition: background 0.18s ease, color 0.18s ease; }
.sf-about__x:hover { background: rgba(15, 27, 46, 0.06); color: var(--ink); }
.sf-about__x svg { width: 17px; height: 17px; }
.sf-about__h { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--ink); margin-top: 6px; }
.sf-about__lead { margin-top: 10px; font-size: 15px; line-height: 1.6; color: var(--muted); }
.sf-about__list { margin: 20px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.sf-about__list li { position: relative; padding-left: 26px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.sf-about__list li::before { content: ""; position: absolute; left: 0; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); }
.sf-about__list b { color: var(--ink); font-weight: 650; }
.sf-about__foot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12.5px; line-height: 1.6; color: var(--faint); }
.sf-about__foot a { color: var(--slate); }

/* ---------------- Responsive ---------------- */
@media (max-width: 600px) {
  .sf-modes { margin-left: 0; }
  .sf-mode span { display: none; }
  .sf-mode { padding: 8px 11px; }
  .sf-tool-label { display: none; }
  .sf-actionbar__btns { flex: 1; }
  .sf-run { flex: 1; justify-content: center; }
}
