/* Carnet de vie — papier pointé, crayon et encre. Thème clair uniquement (pour l'instant). */

:root {
  --paper: #fbf8f1;
  --paper-2: #f3ede2;
  --paper-3: #efe9dd;
  --dot: #e7e0d1;
  --line: #e2dacb;
  --outline: #cdc3b1;
  --ink: #34404f;
  --ink-2: #5a5244;
  --ink-3: #6e6555;
  --pencil: #aca291;
  --accent: #41608f;

  --serif: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --pad-x: 20px;

  color-scheme: light;
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

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

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

[hidden] {
  display: none !important;
}

/* ---------- shell ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  padding: calc(var(--safe-t) + 4px) max(var(--pad-x), var(--safe-r)) 0 max(var(--pad-x), var(--safe-l));
  position: relative;
  z-index: 5;
}

.topbar-in {
  max-width: 1200px;
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.crumb {
  min-width: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
  white-space: nowrap;
}

.crumb-text {
  display: inline-block;
  padding: 0 2px;
}

.crumb a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding-right: 10px;
  margin-left: -6px;
  color: var(--ink-3);
  text-decoration: none;
  border-radius: 22px;
  transition: color 0.2s;
}

.crumb a:hover {
  color: var(--ink);
}

.crumb a svg {
  transition: transform 0.25s var(--ease-out);
}

.crumb a:hover svg {
  transform: translateX(-2px);
}

.actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.add-link {
  height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  transition: text-underline-offset 0.25s var(--ease-out), opacity 0.2s;
}

.add-link:hover {
  text-underline-offset: 7px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  transition: background-color 0.2s, transform 0.15s var(--ease-out), opacity 0.2s;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(52, 64, 79, 0.06);
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.icon-btn:disabled {
  opacity: 0.3;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}

.view {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform-origin: 0 0;
  -webkit-overflow-scrolling: touch;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 6px max(var(--pad-x), var(--safe-r)) calc(36px + var(--safe-b)) max(var(--pad-x), var(--safe-l));
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 20px;
}

.arrows {
  display: flex;
  flex: none;
}

.title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(36px, 10vw, 52px);
  line-height: 1;
  letter-spacing: -0.005em;
}

.sub {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink-2);
}

.sub em {
  color: var(--accent);
}

.foot {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
}

/* ---------- buttons & links ---------- */

.btn {
  height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  border: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  transition: transform 0.15s var(--ease-out), filter 0.2s, background-color 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--paper);
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.btn-quiet {
  height: 44px;
  background: transparent;
  color: var(--ink-2);
  font-size: 16px;
}

.btn-quiet[data-armed] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.link {
  height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.link.inline {
  height: auto;
  padding: 0;
  font-size: inherit;
}

.quiet-link {
  align-self: flex-start;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--accent);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  padding: 8px 0;
}

/* ---------- life view ---------- */

.view-life {
  overflow: hidden;
}

.life {
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px max(var(--pad-x), var(--safe-r)) calc(14px + var(--safe-b)) max(var(--pad-x), var(--safe-l));
}

.life-intro {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intro-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lede {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-2);
}

.stats {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  order: 3;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend .c {
  --c: 8px;
}

.life-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.life-wrap::-webkit-scrollbar {
  display: none;
}

/* Short portrait phones (iPhone SE…): give the grid the room. */
@media (orientation: portrait) and (max-height: 740px) {
  .life {
    gap: 10px;
  }

  .life-intro .title {
    font-size: 34px;
  }

  .lede {
    font-size: 16px;
  }

  .legend {
    display: none;
  }

  .quiet-link {
    padding: 2px 0;
  }
}

.life-grid {
  --c: 6px;
  --g: 1.7px;
  position: relative;
  margin: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: var(--g);
  cursor: pointer;
  border-radius: 8px;
  touch-action: pan-y;
}

.life-grid:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.r {
  display: flex;
  align-items: center;
}

.r.dec {
  margin-top: var(--c);
}

.lab {
  width: 22px;
  flex: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(9px, calc(var(--c) * 1.5), 13px);
  line-height: var(--c);
  color: var(--ink-3);
  white-space: nowrap;
}

.cs {
  display: grid;
  grid-template-columns: repeat(52, var(--c));
  gap: var(--g);
}

.c {
  display: block;
  width: var(--c);
  height: var(--c);
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.75px var(--outline);
  transition: background-color 0.35s, box-shadow 0.35s, transform 0.25s var(--ease-out);
}

:root[data-future='subtle'] .c.f {
  box-shadow: inset 0 0 0 0.75px #e2dbcd;
}

.c.p {
  background: var(--pencil);
  box-shadow: none;
}

.c.p.l1 { background: color-mix(in srgb, var(--accent) 45%, var(--pencil)); }
.c.p.l2 { background: color-mix(in srgb, var(--accent) 70%, var(--pencil)); }
.c.p.l3 { background: var(--accent); }
.c.p.l4 { background: color-mix(in srgb, var(--accent) 75%, #1f2833); }

.c.f.l1 {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.c.now {
  position: relative;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.c.now.l1, .c.now.l2, .c.now.l3, .c.now.l4 {
  background: color-mix(in srgb, var(--accent) 40%, transparent);
}

.c.now::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
  opacity: 0.3;
  animation: breathe 4s var(--ease) infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.35); opacity: 0.08; }
}

.c.hover {
  transform: scale(1.7);
  box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink);
  position: relative;
  z-index: 1;
}

.c.drop {
  animation: drop 0.9s var(--ease-out);
}

@keyframes drop {
  0% { transform: scale(1); }
  30% { transform: scale(2.6); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 12px transparent; }
}

.life-grid.intro .r {
  animation: rise 0.8s var(--ease-out) both;
  animation-delay: calc(var(--ri) * 7ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}

.life-grid.inking .c.p {
  animation: ink 0.8s var(--ease-out) both;
  animation-delay: calc(var(--ri) * 16ms);
}

@keyframes ink {
  from { background-color: transparent; box-shadow: inset 0 0 0 0.75px var(--outline); transform: scale(0.4); }
}

.tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 10px)) translateY(4px);
  transition: opacity 0.15s, transform 0.22s var(--ease-out);
}

.tip.show {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 10px));
}

.tip.below {
  transform: translate(-50%, 18px) translateY(-4px);
}

.tip.below.show {
  transform: translate(-50%, 18px);
}

/* onboarding */

.birth {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.birth label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
}

.birth-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
}

.birth-row input {
  flex: 1 1 170px;
}

.birth .btn {
  height: 46px;
  font-size: 17px;
}

.birth .hint {
  margin: 0;
}

.shake {
  animation: shake 0.45s var(--ease-out);
}

@keyframes shake {
  20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}

/* two columns when there is room beside the grid */
@media (min-width: 960px), (orientation: landscape) and (min-width: 640px) {
  .life {
    flex-direction: row;
    align-items: stretch;
    gap: clamp(24px, 4vw, 64px);
  }

  .life-intro {
    width: clamp(220px, 28%, 340px);
    justify-content: center;
    gap: 12px;
  }

  .legend {
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .life-intro .title {
    font-size: 34px;
  }

  .lede {
    font-size: 15px;
  }
}

/* ---------- year view ---------- */

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.yc {
  position: relative;
  height: 46px;
  border: 0;
  border-radius: 7px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  background: var(--paper-3);
  color: var(--ink);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s, background-color 0.35s;
}

.yc b {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  line-height: 1;
}

.yc span {
  font-size: 11px;
  line-height: 1;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.yc.f {
  background: var(--paper);
  box-shadow: inset 0 0 0 1px #ded5c5;
}

.yc.f b,
.yc.f span {
  color: var(--ink-3);
}

.yc.l1 { background: color-mix(in srgb, var(--accent) 16%, var(--paper)); }
.yc.l2 { background: color-mix(in srgb, var(--accent) 28%, var(--paper)); }
.yc.l3 { background: color-mix(in srgb, var(--accent) 40%, var(--paper)); }
.yc.l4 { background: color-mix(in srgb, var(--accent) 52%, var(--paper)); }

.yc.l3 span,
.yc.l4 span {
  color: var(--ink);
}

.yc.f.l1 {
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.yc.f.l1 b {
  color: var(--accent);
}

.yc.now {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--accent);
}

@media (hover: hover) {
  .yc:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -10px rgba(52, 64, 79, 0.45);
  }

  .yc.f:hover {
    box-shadow: inset 0 0 0 1px #d2c8b6, 0 8px 16px -10px rgba(52, 64, 79, 0.35);
  }

  .yc.now:hover {
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--accent), 0 10px 18px -10px rgba(52, 64, 79, 0.45);
  }
}

.yc:active {
  transform: scale(0.97);
}

.yc.drop {
  animation: tile-drop 0.9s var(--ease-out);
}

@keyframes tile-drop {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px transparent; }
}

@media (min-width: 720px) {
  .view-year .page {
    max-width: 1120px;
  }

  .year-grid {
    grid-template-columns: repeat(13, minmax(0, 1fr));
    gap: 8px;
  }

  .yc {
    height: auto;
    aspect-ratio: 1 / 1.1;
    padding: 9px;
  }

  .yc b {
    font-size: 20px;
  }

  .yc span {
    font-size: 11.5px;
  }
}

/* ---------- week view ---------- */

.days {
  list-style: none;
  margin: 0;
  padding: 0;
}

.day {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 8px 4px 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.day.today {
  background: var(--paper-2);
  border-radius: 10px;
  border-bottom-color: transparent;
}

.dn {
  width: 64px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dn small {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}

.dn span {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
}

.day.later .dn span {
  color: var(--ink-3);
}

.ev {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.tag {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.evt {
  max-width: 100%;
  border: 0;
  background: none;
  padding: 3px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.3;
  color: var(--accent);
  text-align: left;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s;
}

.evt:hover {
  text-decoration-color: currentColor;
}

.evt.writing {
  animation: write 0.9s var(--ease-out) both;
}

@keyframes write {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.add-day {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 22px;
  border: 0;
  background: transparent;
  color: #8a8070;
  display: grid;
  place-items: center;
  transition: background-color 0.2s, color 0.2s, transform 0.15s var(--ease-out);
}

.add-day:hover {
  background: rgba(52, 64, 79, 0.06);
  color: var(--accent);
}

.add-day:active {
  transform: scale(0.9);
}

@media (min-width: 720px) {
  .view-week .page {
    max-width: 700px;
  }

  .day {
    min-height: 80px;
  }
}

/* ---------- sheets ---------- */

.sheet {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
  color: var(--ink);
}

.sheet::backdrop {
  background: transparent;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(52, 64, 79, 0.24);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100% - 24px - var(--safe-t));
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(transparent 0 31px, #efe8da 31px 32px);
  border-radius: 24px 24px 0 0;
  padding: 10px max(24px, var(--safe-r)) calc(26px + var(--safe-b)) max(24px, var(--safe-l));
  box-shadow: 0 -16px 40px -16px rgba(52, 64, 79, 0.35);
  transform: translateY(105%);
  transition: transform 0.5s var(--ease-out);
}

.sheet.open .sheet-scrim {
  opacity: 1;
}

.sheet.open .sheet-panel {
  transform: none;
}

.sheet.closing .sheet-panel {
  transition: transform 0.3s var(--ease);
}

.sheet-grip {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #ddd3c2;
  margin: 0 auto 12px;
}

.sheet-body {
  max-width: 560px;
  margin: 0 auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  touch-action: none;
}

.sheet-title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 30px;
  line-height: 1.05;
}

@media (min-width: 720px) {
  .sheet-panel {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(480px, calc(100% - 48px));
    max-height: calc(100% - 64px);
    border-radius: 22px;
    padding: 26px 32px 30px;
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.98);
    transition: transform 0.45s var(--ease-out), opacity 0.3s;
  }

  .sheet.open .sheet-panel {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  .sheet.closing .sheet-panel {
    transition: transform 0.25s var(--ease), opacity 0.2s;
  }

  .sheet-grip {
    display: none;
  }
}

/* ---------- forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > label,
.field > legend {
  padding: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-2);
}

.field > legend {
  margin-bottom: 8px;
}

input[type='date'],
input[type='text'] {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 0;
  border-bottom: 1px solid var(--outline);
  border-radius: 0;
  background: transparent;
  padding: 0 2px;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type='date']::-webkit-date-and-time-value {
  text-align: left;
}

input[type='date']:focus,
input[type='text']:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

input::placeholder {
  color: #8a8070;
  font-style: italic;
}

.hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-3);
}

.form-error {
  margin: -6px 0 0;
  font-size: 13.5px;
  color: #8a4b2e;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seg label {
  position: relative;
}

.seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px var(--outline);
  font-size: 14px;
  color: var(--ink-2);
  background: var(--paper);
  transition: background-color 0.25s, color 0.25s, box-shadow 0.25s;
}

.seg input:checked + span {
  background: var(--ink);
  color: var(--paper);
  box-shadow: none;
}

.seg input:focus-visible + span,
.swatch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.swatch {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.swatch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px transparent;
  transition: box-shadow 0.25s, transform 0.25s var(--ease-out);
}

.swatch.custom span {
  background: conic-gradient(from 90deg, #c77d5a, #b8a25b, #6f9a72, #5a87a8, #8a6fa5, #c77d5a);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px transparent;
}

.swatch.custom input:checked + span {
  background: var(--sw);
}

.swatch input:checked + span {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink);
  transform: scale(1.06);
}

.color-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  border: 0;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--outline);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.chip-btn:hover {
  background: var(--paper-2);
}

.chip-btn.armed {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.settings-foot {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- toast ---------- */

.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(20px + var(--safe-b));
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 8px 0 18px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 12px 30px -12px rgba(52, 64, 79, 0.55);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.45s var(--ease-out), opacity 0.3s;
}

.toast:not(:has(button)) {
  padding-right: 18px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast button {
  height: 36px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: #c9d6ea;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- small phones ---------- */

@media (max-width: 360px) {
  :root {
    --pad-x: 14px;
  }

  .yc {
    padding: 5px 6px;
  }

  .dn {
    width: 56px;
  }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
