/* Gdańsk i jul – julig men lugn: midnattsblått, julrött och guld. */

:root {
  --bg: #f7f1e6;
  --surface: #fffdf8;
  --surface-2: #f0e7d6;
  --text: #1c2233;
  --muted: #5e6475;
  --line: #e2d6c1;
  --primary: #a8232d;
  --primary-text: #fff;
  --accent: #b8862b;
  --accent-soft: #f6e7c4;
  --ok: #2f7a4a;
  --ok-soft: #dcefe2;
  --warn: #9a5a00;
  --warn-soft: #fbe9c9;
  --info-soft: #e3ebf7;
  --day1: #a8232d;
  --day2: #2f7a4a;
  --day3: #2b5fae;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 6%);
  --radius: 14px;
  --bar: #13213a;
  --bar-text: #f5e9cf;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d1626;
    --surface: #15223a;
    --surface-2: #1c2c48;
    --text: #f3ead8;
    --muted: #a7b0c2;
    --line: #2a3b5c;
    --primary: #d2434d;
    --accent: #e0b354;
    --accent-soft: #3a3020;
    --ok: #6cc28c;
    --ok-soft: #1f3a2a;
    --warn: #f0b765;
    --warn-soft: #3d2f17;
    --info-soft: #1d2d4a;
    --day1: #e0606a;
    --day2: #5fbf83;
    --day3: #6b9be6;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --bar: #0a1220;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0d1626;
  --surface: #15223a;
  --surface-2: #1c2c48;
  --text: #f3ead8;
  --muted: #a7b0c2;
  --line: #2a3b5c;
  --primary: #d2434d;
  --accent: #e0b354;
  --accent-soft: #3a3020;
  --ok: #6cc28c;
  --ok-soft: #1f3a2a;
  --warn: #f0b765;
  --warn-soft: #3d2f17;
  --info-soft: #1d2d4a;
  --bar: #0a1220;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

a {
  color: var(--primary);
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0.4rem 0;
}

button {
  font: inherit;
  color: inherit;
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 100;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.spacer {
  flex: 1;
}

/* --- Frame ----------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bar);
  color: var(--bar-text);
}

.topbar__title {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.topbar__dates {
  font-size: 0.85rem;
  opacity: 0.8;
}

.offline {
  margin: 0;
  padding: 8px 16px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.9rem;
}

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  outline: none;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  font-size: 0.68rem;
  color: var(--muted);
  text-decoration: none;
  min-width: 0;
}

.tabbar a span {
  font-size: 1.25rem;
  line-height: 1;
}

.tabbar a[aria-current='page'] {
  color: var(--primary);
  font-weight: 700;
}

body[data-route='login'] .tabbar,
body[data-route='login'] .topbar {
  display: none;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 8px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.count {
  background: var(--primary);
  color: var(--primary-text);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.8rem;
}

/* --- Cards & common blocks ------------------------------------------------------- */

.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.card h2 {
  margin-bottom: 6px;
}

.card--highlight {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

.card--booking {
  border-left: 5px solid var(--ok);
}

.card--todo {
  border-left: 5px solid var(--accent);
}

.card--lucka {
  background: linear-gradient(135deg, var(--surface) 60%, var(--accent-soft));
}

.card--lucka h2::before {
  content: '🎁 ';
}

.link {
  display: inline-block;
  margin-top: 6px;
  font-weight: 600;
  text-decoration: none;
}

.mini-list {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}

.mini-list li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

.mini-list li:last-child {
  border-bottom: 0;
}

.time {
  display: inline-block;
  min-width: 3.2em;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.big {
  font-size: 1.2rem;
  font-weight: 700;
}

.confirmation {
  display: inline-block;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 2px 8px;
}

.confirmation--big {
  font-size: 1.9rem;
  padding: 8px 14px;
  margin: 4px 0 0;
  word-break: break-all;
}

.notice {
  background: var(--warn-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 0.92rem;
}

.notice--info {
  background: var(--info-soft);
}

.check {
  color: var(--warn);
  font-size: 0.9rem;
}

.warn {
  display: block;
  color: var(--warn);
  font-size: 0.85rem;
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 6px 2px;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: none;
}

.tag--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

/* --- Home ------------------------------------------------------------------------ */

.hero {
  text-align: center;
  padding: 18px 0 8px;
}

.hero__count {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1;
  margin: 0;
  color: var(--primary);
}

.hero__label {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 4px 0;
}

.weather {
  text-align: center;
  color: var(--muted);
}

.weather--trip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0;
}

.weather--trip div {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  font-size: 0.85rem;
}

/* --- Buttons & forms ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn--accent {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: var(--primary);
  border-color: transparent;
  background: transparent;
}

.btn--small {
  min-height: 34px;
  padding: 4px 10px;
  font-size: 0.88rem;
}

.btn--block {
  width: 100%;
}

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  padding: 6px;
  min-width: 36px;
  min-height: 36px;
  cursor: pointer;
  text-decoration: none;
  border-radius: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.chip[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  margin: 8px 0;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 9px 6px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-selected='true'] {
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.form__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.field small {
  font-weight: 400;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  font-weight: 400;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

.check input {
  width: 20px;
  height: 20px;
}

.form__error {
  color: var(--primary);
  font-weight: 600;
  margin: 0;
}

.form__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.row--wrap {
  flex-wrap: wrap;
}

/* --- Sheets (dialogs) ------------------------------------------------------------ */

dialog.sheet {
  border: 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  width: min(560px, 100vw);
  max-width: 100vw;
  max-height: 92dvh;
  margin: auto auto 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
}

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

dialog.sheet::backdrop {
  background: rgb(5 10 20 / 55%);
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

/* --- Program ------------------------------------------------------------------- */

.sync .btn {
  white-space: nowrap;
}

.sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.event {
  display: grid;
  grid-template-columns: 3.6em 1fr auto;
  gap: 10px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}

.event--new {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.event__time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
}

.event__desc {
  font-size: 0.9rem;
}

.tip header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.tip__links {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
  margin: 6px 0;
}

.tip__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Bookings ------------------------------------------------------------------ */

.booking {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}

.booking__icon {
  font-size: 1.6rem;
}

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

.booking__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.85rem;
}

.status {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.status--att_boka {
  background: var(--accent-soft);
  color: var(--warn);
}

.status--bokad {
  background: var(--ok-soft);
  color: var(--ok);
}

.status--avbokad {
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: line-through;
}

.cancelled summary {
  cursor: pointer;
  color: var(--muted);
  margin: 18px 0 6px;
}

.detail__when {
  font-size: 1.05rem;
  font-weight: 600;
}

.detail__conf {
  margin: 12px 0;
}

.detail__conf small {
  display: block;
  color: var(--muted);
}

.detail__files .upload {
  display: flex;
  width: 100%;
}

.detail__files > small {
  display: block;
}

.detail__notes {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
}

.detail__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.detail__files {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.files {
  list-style: none;
  padding: 0;
}

.files li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.files li a {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload {
  cursor: pointer;
  margin: 6px 0;
}

/* --- Plan -------------------------------------------------------------------------- */

.day--today .section-title {
  color: var(--primary);
}

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

.entry {
  display: grid;
  grid-template-columns: 3.2em 1fr auto;
  gap: 8px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}

.entry--booking {
  border-left: 5px solid var(--ok);
}

.entry--done .entry__body strong {
  text-decoration: line-through;
  opacity: 0.6;
}

.entry__time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.entry__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

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

.done {
  width: 22px;
  height: 22px;
  accent-color: var(--ok);
}

/* --- Bingo -------------------------------------------------------------------------- */

.progress {
  position: relative;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0 14px;
}

.progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.progress span {
  position: relative;
  display: block;
  text-align: center;
  line-height: 30px;
  font-weight: 700;
  font-size: 0.9rem;
}

.bingo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.bingo__tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  min-height: 130px;
}

.bingo__tile small {
  color: var(--muted);
  font-size: 0.8rem;
}

.bingo__emoji {
  font-size: 1.7rem;
}

.bingo__tile.is-done {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.bingo__by {
  margin-top: auto;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ok);
}

/* --- Phrases ------------------------------------------------------------------------ */

.phrase {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}

.phrase__pl {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.phrase__say {
  color: var(--accent);
  margin: 2px 0;
  font-size: 0.92rem;
}

.phrase__sv {
  margin: 0;
  color: var(--muted);
}

/* --- More ---------------------------------------------------------------------------- */

.menu-list {
  display: grid;
  gap: 0;
}

.menu-item {
  display: flex;
  gap: 14px;
  align-items: center;
}

.menu-item > span:first-child {
  font-size: 1.8rem;
}

.menu-item span {
  display: flex;
  flex-direction: column;
}

.menu-item small {
  color: var(--muted);
}

/* --- Map ------------------------------------------------------------------------------ */

body[data-route='karta'] .view {
  max-width: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  /* Fill the space between the top bar (~46px) and the tab bar (68px). */
  height: calc(100dvh - 114px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.map-panel {
  padding: 4px 12px 6px;
}

.map-panel .chips {
  margin: 4px 0 6px;
}

.map-tools {
  margin: 0;
  gap: 6px;
}

.map-tools .opacity {
  flex: 1;
  min-width: 70px;
  accent-color: var(--primary);
}

.map-tools__note {
  flex: 1;
}

.map {
  /* Leaflet's panes and controls use z-indexes up to 1000; keep them below the tab bar. */
  isolation: isolate;
  flex: 1;
  min-height: 240px;
  background: var(--surface-2);
}

.calib {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 6px 10px;
}

.calib .row {
  margin: 4px 0 2px;
}

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

.mk {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 17px;
  background: #fff;
  border: 2px solid #13213a;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
  color: #13213a;
}

.mk--tip {
  border-color: #b8862b;
}

.mk--plan {
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.mk--day1 {
  background: #a8232d;
  border-color: #fff;
}

.mk--day2 {
  background: #2f7a4a;
  border-color: #fff;
}

.mk--day3 {
  background: #2b5fae;
  border-color: #fff;
}

.mk--booking {
  border-color: #2f7a4a;
}

.mk--att_boka {
  border-style: dashed;
  border-color: #b8862b;
}

.mk--pin {
  background: #fff8e6;
}

.mk--handle {
  background: #a8232d;
  color: #fff;
  border-color: #fff;
  font-weight: 800;
  cursor: grab;
}

.mk--mover {
  background: #13213a;
}

.leaflet-popup-content p {
  margin: 4px 0;
}

.leaflet-container {
  font-family: inherit;
}

/* --- Login & toasts ------------------------------------------------------------------- */

.login {
  min-height: 85dvh;
  display: grid;
  place-items: center;
}

.login__card {
  width: min(380px, 100%);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 20px;
  box-shadow: var(--shadow);
}

.login__card .form {
  text-align: left;
  margin-top: 16px;
}

.login__flake {
  font-size: 2.6rem;
  margin: 0;
  color: var(--accent);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  background: var(--bar);
  color: var(--bar-text);
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: opacity 0.4s;
}

.toast--error {
  background: var(--primary);
  color: #fff;
}

.toast--out {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
