* { box-sizing: border-box }
:root {
  color-scheme: light;
  --page: #f7f3eb;
  --paper: #fcfaf4;
  --ink: #14291f;
  --muted: #53655b;
  --line: #e6dfd1;
  --line-strong: #d5cbba;
  --forest: #153b2b;
  --forest-hover: #24523e;
  --accent: #efad58;
  --focus: #38724f;
  --bar-height: 72px;
  --map-inset: clamp(18px, 2.25vw, 36px);
  font: 16px/1.5 system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}
[hidden] { display: none !important }
body { margin: 0 }
h1, h2, p { margin: 0 }
h1, h2, .brand span { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.035em }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.08 }
h2 { margin-bottom: 14px; font-size: 1.65rem; line-height: 1.15 }
p { color: var(--muted); margin-top: 8px }
button, input, select { font: inherit; color: inherit }
button {
  cursor: pointer;
  font-weight: 640;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  min-height: 44px;
  transition: background-color .15s, border-color .15s;
}
button:disabled { opacity: .65; cursor: wait }
:where(button, a, input, select):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px }
.primary { color: white; background: var(--forest); border-color: var(--forest) }
.primary:hover { background: var(--forest-hover); border-color: var(--forest-hover) }
.quiet { background: var(--paper); border-color: var(--line-strong) }
.quiet:hover { background: #f1eadc; border-color: #bcb19c }
.danger { background: #fbefeb; border-color: #eccfc3; color: #832e23 }
.danger:hover { background: #f7e2d9 }

.top { background: var(--forest); color: #fffaf0; position: relative; z-index: 3 }
.bar {
  min-height: var(--bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px clamp(16px, 2.1vw, 32px);
}
.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; white-space: nowrap }
.brand span { font-size: 1.7rem }
.brand img { width: 43px; height: 43px }
.header-actions, #account-tools { display: flex; align-items: center; gap: 9px; min-width: 0 }
.header-actions { justify-content: flex-end }
.account-chip { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 5px; border-radius: 999px; background: #ffffff16 }
#account-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--forest);
  font-size: .875rem;
  font-weight: 750;
}
#account-name { max-width: min(22vw, 210px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#logout, #admin-toggle { color: #fffaf0; background: transparent }
#logout { border-color: #ffffff55 }
#logout:hover, #admin-toggle:hover, #admin-toggle[aria-expanded="true"] { background: #ffffff19 }
.admin-short { display: none }
.top :focus-visible { outline-color: var(--accent) }

main { width: min(1440px, 100%); margin: auto; padding: clamp(24px, 4vw, 52px) clamp(16px, 4vw, 58px) 40px }
.dashboard-view main { width: 100%; padding: 0 }
.auth-shell {
  width: min(1020px, 100%);
  min-height: 530px;
  margin: clamp(12px, 4vh, 50px) auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 20px 60px -34px #18332866;
}
.auth-art { display: grid; grid-template-rows: 1fr auto; min-width: 0; margin: 0; background: #e9d6b7 }
.auth-map { position: relative; min-height: 0 }
.auth-map img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover }
.auth-art figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 12px;
  padding: 12px 18px;
  background: #efe5d1;
  color: #3c3326;
  font-size: .875rem;
}
.auth-content { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 5vw, 66px); min-width: 0; background: #faf6ee }
.auth-content h1 { font-size: clamp(2.15rem, 4vw, 3.25rem) }
.auth-content form { margin-top: 24px; gap: 16px }
.auth-content button { margin-top: 4px }
.auth-content input { min-height: 48px }

body:not(.dashboard-view) #site-header[hidden] + main {
  display: grid;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-block: 24px;
}
#site-header[hidden] + main .auth-shell { margin-top: 0 }

.layout {
  position: relative;
  min-height: 400px;
  height: calc(100vh - var(--bar-height));
  height: calc(100dvh - var(--bar-height));
  background: #e8eadc;
}
.layout.guest { height: 100vh; height: 100dvh }
.map-card { position: relative; height: 100%; isolation: isolate }
#map { width: 100%; height: 100%; background: #e5e9db }
#map-note { position: absolute; z-index: 1; left: 12px; bottom: 12px; margin: 0; padding: 6px 10px; border-radius: 8px; background: var(--paper); font-size: .875rem }
.map-card .leaflet-control-zoom {
  border: 1px solid var(--line-strong);
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 10px #153b2b35;
  margin: 14px 0 0 14px;
}
.map-card .leaflet-control-zoom a { width: 36px; height: 36px; line-height: 36px; color: var(--ink); background: var(--paper) }
.map-card .leaflet-control-attribution { border-top-left-radius: 8px; padding: 2px 7px }
.map-card .leaflet-tooltip { background: var(--forest); color: white; border-color: var(--forest); border-radius: 7px; padding: 4px 8px; font-weight: 650 }
.map-card .leaflet-tooltip-top::before { border-top-color: var(--forest) }
.map-pin .pin-head {
  display: block;
  width: 24px;
  height: 24px;
  margin: 2px auto 0;
  border: 2px solid #fffdf5;
  border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  box-shadow: -2px 3px 5px #1a3a2966;
}
.map-pin .pin-head::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #fffdf5 }
.map-pin.stale .pin-head { opacity: .72; border-style: dashed }

.sidebar {
  position: absolute;
  z-index: 2;
  inset: var(--map-inset) var(--map-inset) auto auto;
  display: grid;
  gap: 15px;
  width: clamp(300px, 28vw, 406px);
  max-height: calc(100% - var(--map-inset) * 2);
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  pointer-events: none;
}
.sidebar > .card, .sidebar > * > .feedback { pointer-events: auto }
#dashboard-feedback { display: contents }
.card {
  min-width: 0;
  padding: clamp(18px, 2vw, 27px);
  border: 1px solid #f8f3e8;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 3px 16px #193a2620;
}
#shared-panel h1 { font-size: clamp(1.85rem, 3vw, 2.5rem) }
#summary { margin-top: 8px }
#summary.has-live { display: flex; align-items: center; gap: 8px }
#summary.has-live::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #bd6044 }
#shared-list { margin-top: 15px }
#shared-list > p:only-child { margin: 0 }
.shared {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px;
  margin: 0 0 8px;
  border: 1px solid #ece5d8;
  border-radius: 17px;
  background: #eee8db;
  text-align: left;
  overflow-wrap: anywhere;
}
.shared:last-child { margin-bottom: 0 }
button.shared:hover { background: #e7dfcd }
.shared-person { display: block; min-width: 0 }
.shared-person strong { font-weight: 680 }
.shared-color {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: none;
  border-radius: 50%;
  color: white;
  font-weight: 740;
}
.shared small { display: block; color: var(--muted); font-size: .875rem; font-weight: 450 }

form { display: grid; gap: 14px; margin-top: 16px }
label, legend { display: block; font-size: .9375rem; font-weight: 620 }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #fffdf9;
}
select { background: #f7f2e9 }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px }
.actions button { overflow-wrap: anywhere }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0 }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-weight: 500; overflow-wrap: anywhere }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--forest) }
.form-note { font-size: .875rem }
#people { max-height: 220px; overflow: auto }
#link-box { margin-top: 16px }
#copy-link { margin-top: 8px }
#start > .primary { width: 100% }
#arrival-panel .actions button { flex: 1 1 120px }
#arrival-result { color: var(--ink); font-weight: 650; margin: 14px 0 5px }
#arrival-panel .form-note { margin: 0 }
#arrival-map[aria-pressed="true"] { background: #ede3c6 }
.leaflet-container.picking-destination { cursor: crosshair }

.feedback { margin: 0; padding: 11px 14px; border: 1px solid #c7dbc7; border-radius: 13px; background: #eaf1e5 }
.feedback.error { color: #7f281d; background: #fbefeb; border-color: #eccfc3 }
#auth-feedback .feedback { margin: 12px 0 0 }
.admin-users { margin-top: 20px }
.admin-row { display: grid; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere }
.admin-row:last-child { padding-bottom: 0 }
.admin-identity { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0 }
.admin-identity > span { color: var(--muted); font-size: .875rem }
.admin-identity .account-role { padding: 2px 8px; border-radius: 8px; background: #e9eee2; color: #2b583f }
.admin-row .actions { margin-top: 0 }
.admin-row .actions button { padding-inline: 11px; font-size: .875rem }
.admin-row > form { margin-top: 0; padding: 12px; background: #f3eddf; border-radius: 11px }
.admin-row > form button { justify-self: start }

@media (max-width: 740px) {
  :root { --bar-height: 62px }
  .bar { padding-inline: 12px; gap: 6px }
  .brand { gap: 7px }
  .brand img { width: 34px; height: 34px }
  .brand span { font-size: 1.19rem }
  .header-actions, #account-tools { gap: 4px }
  .account-chip { display: none }
  #logout, #admin-toggle { padding-inline: 9px; font-size: .875rem }
  .auth-shell { max-width: 460px; min-height: 0; margin-top: 6px; grid-template-columns: minmax(0, 1fr); border-radius: 21px }
  .auth-map { min-height: clamp(150px, 49vw, 218px) }
  .auth-map img { object-position: center 72% }
  .auth-art figcaption { padding-inline: 12px }
  .auth-content { padding: 24px }
  .layout { height: auto; min-height: calc(100vh - var(--bar-height)); background: var(--page) }
  .map-card { height: 48vh; height: clamp(275px, 49svh, 460px) }
  .sidebar {
    position: static;
    max-height: none;
    width: auto;
    padding: 13px;
    gap: 12px;
    pointer-events: auto;
    overflow: visible;
  }
  .card { padding: 17px; border-radius: 19px }
  h2 { font-size: 1.42rem }
  .layout.guest { min-height: 100vh; min-height: 100dvh; height: auto }
  .layout.guest .map-card { height: 73vh; height: 73svh }
}
@media (max-width: 460px) {
  .admin-full { display: none }
  .admin-short { display: inline }
}
@media (max-width: 360px) {
  .brand span { font-size: 1.06rem }
  .brand img { width: 30px; height: 30px }
  #admin-toggle, #logout { padding-inline: 6px }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none }
}
