@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../assets/fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url("../assets/fonts/inter-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #0d0f10;
  --surface: #15181a;
  --line: #262a2d;
  --text: #e8e4da;
  --muted: #8f9296;
  --accent: #e9b44c;
  --on-accent: #14110a;
  --gutter: 16px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, legend {
  font-weight: 600;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px var(--gutter) 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* Intro */
.intro h1 {
  font-size: 18px;
  letter-spacing: 0.02em;
}
.note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* Preview */
.stage { min-width: 0; }
.phone {
  width: min(100%, calc(68vh * 1290 / 2796));
  width: min(100%, calc(68dvh * 1290 / 2796));
  margin: 0 auto;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  line-height: 0;
}
#preview {
  display: block;
  width: 100%;
  height: auto;
}
.msg {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Controls */
.controls {
  display: grid;
  gap: 14px;
}
fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.optional {
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  margin-left: 6px;
}

/* Chips (month, placement) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips.three { display: grid; grid-template-columns: repeat(3, 1fr); }
.chips.two { display: grid; grid-template-columns: repeat(2, 1fr); }
.chip { position: relative; }
.chip input, .switch input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
}
.chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chip input:checked + span {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}
.chip input:focus-visible + span,
.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Switches */
.show-grid {
  display: flex;
  flex-wrap: wrap;               /* wraps only on very narrow screens */
  justify-content: space-between;
  column-gap: 8px;
}
/* Smaller switches so all three sit on one line, down to 360 px wide screens */
.show-grid { column-gap: 6px; }
.show-grid .switch { gap: 4px; font-size: 12px; }
.show-grid .track { width: 26px; height: 15px; border-radius: 8px; }
.show-grid .track::after { top: 2px; left: 2px; width: 11px; height: 11px; }
.show-grid .switch input:checked + .track::after { transform: translateX(11px); }
.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.track {
  flex: none;
  width: 38px; height: 22px;
  border-radius: 11px;
  background: var(--line);
  position: relative;
  transition: background 0.15s;
}
.track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--on-accent); }

/* Birthday */
.add {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 6px;
}
.add-btn {
  min-height: 38px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--text);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.add-btn:disabled { opacity: 0.4; cursor: default; }
.add-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.marks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.marks li {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px 0 12px;
  min-height: 32px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: var(--surface);
}
.marks button {
  width: 28px;
  height: 28px;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.marks button:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.select select {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.select select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Result fallback */
.result { text-align: center; }
.result h2 {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.result img {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto;
  border-radius: 20px;
  border: 1px solid var(--line);
  -webkit-touch-callout: default;
  user-select: auto;
}
.long-press { margin: 14px 0 4px; font-weight: 600; }
.link { color: var(--accent); }

/* Save bar */
.savebar {
  position: sticky;
  bottom: 0;
  margin: 0 calc(var(--gutter) * -1);
  padding: 16px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(13, 15, 16, 0), var(--bg) 28%);
}
.status {
  min-height: 0;
  margin: 0 0 8px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.status:empty { display: none; }
.save {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.save:disabled { opacity: 0.45; cursor: default; }
.save:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.noscript { padding: var(--gutter); text-align: center; }

/* Wide screens: preview beside controls */
@media (min-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas:
      "intro intro"
      "stage controls"
      "stage save"
      "stage all"
      "stage result"
      "stage howto";
    column-gap: 56px;
    align-items: start;
    padding-top: 44px;
    padding-bottom: 48px;
  }
  .intro { grid-area: intro; }
  .stage { grid-area: stage; position: sticky; top: 24px; }
  .phone { width: min(100%, calc(84vh * 1290 / 2796)); width: min(100%, calc(84dvh * 1290 / 2796)); }
  .controls { grid-area: controls; }
  .result { grid-area: result; }
  .howto { grid-area: howto; }
  #all-field { grid-area: all; }
  .savebar {
    grid-area: save;
    position: static;
    margin: 0;
    padding: 0;
    background: none;
  }
}


/* Footer */
.foot {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.foot p { margin: 0 0 6px; }
.foot a, .link-btn {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.foot a:hover, .link-btn:hover { color: var(--text); }
.link-btn {
  padding: 0;
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.foot a:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }



/* Wallpaper setup steps, shown after saving */
.howto {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.howto summary {
  padding: 11px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after {
  content: "+";
  float: right;
  color: var(--muted);
  font-weight: 400;
}
.howto[open] summary::after { content: "\2212"; }
.howto summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.howto-body { padding: 0 14px 12px; }
.howto h3 {
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.howto ol { margin: 0; padding-left: 20px; }
.howto li { margin: 2px 0; }

/* Size and Placement side by side */
.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.side-by-side .chip span { padding: 0; }
.side-hint { margin-top: -6px; }

/* Slider: a line with three stops (Frosted strength) */
.slider {
  --t: 26px;                       /* thumb size */
  position: relative;
  height: 34px;
}
.slider-line {
  position: absolute;
  left: calc(var(--t) / 2);
  right: calc(var(--t) / 2);
  top: 50%;
  height: 2px;
  background: var(--line);
  transform: translateY(-50%);
  pointer-events: none;
}
.slider-line i {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transform: translate(-50%, -50%);
}
.slider-line i:nth-child(1) { left: 0; }
.slider-line i:nth-child(2) { left: 50%; }
.slider-line i:nth-child(3) { left: 100%; }
.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.slider input[type="range"]::-webkit-slider-runnable-track { height: 34px; background: transparent; border: 0; }
.slider input[type="range"]::-moz-range-track { height: 34px; background: transparent; border: 0; }
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--t);
  height: var(--t);
  margin-top: 4px;                 /* centres the thumb on the 34px track */
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--text);
  box-shadow: 0 0 0 1px var(--muted);
}
.slider input[type="range"]::-moz-range-thumb {
  width: calc(var(--t) - 6px);
  height: calc(var(--t) - 6px);
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--text);
  box-shadow: 0 0 0 1px var(--muted);
}
.slider input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 17px; }
.slider-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}
.slider-labels span:nth-child(1) { text-align: left; }
.slider-labels span:nth-child(2) { text-align: center; }
.slider-labels span:nth-child(3) { text-align: right; }
.slider-labels span.on { color: var(--text); font-weight: 600; }

/* All 12 months: progress bar and ready state */
#all-field .outline { margin-top: 8px; }
.bar {
  height: 6px;
  margin-top: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s;
}
.ready-text { margin: 0 0 8px; font-weight: 600; }
#all-ready .link-btn { margin-top: 2px; }

/* Secondary button */
.outline {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--text);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.outline:disabled { opacity: 0.4; cursor: default; }
.outline:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One download link per month */
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.month-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.month-grid a:hover { border-color: var(--text); }
.month-grid a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
