@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(/fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(/fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(/fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --ink: #18261f;
  --ink-soft: #52625a;
  --paper: #eef1ec;
  --field: #fbfcfa;
  --line: #bcc7bf;
  --rule: #f5c518;
  --rule-ink: #18261f;
  --error: #a3271c;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: Barlow, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e8eee9;
    --ink-soft: #a3b1a8;
    --paper: #17201c;
    --field: #202b26;
    --line: #3d4b44;
    --error: #ff9c8f;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.45 var(--body);
}

main {
  max-width: 36rem;
  margin: 0 auto;
  padding-bottom: calc(3rem + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; font-family: var(--display); font-weight: 600; line-height: 1.1; }
h1 { flex: 1; font-size: 1.625rem; }
h2 { font-size: 1.375rem; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }

input, button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 3.5rem;
  padding: env(safe-area-inset-top) 1rem 0;
}

.back {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: -.75rem;
  font-size: 2rem;
  line-height: 1;
  text-decoration: none;
}

.settings { padding: .625rem 0; font-weight: 500; }

.page { display: grid; gap: 1.75rem; padding: 1.25rem 1rem 0; }

.menu { padding: .5rem 1rem; }
.menu a {
  display: grid;
  gap: .125rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.menu strong { font: 600 1.625rem/1.15 var(--display); }
.menu span { color: var(--ink-soft); }

/* Le mètre pliant : le résultat reste visible au-dessus du clavier du téléphone. */
.ruler {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: .75rem 1rem 1.5rem;
  color: var(--rule-ink);
  background:
    repeating-linear-gradient(90deg, var(--rule-ink) 0 2px, transparent 2px 50px) left bottom / 100% 14px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-ink) 0 1px, transparent 1px 10px) left bottom / 100% 7px no-repeat,
    var(--rule);
}

.amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.amount { display: grid; gap: .125rem; }
.amount-label { font-weight: 500; line-height: 1.2; }
.amount-label small { display: block; font-size: .875rem; font-weight: 400; }
.amount-value {
  font: 600 3.5rem/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.amount-value small { margin-left: .25rem; font-size: 1.375rem; }

.instruction { margin-top: .375rem; font-weight: 500; line-height: 1.3; }

.notice { padding: .625rem .75rem; border-left: 4px solid var(--rule); background: var(--field); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .25rem;
}
.section-head p { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.surface { display: grid; gap: .25rem; padding: .375rem 0 .625rem; border-bottom: 1px solid var(--line); }

.surface-head { display: flex; align-items: center; gap: .5rem; }

.surface-name {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 500;
}
.surface-name::placeholder { color: var(--ink-soft); opacity: 1; }

.switch { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.switch button { width: 2.75rem; min-height: 2.25rem; padding: 0; border: 0; background: none; cursor: pointer; }
.switch [aria-pressed='true'] { background: var(--ink); color: var(--paper); font-weight: 500; }

.surface-values { display: flex; align-items: center; gap: .375rem; }
.surface-values .with-unit { flex: 1 1 0; min-width: 0; }
.surface-values .count { flex: 0 0 3rem; }
.surface-values input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0 1.875rem 0 .5rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--field);
  font-size: 1.0625rem; /* au-dessus de 16 px : iOS ne zoome pas sur le champ */
  font-variant-numeric: tabular-nums;
}
.surface-values input::placeholder { color: var(--ink-soft); opacity: 1; }
.surface-values .with-unit small { right: .5rem; font-size: .875rem; }
.surface-values .count input { padding-right: .25rem; text-align: center; }
.times { flex: none; color: var(--ink-soft); }

.field { display: grid; gap: .25rem; }
.field > span:first-child { font-weight: 500; }
.field em { color: var(--ink-soft); font-size: .9375rem; font-style: normal; }

.with-unit { position: relative; display: block; }
.with-unit small { position: absolute; top: 50%; right: .75rem; color: var(--ink-soft); font-size: 1rem; transform: translateY(-50%); pointer-events: none; }

.field input {
  width: 100%;
  min-height: 3rem;
  padding: 0 3.25rem 0 .75rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--field);
  font-size: 1.1875rem; /* au-dessus de 16 px : iOS ne zoome pas sur le champ */
  font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: var(--ink-soft); opacity: 1; }
.save .field input { padding-right: .75rem; }

.surface-area { flex: 0 0 4.25rem; color: var(--ink-soft); font-size: .9375rem; font-variant-numeric: tabular-nums; line-height: 1.15; text-align: right; }
.surface-area.invalid { color: var(--error); font-weight: 500; }

.primary, .secondary {
  width: 100%;
  min-height: 3.25rem;
  padding: 0 1rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
}
.primary { background: var(--ink); color: var(--paper); }
.secondary { margin-top: .875rem; background: none; }

.link {
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.quiet {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  margin-right: -.75rem;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.applied { color: var(--ink-soft); }

.save, .settings-form { display: grid; gap: .875rem; }
.settings-form { gap: 1.25rem; }

.status:empty { display: none; }
.status { font-weight: 500; }

.history li { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--line); }
.history a { flex: 1; min-width: 0; display: grid; padding: .625rem 0; text-decoration: none; }
.history strong { font-weight: 500; overflow-wrap: anywhere; }
.history span { color: var(--ink-soft); font-size: .9375rem; }
.history .empty { display: block; padding: .625rem 0; color: var(--ink-soft); }
