/* Execur Apps - Liquid Glass launcher.
   Colours follow the phone: near-white pearl in light mode, near-black in dark. */

:root {
  --bg: #eef0f3;
  --text: #1d1d1f;
  --text-2: rgba(29, 29, 31, .62);
  --label: #1d1d1f;
  --label-shadow: 0 1px 1px rgba(255, 255, 255, .6);
  --glass: rgba(255, 255, 255, .42);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-edge: rgba(255, 255, 255, .75);
  --glass-edge-low: rgba(255, 255, 255, .25);
  --rim: rgba(0, 0, 0, .10);
  --rim-top: rgba(255, 255, 255, .55);
  --glass-shadow: 0 10px 40px rgba(20, 30, 50, .12), 0 1px 3px rgba(20, 30, 50, .08);
  --sep: rgba(60, 60, 67, .16);
  --row: rgba(255, 255, 255, .55);
  --accent: #0a7aff;
  --danger: #ff3b30;
  --dim: rgba(240, 242, 246, .35);
  --icon-empty: linear-gradient(145deg, #e3e6eb, #c9ced6);
  --radius-sheet: 38px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0b0e;
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, .6);
    --label: #f5f5f7;
    --label-shadow: 0 1px 2px rgba(0, 0, 0, .7);
    --glass: rgba(40, 42, 48, .38);
    --glass-strong: rgba(36, 38, 44, .72);
    --glass-edge: rgba(255, 255, 255, .22);
    --glass-edge-low: rgba(255, 255, 255, .06);
    --rim: rgba(255, 255, 255, .13);
    --rim-top: rgba(255, 255, 255, .22);
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .3);
    --sep: rgba(84, 84, 88, .5);
    --row: rgba(44, 46, 52, .55);
    --accent: #3d9bff;
    --danger: #ff453a;
    --dim: rgba(0, 0, 0, .35);
    --icon-empty: linear-gradient(145deg, #2c2f36, #16181d);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { overflow: hidden; position: fixed; inset: 0; }
/* An app launcher, not a document: a long press anywhere must never start a
   text selection or lift an icon for drag and drop. Text fields opt back in. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img { -webkit-user-drag: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---- wallpaper ------------------------------------------------------------ */

#silk {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg);
}

/* ---- Liquid Glass ------------------------------------------------------------ */

.glass {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(185%);
  backdrop-filter: blur(22px) saturate(185%);
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    inset 0 -1px 0 var(--glass-edge-low),
    inset 1px 0 0 var(--glass-edge-low),
    inset -1px 0 0 var(--glass-edge-low),
    var(--glass-shadow);
  isolation: isolate;
}
/* the specular sheen that sits on top of real glass */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 20% -10%, rgba(255, 255, 255, .35), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, .10), transparent 40%);
  mix-blend-mode: soft-light;
  z-index: -1;
}
.glass.strong { background: var(--glass-strong); }

/* ---- home ----------------------------------------------------------------- */

#home {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 22px) 18px calc(env(safe-area-inset-bottom) + 120px);
  transition: transform .5s var(--ease-out), opacity .35s ease, filter .35s ease;
}
body.app-open #home, body.app-open #dock { visibility: hidden; transition: visibility 0s .45s; }
body.menu-open #home { filter: blur(0); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  row-gap: 26px;
  column-gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(6, 1fr); max-width: 760px; } }

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.tile .icon-wrap {
  position: relative;
  isolation: isolate;
  width: 62px;
  height: 62px;
  border-radius: 14px;
  transition: transform .18s var(--ease-out);
}
.tile:active .icon-wrap { transform: scale(.9); }
.tile .icon {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  display: block;
  object-fit: cover;
  background: var(--icon-empty);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .14), 0 1px 2px rgba(0, 0, 0, .12), inset 0 0 0 .5px rgba(255, 255, 255, .2);
  -webkit-user-drag: none;
}
.tile .label {
  max-width: 100%;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--label);
  text-shadow: var(--label-shadow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

/* not downloaded: greyed with a download arrow */
.tile.available .icon { filter: grayscale(1) contrast(.85); opacity: .5; }
.tile.available .label { opacity: .62; }
.tile .get {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.tile .get svg { width: 13px; height: 13px; stroke-width: 2.4; }

/* update waiting */
.tile .update {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 0 0 1.5px rgba(255, 255, 255, .85);
}
.tile .update svg { width: 12px; height: 12px; stroke-width: 2.6; }
.tile .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 4px; vertical-align: 1px; }

/* App Store download ring */
.tile .ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, .42);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .25s ease;
}
.tile.downloading .ring { opacity: 1; }
.tile.downloading .icon { filter: none; opacity: 1; }
.tile.downloading .get, .tile.downloading .update { display: none; }
.ring svg { width: 34px; height: 34px; transform: rotate(-90deg); }
.ring .track { stroke: rgba(255, 255, 255, .28); stroke-width: 3; }
.ring .arc { stroke: #fff; stroke-width: 3; transition: stroke-dashoffset .2s linear; }
.ring.waiting svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(270deg); } }

.empty {
  text-align: center;
  color: var(--text-2);
  margin: 40px auto;
  max-width: 280px;
  font-size: 15px;
}

/* ---- notice (sign-in card) -------------------------------------------------- */

.notice {
  max-width: 520px;
  margin: 0 auto 26px;
  border-radius: 28px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.notice h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.notice p { margin: 0; color: var(--text-2); font-size: 15px; }
.notice .actions { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.notice .actions .btn.plain { min-height: 40px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -.01em;
  transition: transform .15s var(--ease-out), opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--text); color: var(--bg); }
.btn.tinted { background: var(--accent); color: #fff; }
.btn.plain { color: var(--accent); padding: 0 8px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.wide { width: 100%; }
.btn svg { width: 20px; height: 20px; }

/* ---- dock: Search pill + settings ----------------------------------------- */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 20px 0 16px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 590;
  color: var(--text);
}
.pill svg { width: 17px; height: 17px; stroke-width: 2.2; }
.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.round svg { width: 21px; height: 21px; }
.pill:active, .round:active { transform: scale(.94); }

/* ---- app view ----------------------------------------------------------------- */

.appview {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  transform-origin: 0 0;
  will-change: transform, clip-path;
  overflow: hidden;
}
.appview iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
}
.appsplash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 2;
  transition: opacity .25s ease;
}
.appsplash img { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.appsplash.gone { opacity: 0; pointer-events: none; }

/* the flight (js/appview.js): the cover the window opens out of and closes
   into (the icon's artwork over an aura in its colours, over the loading
   screen's background), a soft shadow beneath the window and a hairline rim
   on it while it is in the air */
.appcover { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: var(--bg); }
.appcover .aura { position: absolute; inset: 0; }
.appcover img { position: absolute; display: block; opacity: 0; }
.appshadow, .apprim { position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; will-change: transform, opacity; }
.appshadow { z-index: 19; box-shadow: 0 30px 64px -14px rgba(0, 0, 0, .5), 0 10px 24px -8px rgba(0, 0, 0, .32); }
.apprim { z-index: 21; box-shadow: inset 0 0 0 .5px var(--rim), inset 0 1px 0 var(--rim-top); }

/* the landing: a glow in the icon's colour and one glint across the glass */
.land-glow { position: absolute; inset: 0; border-radius: inherit; z-index: -1; filter: blur(12px); pointer-events: none; opacity: 0; }
.land-sheen { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; clip-path: inset(0 round 14px); pointer-events: none; }
.land-sheen i {
  position: absolute; top: -25%; bottom: -25%; left: 0; width: 50%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .42) 50%, rgba(255, 255, 255, 0));
  transform: translateX(-130%) skewX(-18deg);
}

/* ---- layer: sheets, menus, action sheets --------------------------------- */

#layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#layer > * { pointer-events: auto; }

.scrim {
  position: fixed;
  inset: 0;
  background: var(--dim);
  opacity: 0;
  transition: opacity .3s ease;
}
.scrim.show { opacity: 1; }
.scrim.blur { -webkit-backdrop-filter: blur(14px) saturate(120%); backdrop-filter: blur(14px) saturate(120%); }

.sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  max-height: calc(100% - env(safe-area-inset-top) - 36px);
  max-width: 560px;
  margin: 0 auto;
  border-radius: var(--radius-sheet);
  display: flex;
  flex-direction: column;
  transform: translateY(110%);
  transition: transform .5s var(--ease-out);
  overflow: hidden;
}
.sheet.show { transform: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 8px auto 0; flex: none; }
.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px 22px;
  flex: none;
}
.sheet header h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.sheet .close { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.sheet .close svg { width: 15px; height: 15px; stroke-width: 2.4; }
.sheet .body { overflow-y: auto; padding: 6px 16px 22px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet.tall { top: calc(env(safe-area-inset-top) + 28px); }

.group-title {
  margin: 20px 16px 7px;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--text-2);
}
.group { border-radius: 22px; overflow: hidden; background: var(--row); }
.group-note { margin: 7px 16px 0; font-size: 13px; color: var(--text-2); }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 16px;
  height: .5px;
  background: var(--sep);
}
.row.has-icon + .row.has-icon::before { left: 64px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 17px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.row .value { color: var(--text-2); font-size: 15px; white-space: nowrap; }
.row img.mini { width: 36px; height: 36px; border-radius: 8.5px; flex: none; object-fit: cover; background: var(--icon-empty); }
.row button.link { color: var(--accent); font-size: 17px; }
.row button.danger, .danger-text { color: var(--danger); }
.row.button { justify-content: center; color: var(--accent); cursor: pointer; }
.row.button.danger { color: var(--danger); }
.row.button:active { background: var(--sep); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--sep); color: var(--text-2); margin-left: 6px; vertical-align: 2px; }

/* iOS switch: Safari 17.4+ renders <input type=checkbox switch> natively (with
   haptics); elsewhere this draws the same thing. */
input.switch { flex: none; }
html:not(.native-switch) input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: var(--sep);
  position: relative;
  transition: background .25s;
  cursor: pointer;
  margin: 0;
}
html:not(.native-switch) input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .25s var(--ease-out);
}
html:not(.native-switch) input.switch:checked { background: #34c759; }
html:not(.native-switch) input.switch:checked::after { transform: translateX(20px); }
html:not(.native-switch) input.switch:disabled { opacity: .5; }

.field {
  width: 100%;
  height: 50px;
  border-radius: 16px;
  border: 0;
  padding: 0 16px;
  font: inherit;
  color: var(--text);
  background: var(--row);
  outline: none;
}
.field:focus { box-shadow: 0 0 0 2px var(--accent); }

.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; padding: 6px 6px 4px; }
.lead { font-size: 15px; color: var(--text-2); margin: 0; line-height: 1.4; }
.bigcode {
  font: 700 40px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .08em;
  text-align: center;
  padding: 18px 0 8px;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--sep);
  border-top-color: var(--text);
  animation: spin2 .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin2 { to { transform: rotate(360deg); } }
.faceid { width: 64px; height: 64px; margin: 8px auto 0; color: var(--accent); }
.faceid svg { width: 64px; height: 64px; stroke-width: 1.6; }

/* info sheet header */
.hero { display: flex; gap: 16px; align-items: center; padding: 6px 6px 4px; }
.hero img { width: 84px; height: 84px; border-radius: 19px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); background: var(--icon-empty); }
.hero h3 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.hero p { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }

/* search */
.searchbar { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 44px; border-radius: 22px; background: var(--row); }
.searchbar svg { width: 17px; height: 17px; color: var(--text-2); flex: none; stroke-width: 2.2; }
.searchbar input { flex: 1; border: 0; background: none; font: inherit; color: var(--text); outline: none; min-width: 0; }

/* ---- context menu (long-press) ------------------------------------------ */

.lift {
  position: fixed;
  z-index: 2;
  border-radius: 14px;
  transition: transform .35s var(--ease-out);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.lift img { width: 100%; height: 100%; border-radius: inherit; display: block; }
.menu {
  position: fixed;
  z-index: 3;
  width: 250px;
  border-radius: 22px;
  overflow: hidden;
  transform-origin: top left;
  transform: scale(.6);
  opacity: 0;
  transition: transform .38s var(--ease-out), opacity .2s ease;
}
.menu.show { transform: none; opacity: 1; }
.menu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 46px;
  font-size: 17px;
  letter-spacing: -.01em;
  position: relative;
  text-align: left;
}
.menu button + button::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: .5px; background: var(--sep); }
.menu button:active { background: var(--sep); }
.menu button svg { width: 19px; height: 19px; }
.menu button.danger { color: var(--danger); }
.menu .gap { height: 8px; background: var(--sep); opacity: .5; }

/* ---- action sheet (remove) ----------------------------------------------- */

.actions-sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(120%);
  transition: transform .45s var(--ease-out);
}
.actions-sheet.show { transform: none; }
.actions-sheet .groupbox { border-radius: 26px; overflow: hidden; }
.actions-sheet .head { padding: 16px 20px 12px; text-align: center; font-size: 13px; color: var(--text-2); line-height: 1.35; }
.actions-sheet .head b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; color: var(--text-2); }
.actions-sheet button { width: 100%; height: 57px; font-size: 20px; color: var(--accent); position: relative; }
.actions-sheet button::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: .5px; background: var(--sep); }
.actions-sheet button.danger { color: var(--danger); }
.actions-sheet button.cancel { font-weight: 600; }
.actions-sheet button.cancel::before { display: none; }
.actions-sheet button:active { background: var(--sep); }

/* ---- toast ------------------------------------------------------------------- */

.toast {
  position: fixed;
  z-index: 60;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translate(-50%, -140%);
  padding: 11px 18px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 590;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform .45s var(--ease-out);
}
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
