/* Fontit ovat sovelluksen mukana (SIL Open Font License, ks. fonts/), jotta ne toimivat myös ilman verkkoa. */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/montserrat-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/montserrat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Satisfy"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/satisfy-latin-400-normal.woff2") format("woff2"); }

:root {
  --beige: #efe7dc;
  --paper: #f7f2ea;
  --blue: #adc1c2;
  --blue-deep: #7f9c9e;
  --gold: #9a6d3a;
  --gold-deep: #7e5a30;
  --ink: #574e47;
  --ink-soft: #7c726a;
  --line: rgba(126, 90, 48, 0.18);
  --shadow: 0 1px 2px rgba(70, 50, 30, 0.08), 0 10px 28px -10px rgba(70, 50, 30, 0.28);
  --radius: 18px;
  --tabbar-h: 64px;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --script: "Satisfy", "Brush Script MT", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--beige);
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; height: auto; }

a { color: inherit; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  outline: none;
}

body[data-view="main"] main,
body[data-locked] main,
body[data-splash] main { padding-top: calc(16px + env(safe-area-inset-top)); }

/* ---------- Yläpalkki ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  background: color-mix(in srgb, var(--beige) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar[hidden] { display: none; }

.topbar-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font: 400 30px/1 var(--script);
  color: var(--gold);
}

.icon-btn, .icon-btn-spacer {
  width: 44px;
  height: 44px;
  flex: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}

.icon-btn:active { background: var(--line); }

.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Alavalikko ---------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: 12px;
}

.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.tabbar a[aria-current] { color: var(--gold); }
.tabbar a[aria-current] svg { stroke-width: 2; }

/* ---------- Painikkeet ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 20px;
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold-deep);
  font-weight: 500;
  font-size: 16px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

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

.btn.primary { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.primary:active { background: var(--gold-deep); }

.btn.ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }

/* ---------- Etusivu ---------- */

.cover {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(100%, 34dvh, 320px);
  margin: 0 auto;
}

.lead {
  margin: 0;
  text-align: center;
  font-size: 17px;
  color: var(--ink);
  text-wrap: balance;
}


/* ---------- Kääntyvä kortti ---------- */

.flip {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1400px;
  animation: deal 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--delay, 0ms);
}

.flip-inner {
  position: relative;
  display: block;
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.flip.flipped .flip-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face-back { transform: rotateY(180deg); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

.face-back, .guide-card { outline: 1px solid var(--line); outline-offset: -1px; }

/* Englanninkielinen taustapuoli kirjoitetaan kortille samaan tyyliin kuin painetussa kortissa. */
.face-text {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6%;
  padding: 10% 14%;
  background: #f1e8dd;
  color: var(--gold);
  text-align: center;
  line-height: 1.3;
  text-wrap: balance;
}

/* Koko kortin leveydestä (cqw viittaa .face-textiin vain sen sisällä). Pitkä teksti pienemmällä. */
.face-text > span { font-size: 12cqw; }
.face-text.pitka > span { font-size: 9.5cqw; }

.face-text img { position: absolute; top: 6%; left: 50%; translate: -50% 0; width: 9%; height: auto; border-radius: 50%; }

@keyframes deal {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .flip { animation: none; }
  .flip-inner { transition: none; }
}

.caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 12px 0 0;
}

.name {
  font: 400 30px/1.2 var(--script);
  color: var(--gold);
  text-align: center;
}

.fav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--gold);
  cursor: pointer;
}

.fav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; transition: transform 0.2s ease; }
.fav[aria-pressed="true"] svg { fill: currentColor; animation: pop 0.3s ease; }

@keyframes pop { 50% { transform: scale(1.25); } }

.hint {
  margin: 4px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---------- Ohjattu valinta ---------- */


.hetki-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.hetki-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-size: 15.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Kipinä vaihtoehdon edessä; valittuna tilalle tulee kultainen valintamerkki. Valitaan yksi. */
.hetki-option::before {
  content: "✨";
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  transition: background-color 0.15s ease;
}

.hetki-option[aria-pressed="true"] { border-color: var(--gold); background: #fff; color: var(--gold-deep); }
.hetki-option[aria-pressed="true"]::before {
  content: "";
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.hetki-intro p + p { margin-top: 10px; }

/* Ryhmät: itseni ja suhde toiseen. Avoimen ryhmän vaihtoehdot näkyvät painikkeiden alla. */
.hetki-ryhmat { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 16px; }

.hetki-ryhma {
  min-height: 64px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.hetki-ryhma[aria-expanded="true"] { border-color: var(--gold); background: var(--gold); color: #fff; }
#hetki-ryhmat { scroll-margin-top: calc(12px + env(safe-area-inset-top)); }
.hetki-question { margin: 4px 0 4px; text-align: center; font-size: 18px; font-weight: 600; color: var(--gold-deep); }
.hetki-note { margin: 0 auto 14px; max-width: 36ch; text-align: center; font-size: 14px; color: var(--ink-soft); text-wrap: pretty; }

/* Valitut hetket valinnan, tallennuksen ja tallennetun yläosassa */
.hetki-line { margin: 0 auto 4px; max-width: 36ch; text-align: center; font-size: 15px; color: var(--gold-deep); }
.hetki-line .eyebrow { display: block; margin-bottom: 2px; }
.hetki-name { display: block; margin-bottom: 4px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.hetki-name + .hetki-item { font-size: 14px; color: var(--ink-soft); }
.hetki-item { display: block; }
.hetki-item + .hetki-item { margin-top: 4px; }

/* ---------- Vaiheet ---------- */

.wizard { display: flex; flex-direction: column; padding-bottom: 64px; }

.stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 0 0 22px;
  padding: 0;
}

.stepper button {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.stepper button:disabled { opacity: 0.45; cursor: default; }
.stepper .skipped .step-dot { border-style: dashed; } /* lahjavalinnassa kuorivaihe ohitetaan */

.step-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
}

.stepper .done { color: var(--gold-deep); }
.stepper .done .step-dot { border-color: var(--gold); color: var(--gold-deep); }
.stepper [aria-current="step"] { color: var(--gold-deep); font-weight: 600; }
.stepper [aria-current="step"] .step-dot { background: var(--gold); border-color: var(--gold); color: #fff; }

/* Edellinen ja Seuraava pysyvät alareunassa alavalikon yläpuolella. */
.step-bar {
  position: fixed;
  inset: auto 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom)) 0;
  z-index: 9;
  display: flex;
  gap: 12px;
  padding: 10px max(16px, calc(50% - 264px));
  background: color-mix(in srgb, var(--beige) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.step-bar .btn { min-height: 42px; padding: 6px 20px; font-size: 15px; }
.step-bar #step-next { margin-left: auto; }
.step-bar .btn:disabled { opacity: 0.45; cursor: default; }

.wizard .intro h2 { font-size: 32px; }
.wizard > .btn.ghost { margin-top: 12px; }
.wizard > .btn.reset { margin-top: 20px; color: var(--ink-soft); }
.wizard .hetki-line { margin-bottom: 12px; }

.outro { margin-top: 24px; text-align: center; color: var(--ink-soft); font-size: 15px; }
.outro p { margin: 0 auto; max-width: 34ch; text-wrap: pretty; }
.motto { margin-top: 10px !important; font: 400 28px/1.2 var(--script); color: var(--gold); }

.shell.medium { max-width: 300px; }

.yhteys-intro { margin: 28px 0 16px; }

.yhteys {
  margin-bottom: 24px;
  padding: 20px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15.5px;
}

.yhteys h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--gold-deep); }
.yhteys p { margin: 0 0 10px; text-wrap: pretty; }
.yhteys p + h3 { margin-top: 20px; }
.yhteys > :last-child { margin-bottom: 0; }

.saved-detail { display: flex; flex-direction: column; }

.intro { margin-bottom: 20px; text-align: center; }

.intro h2 {
  margin: 0 0 6px;
  font: 400 36px/1.15 var(--script);
  color: var(--gold);
}

.intro p, .intro-text { margin: 0 auto; max-width: 36ch; color: var(--ink); font-size: 15.5px; text-wrap: pretty; }
.intro-text { margin-bottom: 14px; text-align: center; color: var(--ink-soft); }
.intro em { font-style: normal; font-weight: 600; color: var(--gold-deep); }

.saved-detail .eyebrow { margin-top: 20px; }

.btn.small { min-height: 40px; padding: 6px 16px; font-size: 14.5px; align-self: center; }


.eyebrow {
  margin: 0 0 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Selaus ---------- */

.page-title {
  margin: 4px 0 16px;
  text-align: center;
  font: 400 40px/1.15 var(--script);
  color: var(--gold);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.segmented a {
  padding: 10px 4px;
  font-size: 15px;
  white-space: nowrap;
  border-radius: 999px;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  color: var(--ink-soft);
}

.segmented a span { opacity: 0.7; font-weight: 400; margin-left: 2px; }

.segmented a[aria-selected="true"] { background: var(--gold); color: #fff; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
}

@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: none;
  cursor: pointer;
}

.tile-img { position: relative; display: block; }

.tile-img img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--blue);
}

.tile:active .tile-img { transform: scale(0.98); }

.tile[data-chosen] .tile-img img { opacity: 0.55; }
.tile[data-chosen] .tile-name { color: var(--gold-deep); font-weight: 500; }

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  box-shadow: 0 2px 6px rgba(70, 50, 30, 0.3);
}

.badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.add-box {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1.5px dashed var(--gold);
  border-radius: 12px;
  background: var(--paper);
  color: var(--gold);
  font-size: 44px;
  font-weight: 300;
  line-height: 1;
}

.add-tile .tile-name { color: var(--gold-deep); font-weight: 500; }

.tile-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13.5px;
  text-align: center;
  color: var(--ink);
  line-height: 1.3;
}

.tile-fav svg { width: 13px; height: 13px; fill: var(--gold); stroke: none; display: block; }

/* ---------- Kortin katselu ---------- */

.viewer { display: flex; flex-direction: column; }

.viewer .flip { touch-action: pan-y; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.pager .icon-btn { border: 1.5px solid var(--line); }

.pager-pos { min-width: 64px; text-align: center; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- Suosikit / tyhjä ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 12px;
  text-align: center;
  color: var(--ink-soft);
}

.empty p { margin: 0; max-width: 30ch; }

.empty-icon svg { width: 44px; height: 44px; fill: none; stroke: var(--gold); stroke-width: 1.2; }

/* ---------- Ohjeet ---------- */

.guide { display: flex; flex-direction: column; gap: 16px; }

.guide-card { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }

/* Englanninkielinen ohjekortti tekstinä (kuvan teksti on suomeksi). */
.guide-text {
  position: relative;
  padding: 44px 26px 26px;
  background: #f1e8dd;
  color: var(--gold-deep);
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.55;
}

.guide-text img { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border-radius: 50%; }
.guide-text p { margin: 0; text-wrap: pretty; }
.guide-text p + p { margin-top: 12px; }

/* Kielen vaihto: aloitus- ja lukitusnäytöllä sekä Ohjeet-sivulla */
.lang-switch { display: flex; justify-content: center; gap: 6px; }

.lang-switch button {
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
}

.lang-switch [aria-pressed="true"] { border-color: var(--gold); background: var(--paper); color: var(--gold-deep); font-weight: 600; }

body[data-splash] .lang-switch button { border-color: rgba(63, 56, 51, 0.25); color: #3f3833; }
body[data-splash] .lang-switch [aria-pressed="true"] { background: rgba(255, 255, 255, 0.5); border-color: var(--gold); color: var(--gold-deep); }

.note {
  padding: 20px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}

.note h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; color: var(--gold-deep); }
.note p { margin: 8px 0 0; }

.signature { margin: 8px 0 0; text-align: center; font-size: 20px; letter-spacing: 0.02em; color: var(--gold); }

/* ---------- Esikatselupaneeli ---------- */

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 94dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--beige);
  color: var(--ink);
  box-shadow: 0 -10px 40px rgba(40, 30, 20, 0.25);
  overflow: auto;
  overscroll-behavior: contain;
}

.sheet[open] { animation: sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }

.sheet::backdrop { background: rgba(50, 40, 30, 0.45); }

@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

@media (min-width: 600px) {
  .sheet { margin: auto; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open] { animation: none; }
}

.sheet-body {
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}

.sheet-body .flip { max-width: min(340px, 44dvh); margin: 0 auto; animation: none; }

.sheet-body .caption { margin-top: 8px; }

.sheet-actions { display: grid; gap: 8px; margin-top: 12px; }

/* ---------- Tallennuslomake ---------- */

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

.mini-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.mini-row img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mini-caption { margin: -6px 0 4px; text-align: center; font-size: 14px; color: var(--ink-soft); }

.field { display: flex; flex-direction: column; gap: 6px; }

.field > :is(span, label):first-child { font-size: 14px; font-weight: 600; color: var(--gold-deep); letter-spacing: 0.02em; }

.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* estää iOS:n automaattisen zoomauksen */
}

.field textarea { resize: vertical; min-height: 140px; line-height: 1.5; }

.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }

.field input[aria-invalid] { border-color: #b4553c; }

.field-error { font-size: 13.5px; color: #a1452e; }

/* Hetki 2/2: nimiehdotukset ja apukysymykset kentän yläpuolella */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.suggest-label { width: 100%; font-size: 13.5px; color: var(--ink-soft); }

.suggest-chip {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.suggest-chip[aria-pressed="true"] { border-color: var(--gold); background: #fff; color: var(--gold-deep); }

/* Yhteys-vaiheen yhteenveto hetkestä ennen tallennusta */
.hetki-summary { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hetki-summary .selite { align-self: stretch; margin: 10px 0 16px; }
.hetki-summary .link-btn { margin-top: 4px; }

/* ---------- Tallennetut ---------- */

.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.saved-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  text-decoration: none;
}

.saved-item:active { background: #f2ebe1; }

.saved-thumbs { flex: none; }

.saved-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.saved-name { font-weight: 600; font-size: 16.5px; color: var(--gold-deep); overflow-wrap: anywhere; }

.saved-meta { font-size: 13px; color: var(--ink-soft); }

.saved-desc {
  margin-top: 2px;
  font-size: 14px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.device-note { margin: 20px 0 0; text-align: center; font-size: 13px; color: var(--ink-soft); }

.detail-head { text-align: center; margin-bottom: 8px; }

.detail-title {
  margin: 4px 0 2px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--gold-deep);
  overflow-wrap: anywhere;
}

.meta { margin: 0; font-size: 13.5px; color: var(--ink-soft); }

.selite {
  margin: 16px 0 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-actions { display: grid; gap: 8px; margin-top: 28px; }

.btn.danger { color: #a1452e; }

.saved-detail > .flip { max-width: min(100%, 300px); margin: 0 auto; }

/* ---------- Lukitus ---------- */

body[data-locked] .tabbar { display: none; }

body[data-locked] main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

/* Salattu kuva näkyy vasta, kun se on purettu; sitä ennen ei näytetä alt-tekstiä. */
img[data-src] { color: transparent; }

.lock { display: flex; flex-direction: column; gap: 24px; }

.lock-lead { margin: 0; text-align: center; font-size: 16.5px; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}

.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); }

.btn:disabled { opacity: 0.7; cursor: progress; }

.lock .field-error { margin: -6px 0 0; }

/* Pääsykoodi on sähköpostikirjautumisen vaihtoehto, joten se avataan erikseen. */
.code-login { border-top: 1px solid var(--line); padding-top: 8px; }

.code-login summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  list-style: none;
  cursor: pointer;
  color: var(--gold-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.code-login summary::-webkit-details-marker { display: none; }

.code-login[open] summary { margin-bottom: 12px; }

.test-env {
  margin: 0;
  padding: 8px 12px;
  border: 1px dashed var(--gold);
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--gold-deep);
}

.guide .test-env { margin-top: 24px; }

.logged-in { margin: 24px 0 0; text-align: center; font-size: 14.5px; color: var(--ink-soft); }

/* ---------- Aloitusnäyttö ---------- */

body[data-splash] { background: var(--blue); }

body[data-splash] main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.splash {
  min-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

/* Kansikuvan tausta on sama sininen kuin näytön tausta, joten logo sulautuu siihen. */
.splash-cover { width: min(100%, 52dvh, 440px); }

.splash-logo { display: block; width: 100%; height: auto; }

/* Kaareva otsikko kansikuvan päällä samassa kohdassa kuin painetussa kannessa */
.cover-art { position: relative; }

.cover-title { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.cover-title text { font-family: var(--sans); font-weight: 400; fill: var(--gold); }
.cover-title-fi text { font-size: 80px; letter-spacing: -4px; }
.cover-title-en text { font-size: 61px; letter-spacing: -2px; }

/* Iskulause kansikuvan alla samassa fontissa ja värissä kuin kuvan otsikko; koko seuraa kuvan leveyttä. */
.splash-tagline {
  margin: 0.4em 0 0;
  font-size: calc(min(100vw - 40px, 52dvh, 440px) * 0.05);
  line-height: 1.2;
  color: var(--gold);
}

/* Iskulauseen jälkeen yksi tyhjä rivi (1.5em = tekstin rivinkorkeus) */
.splash-text {
  margin: 1.5em 0 0;
  max-width: 30ch;
  font-size: 17px;
  line-height: 1.5;
  color: #3f3833;
  text-wrap: balance;
}

.splash-btn { width: min(100%, 320px); margin-top: 8px; }

.splash-note { margin: -8px 0 0; font-size: 15px; color: #3f3833; }

.home-head { display: flex; flex-direction: column; align-items: center; }

.home-head .page-title { margin: 10px 0 0; }

.logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }

/* ---------- Simpukka ja helmet ---------- */

.shell {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--blue);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.shell-img { width: 100%; height: 100%; }

.pearl {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--d);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue-deep);
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 8px rgba(40, 55, 55, 0.35);
  transition: left 0.6s cubic-bezier(0.3, 0.8, 0.3, 1), top 0.6s cubic-bezier(0.3, 0.8, 0.3, 1),
    width 0.6s cubic-bezier(0.3, 0.8, 0.3, 1);
}

button.pearl { cursor: pointer; }

.pearl img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* Kevyt valo ja varjo tekevät valokuvasta pyöreän helmen näköisen. */
.pearl::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.22) 100%);
}

.pearl.drop { animation: pearl-drop 0.8s cubic-bezier(0.25, 1.35, 0.5, 1) both; }

@keyframes pearl-drop {
  0% { transform: translate(-50%, -320%) scale(0.6); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pearl { transition: none; }
  .pearl.drop { animation: none; }
}

.shell.small { max-width: 200px; }

.shell.mini { width: 76px; border-radius: 12px; box-shadow: 0 1px 4px rgba(70, 50, 30, 0.25); }
.shell.mini .pearl { box-shadow: 0 1px 2px rgba(40, 55, 55, 0.35); }

.shell-head { text-align: center; }

.shell-name { margin: -4px 0 12px; font: 400 34px/1.15 var(--script); color: var(--gold); }

.pearl-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

.pearl-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  cursor: pointer;
}

.pearl-chip img { width: 30px; height: 30px; border-radius: 50%; }

.add-pearl { margin-top: 16px; }

.shell-links { display: flex; justify-content: center; gap: 20px; margin-top: 4px; }

.link-btn {
  padding: 10px 4px;
  border: 0;
  background: none;
  color: var(--gold-deep);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Helmien valinta ---------- */

/* Simpukka ja Hetki-teksti pysyvät näkyvissä, kun helmilistaa vieritetään. */
.stage {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(120px, 42%) 1fr;
  gap: 14px;
  align-items: center;
  margin: 0 -16px 16px;
  padding: 8px 16px 12px;
  background: var(--beige);
  box-shadow: 0 12px 12px -14px rgba(70, 50, 30, 0.45);
}

.stage .shell { max-width: none; }

@media (max-height: 620px) {
  .stage { position: static; box-shadow: none; }
}

.pearl-info { min-height: 5.5em; font-size: 14.5px; line-height: 1.45; }
.pearl-info p { margin: 0; }
.pearl-info-name { margin-bottom: 2px !important; font: 400 26px/1.15 var(--script); color: var(--gold); }
.pearl-info-text { color: var(--ink); text-wrap: pretty; }
.pearl-info-hint { color: var(--ink-soft); font-size: 14px; }
.pearl-info-hint strong { color: var(--gold-deep); font-weight: 600; }

/* Helmiryhmän otsikko helmivalinnassa ja selauksessa */
.pearl-group { margin: 28px 0 12px; text-align: center; font-size: 18px; font-weight: 600; color: var(--gold-deep); }
.pearl-group:first-of-type { margin-top: 20px; }

.pearl-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 10px;
  margin: 0;
  padding: 0;
}

@media (min-width: 480px) {
  .pearl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pearl-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.pearl-pick-name {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 2.5em;
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
}

.pearl-pick-img {
  position: relative;
  width: min(100%, 92px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--blue-deep);
  box-shadow: 0 3px 8px rgba(40, 55, 55, 0.3);
  transition: transform 0.15s ease;
}

.pearl-pick-img img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.pearl-pick-img::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.22) 100%);
}

.pearl-pick:active .pearl-pick-img { transform: scale(0.94); }

.pearl-pick[aria-pressed="true"] .pearl-pick-img { outline: 3px solid var(--gold); outline-offset: 3px; }
.pearl-pick[aria-pressed="true"] .pearl-pick-name { color: var(--gold-deep); font-weight: 600; }

.pearl-pick .badge { top: -4px; right: -4px; z-index: 1; }



/* ---------- Ilmaisversio ja koko pakka (sovellus) ---------- */

.badge.lock { background: var(--paper); color: var(--gold-deep); }
.badge.lock svg { stroke-width: 1.8; }

.tile[data-locked] .tile-img img,
.pearl-pick[data-locked] .pearl-pick-img img { opacity: 0.5; filter: grayscale(0.6); }
.tile[data-locked] .tile-name,
.pearl-pick[data-locked] .pearl-pick-name { color: var(--ink-soft); }

.pro h2 { margin: 2px 0 10px; color: var(--gold-deep); }
.pro p { margin: 0 0 10px; }

.pro-reason {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--gold-deep);
  font-weight: 500;
}

.pro-reason .link-btn { padding: 4px 0; font-weight: 500; }

.pro-list { display: grid; gap: 8px; margin: 4px 0 12px; padding: 0; list-style: none; }
.pro-list li { display: flex; gap: 10px; align-items: flex-start; }
.pro-list svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.pro-note { margin-top: 12px; font-size: 13.5px; color: var(--ink-soft); text-align: center; }

.pro-page .page-title { margin: 0; }

.plans { display: grid; gap: 8px; margin: 4px 0 8px; }

.plan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.plan:active { transform: scale(0.98); }
.plan:disabled { opacity: 0.6; }
.plan-name { font-weight: 600; }
.plan-price { font-weight: 600; color: var(--gold-deep); white-space: nowrap; }
.plan-note { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-soft); }

.plan-main { border: 2px solid var(--gold); }

.pro-code-link { display: block; margin: 4px auto 0; font-size: 14px; }
.pro-code { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pro-code[hidden], .pro-code-link[hidden] { display: none; }
