:root {
  --cream: #faf5ea; --paper: #fffdf8; --line: #e6dcc7; --ink: #3a2a24; --muted: #8a7b6c;
  --wine: #7b2d3b; --wine-dark: #5d1f2b; --leaf: #6b7a3a; --gold: #c99a3b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--cream); }
body.app { display: flex; }
a { color: var(--wine); }
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0; }
.muted { color: var(--muted); } .small { font-size: .82rem; }

.rail { width: 76px; flex: none; background: var(--wine-dark); color: #f3e6d8; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; }
.rail a { color: inherit; text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 60px; padding: 9px 0; border-radius: 12px; font-size: .72rem; opacity: .8; }
.rail a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.rail a.active { opacity: 1; background: rgba(255,255,255,.16); }
.rail .brand { margin-bottom: 14px; color: var(--gold); opacity: 1; }
.rail .brand circle { fill: currentColor; }

.mapPage { flex: 1; display: flex; min-width: 0; height: 100vh; }
.mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #e9e1cd; }
.mapTools { position: absolute; z-index: 500; top: 14px; left: 56px; display: flex; gap: 8px; flex-wrap: wrap; }
.tool { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 7px 13px; border-radius: 999px; cursor: pointer; box-shadow: 0 1px 3px rgba(60,30,20,.15); }
.tool:hover { border-color: var(--wine); }
.tool.primary { background: var(--wine); color: #fff; border-color: var(--wine); }
.tool.on { background: var(--gold); border-color: var(--gold); color: #2b1d10; }
.hint, .status { position: absolute; z-index: 500; left: 50%; transform: translateX(-50%); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: .85rem; box-shadow: 0 2px 8px rgba(60,30,20,.18); max-width: 80%; }
.hint { top: 58px; } .status { bottom: 18px; } .status:empty { display: none; }
[hidden] { display: none !important; }

.panel { width: 400px; flex: none; background: var(--paper); border-left: 1px solid var(--line); overflow-y: auto; padding: 18px 20px 28px; }
.panelHead h1 { font-size: 1.6rem; color: var(--wine-dark); }
.where { margin: 4px 0 14px; color: var(--muted); font-size: .88rem; }
.group { margin-bottom: 14px; } .group.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; display: block; }
.group.row .label { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .82rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--cream); cursor: pointer; color: var(--ink); }
.chip small { color: var(--muted); margin-left: 3px; }
.chip[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; } .chip[aria-pressed="true"] small { color: #e8c9cf; }
select, input[type=text], #saveName { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.check { font-size: .88rem; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.areas { list-style: none; margin: 0 0 6px; padding: 0; } .areas li { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; margin-bottom: 4px; background: rgba(201,154,59,.16); border-radius: 8px; font-size: .85rem; }
.areas button { border: 0; background: none; cursor: pointer; color: var(--wine); font: inherit; }
.save { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; margin: 4px 0 14px; }
.saveRow { display: flex; gap: 8px; margin-bottom: 6px; } #saveName { flex: 1; min-width: 0; }

.listHead { font-family: var(--serif); font-size: 1.05rem; margin-bottom: 8px; } .listHead .muted { font-family: var(--sans); font-size: .8rem; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.card:hover, .card:focus-visible { border-color: var(--wine); outline: none; box-shadow: 0 2px 8px rgba(123,45,59,.14); }
.card h3 { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.km { font-family: var(--serif); font-size: 1.15rem; color: var(--wine); text-align: right; white-space: nowrap; } .km small { font-size: .75rem; color: var(--muted); }
.meta { grid-column: 1 / -1; font-size: .83rem; color: var(--muted); }
.tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: .73rem; padding: 2px 8px; border-radius: 999px; background: #eef0dc; color: #4b5a22; }
.tag.rest { background: #f6e3e6; color: var(--wine-dark); }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

.pin { width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--wine); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.rest { background: var(--leaf); } .pin.sel { background: var(--gold); }
.me { width: 16px; height: 16px; border-radius: 50%; background: #2c6fbb; border: 3px solid #fff; box-shadow: 0 0 0 3px rgba(44,111,187,.3); }
.cell { background: rgba(123,45,59,.88); color: #fff; border: 3px solid rgba(255,255,255,.85); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 700; box-shadow: 0 1px 6px rgba(0,0,0,.35); }

.page { flex: 1; overflow-y: auto; padding: 32px 40px 60px; max-width: 860px; }
.page h1 { font-size: 2rem; color: var(--wine-dark); } .page h2 { font-size: 1.25rem; margin: 28px 0 10px; }
.lede { color: var(--muted); max-width: 60ch; }
.saves, .plain { list-style: none; padding: 0; margin: 0; }
.saveItem { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 999px; margin-left: 6px; } .badge.ok { background: #e4ebcb; color: #44541c; } .badge.warn { background: #f8e2c3; color: #7a4b0b; }
.matchBox { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.matchHead { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.plain li { padding: 3px 0; } .error { color: #9c2b2b; }

@media (max-width: 860px) {
  body.app { flex-direction: column-reverse; height: auto; }
  .rail { width: 100%; flex-direction: row; justify-content: center; padding: 6px; position: sticky; bottom: 0; z-index: 900; }
  .rail .brand { display: none; }
  .mapPage { flex-direction: column; height: auto; }
  .mapWrap { height: 55vh; flex: none; }
  .panel { width: 100%; border-left: 0; }
  .page { padding: 20px; }
}
