/* Ransu 3.1: lämmin musta, hillityt kulmat, selkeät rivit, alapalkki kuvakkeilla. */
:root {
  --bg: #0D0C0B;
  --card: #181715;
  --card-2: #211F1D;
  --line: rgba(255, 248, 235, .07);
  --ink: #F4F1EA;
  --soft: #C2BDB4;
  --muted: #8C877F;
  --coral: #E8892F;
  --coral-hi: #F2A055;
  --coral-tint: rgba(232, 137, 47, .14);
  --dark: #14110E;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: #0D0C0B; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: pan-y; scrollbar-width: none; overscroll-behavior-y: none; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg);
  overscroll-behavior-y: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-font-smoothing: antialiased;
}
input, textarea, .quote, .info .v { -webkit-user-select: text; user-select: text; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { font-size: 16px; }
button { cursor: pointer; }
a, button { -webkit-touch-callout: none; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
svg { display: block; }

#app {
  max-width: 520px; min-height: 100dvh; margin: 0 auto; position: relative; background: var(--bg);
  padding: env(safe-area-inset-top) 18px calc(104px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { #app { box-shadow: 0 0 80px rgba(0, 0, 0, .6); } }

/* ---------- Yläpalkki ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 10px 0 6px; }
.bar-brand { display: flex; align-items: center; gap: 8px; }
.bar-brand svg { height: 22px; width: auto; }
.bar-right { display: flex; align-items: center; gap: 4px; }
.plain-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--ink); border-radius: var(--r-sm); }
.plain-btn svg { width: 24px; height: 24px; }
.plain-btn:active { background: var(--card); }
.back { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 8px 0 0; border: 0; background: none; color: var(--ink); font-weight: 600; }
.back svg { width: 22px; height: 22px; }
.demo-tag { padding: 3px 8px; border-radius: 6px; background: var(--coral-tint); color: var(--coral-hi); font-size: 11px; font-weight: 700; }

/* ---------- Haku ---------- */
.search { position: relative; margin: 4px 0 14px; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 50px; padding: 0 14px 0 44px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); outline: none; }
.search input:focus { border-color: var(--coral); }
.search input::placeholder { color: var(--muted); }

/* ---------- Hero (kuten lompakkosovelluksen pääkortti) ---------- */
.hero { margin: 8px 0 26px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid rgba(232, 137, 47, .28); }
.hero-top {
  background: radial-gradient(110% 90% at 50% 0%, #2E2219 0%, #1A1714 60%, #141210 100%);
  padding: 22px 20px 20px; text-align: center; display: grid; justify-items: center; gap: 4px;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6);
}
.hero-label { font-size: 14px; font-weight: 600; color: var(--soft); }
.hero-num { font-size: 72px; line-height: 1; font-weight: 700; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.hero-sub { color: var(--muted); font-size: 14px; font-weight: 500; }
.faces { display: flex; margin-top: 14px; }
.face { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: #E9C9A4; color: var(--dark); border: 2px solid #1A1714; margin-left: -8px; }
.face:first-child { margin-left: 0; background: #F4F1EA; }
.face:nth-child(2) { background: #F0B47A; }
.face.more { background: #3A3530; color: var(--ink); font-size: 13px; }
.hero-cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 0 16px;
  background: none; border: 0; color: var(--dark); font-weight: 700; font-size: 16px; text-decoration: none;
}
.hero-cta svg { width: 18px; height: 18px; }
.hero-cta.static { font-weight: 600; }

/* ---------- Osion otsikko ---------- */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 2px 12px; }
.sec-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; }
.sec-title.small { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 2px 10px; }
.sec-count { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--card); border-radius: 6px; padding: 2px 8px; }
.sec-meta { font-size: 13px; color: var(--muted); }

/* ---------- Pyyntörivit (kuten tapahtumalista) ---------- */
.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%;
  padding: 14px; border: 0; border-radius: var(--r-md); text-align: left; color: var(--ink);
  background: linear-gradient(90deg, var(--tint) 0%, var(--card) 55%);
}
.row:active { filter: brightness(1.12); }
.row-av { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 17px; background: var(--dot); color: var(--dark); }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-msg { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: grid; justify-items: end; gap: 4px; }
.row-time { font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.row-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); display: block; }
.row-status.big { font-size: 14px; height: 34px; padding: 0 12px; border-radius: var(--r-sm); background: var(--card); }
.row-status.big i { width: 9px; height: 9px; }

[data-tila="uusi"]       { --dot: #E8892F; --tint: rgba(232, 137, 47, .16); }
[data-tila="yhteydessa"] { --dot: #8BA3B8; --tint: rgba(139, 163, 184, .13); }
[data-tila="tarjous"]    { --dot: #E3C065; --tint: rgba(227, 192, 101, .12); }
[data-tila="kauppa"]     { --dot: #84B37A; --tint: rgba(132, 179, 122, .14); }
[data-tila="havitty"]    { --dot: #D4645A; --tint: rgba(212, 100, 90, .14); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--card); border-radius: var(--r-md); }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 18px; }
.empty p { margin: 0 auto; max-width: 30ch; }

/* ---------- Alapalkki ---------- */
.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: #100F0E;
  border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 4px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab-ic { position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--coral); }
.tabs-brand { display: none; }
.tab-badge { position: absolute; top: -6px; right: -12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--coral); color: var(--dark); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }

/* ---------- Liidin sivu ---------- */
.sheet { }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .toast { transition: none !important; } }
.d-name { margin: 10px 2px 16px; font-size: 32px; line-height: 1.08; font-weight: 700; letter-spacing: -.8px; }
.panel { background: var(--card); border-radius: var(--r-md); padding: 16px; }
.list-panel { padding: 0 16px; }
.info { padding: 14px 0; display: grid; gap: 2px; }
.info + .info { border-top: 1px solid var(--line); }
.k { color: var(--muted); font-size: 13px; font-weight: 600; }
.info .v { font-size: 16px; font-weight: 600; word-break: break-word; }
.acts { display: grid; gap: 8px; margin-top: 14px; }
.btn-main {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; border-radius: var(--r-md); border: 0;
  background: var(--coral); color: var(--dark); text-decoration: none; font-weight: 700; font-size: 17px;
}
.btn-main svg { width: 20px; height: 20px; }
.btn-main:active { filter: brightness(.92); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row.one { grid-template-columns: 1fr; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; border-radius: var(--r-md); background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; }
.btn svg { width: 19px; height: 19px; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.btn-ghost { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; border-radius: var(--r-md); background: var(--card); border: 0; font-weight: 600; margin-top: 16px; }
.btn-ghost svg { width: 19px; height: 19px; }
.d-block { margin-top: 24px; }
.states { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.state-btn { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: var(--r-sm); background: var(--card); border: 1px solid transparent; font-weight: 600; text-align: left; }
.state-btn i { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex: none; }
.state-btn[aria-pressed="true"] { border-color: var(--dot); background: var(--tint); }
.note { width: 100%; min-height: 110px; padding: 14px; resize: vertical; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); outline: none; }
.note:focus { border-color: var(--coral); }
.note::placeholder { color: var(--muted); }
.hint { margin: 8px 2px 0; color: var(--muted); font-size: 13px; }
.quote { margin: 0; padding: 16px; background: var(--card); border-radius: var(--r-md); white-space: pre-wrap; line-height: 1.5; }
details.bot { background: var(--card); border-radius: var(--r-md); }
details.bot summary { padding: 16px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.bot summary::-webkit-details-marker { display: none; }
details.bot summary svg { width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
details.bot[open] summary svg { transform: rotate(90deg); }
details.bot .quote { border-top: 1px solid var(--line); border-radius: 0 0 var(--r-md) var(--r-md); }

/* ---------- Yhteenveto ---------- */
.weeks { width: 100%; height: auto; }
.weeks text { font-family: var(--font); font-size: 11px; fill: #8C877F; font-weight: 600; }
.weeks .val { fill: var(--ink); font-weight: 700; font-size: 12px; }
.funnel { display: grid; gap: 16px; }
.f-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; font-weight: 600; }
.f-row span { display: inline-flex; align-items: center; gap: 8px; }
.fdot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); display: block; }
.f-row .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.f-row .fill { height: 100%; border-radius: 3px; background: var(--dot); min-width: 4px; }

/* ---------- Tili ---------- */
.acct-card { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.acct-av { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; font-weight: 700; background: var(--coral); color: var(--dark); flex: none; }
.acct-card b { display: block; font-size: 18px; }
.muted { color: var(--muted); overflow-wrap: anywhere; font-size: 14px; }
.version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }

/* ---------- Kirjautuminen ja viestit ---------- */
.login-wrap { margin: 0 -18px; min-height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(520px 380px at 80% 0%, rgba(232, 137, 47, .2), transparent 70%), var(--bg); }
.login-top { padding: calc(70px + env(safe-area-inset-top)) 24px 32px; }
.login-top svg { width: 60px; height: 60px; border-radius: 14px; }
.login-top h1 { margin: 24px 0 10px; font-size: 34px; line-height: 1.08; font-weight: 700; letter-spacing: -.8px; }
.login-top p { margin: 0; color: var(--soft); font-size: 16px; }
.login-sheet { margin-top: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 26px 20px calc(30px + env(safe-area-inset-bottom)); }
.login-sheet form { display: grid; gap: 14px; }
.login-sheet label { display: grid; gap: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.login-sheet input { height: 54px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--ink); outline: none; }
.login-sheet input:focus { border-color: var(--coral); }
.error { min-height: 1.4em; color: #FFB08A; font-weight: 600; }
.setup { padding-top: 70px; }
.setup svg { width: 60px; height: 60px; border-radius: 14px; }
.setup h1 { font-size: 30px; font-weight: 700; letter-spacing: -.6px; }
.setup p { color: var(--soft); }
.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--coral-tint); color: var(--coral-hi); font-weight: 600; }
.loading { min-height: 70dvh; display: grid; place-items: center; align-content: center; gap: 16px; color: var(--muted); font-weight: 600; }
.loading svg { width: 52px; height: 52px; border-radius: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  max-width: min(440px, calc(100% - 32px)); padding: 12px 18px; border-radius: var(--r-md);
  background: #FBF7EF; color: var(--dark); font-weight: 600; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #3A2612; color: #FFC58A; }

/* ---------- Päivitys vetämällä alas ---------- */
.ptr {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) - 34px); z-index: 60;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card-2); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  transform: translate(-50%, 0); opacity: 0; transition: transform .2s, opacity .2s; pointer-events: none;
}
.ptr svg { width: 20px; height: 20px; }
.ptr.ready { color: var(--coral); }
.ptr.spin svg { animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ptr.spin svg { animation: none; } }
.hero:has(.hero-cta) { background: linear-gradient(180deg, #E8892F 0%, #CF6619 100%); border: 0; }
.hero:has(.hero-cta) .hero-top { border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Keskustelu */
.chat { display: grid; gap: 10px; }
.chat-wait { color: var(--muted); font-size: 14px; padding: 6px 2px; }
.msg { max-width: 86%; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.msg.in { justify-self: start; border-bottom-left-radius: 6px; }
.msg.out { justify-self: end; border-bottom-right-radius: 6px; background: var(--coral-tint); border-color: rgba(232, 137, 47, .22); }
.msg[data-who="yritys"] { background: var(--card-2); border-color: var(--line); }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-meta b { color: var(--soft); font-weight: 700; }
.msg.out .msg-meta b { color: var(--coral-hi); }
.msg-text { white-space: pre-wrap; line-height: 1.45; font-size: 15px; -webkit-user-select: text; user-select: text; }
/* Keskustelukortti pyynnön sivulla */
.chat-card { display: grid; gap: 8px; width: 100%; padding: 16px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); cursor: pointer; }
.chat-card.wait { color: var(--muted); font-size: 14px; cursor: default; }
.cc-top { display: flex; justify-content: space-between; align-items: center; }
.cc-count { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.cc-count svg { width: 18px; height: 18px; color: var(--coral); }
.cc-open { display: inline-flex; align-items: center; gap: 2px; color: var(--coral-hi); font-weight: 600; font-size: 14px; }
.cc-open svg { width: 16px; height: 16px; }
.cc-last { color: var(--soft); font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-last b { color: var(--ink); font-weight: 600; }
.cc-time { color: var(--muted); font-size: 12px; }
.sec-count.small { margin-left: 8px; font-size: 12px; padding: 2px 7px; vertical-align: 1px; }

/* Kuvarivi: swipe sivuttain */
.strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
.strip::-webkit-scrollbar { display: none; }
.strip .pic { flex: 0 0 auto; width: 112px; scroll-snap-align: start; }
.strip.in-msg { margin-top: 10px; }
.strip.in-msg .pic { width: 96px; }
.pic { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--card-2); cursor: zoom-in; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Koko keskustelu omana näkymänään */
body.locked { overflow: hidden; }
.chat-view { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); animation: slidein .2s ease-out; }
.chat-view > * { max-width: 488px; margin-left: auto; margin-right: auto; }
.cv-bar { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: max(10px, env(safe-area-inset-top)); margin-bottom: 8px; }
.cv-title { font-weight: 700; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-view { animation: none; } }

/* Kuvagalleria */
.lightbox { position: fixed; inset: 0; z-index: 100; background: #000; }
.gl-track { position: absolute; inset: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.gl-track::-webkit-scrollbar { display: none; }
.gl-slide { flex: 0 0 100%; height: 100%; scroll-snap-align: center; display: grid; place-items: center; padding: 64px 12px calc(24px + env(safe-area-inset-bottom)); }
.gl-slide img { max-width: 100%; max-height: 100%; border-radius: 10px; object-fit: contain; }
.gl-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: max(12px, env(safe-area-inset-top)) 16px 12px; pointer-events: none; }
.gl-top > * { pointer-events: auto; }
.gl-count { color: #fff; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.gl-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; display: none; place-items: center; }
.gl-nav svg { width: 20px; height: 20px; }
.gl-nav.prev { left: 12px; } .gl-nav.next { right: 12px; }
@media (hover: hover) { .gl-nav { display: grid; } }
.lb-close { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; display: grid; place-items: center; }
.lb-close svg { width: 20px; height: 20px; }

/* Yhteenveto */
.sum .info { grid-template-columns: 96px 1fr; gap: 12px; align-items: baseline; }
.sum .info .k { font-size: 14px; }
.sum .info .v { font-size: 15px; font-weight: 600; line-height: 1.4; }
.sum .info .v.plain { grid-column: 1 / -1; font-weight: 500; color: var(--soft); }
.sum .info.miss .k { color: var(--coral-hi); }
.sum .info.miss .v { color: var(--coral-hi); }
.cv-note { color: var(--muted); font-size: 13px; margin: 0 2px 12px; }

/* Paras soittoaika Soita-napin alla */
.calltime { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--coral-tint); border: 1px solid rgba(232, 137, 47, .22); color: var(--ink); font-size: 15px; line-height: 1.35; }
.calltime svg { width: 18px; height: 18px; flex: none; color: var(--coral-hi); }
.calltime b { font-weight: 700; }
.calltime.none { background: var(--card); border-color: var(--line); color: var(--muted); }
.calltime.none svg { color: var(--muted); }
.sum .info.unk .v { color: var(--muted); font-weight: 500; }

/* Ilmoitukset */
.push-panel p { margin: 0; color: var(--soft); line-height: 1.45; font-size: 15px; }
.push-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.push-row > div { display: grid; gap: 2px; }
.push-row .muted { font-size: 13px; }
.btn-main.small, .btn-ghost.small { width: auto; min-height: 42px; padding: 0 16px; font-size: 15px; margin: 0; flex: none; }
.nudge { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; margin: 4px 0 14px; border-radius: var(--r-md); background: var(--card); border: 1px solid rgba(232, 137, 47, .28); font-size: 14px; line-height: 1.35; }
.nudge > svg { width: 20px; height: 20px; color: var(--coral); flex: none; }
.nudge > span { flex: 1; }
.nudge-x { flex: none; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.nudge-x svg { width: 18px; height: 18px; }
.push-row .muted { word-break: normal; overflow-wrap: normal; }

/* Huomiomerkit */
.row-flag { font-size: 12px; font-weight: 700; color: #1a1208; background: var(--coral); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.row-flag.soft { background: var(--card-2); color: var(--soft); font-weight: 600; }
.row-flag.call { background: var(--coral-tint); color: var(--coral-hi); font-weight: 600; }
.row-flag.call.now { background: var(--coral); color: #1a1208; font-weight: 700; }
.attn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 10px; border-radius: var(--r-md); background: var(--coral-tint); border: 1px solid rgba(232, 137, 47, .3); font-size: 14px; line-height: 1.4; }
.attn svg { width: 18px; height: 18px; flex: none; color: var(--coral-hi); margin-top: 1px; }
.attn.soft { background: var(--card); border-color: var(--line); color: var(--soft); }
.attn.soft svg { color: var(--muted); }

/* Paluukysymys alareunassa */
.bsheet-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s ease-out; }
.bsheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 8px; animation: sheetup .22s ease-out; }
.bs-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); justify-self: center; margin-bottom: 6px; background: rgba(255,255,255,.18); }
.bsheet h2 { margin: 0; font-size: 20px; }
.bsheet p { margin: 0 0 6px; font-size: 14px; }
.sheet-opt { min-height: 52px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card-2); color: var(--ink); font-weight: 600; font-size: 16px; text-align: left; padding: 0 16px; }
.sheet-opt.main { background: var(--coral); color: #1a1208; border-color: transparent; }
.sheet-opt.ghost { background: none; color: var(--muted); text-align: center; }
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bsheet, .bsheet-wrap { animation: none; } }

/* Ilmoitusasetukset */
.push-set { display: grid; margin-top: 14px; border-top: 1px solid var(--line); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.set-row > span { display: grid; gap: 2px; }
.set-row b { font-weight: 600; font-size: 15px; }
.set-row .muted { font-size: 13px; line-height: 1.35; }
.sw { appearance: none; -webkit-appearance: none; flex: none; width: 48px; height: 28px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--soft); transition: transform .15s, background .15s; }
.sw:checked { background: var(--coral); border-color: transparent; }
.sw:checked::after { transform: translateX(20px); background: #fff; }
.sw:focus-visible { outline: 2px solid var(--coral-hi); outline-offset: 2px; }
.quiet-times { display: flex; align-items: center; gap: 8px; padding: 12px 0 2px; color: var(--soft); }
.quiet-times select { height: 40px; border-radius: 10px; background: var(--card-2); color: var(--ink); border: 1px solid var(--line); padding: 0 10px; font-size: 15px; }

/* Käyttöohjeet */
.help-link { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 20px; padding: 14px 16px; border: 0; border-radius: var(--r-md); background: var(--card); color: var(--ink); text-align: left; cursor: pointer; }
.help-link > svg:first-child { width: 22px; height: 22px; color: var(--coral); flex: none; }
.help-link > svg:last-child { width: 18px; height: 18px; color: var(--muted); flex: none; margin-left: auto; }
.help-link > span { display: grid; gap: 2px; }
.help-link b { font-weight: 600; font-size: 16px; }
.help-list { display: grid; gap: 8px; padding-bottom: 12px; }
.help-item { background: var(--card); border-radius: var(--r-md); }
.help-item summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; font-weight: 600; font-size: 16px; cursor: pointer; }
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary svg { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform .2s; }
.help-item[open] summary svg { transform: rotate(90deg); }
.help-body { padding: 0 16px 14px; display: grid; gap: 10px; }
.help-body p { margin: 0; color: var(--soft); font-size: 15px; line-height: 1.5; }
.help-pin { border: 1px solid rgba(232, 137, 47, .3); }
.help-pin h2 { margin: 0; padding: 16px 16px 10px; font-size: 16px; font-weight: 600; color: var(--coral-hi); }

/* Asennuskehote */
.inst-head { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.inst-head > svg, .inst-head > span, .inst-head > div:first-child:not(:last-child) { flex: none; }
.inst-head h2 { margin: 0 0 4px; }
.inst-head p { margin: 0; }
.inst-steps { margin: 6px 0 8px; padding-left: 22px; display: grid; gap: 8px; color: var(--soft); font-size: 15px; line-height: 1.4; }
.inst-steps b { color: var(--ink); }
.inst-head > svg { width: 52px; height: 52px; border-radius: 12px; }
.inst-head { align-items: flex-start; }

.bs-who { display: flex; align-items: center; gap: 12px; padding: 6px 0 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.bs-who .row-av { flex: none; width: 48px; height: 48px; font-size: 19px; background: var(--coral); color: #1a1208; }
.bs-who > div { display: grid; gap: 2px; min-width: 0; }
.bs-who b { font-size: 18px; font-weight: 700; }
.bs-who .muted { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sheet-opt { transition: background .12s, color .12s, border-color .12s; }
.sheet-opt:active, .sheet-opt.flash { background: var(--coral); color: #1a1208; border-color: transparent; }
.sheet-opt.main:active, .sheet-opt.main.flash { background: var(--coral-hi); }
.sheet-opt.flash { animation: optflash .32s ease-out; }
.sheet-opt:disabled { opacity: 1; }
@keyframes optflash { 0% { transform: scale(1); } 40% { transform: scale(.98); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .sheet-opt.flash { animation: none; } }

/* Soita / Tekstiviesti / Sähköposti: välähdys painettaessa */
.acts .btn, .acts .btn-main { transition: background .12s, color .12s; }
.acts .btn:active, .acts .btn.flash { background: var(--coral); color: #1a1208; }
.acts .btn:active svg, .acts .btn.flash svg { color: #1a1208; }
.acts .btn-main:active, .acts .btn-main.flash { background: var(--coral-hi); }
.acts .flash { animation: optflash .32s ease-out; }
@media (prefers-reduced-motion: reduce) { .acts .flash { animation: none; } }

/* Yhteenvedon muokkaus */
.sum-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sum-head .sec-title.small { margin: 0 2px; }
.sum-edit { border: 0; background: none; color: var(--coral-hi); font-weight: 600; font-size: 15px; padding: 6px 2px; cursor: pointer; }
.sum-empty { color: var(--muted); font-size: 15px; }
.sum-legend { display: inline-flex; align-items: center; gap: 6px; }
.sum .mine { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-left: 6px; vertical-align: 2px; }
.sum-form { display: grid; gap: 12px; }
.sum-field { display: grid; gap: 6px; }
.sum-field input, .sum-field select { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink); padding: 0 14px; font-size: 16px; outline: none; }
.sum-field input:focus, .sum-field select:focus { border-color: rgba(232, 137, 47, .6); }
.sum-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 12px; }
.sum-actions .btn, .sum-actions .btn-main { margin: 0; min-height: 52px; }
.mine-inline { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); vertical-align: 1px; }

/* Kevyt paluupalkki */
.obar { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 70; max-width: 496px; margin: 0 auto; background: var(--card-2); border: 1px solid rgba(232, 137, 47, .3); border-radius: 18px; padding: 12px 12px 12px 14px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .7); animation: obin .22s ease-out; display: grid; gap: 8px; }
.obar.low { bottom: calc(16px + env(safe-area-inset-bottom)); }
.obar.out { opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.ob-top { display: flex; align-items: center; gap: 10px; }
.ob-av { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--coral); color: #1a1208; font-weight: 700; flex: none; }
.ob-txt { display: grid; min-width: 0; flex: 1; }
.ob-txt .muted { font-size: 12px; }
.ob-txt b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-x { width: 34px; height: 34px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; flex: none; }
.ob-x svg { width: 18px; height: 18px; }
.ob-q { font-size: 15px; color: var(--soft); padding-left: 2px; }
.ob-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ob-btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 15px; transition: background .12s, color .12s; }
.ob-btn:active, .ob-btn.flash { background: var(--coral); color: #1a1208; border-color: transparent; }
@keyframes obin { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .obar { animation: none; } }
.ob-acts.three { grid-template-columns: 1fr 1fr 1fr; }
.ob-acts.three .ob-btn { font-size: 14px; padding: 0 4px; }

/* Yhteydenottotapa listassa ja pyynnössä */
.row-status.via svg { width: 14px; height: 14px; flex: none; color: var(--via); }
.row-status.via em { font-style: normal; color: var(--muted); font-weight: 500; }
[data-tapa="puhelu"]       { --via: #84B37A; }
[data-tapa="tekstiviesti"] { --via: #8BA3B8; }
[data-tapa="sahkoposti"]   { --via: #E3C065; }
.via-line { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 10px; border-radius: var(--r-md); background: var(--card); font-size: 14px; color: var(--soft); }
.via-line svg { width: 18px; height: 18px; flex: none; color: var(--via); }
.via-line b { color: var(--ink); font-weight: 600; }

/* iOS-kotinäyttöappi: alapalkki näytön alareunaan näytön korkeuden mukaan (iOS:n käynnistysbugi) */
.ios-pwa .tabs { bottom: auto; top: var(--sh); transform: translate(-50%, -100%); }
.ios-pwa #app { min-height: var(--sh); }
/* Sama iOS-bugi koskee koko ruudun päällekkäisiä näkymiä (keskustelu, kuvat, alavalikot) ja alareunan ilmoituksia:
   iOS voi antaa niille hetkeksi liian matalan näkymän, jolloin ne jäävät puolikkaiksi. Korkeus näytön mukaan. */
.ios-pwa .chat-view, .ios-pwa .lightbox, .ios-pwa .bsheet-wrap { bottom: auto; height: var(--sh); }
.ios-pwa .obar { bottom: auto; top: calc(var(--sh) - 84px - env(safe-area-inset-bottom)); translate: 0 -100%; }
.ios-pwa .obar.low { top: calc(var(--sh) - 16px - env(safe-area-inset-bottom)); }
.ios-pwa .toast { bottom: auto; top: calc(var(--sh) - 92px - env(safe-area-inset-bottom)); translate: 0 -100%; }

/* Vaakatila puhelimessa: appi täyttää koko näytön, lovi ja reunat huomioidaan */
@media (orientation: landscape) and (max-height: 540px) {
  #app { max-width: none; box-shadow: none; padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .tabs { max-width: none; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
}

/* ---------- Tietokone: sivupalkki vasemmalla, sisältö koko leveydelle ---------- */
@media (min-width: 960px) {
  html, body { background: var(--bg); }
  #app { max-width: none; margin: 0; margin-left: 240px; box-shadow: none; padding: 28px 48px 64px; min-height: 100vh; }
  .tabs {
    left: 0; top: 0; bottom: 0; transform: none; width: 240px; max-width: none;
    display: flex; flex-direction: column; gap: 4px; padding: 26px 14px;
    background: #100F0E; border-top: 0; border-right: 1px solid var(--line);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabs-brand { display: block; padding: 0 12px 22px; }
  .tab { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm); font-size: 15px; text-align: left; }
  .tab svg { width: 22px; height: 22px; }
  .tab:hover { background: var(--card); color: var(--soft); }
  .tab[aria-current="page"] { background: var(--coral-tint); color: var(--coral-hi); }
  .tab-badge { top: -7px; right: -10px; }
  .bar-brand > svg { display: none; }
  .tabs-brand svg { height: 28px; width: auto; display: block; }
  .hero-top { padding-top: 26px; padding-bottom: 26px; }
  .row { padding-top: 16px; padding-bottom: 16px; }
  .row:hover { background: var(--card-2); }
  .d-name { font-size: 40px; margin-bottom: 22px; }
  .d-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px; align-items: start; }
  .d-col { display: grid; gap: 14px; align-content: start; }
  .d-col > .d-block { margin-top: 10px; }
  .chat-view { padding-left: max(24px, calc((100vw - 820px) / 2)); padding-right: max(24px, calc((100vw - 820px) / 2)); }
  .toast { bottom: 32px; margin-left: 120px; }
  .obar { left: 264px; right: 24px; bottom: 24px; }
  .weeks { display: block; width: 100%; max-width: 640px; max-height: 260px; margin: 0 auto; }
  .bar:not(:has(.demo-tag)):has(.bar-brand):has(.bar-right:empty) { display: none; }
}

/* Pyynnön poisto */
.btn-del { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-top: 28px; border: 1px solid rgba(212, 100, 90, .28); border-radius: var(--r-md); background: none; color: #E0857C; font-weight: 600; font-size: 15px; }
.btn-del svg { width: 18px; height: 18px; }
.btn-del:hover { background: rgba(212, 100, 90, .08); }
.del-head h2 { margin: 4px 0 6px; font-size: 20px; }
.del-head p { margin: 0 0 10px; line-height: 1.45; }
.sheet-opt.danger { background: #D4645A; color: #1a0a08; border-color: transparent; text-align: center; }
.sheet-opt.danger:active, .sheet-opt.danger.flash { background: #E07A70; }

/* Välilehden vaihto pyyhkäisemällä */
@keyframes swl { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes swr { from { transform: translateX(-28px); opacity: .4; } to { transform: none; opacity: 1; } }
#app.swipe-l > :not(.tabs) { animation: swl .24s ease-out; }
#app.swipe-r > :not(.tabs) { animation: swr .24s ease-out; }

/* Pyyhkäisyn aikana näkyvä viereinen sivu */
.peek { position: fixed; top: 0; left: 0; right: 0; z-index: 25; height: 100vh; overflow: hidden; pointer-events: none;
  max-width: 520px; margin: 0 auto; background: var(--bg); padding: env(safe-area-inset-top) 18px 104px; will-change: transform; }
.ios-pwa .peek { height: var(--sh); }
/* Pyynnöstä takaisin vedettäessä lista näkyy pyynnön alta */
#app.dragback { background: transparent; z-index: 26; }
#app.dragback > .page { background: var(--bg); min-height: 100vh; margin: 0 -18px; padding: 0 18px; box-shadow: -24px 0 40px rgba(0, 0, 0, .55); }

/* Ilmoitusten lisäasetukset kokoon taitettuna */
.set-more { }
.set-more > summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; list-style: none; cursor: pointer; color: var(--soft); font-weight: 600; }
.set-more > summary::-webkit-details-marker { display: none; }
.set-more > summary svg { width: 18px; height: 18px; transition: transform .15s; }
.set-more[open] > summary svg { transform: rotate(90deg); }

/* Siirtymät: pyyntö liukuu oikealta, lista palaa vasemmalta, välilehdet suunnan mukaan */
@keyframes navpush { from { transform: translate3d(42%, 0, 0); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes navpop { from { transform: translate3d(-18%, 0, 0); opacity: .5; } to { transform: none; opacity: 1; } }
#app.nav-push > :not(.tabs) { animation: navpush .28s cubic-bezier(.2, .8, .2, 1); }
#app.nav-pop > :not(.tabs) { animation: navpop .26s cubic-bezier(.2, .8, .2, 1); }
#app.swipe-l > :not(.tabs) { animation: swl .26s cubic-bezier(.2, .8, .2, 1); }
#app.swipe-r > :not(.tabs) { animation: swr .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes swl { from { transform: translate3d(36%, 0, 0); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes swr { from { transform: translate3d(-36%, 0, 0); opacity: .4; } to { transform: none; opacity: 1; } }

/* Kosketuspalaute: painettava asia painuu hieman */
.row, .state-btn, .tab, .btn, .btn-main, .help-link, .chat-card { transition: transform .12s ease, filter .12s ease, background .12s; }
.row:active { transform: scale(.985); }
.state-btn:active, .btn:active, .btn-main:active, .help-link:active { transform: scale(.97); }
.tab:active { transform: scale(.9); }
@media (prefers-reduced-motion: reduce) { #app > * { animation: none !important; } .row:active, .tab:active, .state-btn:active, .btn:active, .btn-main:active { transform: none; } }

/* Vaakasuuntaiset vierityslistat ja kuvagalleria saavat vierittää sivuttain (muu sivu vain pystyyn) */
.strip, .gl-track, .lightbox { touch-action: pan-x pan-y; }
.page { transform: translateZ(0); }

/* Ei vierityspalkkia oikeassa reunassa */
html::-webkit-scrollbar, body::-webkit-scrollbar, .chat-view::-webkit-scrollbar { display: none; width: 0; height: 0; }
.chat-view { scrollbar-width: none; }
