/* Kahakka – musta, kromi, alumiini ja taktiset värit.
   Kaikki värit ovat muuttujina: tumma on oletus, päivänvalotila (data-theme="light") radalle aurinkoon. */
:root {
  --bg: #0b0c0d;
  --surface: #16181b;
  --raised: #22262b;
  --line: #2e3238;
  --text: #eceef0;
  --muted: #a7adb4;
  --accent: #b08d57;        /* coyote: pääkorostus ja täytöt */
  --accent-text: #c9a56c;   /* coyote tekstinä */
  --accent-line: #8a6a36;
  --on-accent: #0b0c0d;
  --ok: #9db06a;            /* ranger green tekstinä tummalla */
  --warn: #f08a45;          /* signaalioranssi */
  --danger: #ef7d6b;
  --nav-bg: #111316;
  --chrome: linear-gradient(180deg, #f4f6f8 0%, #c3c9cf 44%, #6f7780 52%, #dde1e5 100%);
  --topbar: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px), linear-gradient(180deg, #1f2226 0%, #111316 100%);
  --radius: 10px;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-logo: "Saira Stencil One", "Barlow Condensed", sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #e9ecef;
  --surface: #ffffff;
  --raised: #dde1e5;
  --line: #c3c9cf;
  --text: #0b0c0d;
  --muted: #4a5058;
  --accent-text: #6e5226;
  --ok: #46562a;
  --warn: #a84c0e;
  --danger: #b3261e;
  --nav-bg: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* Yläpalkki pysyy mustana molemmissa teemoissa. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px; padding: 0 8px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--topbar); border-bottom: 1px solid #2e3238; color: #b9c0c7;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo {
  font-family: var(--font-logo); font-size: 24px; letter-spacing: 2px;
  background: var(--chrome); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-button {
  width: 44px; height: 44px; border: 0; border-radius: 8px;
  background: transparent; color: #b9c0c7;
  display: flex; align-items: center; justify-content: center;
}
.icon-button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

main {
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(96px + env(safe-area-inset-bottom));
}
.view { display: flex; flex-direction: column; gap: 12px; }
.view[hidden] { display: none; }

.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 {
  margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 30px; line-height: 1.05;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.head-link { font-size: 15px; font-weight: 600; color: var(--accent-text); text-decoration: none; padding: 10px 0; }

.label-heading, .field-label {
  margin: 0; font-family: var(--font-head); font-weight: 600; font-size: 16px;
  letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
}
.field-label { font-family: var(--font-body); font-size: 12px; letter-spacing: 1px; }

.card {
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.card p { margin: 0; }
.card.info p { color: var(--muted); font-size: 15px; }

/* Tilastot */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat {
  padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.stat strong { font-family: var(--font-head); font-weight: 700; font-size: 26px; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); }

/* Pikakirjaus */
.quick.editing { border-color: var(--accent-line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill-button {
  min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--accent-line); background: transparent; color: var(--accent-text);
  font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px;
}
.pill-button:disabled { opacity: 0.4; cursor: default; }

.chips { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: 0.5px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.more-chip { background: transparent; color: var(--muted); }
.chip.more-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.rounds { display: flex; flex-direction: column; gap: 6px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.step {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--raised); font-size: 28px; line-height: 1;
}
#rounds {
  flex-grow: 1; min-width: 0; height: 52px; border: 0; background: transparent; text-align: center;
  font-family: var(--font-head); font-weight: 700; font-size: 46px; line-height: 1;
  -moz-appearance: textfield; appearance: textfield;
}
#rounds::-webkit-outer-spin-button, #rounds::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quick-adds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.quick-adds button {
  height: 40px; border-radius: 6px; border: 1px solid var(--line); background: transparent;
  font-family: var(--font-head); font-weight: 600; font-size: 17px;
}

.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row {
  min-height: 52px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); color: var(--muted);
}
.row-label { width: 44px; flex-shrink: 0; font-size: 13px; }
.row input {
  flex-grow: 1; min-width: 0; height: 50px; border: 0; background: transparent;
  color: var(--text); font-size: 16px;
}
.row input::placeholder { color: var(--muted); opacity: 0.8; }

.more summary {
  min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: 14px; cursor: pointer; list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "▾"; font-size: 16px; }
.more[open] summary::after { content: "▴"; }
.more-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-bottom: 4px; }
.more-fields label, .stacked { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.more-fields .wide { grid-column: 1 / -1; }
.more-fields input, .more-fields textarea, .stacked input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text); font-size: 16px;
}
.more-fields textarea { resize: vertical; }

.primary-button, .secondary-button, .danger-button {
  min-height: 52px; padding: 0 18px; border-radius: 8px;
  font-family: var(--font-head); font-weight: 700; font-size: 21px; letter-spacing: 2px; text-transform: uppercase;
}
.primary-button { border: 0; background: var(--accent); color: var(--on-accent); }
.primary-button:disabled { opacity: 0.6; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.danger-button { border: 1px solid var(--danger); background: transparent; color: var(--danger); font-size: 18px; letter-spacing: 1px; }
.edit-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.edit-actions[hidden] { display: none; }

/* Aseen valinta omasta kalustosta */
.gear-pick { display: flex; flex-direction: column; gap: 6px; }
.gear-pick-head { display: flex; align-items: center; justify-content: space-between; }
.text-button {
  min-height: 40px; padding: 0 4px; border: 0; background: transparent;
  color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.gear-chip { display: inline-flex; align-items: baseline; gap: 6px; }
.gear-chip small { font-family: var(--font-body); font-size: 12px; font-weight: 500; letter-spacing: 0; opacity: 0.75; }
.custom-input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--accent-line); background: var(--raised); color: var(--text); font-size: 16px;
}
.gear-hint { margin: 0; font-size: 14px; color: var(--muted); }

.demo-note {
  padding: 4px 4px 4px 12px; border-radius: 8px; border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--muted);
}

.id-line {
  align-self: flex-start; min-height: 36px; margin-top: -6px; padding: 0; border: 0; background: transparent;
  color: var(--muted); font-size: 14px; text-align: left;
}
.id-line strong { color: var(--text); font-family: var(--font-head); font-size: 17px; letter-spacing: 1px; }
.id-line.missing { color: var(--accent-text); font-weight: 600; }
.profile-fields { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; }
.profile-fields input[data-profile-field="sraId"] { font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: 1px; }

/* Seura: Kahakat-näkymä, portaali ja vahvistukset */
.view-body { display: flex; flex-direction: column; gap: 12px; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); font-weight: 600; }
.date-block {
  width: 54px; flex-shrink: 0; padding: 6px 0; border-radius: 8px; background: var(--raised);
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.date-block span { font-size: 11px; font-weight: 600; color: var(--muted); }
.date-block strong { font-family: var(--font-head); font-weight: 700; font-size: 26px; line-height: 1; }
.event-card {
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.event-card.registered { border-color: var(--accent-line); }
.event-top { display: flex; gap: 12px; align-items: flex-start; }
.event-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.event-body h3 { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 22px; line-height: 1.1; }
.event-desc { margin: 4px 0 0; font-size: 14px; }
.capacity { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.notice { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); border-left-width: 1px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.notice p { margin: 0; font-size: 14px; color: var(--muted); }
.notice-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.tabs.tabs-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.role-chips legend { margin-bottom: 6px; }
.attest-box { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.attest-box:empty { display: none; }
.attest-status { margin: 8px 0 0; font-size: 15px; font-weight: 600; }
.request-title { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 20px; line-height: 1.15; }
.request-member { margin: 0; font-size: 14px; }
.request-note { margin: 0; font-size: 14px; }
.request-rows { margin: 0; padding: 0; list-style: none; max-height: 240px; overflow-y: auto; }
.request-rows li { display: grid; grid-template-columns: 90px 1fr 20px; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.tabs button {
  min-height: 44px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: 0.5px;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.checklist { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.check-row { min-height: 48px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.entry.static { cursor: default; }
.icon-button.small { width: 44px; height: 44px; flex-shrink: 0; color: var(--muted); }
.icon-button.danger-icon:hover { color: var(--danger); }
.status { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.danger { color: var(--danger); }
.status.muted { color: var(--muted); }
.member-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .stacked textarea, .stacked input[type="search"] {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text); font-size: 16px;
}
.pending { border-color: var(--ok); }
.pending-row { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.pending-actions { display: flex; flex-direction: column; align-items: stretch; gap: 2px; flex-shrink: 0; }
.pending-actions .primary-button { min-height: 44px; padding: 0 16px; }
.menu-link span small { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.card > p { font-size: 15px; }

/* Taulukuvat */
.photo-pick { display: flex; flex-direction: column; gap: 6px; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.photo-add, .photo-thumb {
  position: relative; width: 76px; height: 76px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
}
.photo-add {
  border: 1px dashed var(--accent-line); color: var(--accent-text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 600;
}
.photo-add:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-add.busy { opacity: 0.6; pointer-events: none; }
.photo-thumb { border: 1px solid var(--line); padding: 0; background: var(--raised); }
.photo-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.photo-thumb img, .entry-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; border: 0; border-radius: 16px;
  background: rgba(11, 12, 13, 0.75); color: #eceef0; font-size: 18px; line-height: 1;
}
.entry-thumb { width: 48px; height: 48px; flex-shrink: 0; padding: 0; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--raised); }
.photo-viewer {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 10px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--text);
}
.photo-viewer::backdrop { background: rgba(0, 0, 0, 0.8); }
.photo-viewer img { width: 100%; max-height: 72vh; object-fit: contain; display: block; border-radius: 8px; }
.photo-viewer form { margin-top: 10px; display: flex; }
.photo-viewer form button { flex-grow: 1; }

/* Oma kalusto */
.topbar-actions { display: flex; align-items: center; }
.lead { margin: 0; color: var(--muted); font-size: 15px; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; vertical-align: 2px;
  border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
}
.small-button { min-height: 44px; font-size: 16px; letter-spacing: 1px; }
.menu-link {
  min-height: 56px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 600; text-align: left;
}
.menu-link svg { color: var(--muted); }

/* Lista */
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; }
.section-heading h2 { margin: 0; font-family: var(--font-head); font-weight: 600; font-size: 16px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.section-heading span { font-size: 13px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.entry {
  width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left;
  border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: 12px;
}
.entry.selected { border-color: var(--accent); }
.entry-date { width: 44px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.entry-date strong { font-family: var(--font-head); font-weight: 700; font-size: 24px; line-height: 1; }
.entry-date span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.entry-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.entry-title { font-size: 15px; font-weight: 600; }
.entry-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-chevron { color: var(--muted); flex-shrink: 0; }
.entry-result { font-size: 13px; font-weight: 600; color: var(--accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { margin: 0; padding: 16px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 15px; text-align: center; }

/* Vienti */
.export { margin-top: 8px; scroll-margin-top: 72px; }
.segmented { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.segmented legend { margin-bottom: 6px; padding: 0; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  min-height: 44px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--raised);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--font-head); font-weight: 600; font-size: 16px;
}
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.export-buttons { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.fine-print { font-size: 12px; color: var(--muted); }

/* Alavalikko */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 0 6px env(safe-area-inset-bottom);
  background: var(--nav-bg); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
}
.bottom-nav button {
  height: 64px; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600;
}
.bottom-nav button[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.bottom-nav .nav-plus {
  justify-self: center; width: 56px; height: 56px; margin-top: -20px; border-radius: 28px;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 4px var(--bg);
}

/* Ilmoitus ja kumoa */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%); width: min(528px, calc(100% - 32px));
  padding: 6px 6px 6px 16px; min-height: 52px; border-radius: 10px;
  background: #22262b; color: #eceef0; border: 1px solid #3a3f46;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px;
}
.toast[hidden] { display: none; }
.toast button {
  min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  color: #c9a56c; font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: 1px;
}
.toast button[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

#diary-form, #gear-form { scroll-margin-top: 68px; }

/* Aseluvan muistutukset */
.permit-banner {
  padding: 12px 8px 12px 14px; border-radius: var(--radius); border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--text);
  display: flex; align-items: flex-start; gap: 10px;
}
.permit-banner > svg { color: var(--warn); flex-shrink: 0; margin-top: 1px; }
.permit-banner-body { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.permit-banner-body p { margin: 0; }
.permit-banner .text-button { flex-shrink: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row span { display: flex; flex-direction: column; font-size: 15px; }
.setting-row small { font-size: 13px; color: var(--muted); }
.setting-row .small-button { min-width: 100px; }

/* Sivurakenne: välilehdet ja niiden alasivut */
.back-button {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin: -8px 0 -8px -8px; padding: 0 12px 0 4px; border: 0; background: transparent;
  color: var(--accent-text); font-size: 16px; font-weight: 600;
}
[data-new-entry] { display: flex; align-items: center; justify-content: center; gap: 8px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  min-height: 92px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 10px; text-align: left;
  font-family: var(--font-head); font-size: 18px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
}
.tile svg { color: var(--accent-text); }
.tile small { display: block; margin-top: 2px; font-family: var(--font-body); font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); }
.who-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  min-height: 48px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--raised);
  color: var(--text); font-size: 14px; text-align: left;
}
.who-line small { flex-shrink: 0; color: var(--accent-text); font-weight: 600; font-size: 14px; }

/* Ehdotukset radalla: korostus kertoo, mitä ehdotetaan. Valittu ehdotus näyttää pisteen. */
.chip.suggested { position: relative; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chip.suggested::after {
  content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn); border: 2px solid var(--surface);
}
.row.suggested { box-shadow: inset 3px 0 0 var(--warn); }
.rounds-suggest { display: flex; }
.suggest-chip {
  display: inline-flex; align-items: baseline; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--raised); color: var(--text);
  font-family: var(--font-head); font-size: 22px; font-weight: 700; letter-spacing: 1px;
}
.suggest-chip small { font-family: var(--font-body); font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.entry-context {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px dashed var(--line); color: var(--muted); font-size: 14px;
}
.entry-context small { display: block; font-size: 13px; color: var(--muted); }
.entry-context.strong { border: 1px solid var(--warn); color: var(--text); font-weight: 600; }
.entry-context.strong small { font-weight: 400; }
.context-mark { font-size: 20px; color: var(--warn); }

/* Aselupavaroitus on linkki poliisin aselupasivulle. */
a.permit-banner-body { color: inherit; text-decoration: none; }
a.permit-banner-body:hover .permit-link, a.permit-banner-body:focus-visible .permit-link { text-decoration: underline; }
.permit-link { margin-top: 4px; color: var(--accent-text); font-weight: 600; font-size: 14px; }

/* Aseluvat */
.scan-button { display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; }
.permit-thumb {
  width: 52px; height: 64px; flex-shrink: 0; border-radius: 6px; overflow: hidden; border: 1px solid var(--line);
  background: var(--raised); color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.permit-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.permit-entry { gap: 12px; }
#permit-quick-dates { margin-top: -4px; }

/* Paneeli (bottom sheet): harjoitus ja kirjaus avautuvat alhaalta, ja sivu jää sumennettuna taustalle. */
body.sheet-open { overflow: hidden; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(5, 6, 7, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 180ms ease-out;
}
.view.sheet {
  position: fixed; z-index: 26; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - 44px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transition: transform 200ms ease-out;
  animation: sheet-up 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin: 0 -16px; padding: 22px 8px 10px 16px; background: var(--bg); touch-action: none;
}
/* Vetokahva: vihje, että paneelin voi vetää alas kiinni. */
.sheet-head::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px;
  border-radius: 3px; background: var(--line);
}
.sheet-head h1 { flex: 1; min-width: 0; font-size: 26px; overflow-wrap: anywhere; }
.sheet-close { width: 44px; height: 44px; flex-shrink: 0; color: var(--muted); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .view.sheet, .sheet-backdrop { animation: none; }
}

/* Harjoituksen tiedot paneelissa */
.entry-detail { display: flex; flex-direction: column; gap: 14px; }
.detail-hero { display: flex; align-items: baseline; gap: 10px; }
.detail-hero strong { font-family: var(--font-head); font-size: 56px; line-height: 1; font-weight: 700; }
.detail-hero span { color: var(--muted); font-size: 16px; }
.detail-result { margin: 0; color: var(--accent-text); font-weight: 600; font-size: 17px; }
.detail-confirmed { margin: 0; color: var(--ok); font-weight: 600; }
.detail-rows { margin: 0; border-top: 1px solid var(--line); }
.detail-rows div { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.detail-rows dt { width: 72px; flex-shrink: 0; color: var(--muted); font-size: 14px; }
.detail-rows dd { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.detail-notes { margin: 0; white-space: pre-wrap; font-size: 16px; line-height: 1.5; }
.detail-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.detail-photos .photo-open { aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--raised); }
.detail-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.danger-text { color: var(--danger); min-height: 44px; }

/* Juuri tallennettu merkintä välähtää listassa, jotta näkee, minne se meni. */
.entry.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Ratakartta */
.map-search { display: flex; gap: 8px; }
.map-search input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px;
}
.map-search .small-button { flex-shrink: 0; padding: 0 12px; letter-spacing: 0.5px; font-size: 16px; }
.filter-rows { display: flex; flex-direction: column; gap: 6px; margin: 0 -16px; }
/* Yksi rivi vaihtoehtoja, jota selataan sormella sivuttain: puhelimella ei vie pystytilaa. */
.chip-scroll { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .chip { flex-shrink: 0; scroll-snap-align: start; white-space: nowrap; }
.kind-chip[aria-pressed="false"] { opacity: 0.75; }
.kind-chip::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; vertical-align: 0; }
.kind-kilpailu::before { background: #e8742a; }
.kind-koulutus::before { background: #b08d57; }
.kind-harjoitus::before { background: #7d9150; }
.kind-radat::before { background: #a7adb4; }
.kind-chip[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--on-accent); }
.range-map {
  height: 46vh; min-height: 260px; max-height: 480px; margin: 0 -16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
}
.range-map.leaflet-container { display: block; font-family: var(--font-body); }
.map-loading { color: var(--muted); padding: 16px; text-align: center; }
/* Tumma teema: karttapohja tummennetaan, jotta se sopii ulkoasuun. Merkit säilyvät värillisinä. */
:root:not([data-theme="light"]) .range-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.range-map .leaflet-control-attribution { font-size: 10px; }
.map-legend { margin: -4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.map-legend i, .kind-dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; vertical-align: 0; }
.map-legend .dot-range { width: 8px; height: 8px; background: #a7adb4; }
.list-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.list-tabs button {
  min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: var(--font-head); font-size: 17px; font-weight: 600; letter-spacing: 0.5px;
}
.list-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.list-tabs span { opacity: 0.8; margin-left: 4px; }
.event-row { align-items: center; gap: 12px; }
.kahakka-badge { border-color: var(--accent); color: var(--accent-text); }
.accent-text { color: var(--accent-text); }
.tag { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.range-actions { display: flex; flex-direction: column; gap: 8px; }
.link-button { display: flex; align-items: center; justify-content: center; text-decoration: none; }
/* Leafletin sisäiset kerrokset (z-index 400–1000) pysyvät kartan sisällä, jolloin paneeli ja tausta peittävät kartan. */
.range-map { position: relative; z-index: 0; isolation: isolate; }
.range-map .leaflet-bar a { background: var(--raised); color: var(--text); border-bottom-color: var(--line); width: 40px; height: 40px; line-height: 40px; }
.range-map .leaflet-bar { border: 1px solid var(--line); }
.range-map .leaflet-control-attribution { background: rgba(11, 12, 13, 0.7); color: var(--muted); }
.range-map .leaflet-control-attribution a { color: var(--accent-text); }

/* Kauppapaikka */
.market-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.listing-card {
  display: flex; flex-direction: column; gap: 3px; padding: 0 0 10px; overflow: hidden; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.listing-card.sold { opacity: 0.6; }
.listing-photo {
  position: relative; aspect-ratio: 1; margin-bottom: 6px; background: var(--raised); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.listing-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sold-tag { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 4px; background: var(--warn); color: #111; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.listing-price, .listing-title, .listing-meta { padding: 0 10px; }
.listing-price { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.listing-title { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listing-meta { color: var(--muted); font-size: 12px; }
.listing-photos { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.listing-photos::-webkit-scrollbar { display: none; }
.listing-photos .photo-open { flex: 0 0 86%; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--raised); scroll-snap-align: start; }
.listing-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing-photos.empty-photo { margin: 0; padding: 0; height: 140px; border-radius: 12px; background: var(--raised); color: var(--muted); flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 14px; }
.notice-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.notice-box.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.notice-box p { margin: 0; font-size: 14px; color: var(--muted); }
.notice-box .check-row { border-bottom: 0; color: var(--text); }
.price-input { font-family: var(--font-head); font-size: 26px !important; font-weight: 700; }
.sell-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.sell-gear-name { margin: 4px 0 0; font-family: var(--font-head); font-size: 22px; font-weight: 700; }
.sell-gear-name small { display: block; font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--muted); }
.listing-photo { overflow: hidden; }
.listing-photo img { position: absolute; inset: 0; }
.detail-rows dt { width: 96px; }
.art-tag {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 4px;
  background: rgba(11, 12, 13, 0.72); color: #c3c9cf; font-size: 10px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
}
.listing-photos .photo-open { position: relative; }
.listing-photos.single .photo-open { flex: 0 0 100%; aspect-ratio: 1; max-height: 340px; }

/* Koti */
.home-hello h1 { font-size: 32px; }
.home-hello p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.home-section { display: flex; flex-direction: column; gap: 8px; }
.home-section .section-heading { margin-top: 4px; }
.home-section .section-heading .text-button { min-height: 36px; padding: 0; }
.todo-row {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px;
}
.todo-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.tone-warn { border-color: var(--warn); } .tone-warn .todo-dot { background: var(--warn); }
.tone-danger { border-color: var(--danger); } .tone-danger .todo-dot { background: var(--danger); }
.tone-ok .todo-dot { background: var(--ok); }
.todo-text { flex: 1; min-width: 0; }
.todo-action { flex-shrink: 0; color: var(--accent-text); font-weight: 600; font-size: 14px; }
.home-log { display: flex; align-items: center; justify-content: center; gap: 8px; }
.next-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.home-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
.home-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.home-tile {
  min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px 4px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
}
.home-tile svg { color: var(--accent-text); }
.home-listings { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.home-listings::-webkit-scrollbar { display: none; }
.mini-listing {
  flex: 0 0 132px; display: flex; flex-direction: column; gap: 2px; padding: 0 0 8px; overflow: hidden; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.mini-photo { aspect-ratio: 1; margin-bottom: 4px; background: var(--raised); overflow: hidden; }
.mini-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-listing strong, .mini-listing > span { padding: 0 8px; }
.mini-listing strong { font-family: var(--font-head); font-size: 17px; }
.mini-listing > span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-photo { display: block; width: 100%; }

/* Hyväksyntä radalla (QR) */
.approve-start { display: flex; align-items: center; justify-content: center; gap: 8px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.choice.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice:disabled { opacity: 0.5; }
.choice strong { display: block; font-size: 16px; }
.choice small { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; }
.choice-dot { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line); }
.choice.selected .choice-dot { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.chip-scroll.flush { margin: 0 -16px; }
.approve-summary { margin: 0; font-size: 15px; font-weight: 600; }
/* QR aina mustavalkoisena valkoisella pohjalla, myös tummassa teemassa, jotta kamera lukee sen. */
.qr-box { width: min(78vw, 320px); aspect-ratio: 1; margin: 4px auto 0; padding: 0; border-radius: 14px; background: #fff; overflow: hidden; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box.expired { background: var(--raised); opacity: 0.5; }
.handshake { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }
.handshake strong { color: var(--text); font-family: var(--font-head); font-size: 26px; letter-spacing: 3px; margin-left: 6px; }
.countdown { margin: -6px 0 0; text-align: center; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.approve-who { margin: 0; text-align: center; font-size: 15px; line-height: 1.5; color: var(--muted); }
.approve-who strong { color: var(--text); }
.demo-button { border-style: dashed; }
.result-mark { width: 88px; height: 88px; margin: 8px auto 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 48px; font-weight: 700; }
.result-mark.ok { background: var(--ok); color: #fff; }
.result-mark.declined { background: var(--danger); color: #fff; }
.result-title { margin: 0; text-align: center; font-family: var(--font-head); font-size: 26px; font-weight: 700; text-transform: uppercase; }
.shooter-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.shooter-card strong { font-family: var(--font-head); font-size: 24px; color: var(--text); }
.review-entry { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.review-entry strong { font-size: 18px; color: var(--text); }
.review-rows summary { min-height: 44px; display: flex; align-items: center; color: var(--accent-text); font-weight: 600; cursor: pointer; }
.review-rows .check-row span { font-size: 14px; }
.statement { margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--surface); font-size: 15px; line-height: 1.5; }
.approver-line { display: flex; flex-direction: column; gap: 6px; }
.decision-buttons { display: flex; flex-direction: column; gap: 8px; }
.approve-button, .decline-button {
  min-height: 60px; border-radius: 10px; font-family: var(--font-head); font-size: 22px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
}
.approve-button { border: 0; background: var(--ok); color: #fff; }
.approve-button:disabled { opacity: 0.4; }
.decline-button { border: 2px solid var(--danger); background: transparent; color: var(--danger); }
.decline-box { display: flex; flex-direction: column; gap: 8px; }
.code-form { display: flex; gap: 8px; }
.code-form input {
  flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: var(--font-head); font-size: 22px; letter-spacing: 2px; text-transform: uppercase;
}
.decision-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.scan-video { width: 100%; border-radius: 12px; background: #000; }
.verify-result { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius); border: 2px solid var(--ok); }
.verify-result.revoked { border-color: var(--danger); }
.verify-result > strong { font-family: var(--font-head); font-size: 22px; }
.verify-result.ok > strong { color: var(--ok); }
/* Päätöspainikkeet pysyvät paneelin alareunassa peukalon ulottuvilla, vaikka merkintälista on pitkä. */
.decision-buttons, .decline-box {
  position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom)); z-index: 1;
  margin: 0 -16px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.decision-buttons { flex-direction: row; }
.decision-buttons .approve-button { flex: 2; }
.decision-buttons .decline-button { flex: 1; }
.decision-buttons .approve-button, .decision-buttons .decline-button { font-size: 19px; letter-spacing: 1px; padding: 0 10px; }

/* Kauppapaikka: ostetaan, vaihto ja tarjoukset */
.market-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.market-actions .secondary-button { min-height: 52px; font-size: 19px; letter-spacing: 1px; }
.listing-kinds { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px; min-height: 0; }
.listing-kinds:empty { display: none; }
.entry-detail > .listing-kinds { padding: 0; }
.kind-tag { padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.kind-tag.buy { background: var(--accent); color: var(--on-accent); }
.kind-tag.trade { border: 1px solid var(--ok); color: var(--ok); }
.trade-wants { margin: 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--ok); font-size: 15px; }
.trade-wants span { display: block; margin-bottom: 2px; color: var(--ok); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.trade-box { display: flex; flex-direction: column; gap: 6px; }
.trade-box .check-row { border-bottom: 0; }
.plain-button { padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* Minä-välilehti */
.me-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.me-avatar { width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; background: var(--raised); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.me-text strong { font-family: var(--font-head); font-size: 22px; }
.me-text small { color: var(--muted); font-size: 13px; }
.me-card > svg { color: var(--muted); }

/* Tapahtumaan kirjautuminen ja osallistujien hyväksyntä */
.event-card.today { border-color: var(--accent); }
.today-block { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.today-tag { align-self: flex-start; padding: 2px 8px; border-radius: 4px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.checkin-actions { display: flex; flex-direction: column; gap: 8px; }
.checked-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.decision-chip { margin: 0; display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.decision-chip.ok { color: var(--ok); border: 1px solid var(--ok); }
.decision-chip.rejected { color: var(--danger); border: 1px solid var(--danger); }
.participant { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.participant-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.participant-check { width: 44px; min-height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.participant-check input { width: 24px; height: 24px; accent-color: var(--accent); }
.participant-check.placeholder { font-size: 20px; font-weight: 700; color: var(--muted); }
.participant.decided-approved .participant-check { color: var(--ok); }
.participant.decided-rejected .participant-check { color: var(--danger); }
.participant.rejecting { flex-direction: column; padding: 12px; margin: 6px 0; border: 1px solid var(--danger); border-radius: var(--radius); }
.reject-box { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.reject-box textarea, .decline-box textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.approver-note { margin: 0; font-size: 14px; color: var(--muted); }

/* Minä: roolit ja tilin vaihto (demo) */
.me-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.me-roles:empty { display: none; }
.role-badge { padding: 1px 6px; border-radius: 4px; border: 1px solid var(--ok); color: var(--ok); font-size: 12px; font-weight: 600; }
.role-badge.invalid { border-color: var(--danger); color: var(--danger); }
.account-switch { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius); border: 1px dashed var(--line); }
.club-link { border-color: var(--accent); }

/* Sää, tiesää ja seuran rekisteritieto */
.weather-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.weather-now { margin: 0; font-size: 17px; font-weight: 600; }
.weather-hours { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 13px; color: var(--muted); }
.weather-hours small { display: block; font-weight: 700; color: var(--text); }
.road-weather { margin: 0; font-size: 13px; color: var(--muted); }
.road-weather:empty { display: none; }
.event-weather { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.event-weather:empty { display: none; }
.direction-buttons { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.direction-buttons .secondary-button { min-height: 52px; font-size: 18px; letter-spacing: 1px; }
.inline-button { min-height: 0; padding: 0; font-size: inherit; }
.registry-line { font-size: 14px; }
.registry-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius); border: 1px dashed var(--line); }
.registry-card.ok { border: 1px solid var(--ok); }
.registry-card.ok > strong { color: var(--ok); }
.prh-result { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; text-align: left; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; }
.prh-result span { color: var(--muted); font-size: 13px; }
a.link-button.secondary-button { color: var(--text); }

/* Koti: kotiradan sää, Tänään-kortti, toiminnot */
.home-weather {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-top: 8px; padding: 0; border: 0; background: transparent;
  color: var(--text); font-size: 15px; font-weight: 600; text-align: left;
}
.home-weather-place { color: var(--accent-text); font-weight: 600; font-size: 14px; }
.today-card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius);
  border: 2px solid var(--accent); background: var(--surface);
}
.today-card h2 { margin: 0; font-family: var(--font-head); font-size: 24px; line-height: 1.1; }
.today-card .today-block { border-top: 0; padding-top: 4px; }
.today-card .hidden-tag { background: transparent; color: var(--muted); padding: 0; letter-spacing: 0; text-transform: none; font-weight: 600; font-size: 13px; }
.home-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.home-approve { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 17px; letter-spacing: 0.5px; padding: 0 8px; }
.todo-more { align-self: flex-start; min-height: 36px; padding: 0; }
.fit-tag { margin: -2px 8px 2px; padding: 1px 6px; align-self: flex-start; border-radius: 4px; background: var(--ok); color: #fff; font-size: 11px; font-weight: 700; }
.fit-tag { color: #0b0c0d; }
.home-stats .stat small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

/* Kotiradan valinta */
.home-weather-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 4px 12px; }
.home-weather-row .home-weather { flex: 1 1 220px; }
.change-range {
  min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent-text); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.range-pick-list { display: flex; flex-direction: column; gap: 6px; }
.range-pick {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 8px 14px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.range-pick.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.range-pick strong { display: block; font-size: 16px; }
.range-pick small { display: block; color: var(--muted); font-size: 13px; }
.home-actions.three { grid-template-columns: 1.4fr 1fr 1fr; }
.home-actions.three .home-approve { font-size: 15px; padding: 0 4px; gap: 4px; }
.notice-box.no-rights { border-color: var(--danger); }

/* Radalla nyt, keskustelu ja syöte */
.presence-link { align-self: flex-start; margin-top: 6px; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--ok); background: transparent; color: var(--ok); font-size: 14px; font-weight: 600; }
.presence-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius); border: 2px solid var(--ok); background: var(--surface); }
.presence-card .today-tag { background: var(--ok); color: #fff; }
.presence-card h2 { margin: 0; font-family: var(--font-head); font-size: 22px; }
.presence-last { margin: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence-avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: var(--raised); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-size: 18px; font-weight: 700; }
.presence-row { align-items: center; }
.presence-checkin { display: flex; flex-direction: column; gap: 8px; }
.decision-buttons.inline { position: static; margin: 0; padding: 0; background: none; }
.chat-box { display: flex; flex-direction: column; gap: 8px; }
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px 0; }
.chat-message { align-self: flex-start; max-width: 85%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); }
.chat-message.mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border-color: var(--accent); }
.chat-meta { display: block; font-size: 12px; color: var(--muted); }
.chat-text { display: block; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom)); padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.chat-form input { flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border-radius: 24px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; }
.chat-send { min-height: 48px; width: 56px; padding: 0; border-radius: 24px; font-size: 20px; }
.post { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-who { display: flex; flex-direction: column; min-width: 0; }
.post-who small { color: var(--muted); font-size: 12px; }
.post-text { margin: 0; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.post-media-grid { display: grid; gap: 4px; margin: 0 -12px; }
.post-media-grid.multi { grid-template-columns: 1fr 1fr; }
.post-media-wrap { position: relative; display: block; }
.post-media { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; background: var(--raised); }
video.post-media { aspect-ratio: auto; max-height: 60vh; object-fit: contain; background: #000; }
.post-actions { display: flex; align-items: center; gap: 14px; }
.post-like { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 15px; font-weight: 600; }
.post-like.liked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-text); }
.photo-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.presence-card .primary-button { font-size: 18px; letter-spacing: 1px; }

/* Koti: pikakirjaus ja hienovarainen muistutus */
.repeat-last {
  align-self: stretch; min-height: 44px; margin-top: -4px; padding: 0 12px; border-radius: 8px; border: 1px dashed var(--line);
  background: transparent; color: var(--accent-text); font-size: 15px; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.todo-row.tone-soft { border-style: dashed; color: var(--muted); }
.tone-soft .todo-dot { background: var(--muted); }
