/* InkMyWorld — light, near-monochrome UI after the Ronas IT delivery app: white cards on a soft grey
   canvas, black actions, and colour reserved for the places you mark. */

:root {
  --bg: #efefed;
  --card: #ffffff;
  --well: #f5f5f3;
  --line: #e4e4e1;
  --text: #1c1c1c;
  --muted: #777774;
  --land: #e3e3e0;
  --land-edge: #ffffff;
  --coast: #b9b9b5;
  --primary: #1c1c1c;
  --on-primary: #ffffff;
  --tag: #c5f04a;
  --danger: #c4314b;
  --spot: #c5f04a;
  --on-spot: #1c1c1c;
  --radius: 22px;
  --radius-sm: 14px;
  --font: "Lexend", system-ui, sans-serif;
  --gutter: clamp(16px, 3vw, 32px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --card: #1b1b1b;
    --well: #242424;
    --line: #2e2e2e;
    --text: #f1f1ef;
    --muted: #9b9b97;
    --land: #2c2c2b;
    --land-edge: #1b1b1b;
    --coast: #4a4a48;
    --primary: #f1f1ef;
    --on-primary: #121212;
    --danger: #ff7a91;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212;
  --card: #1b1b1b;
  --well: #242424;
  --line: #2e2e2e;
  --text: #f1f1ef;
  --muted: #9b9b97;
  --land: #2c2c2b;
  --land-edge: #1b1b1b;
  --coast: #4a4a48;
  --primary: #f1f1ef;
  --on-primary: #121212;
  --danger: #ff7a91;
  color-scheme: dark;
}

/* One stack for every script: Lexend for Latin, then a matching face per script. A family is only
   downloaded once its script actually appears on the page (see ensureFontsFor in i18n.js). */
:root { --font: "Lexend", "Onest", "Anek Bangla", "Anek Devanagari", "Noto Kufi Arabic", "Noto Sans SC", "PingFang SC", system-ui, sans-serif; }
/* Letter-spacing breaks joined and conjunct scripts. */
:root:is([lang="bn"], [lang="hi"], [lang="ar"]) * { letter-spacing: 0 !important; }

*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  overflow-x: hidden;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute;
  inset-inline-start: 8px;
  top: -60px;
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 14px;
  border-radius: 10px;
  z-index: 200;
}
.skip:focus { top: 8px; }

.card { background: var(--card); border-radius: var(--radius); }

/* ---------- Top bar & footer ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px var(--gutter) 0;
  padding: 10px 12px 10px 16px;
  background: var(--card);
  border-radius: var(--radius);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 19px; letter-spacing: -0.01em; }
.brand-mark { width: 34px; height: 34px; }
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav a, .topnav span { white-space: nowrap; }
.topnav > a:not(.kofi) {
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}
.topnav > a:not(.kofi):hover { background: var(--well); }
.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-inline-start: 12px;
  height: 42px;
  border-radius: 12px;
  background: var(--well);
}
.lang svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.lang select {
  appearance: none;
  border: 0;
  background: transparent;
  height: 42px;
  padding-inline: 2px 30px;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
[dir="rtl"] .lang select { background-position: 15px 50%, 10px 50%; }
.lang select:focus-visible { outline: none; }
.lang:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.kofi {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px 0 12px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}
.kofi:hover { opacity: 0.88; }
.cup { width: 20px; height: 20px; flex: none; }

main { flex: 1; width: 100%; }
main:focus { outline: none; }

.foot {
  margin: 0 var(--gutter) 18px;
  padding: 18px 20px;
  background: var(--card);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 32px;
  font-size: 13px;
  color: var(--muted);
}
.foot p { margin: 0; max-width: 72ch; }
.foot a { color: var(--text); }
.foot-kofi { flex-basis: 100%; }
.foot-kofi a { font-weight: 500; }

/* ---------- Shared bits ---------- */

.display {
  font-weight: 600;
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0;
  text-wrap: balance;
}
:root:is([lang="bn"], [lang="hi"], [lang="ar"]) .display { line-height: 1.3; }
.display.small { font-size: clamp(28px, 4vw, 40px); }
.eyebrow { margin: 0; font-size: 13px; color: var(--muted); }
.label { font-size: 13px; color: var(--muted); }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:hover { background: var(--well); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { opacity: 0.88; }
.btn.big { min-height: 54px; font-size: 16px; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--well); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--tag);
  color: #1c1c1c;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap;
}
.tag.lived { background: #d7a6ff; }
.tag.want { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--well);
  border: 0;
  margin: 0;
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  text-align: center;
}
.segmented input:checked + span { background: var(--primary); color: var(--on-primary); }
.segmented input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 1px; }

/* Swatches for a mark: solid, solid + dots, tint + hatching. */
.mark {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--land);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.mark.been { background: var(--spot); }
.mark.lived { background: radial-gradient(circle, var(--on-spot) 0.9px, transparent 1.2px) 0 0 / 3.6px 3.6px, var(--spot); }
.mark.want {
  background: repeating-linear-gradient(45deg, rgba(28, 28, 28, 0.55) 0 1.2px, transparent 1.2px 5px),
    color-mix(in srgb, var(--spot) 38%, var(--land));
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 16px;
  padding: 16px var(--gutter);
  max-width: 1480px;
  margin: 0 auto;
  align-items: stretch;
}
.hero-copy { padding: clamp(24px, 3.4vw, 44px); display: flex; flex-direction: column; gap: 22px; }
.lede { font-size: clamp(16px, 1.3vw, 18px); color: var(--muted); margin: 0; max-width: 46ch; font-weight: 300; }
.suggest {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 500;
  cursor: pointer;
}
.suggest::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tag); box-shadow: 0 0 0 1px #1c1c1c; }

.maker { display: grid; gap: 16px; }
.maker-title { margin: 6px 0 0; font-size: 20px; font-weight: 600; }
.field { display: grid; gap: 7px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend, .field > label { font-size: 13px; color: var(--muted); padding: 0; }

/* Country picker: a list of matches in every language, under the input. */
.combo { position: relative; }
.combo-list {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 320px;
  overflow: auto;
}
.combo-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.combo-list li small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--well); }
.field input,
.search,
.pnote input,
.pnote textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--well);
  font-size: 16px;
}
.field input:focus,
.search:focus,
.pnote input:focus,
.pnote textarea:focus { outline: none; border-color: var(--text); background: var(--card); }
.field input::placeholder,
textarea::placeholder,
.search::placeholder { color: var(--muted); opacity: 0.85; }
.field-note { font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-empty { margin: 0; color: var(--muted); font-size: 14.5px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.chip span {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--well);
  font-weight: 500;
  font-size: 14.5px;
}
.chip em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.chip input:checked + span { background: var(--primary); color: var(--on-primary); }
.chip input:checked + span em { color: inherit; opacity: 0.7; }
.chip input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

.form-error { margin: 0; color: var(--danger); font-weight: 500; font-size: 14.5px; }
.notice { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--well); font-size: 14.5px; }
.restore-line { margin: 0; font-size: 14px; color: var(--muted); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.hero-map {
  margin: 0;
  position: relative;
  padding: clamp(20px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 520px;
}
.hero-map .map-frame { transition: opacity 0.2s; }
.hero-map .map-frame.is-loading { opacity: 0.4; }
.hero-map figcaption {
  margin: 16px auto 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--well);
  font-size: 13px;
  color: var(--muted);
  max-width: 60ch;
  text-align: center;
}

.shelf { max-width: 1480px; margin: 0 auto; padding: 0 var(--gutter) 24px; }
.shelf-inner { padding: clamp(20px, 3vw, 32px); }
.shelf-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 20px; }
.shelf-head h2 { font-size: 22px; font-weight: 600; margin: 0; }
.shelf-head p { margin: 0; color: var(--muted); font-size: 14px; flex: 1 1 320px; }
.shelf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card-link {
  display: grid;
  gap: 4px;
  padding: 10px 10px 14px;
  border-radius: 18px;
  background: var(--well);
  text-decoration: none;
  transition: transform 0.15s;
}
.card-link:hover { transform: translateY(-2px); }
.card-link img, .card-blank {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 8px;
}
.card-title { font-weight: 500; font-size: 16px; padding: 0 4px; }
.card-meta { font-size: 13px; color: var(--muted); padding: 0 4px; }

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

.map-frame {
  position: relative;
  --tall: 78vh;
  width: min(100%, calc(var(--tall) * var(--r, 0.8)));
  margin-inline: auto;
  aspect-ratio: var(--ratio, 4 / 5);
}
.map-frame .map { display: block; width: 100%; height: 100%; overflow: visible; }
.map .base path { fill: var(--land); stroke: var(--land-edge); stroke-width: 1px; vector-effect: non-scaling-stroke; cursor: pointer; }
.hero-map .map .base path { cursor: default; }
.map .solid path { fill: var(--spot); }
.map .want path { pointer-events: none; }
.map .wt-tint { fill: color-mix(in srgb, var(--spot) 38%, var(--land)); }
.map .wt-line { fill: rgba(28, 28, 28, 0.5); }
.map .lived path { pointer-events: none; }
.map .lv-dot { fill: var(--on-spot); opacity: 0.75; }
.map .ink path { pointer-events: none; }
.map .borders { fill: none; stroke: var(--land-edge); stroke-width: 1.1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.map .outline { fill: none; stroke: var(--coast); stroke-width: 1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.map .hover { fill: none; stroke: var(--text); stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.map .flash { fill: var(--text); opacity: 0; pointer-events: none; }
.map .flash.on { animation: flash 0.6s ease-out; }
@keyframes flash { from { opacity: 0.22; } to { opacity: 0; } }
.map.zoomed { cursor: grab; }

/* Tally badge: a round tag in the map's colour, tucked into whichever corner the map leaves empty. */
.stamp-slot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: clamp(104px, 19%, 180px);
  aspect-ratio: 1;
  pointer-events: none;
  rotate: -8deg;
  z-index: 2;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12));
}
.stamp-slot[data-corner="tr"] { bottom: auto; top: 0; }
.stamp-slot[data-corner="bl"] { right: auto; left: 0; }
.stamp-slot[data-corner="tl"] { right: auto; left: 0; bottom: auto; top: 0; }
.stamp-slot svg { width: 100%; height: 100%; overflow: visible; }
.stamp-slot .st-disc { fill: var(--spot); stroke: #1c1c1c; stroke-width: 2.5; }
.stamp-slot .st-ring { fill: none; stroke: var(--on-spot); stroke-width: 1.2; stroke-dasharray: 2 4; opacity: 0.6; }
.stamp-slot text { fill: var(--on-spot); font-family: var(--font); }
.stamp-slot .st-arc { font-weight: 600; font-size: 15px; letter-spacing: 1.6px; text-transform: uppercase; }
.stamp-slot .st-count { font-weight: 700; letter-spacing: -0.03em; }
.stamp-slot .st-of { font-weight: 500; font-size: 14px; }
.stamp-slot.thunk { animation: thunk 0.32s cubic-bezier(0.3, 1.6, 0.6, 1); }
@keyframes thunk { 0% { transform: scale(1.15); } 100% { transform: scale(1); } }

.zoom-ctl { position: absolute; top: 0; left: 0; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.zoom-ctl button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 19px;
  font-weight: 500;
  cursor: pointer;
}
.zoom-ctl button:hover { background: var(--well); }

.tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  pointer-events: none;
  background: var(--card);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: grid;
  gap: 2px;
  font-size: 13px;
  white-space: nowrap;
}
.tooltip strong { font-size: 15px; font-weight: 500; }
.tooltip span { color: var(--muted); }

.hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  translate: -50% 0;
  margin: 0;
  z-index: 4;
  background: var(--primary);
  color: var(--on-primary);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  white-space: nowrap;
}

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

.page { max-width: 1480px; margin: 0 auto; padding: 16px var(--gutter) 24px; }
.loading { padding: 80px 0; color: var(--muted); }
.empty-state { padding: 40px; }
.empty-state p { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.banner { margin: 0 0 14px; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--card); font-size: 15px; display: flex; gap: 10px; align-items: center; }
.banner::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tag); flex: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  position: sticky;
  top: 16px;
  overflow: hidden;
}
.side-head { padding: 22px 22px 14px; display: grid; gap: 14px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-title h2 { margin: 0; font-size: 22px; font-weight: 600; }
.count-chip { font-size: 13px; color: var(--muted); background: var(--well); padding: 6px 10px; border-radius: 10px; white-space: nowrap; }
.inks { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inks legend { float: inline-start; margin-inline-end: 6px; padding: 0; font-size: 13px; color: var(--muted); line-height: 30px; }
.ink { position: relative; cursor: pointer; }
.ink input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.ink span { display: block; width: 28px; height: 28px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.ink input:checked + span { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text); }
.ink input:focus-visible + span { outline: 2px dashed var(--text); outline-offset: 5px; }

.tabs { display: flex; gap: 4px; margin: 0 22px; padding: 4px; border-radius: 16px; background: var(--well); }
.tabs button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 500;
  font-size: 14.5px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.tabs button span { font-size: 12px; color: var(--muted); margin-inline-start: 4px; }

.tab-body { overflow: auto; overscroll-behavior: contain; min-height: 0; flex: 1; }
.finder { position: sticky; top: 0; background: var(--card); padding: 12px 22px; display: grid; gap: 10px; z-index: 1; }
.search { min-height: 44px; font-size: 15px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 0; background: var(--well); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

.places, .diary { list-style: none; margin: 0; padding: 4px 14px 16px; display: grid; gap: 6px; }
.place {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 8px;
  padding: 4px 10px 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--well);
  border: 1px solid transparent;
}
.place.on { background: var(--card); border-color: var(--line); }
.place.pulse { animation: pulse 0.9s ease-out; }
@keyframes pulse { from { border-color: var(--text); } to { border-color: var(--line); } }
.pcheck { display: flex; align-items: center; gap: 11px; min-height: 44px; cursor: pointer; min-width: 0; }
.pcheck input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pcheck input:focus-visible + .mark { outline: 2px solid var(--text); outline-offset: 2px; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.place.on .pname { font-weight: 500; }
.pdate { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pnote-btn {
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  visibility: hidden;
}
.pnote-btn:hover { background: var(--well); color: var(--text); }
.place.on .pnote-btn { visibility: visible; }
.pnote { grid-column: 1 / -1; display: grid; gap: 10px; padding: 4px 0 12px; }
.pnote label { display: grid; gap: 5px; }
.pnote label span { font-size: 12.5px; color: var(--muted); }
.pnote input { min-height: 42px; font-size: 15px; }
.pnote textarea { min-height: 80px; resize: vertical; font-size: 15px; line-height: 1.45; }
.place.ro { grid-template-columns: auto minmax(0, 1fr) auto; min-height: 48px; padding-block: 10px; gap: 4px 11px; }
.pnote-ro { grid-column: 2 / -1; margin: 0; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.list-empty { padding: 18px 10px; color: var(--muted); font-size: 14.5px; list-style: none; }

.diary li:not(.list-empty) { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--well); }
.diary h3 { margin: 4px 0; font-size: 17px; font-weight: 600; }
.d-place { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; text-align: start; }
.d-place:hover { text-decoration: underline; }
.d-when { margin: 0; font-size: 12.5px; color: var(--muted); }
.d-note { margin: 0; white-space: pre-wrap; font-size: 14.5px; }

.stage { display: grid; gap: 16px; min-width: 0; }
.stage-map { position: relative; padding: clamp(16px, 2.4vw, 32px); }

/* The floating summary, like the order card in the reference: title, tag, actions, then stat columns. */
.summary { padding: 18px 22px 20px; display: grid; gap: 16px; }
.sum-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.sum-title { flex: 1 1 280px; display: grid; gap: 2px; min-width: 0; }
.title-input,
.title-text {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  resize: none;
  overflow: hidden;
  display: block;
  border-radius: 0;
}
.title-text, .title-input, .card-title, .display, .d-place, .d-note, .pnote-ro { overflow-wrap: anywhere; }
.title-input:hover { border-bottom-color: var(--line); }
.title-input:focus { outline: none; border-bottom-color: var(--text); }
.sum-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sum-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px 18px;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sum-stats div { display: grid; gap: 2px; }
.sum-stats dt { font-size: 13px; color: var(--muted); }
.sum-stats dd { margin: 0; font-size: 18px; font-weight: 500; }
.progress { height: 6px; border-radius: 999px; background: var(--well); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--spot); border-radius: inherit; transition: width 0.3s; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
[dir="rtl"] .progress i { margin-inline-start: auto; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 16px; border-top: 1px solid var(--line); }
.size { display: inline-flex; align-items: center; gap: 8px; margin-inline-end: auto; }
.size span { font-size: 13px; color: var(--muted); }
.size select {
  appearance: none;
  min-height: 46px;
  padding: 0 34px 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--well);
  font-weight: 500;
  font-size: 14.5px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
[dir="rtl"] .size select { padding: 0 14px 0 34px; background-position: 17px 50%, 12px 50%; }
.thanks { margin: 0; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--well); font-size: 14.5px; }
.thanks a { font-weight: 500; }

/* ---------- Dialog & toast ---------- */

dialog { border: 0; border-radius: var(--radius); background: var(--card); color: var(--text); padding: 26px; max-width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { font-size: 22px; font-weight: 600; margin: 0 0 10px; overflow-wrap: anywhere; }
dialog p { margin: 0 0 22px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  translate: -50% 20px;
  background: var(--primary);
  color: var(--on-primary);
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 500;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, translate 0.2s;
  z-index: 150;
}
#toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .kofi span { display: none; }
  .kofi { padding: 0 11px; }
}
@media (max-width: 1040px) {
  .hero { grid-template-columns: 1fr; }
  .hero-map { min-height: 0; }
  .hero-map .map-frame { --tall: 54vh; }
  .workspace { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .side { position: static; max-height: none; }
  .tab-body { overflow: visible; }
  .map-frame { --tall: 62vh; }
}
@media (max-width: 600px) {
  .topbar { margin-top: 10px; padding: 8px 8px 8px 12px; }
  .brand span { display: none; }
  .topnav > a:not(.kofi) { padding: 10px 8px; font-size: 14px; }
  .kofi span { display: none; }
  .kofi { padding: 0 11px; }
  .lang select { max-width: 110px; }
  .downloads .btn, .sum-actions .btn { flex: 1 1 calc(50% - 8px); }
  .size { flex-basis: 100%; margin: 0; }
  .size select { flex: 1; }
  .tooltip { display: none; }
  .stamp-slot { width: 28%; }
}

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