/* Pressing — thème clair épuré, aux couleurs du logo (graphite + dégradé bleu → indigo) */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: #ffffff;
  --label: #1c1c1e;
  --secondary: #6e6e73;
  --tertiary: #a1a1a6;
  --separator: rgba(60, 60, 67, .14);
  --fill: rgba(118, 118, 128, .10);
  --accent: #0a84ff;
  --accent-tint: rgba(10, 132, 255, .10);
  --indigo: #5e5ce6;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --red-tint: rgba(255, 59, 48, .10);
  --bar: rgba(255, 255, 255, .78);
  --seg-on: #ffffff;
  --grad: linear-gradient(120deg, #0a84ff, #5e5ce6);
  --shadow: 0 1px 2px rgba(17, 17, 26, .04), 0 8px 28px rgba(17, 17, 26, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; }
/* Pas de zoom au double-tap (le zoom à deux doigts reste possible) */
html, body, button, label, a, input, textarea, select { touch-action: manipulation; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 420px at 10% -120px, rgba(10, 132, 255, .13), transparent 70%),
    radial-gradient(800px 420px at 100% -80px, rgba(94, 92, 230, .12), transparent 70%),
    var(--bg);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 100px);
}

/* Titres */
.large-title { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 14px; }
.large-title h1 { font-size: 34px; font-weight: 700; letter-spacing: .2px; }
.brand { margin: 18px 0 18px; display: flex; align-items: center; }
.brand img { height: 34px; width: auto; display: block; }
.section-title {
  font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .3px;
  color: var(--secondary); margin: 28px 16px 7px;
}
.footnote { font-size: 13px; color: var(--secondary); line-height: 1.4; }
.center { text-align: center; }

/* Boutons */
.btn {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer;
  font-size: 17px; font-weight: 600; padding: 12px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, opacity .2s ease; text-decoration: none; user-select: none;
}
.btn:active { transform: scale(.97); opacity: .8; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(52, 92, 240, .28); }
.btn.tinted { background: var(--accent-tint); color: var(--accent); }
.btn.gray { background: var(--fill); color: var(--label); }
.btn.destructive { background: var(--red-tint); color: var(--red); }
.btn.big { width: 100%; padding: 15px; border-radius: 14px; }
.btn.small { font-size: 15px; padding: 7px 14px; border-radius: 999px; }
.btn svg { width: 22px; height: 22px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 17px; cursor: pointer; }
.pick { margin-top: 4px; }

/* Cartes */
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }

/* Pastille coût (Atelier) */
.cost-pill {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 0; border-radius: 18px; padding: 13px 16px; margin-bottom: 12px;
  font-size: 15px; text-align: left; cursor: pointer; box-shadow: var(--shadow);
}
.cost-pill b { font-weight: 600; }
.cost-pill .muted { color: var(--secondary); }
.cost-pill .chev { color: var(--tertiary); font-size: 20px; line-height: 1; }


/* Envoi */
.upload-card { margin-top: 12px; }
.upload-row { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 10px; }
.upload-row span:last-child { color: var(--secondary); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s ease; }

.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }

/* Bandeau notifications */
.banner { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 12px 12px 12px 14px; }
.banner-icon { flex: none; width: 30px; height: 30px; padding: 6px; border-radius: 8px; color: #fff; background: var(--grad); }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--secondary); line-height: 1.35; }
.banner-text b { font-size: 15px; color: var(--label); font-weight: 600; }
.banner-close { flex: none; border: 0; background: none; color: var(--tertiary); font-size: 15px; padding: 4px; cursor: pointer; }

/* Coûts */
.tokens { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--separator); }
.tokens div { flex: 1; }
.tokens .label { font-size: 13px; color: var(--secondary); }
.tokens .value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.prompt-row summary { cursor: pointer; list-style: none; }
.prompt-row summary::-webkit-details-marker { display: none; }
.prompt-row summary::after { content: " ›"; color: var(--tertiary); }
.prompt-row[open] summary { margin-bottom: 10px; }
.prompt-row .link { display: block; margin-top: 8px; }

/* Temps estimé */
.eta-card { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.eta-title { font-weight: 600; font-variant-numeric: tabular-nums; }
.eta-sub { font-size: 13px; color: var(--secondary); margin-top: 2px; line-height: 1.35; }
.spinner.dark { flex: none; width: 22px; height: 22px; border-width: 2.5px; border-color: var(--fill); border-top-color: var(--accent); }

/* Grille de photos */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 0; }
.toolbar span { font-size: 15px; color: var(--secondary); }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; cursor: pointer;
  border-radius: 16px; overflow: hidden; background: #e9e9ee;
  box-shadow: 0 1px 2px rgba(17, 17, 26, .06), 0 6px 16px rgba(17, 17, 26, .06);
  transition: transform .15s ease;
}
.tile:active { transform: scale(.97); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.waiting img { filter: saturate(.5) brightness(.8); }
.tile.working::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  background-size: 250% 100%; animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -130% 0; } }
.badge {
  position: absolute; left: 8px; bottom: 8px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #fff; padding: 5px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.badge.ok { background: rgba(52, 199, 89, .92); }
.badge.err { background: rgba(255, 59, 48, .92); }
.badge.kept { background: rgba(0, 122, 255, .9); }
.badge.dim { background: rgba(60, 60, 67, .7); }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite;
}
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Vides */
.empty { text-align: center; padding: 20px 0 0; color: var(--secondary); }
.compare.demo {
  flex: none; margin: 0; aspect-ratio: 720 / 526; border-radius: 20px; box-shadow: var(--shadow);
  touch-action: pan-y; /* le défilement vertical de la page reste possible */
}
.compare.demo img { object-fit: cover; }
.empty h2 { color: var(--label); font-size: 20px; font-weight: 600; margin: 14px 0 8px; }
.empty p { font-size: 15px; line-height: 1.45; max-width: 320px; margin: 0 auto; }

/* Historique */
.batch { margin-top: 26px; }
.batch-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px; }
.batch-head h2 { font-size: 20px; font-weight: 600; }
.batch-head span { font-size: 13px; color: var(--secondary); }
.batch .grid { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
@media (min-width: 560px) { .batch .grid { grid-template-columns: repeat(4, 1fr); } }
.batch .tile { border-radius: 10px; }
.batch .badge { left: 5px; bottom: 5px; padding: 3px 7px; font-size: 11px; }

/* Coûts */
.hero { text-align: left; }
.hero .label { font-size: 15px; color: var(--secondary); }
.hero .amount {
  font-size: 46px; font-weight: 800; letter-spacing: -1px; margin: 2px 0 4px; font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .sub { font-size: 15px; color: var(--secondary); }
.meter { margin-top: 16px; }
.meter .bar { height: 8px; border-radius: 4px; }
.meter .bar > div { background: var(--green); }
.meter.warn .bar > div { background: var(--orange); }
.meter.over .bar > div { background: var(--red); }
.meter-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--secondary); margin-top: 6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat .label { font-size: 13px; color: var(--secondary); }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.low { color: var(--red); }
.costs-foot { margin: 10px 16px 0; }
.costs-foot a { color: var(--accent); text-decoration: none; }

/* Listes groupées (Réglages) */
.group { background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 10px 16px; position: relative;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--separator);
}
.row > span:first-child { white-space: nowrap; }
.row input, .row select {
  border: 0; background: none; text-align: right; color: var(--secondary);
  min-width: 0; width: 100%; padding: 0; outline: none; font-size: 17px;
}
.row select { width: auto; appearance: none; -webkit-appearance: none; cursor: pointer; }
.input-unit { display: flex; align-items: center; gap: 4px; color: var(--secondary); max-width: 55%; }
.input-unit input { max-width: 110px; }
.row.column { flex-direction: column; align-items: stretch; }
.row textarea {
  width: 100%; border: 0; border-radius: 10px; background: var(--fill); padding: 10px 12px;
  font-size: 16px; line-height: 1.45; resize: vertical; /* < 16 px : iOS zoome au focus */ outline: none; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.row .link { font-size: 15px; align-self: flex-start; }
.group-foot { font-size: 13px; color: var(--secondary); margin: 7px 16px 0; line-height: 1.4; }
.advanced summary { list-style: none; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { content: " ›"; }
.advanced[open] summary::after { content: " ⌄"; }
#save-settings { margin-top: 24px; }
.logout { margin-top: 12px; color: var(--red); }
#mode-note { margin-top: 18px; }

/* Contrôle segmenté */
.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; flex: 0 1 260px; }
.segmented button {
  flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 4px;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background .2s;
}
.segmented button.on { background: var(--seg-on); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); font-weight: 600; }

/* Barre d'onglets */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--separator);
}
.tab {
  flex: 1; max-width: 160px; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 0;
  font-size: 10px; font-weight: 500; color: var(--tertiary);
}
.tab svg { width: 27px; height: 27px; }
.tab.active { color: var(--accent); }

/* Connexion */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.login-logo { width: 104px; height: 104px; filter: drop-shadow(0 14px 30px rgba(28, 28, 30, .28)); }
.login-wordmark { width: min(240px, 70vw); height: auto; margin-top: 28px; }
.login-sub { color: var(--secondary); margin-top: 8px; line-height: 1.4; }
.login-form { width: 100%; max-width: 340px; margin-top: 32px; display: grid; gap: 12px; }
.field {
  width: 100%; border: 0; border-radius: 12px; background: var(--card); padding: 14px 16px;
  font-size: 17px; outline: none; box-shadow: var(--shadow), inset 0 0 0 .5px var(--separator);
}
.field:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.form-error { color: var(--red); font-size: 15px; min-height: 20px; }

/* Visionneuse avant / après */
.viewer {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 12px);
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.viewer-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px 16px; min-height: 52px;
}
.viewer-title { font-weight: 600; font-size: 17px; }
.viewer-cost { justify-self: end; font-size: 15px; color: var(--secondary); font-variant-numeric: tabular-nums; }
.viewer-bar .link { justify-self: start; }
.compare {
  --pos: 50%;
  position: relative; flex: 1; min-height: 0; margin: 0 16px; border-radius: 18px; overflow: hidden;
  background: var(--fill); touch-action: none; user-select: none; -webkit-user-select: none; cursor: ew-resize;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.compare .after { clip-path: inset(0 0 0 var(--pos)); }
.compare .divider {
  position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 8px rgba(0, 0, 0, .35);
}
.compare .knob {
  position: absolute; top: 50%; left: var(--pos); width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border-radius: 50%; background: rgba(255, 255, 255, .92); color: #1c1c1e;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}
.compare .knob svg { width: 22px; height: 22px; }
.compare.single .after, .compare.single .divider, .compare.single .knob, .compare.single .tag { display: none; }
.compare.single { cursor: default; }
.tag {
  position: absolute; top: 12px; font-size: 12px; font-weight: 600; color: #fff;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .45); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.tag.before { left: 12px; }
.tag.after { right: 12px; }
.viewer-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; color: #fff; font-weight: 500;
  background: rgba(0, 0, 0, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#viewer-hint { margin: 10px 16px 0; min-height: 18px; }
.viewer-actions { display: flex; gap: 10px; padding: 12px 16px 0; }
.viewer-actions .btn { flex: 1; padding: 14px 8px; font-size: 16px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); z-index: 30;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: rgba(28, 28, 30, .9); color: #fff; padding: 11px 18px; border-radius: 14px;
  font-size: 15px; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  animation: up .25s ease;
}
