:root {
  --ink: #1c1914;
  --muted: #6b6458;
  --paper: #f6f1e6;
  --sheet: #fffdf8;
  --line: #e4dccb;
  --a: #2f4a38;
  --b: #c3922e;
  --c: #9a2f24;
  --none: #9a9284;
  --shadow: 0 12px 40px rgba(28, 25, 20, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  font: 15px/1.45 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background: var(--paper);
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
}
.word { font-weight: 700; letter-spacing: -0.03em; font-size: 1.25rem; }
.sub { margin-left: 6px; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
.modes { display: flex; gap: 4px; }
.modes button, .boros button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  cursor: pointer;
}
.modes button.on { background: var(--ink); color: var(--paper); }
.city select, .sort select {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
}
.links { margin-left: auto; display: flex; gap: 14px; }
.links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}
#q {
  flex: 1 1 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  background: #fff;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  cursor: pointer;
}
.chips button.on[data-grade="A"], .stamp.A { background: var(--a); color: #f6f1e6; border-color: var(--a); }
.chips button.on[data-grade="B"], .stamp.B { background: var(--b); color: #1c1914; border-color: var(--b); }
.chips button.on[data-grade="C"], .stamp.C { background: var(--c); color: #fff; border-color: var(--c); }
.chips button.on[data-grade="none"], .stamp.none { background: var(--none); color: #fff; border-color: var(--none); }
.chips button.on[data-grade="all"] { background: var(--ink); color: var(--paper); }

.boros {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

#workspace { position: relative; min-height: 0; display: grid; }
#map, #list { min-height: 280px; }
#list {
  overflow: auto;
  padding: 8px 12px 28px;
  background: var(--paper);
}
#list button {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font: inherit;
  padding: 10px 4px;
  cursor: pointer;
}

#picker {
  position: absolute;
  z-index: 4;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  max-width: 280px;
}
#picker button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 6px 8px;
  cursor: pointer;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 48%;
  background: var(--sheet);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: auto;
  z-index: 3;
  padding: 0 16px 24px;
}
.handle {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 8px auto 10px;
}
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.kicker { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { font-size: 1.35rem; margin: 0.2rem 0 0.4rem; }
.meta { color: var(--muted); margin: 0 0 8px; }
.mix { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 0; }
.mix span { font-size: 0.92rem; }
.actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.actions a, .actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  cursor: pointer;
}
.hint { color: var(--muted); font-size: 0.88rem; }
.visits { margin: 12px 0 0; padding: 0; list-style: none; }
.visits li {
  border-top: 1px solid var(--line);
  padding: 8px 0;
  font-size: 0.92rem;
}
#accountBtn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  cursor: pointer;
}
.err { color: var(--c); font-size: 0.88rem; }
.community { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--line); }
.community h2 { font-size: 1rem; margin: 0 0 6px; }
.community textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  background: #fff;
}
.community form { display: grid; gap: 8px; margin-top: 8px; }
dialog.auth {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: var(--sheet);
  color: var(--ink);
  max-width: 360px;
  width: calc(100% - 32px);
}
dialog.auth::backdrop { background: rgba(28, 25, 20, 0.35); }
dialog.auth form { display: grid; gap: 10px; }
dialog.auth label { display: grid; gap: 4px; font-size: 0.9rem; }
dialog.auth input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}
dialog.auth label.check,
label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9rem;
}
label.check input { margin-top: 3px; }
.hp {
  position: absolute;
  left: -9999px;
  height: 0;
  width: 0;
  opacity: 0;
}
.nudge {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #efe6d2;
  border-bottom: 1px solid var(--line);
}
.nudge[hidden] { display: none; }
.nudge p { margin: 0; font-size: 0.92rem; max-width: 62ch; }
.nudge button, .cta button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.nudge button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.cta { display: grid; gap: 8px; margin-top: 8px; }
.cta button { justify-self: start; }
#accountBtn {
  border: 1px solid var(--line);
}

@media (min-width: 900px) {
  body { grid-template-columns: 1fr 380px; grid-template-rows: auto auto auto auto 1fr; }
  .bar, .search-row, .boros, .nudge { grid-column: 1 / -1; }
  #workspace { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
  #map, #list { grid-column: 1; }
  .sheet {
    position: static;
    max-height: none;
    grid-column: 2;
    grid-row: 1;
    border-top: 0;
    border-left: 1px solid var(--line);
    box-shadow: none;
  }
  .handle { display: none; }
}
