/* JOBSITE — dark by default, black + purple, lots of space.
   The brand's visual direction, applied to a tool used in gloves and daylight:
   big targets, high contrast, nothing decorative competing with the photos. */

:root {
  --bg: #0a0a0c;
  --surface: #131318;
  --surface-2: #1c1c23;
  --line: #26262f;
  --text: #f2f2f5;
  --text-2: #a5a5b4;
  --accent: #8b5cf6;
  --accent-ink: #fff;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* THE PAGE ITSELF NEVER SCROLLS. Only the inner body does. This is the standard
   across the apps: it kills rubber-banding, kills the address-bar jump, and
   stops a drag on the header from moving the whole document. */
html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;      /* no double-tap zoom on buttons */
}

#app, #views { position: fixed; inset: 0; }
#views { pointer-events: none; }
#views > * { pointer-events: auto; }

/* Any screen is a column: a fixed header, and one child that scrolls.
   `min-height: 0` is what actually lets the body scroll instead of growing
   past the viewport — without it the pane is simply unscrollable. */
.screen, .view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + var(--safe-bottom) + 24px);
  display: flex; flex-direction: column; gap: 14px;
}

/* ---------- header ---------- */
.hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--pad);
  padding-top: calc(10px + var(--safe-top));   /* clear of the Dynamic Island */
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.hdr h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.hdr h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.sp, .grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 550;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, opacity .18s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.wide { width: 100%; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: 0 0 auto;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: background .18s ease, transform .12s ease;
}
.iconbtn:active { transform: scale(.94); background: var(--surface-2); }

.input {
  width: 100%; min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font: inherit;
  /* 16px minimum, or iOS zooms the whole page when it gains focus. */
  font-size: 16px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); }

.hidden-file { display: none; }
.hidden { display: none; }

/* ---------- jobs list ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.jobrow {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  text-align: left; font: inherit; cursor: pointer;
  transition: transform .12s ease, border-color .18s ease;
}
.jobrow:active { transform: scale(.99); border-color: var(--accent); }
.jobthumb {
  width: 56px; height: 56px; flex: 0 0 auto;
  border-radius: 10px; object-fit: cover; background: var(--surface-2);
}
.jobthumb.blank { display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.jobname { font-weight: 600; }

/* ---------- photo grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}
.cell {
  position: relative; aspect-ratio: 1;
  padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: pointer;
  transition: transform .12s ease;
}
.cell:active { transform: scale(.96); }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .blank { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-2); }

/* ---------- upload progress ---------- */
.progress { display: flex; flex-direction: column; gap: 8px; }
.track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.fails { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.warn { color: var(--warn); }

/* ---------- viewer ---------- */
.viewer { background: #000; display: flex; flex-direction: column; }
.vbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px var(--pad); padding-top: calc(10px + var(--safe-top));
}
.vcap { color: var(--text-2); font-size: 14px; }
.full { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; }
.vnav {
  display: flex; gap: 10px; justify-content: space-between;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + var(--safe-bottom));
}
.vnav .btn { flex: 1; }

/* ---------- overlays ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6);
  opacity: 0; transition: opacity .18s ease;
}
.scrim.in { opacity: 1; }
.sheet {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px var(--pad);
  padding-bottom: calc(20px + var(--safe-bottom));
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  transform: translateY(12px); transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.scrim.in .sheet { transform: none; }
.sheet h3 { margin: 0; font-size: 19px; }
.sheet p { margin: 0; color: var(--text-2); }
.row-end { display: flex; gap: 10px; justify-content: flex-end; }
.row-end .btn { flex: 1; }

/* ---------- misc ---------- */
.auth {
  height: 100%;
  display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: var(--pad); max-width: 420px; margin: 0 auto;
}
.auth h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.muted { color: var(--text-2); margin: 0; }
.small { font-size: 13px; }
.pad { padding: var(--pad); }
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 48px 20px; color: var(--text-2); text-align: center;
}
.empty p { margin: 0; }

.toast {
  position: fixed; left: 50%; z-index: 90;
  bottom: calc(20px + var(--safe-bottom));
  transform: translate(-50%, 16px);
  max-width: 88vw;
  padding: 12px 18px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* View transitions — a pushed screen comes in from the right, the way every
   other app here behaves, so back always feels like back. */
.view { transition: transform .22s cubic-bezier(.2,.8,.2,1); z-index: 10; }
.view.enter { transform: translateX(100%); }
.view.leave { transform: translateX(100%); }

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