@font-face { font-family: "SF"; src: url("/assets/Inter-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SF"; src: url("/assets/Inter-Medium.ttf"); font-weight: 500; font-display: swap; }
@font-face { font-family: "SF"; src: url("/assets/Inter-SemiBold.ttf"); font-weight: 600; font-display: swap; }
@font-face { font-family: "SF"; src: url("/assets/Inter-Bold.ttf"); font-weight: 700; font-display: swap; }

:root {
  --blue: #007aff;
  --ink: #000;
  --chip: rgba(120, 120, 128, 0.16);
  --sat: env(safe-area-inset-top);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font: 400 17px/1.3 "SF", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

body { position: relative; }

/* ---------- status bar ---------- */

#statusbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: calc(var(--sat) + 38px);
  padding: calc(var(--sat) + 8px) 18px 0 26px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  pointer-events: none;
  z-index: 5;
}
.island {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--sat) + 9px); width: 104px; height: 33px;
  border-radius: 17px; background: #000;
}
.glyphs { display: flex; align-items: flex-end; gap: 4px; }
.glyphs i { display: block; }
.sig, .wifi, .batt {
  background: #000;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}
.sig { width: 18px; height: 11px; --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 11'%3E%3Crect x='0' y='7' width='3' height='4' rx='1'/%3E%3Crect x='5' y='5' width='3' height='6' rx='1'/%3E%3Crect x='10' y='2.6' width='3' height='8.4' rx='1'/%3E%3Crect x='15' y='0' width='3' height='11' rx='1'/%3E%3C/svg%3E"); }
.wifi { width: 16px; height: 12px; --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round'%3E%3Cpath d='M1.4 4.1a9.5 9.5 0 0 1 13.2 0'/%3E%3Cpath d='M4 6.9a6 6 0 0 1 8 0'/%3E%3Cpath d='M6.6 9.5a2.4 2.4 0 0 1 2.8 0'/%3E%3C/g%3E%3Ccircle cx='8' cy='11' r='.9' fill='black'/%3E%3C/svg%3E"); }
.batt { width: 25px; height: 12px; --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 12'%3E%3Crect x='.9' y='.9' width='20.2' height='10.2' rx='3' fill='none' stroke='black' stroke-opacity='.45' stroke-width='1.6'/%3E%3Crect x='2.9' y='2.9' width='11' height='6.2' rx='1.4'/%3E%3Cpath d='M22.8 4.2h.6a1 1 0 0 1 1 1v1.6a1 1 0 0 1-1 1h-.6z' fill='black' fill-opacity='.45'/%3E%3C/svg%3E"); }
.island::after {
  content: ""; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.1);
}
/* ---------- canvas ---------- */

#stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background: #fff;
}
#stage.dragging { cursor: grabbing; }

#grid-wrap {
  position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform;
  display: grid; gap: 0;
  filter: saturate(0.18) contrast(1) brightness(1.03);
}
.cell {
  position: relative; overflow: hidden;
  background-size: cover; background-position: center;
  background-repeat: no-repeat;
}
.cell i { position: absolute; inset: 0; display: block; }
#mosaic { display: none; }

/* ---------- header ---------- */

#chrome {
  position: absolute;
  top: calc(var(--sat) + 38px);
  left: 0; right: 0;
  padding: 2px 18px 14px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  pointer-events: none;
  z-index: 3;
}
#chrome button { pointer-events: auto; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.actions { display: flex; align-items: center; gap: 14px; }

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.9px;
  color: #0b0b0c;
  white-space: nowrap;
}

#count { margin: 3px 0 0; font-size: 15px; color: rgba(60, 60, 67, 0.6); }

#select {
  border: 0; background: none; color: var(--blue);
  font: inherit; font-size: 17px; padding: 11px 0 0;
}

.tools { display: flex; gap: 10px; justify-content: flex-end; padding-top: 12px; }

.chip, .round {
  border: 0; padding: 0; background: rgba(120, 120, 128, 0.11); color: var(--ink);
  width: 30px; height: 30px; border-radius: 50%;
  backdrop-filter: blur(12px);
  display: grid; place-items: center;
}

#gear::before, #fit::before, .round::before, .ico-stack::before {
  content: ""; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}

#gear::before { display: none; }
#gear { color: #3a3a3c; font-size: 16px; font-weight: 600; line-height: 1; padding-bottom: 10px; }
#gear.tmp { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9'%3E%3Ccircle cx='12' cy='12' r='3.2'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.05A1.7 1.7 0 0 0 9 19.4a1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.05A1.7 1.7 0 0 0 4.6 9a1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.7 1.7 0 0 0 9 4.6a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.05A1.7 1.7 0 0 0 15 4.6a1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9v.05a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.05a1.7 1.7 0 0 0-1.55 1z'/%3E%3C/svg%3E"); }
#fit::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9'%3E%3Crect x='3.5' y='3.5' width='7' height='7' rx='1.4'/%3E%3Crect x='13.5' y='3.5' width='7' height='7' rx='1.4'/%3E%3Crect x='3.5' y='13.5' width='7' height='7' rx='1.4'/%3E%3Crect x='13.5' y='13.5' width='7' height='7' rx='1.4'/%3E%3C/svg%3E"); }

.ico-stack::before {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9'%3E%3Crect x='7' y='3.5' width='13' height='13' rx='2.6'/%3E%3Cpath d='M16.5 16.5v2.1a2.4 2.4 0 0 1-2.4 2.4H6.4A2.4 2.4 0 0 1 4 18.6V10.9a2.4 2.4 0 0 1 2.4-2.4h2.1'/%3E%3C/svg%3E");
  width: 17px; height: 17px;
}

/* ---------- dock ---------- */

#dock {
  position: absolute;
  left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 24px);
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px; z-index: 3;
}

.tabbar {
  display: flex; align-items: center; gap: 2px;
  height: 46px; border-radius: 23px;
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  padding: 5px; margin: 0 auto;
}

.tab {
  display: flex; align-items: center; gap: 7px;
  height: 37px; padding: 0 12px; border: 0;
  border-radius: 19px; background: transparent;
  font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--ink);
}
.tab.on { color: var(--blue); }
.tab .ico-stack { display: grid; place-items: center; }
#search::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.6'/%3E%3Cpath d='M16 16l4.4 4.4'/%3E%3C/svg%3E"); width: 19px; height: 19px; }

/* ---------- hint ---------- */

#hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 66px);
  transform: translateX(-50%);
  padding: 7px 13px; border-radius: 20px;
  font-size: 13px; color: #3c3c43;
  background: rgba(245, 245, 247, 0.9);
  backdrop-filter: blur(16px);
  white-space: nowrap; transition: opacity 0.45s ease; z-index: 2;
}
#hint.gone { opacity: 0; }

#home {
  position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%);
  width: 140px; height: 4.5px; border-radius: 3px; background: rgba(0, 0, 0, 0.85);
  z-index: 4; pointer-events: none;
}

/* ---------- desktop framing ---------- */

@media (min-width: 520px) {
  body { background: #000; }
  #stage, #chrome, #dock, #hint { max-width: 390px; margin-left: auto; margin-right: auto; }
  #stage { left: calc(50% - 195px); right: auto; width: 390px; }
  #chrome, #dock, #statusbar { left: calc(50% - 195px); right: auto; width: 390px; }
}

#grid-wrap { position: relative; }
#face {
  position: absolute; left: 0; right: 0; grid-column: 1 / -1;
  background-size: 100% 100%; background-repeat: no-repeat;
  pointer-events: none; z-index: 4;
  transition: opacity 0.18s linear;
}
#grid-wrap[data-z="1"] .cell .tint { opacity: 0.22; }
#grid-wrap[data-z="1"] .cell .tone { opacity: 0.38 !important; }
.cell .tint, .cell .tone { transition: opacity 0.18s linear; }
