  :root {
    --paper: #f1eadc;
    --paper-2: #f9f4ea;
    --card: #fdfbf6;
    --ink: #272219;
    --ink-soft: #6f675a;
    --muted: #8d8476;
    --line: #e3d9c8;
    --line-strong: #cdbfa7;
    --accent: #c1440e;
    --accent-ink: #8e3007;
    --teal: #1b5651;
    --danger: #b3261e;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(56,44,28,0.05), 0 16px 40px -26px rgba(56,44,28,0.5);
    --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
    --font-body: "Familjen Grotesk", "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    line-height: 1.5;
    background-color: var(--paper);
    background-image:
      radial-gradient(circle at 10% -12%, rgba(193,68,14,0.10), transparent 42%),
      radial-gradient(circle at 98% -4%, rgba(27,86,81,0.10), transparent 38%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 30h120M0 60h120M0 90h120M30 0v120M60 0v120M90 0v120' fill='none' stroke='%23c9b99f' stroke-width='0.5' opacity='0.33'/%3E%3C/svg%3E");
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
  }
  .masthead {
    border-bottom: 1px solid var(--line-strong);
    background: linear-gradient(180deg, rgba(253,251,246,0.92), rgba(241,234,220,0.55));
    backdrop-filter: blur(8px);
  }
  .masthead__inner {
    width: 100%; padding: 22px 30px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  }
  .brand { display: flex; align-items: center; gap: 15px; }
  .brand__mark { font-size: 24px; color: var(--accent); line-height: 1; }
  .brand h1 {
    font-family: var(--font-display); font-optical-sizing: auto;
    font-weight: 900; font-size: clamp(20px, 2.5vw, 30px);
    margin: 0; letter-spacing: -0.02em;
  }
  .brand p { margin: 3px 0 0; font-size: 13px; color: var(--ink-soft); }
  .coord {
    font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--teal);
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 6px 13px; background: rgba(255,255,255,0.6); white-space: nowrap;
  }
  .layout {
    width: 100%; margin: 26px 0 30px; padding: 0 30px;
    display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start;
  }
  .card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .panel.card, .results.card { padding: 20px; min-width: 0; }
  .results.card { width: 100%; }
  .panel { position: sticky; top: 20px; }
  .section-title {
    font-family: var(--font-display); font-weight: 600; font-size: 15px;
    margin: 0 0 16px; display: flex; align-items: center; gap: 9px; letter-spacing: 0.01em;
  }
  .section-title::before { content: ""; width: 15px; height: 2px; background: var(--accent); }
  .field { margin-bottom: 16px; }
  .field label {
    display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink-soft); margin-bottom: 7px;
  }
  .field .hint {
    text-transform: none; letter-spacing: 0; font-weight: 400;
    color: var(--muted); font-size: 11px;
  }
  .field__row { display: flex; align-items: stretch; gap: 8px; }
  .field__row input { flex: 1 1 auto; width: auto; min-width: 0; }
  .seg--units { flex: 0 0 auto; }
  .seg--units .seg__btn { display: flex; align-items: center; padding: 0 11px; }
  input, textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-body);
    background: #fffdf9; color: var(--ink);
    transition: border-color .15s, box-shadow .15s, background .15s;
  }
  input:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(193,68,14,0.15); background: #fff;
  }
  textarea { resize: vertical; min-height: 84px; font-family: var(--font-mono); font-size: 13px; }
  #city, #radius { font-family: var(--font-mono); font-size: 13px; }
  .actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
  button {
    font-family: var(--font-body); background: var(--accent); color: #fff;
    border: 1px solid var(--accent-ink); padding: 11px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; letter-spacing: 0.01em;
    transition: transform .12s, box-shadow .18s, background .18s;
    box-shadow: 0 8px 18px -12px var(--accent-ink);
  }
  button:hover { background: var(--accent-ink); transform: translateY(-1px); }
  button:active { transform: translateY(0); }
  button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
  button.secondary { background: transparent; color: var(--teal); border: 1px solid var(--line-strong); box-shadow: none; }
  button.secondary:hover { background: rgba(27,86,81,0.08); border-color: var(--teal); }
  button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
  .status { font-size: 12px; color: var(--ink-soft); font-family: var(--font-mono); margin: 12px 0 0; min-height: 1em; }
  .error {
    display: none; background: #fbeae8; border: 1px solid #f0c9c4; color: var(--danger);
    padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
    white-space: pre-wrap; margin-top: 14px;
  }
  /* ---------------- Search history / statistics ---------------- */
  .stats { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
  .stats__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
  .stats__title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink-soft); margin: 0;
  }
  .seg {
    display: flex; gap: 2px; padding: 2px;
    border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper-2);
  }
  .seg__btn {
    font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
    padding: 3px 9px; border: none; border-radius: 999px; background: transparent;
    color: var(--ink-soft); cursor: pointer; box-shadow: none;
    transition: background .15s, color .15s;
  }
  /* Active and hover share the same teal tint: it reads with far better
     contrast against the .seg container (--paper-2) than the old --card fill,
     which was almost identical to the container background. */
  .seg__btn:hover,
  .seg__btn[aria-pressed="true"] { background: rgba(27,86,81,0.10); color: var(--teal); }
  .seg__btn:hover { transform: none; }
  .seg__btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
  .stats__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat {
    background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  }
  .stat__label {
    font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink-soft);
  }
  .stat__value {
    font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--ink);
    line-height: 1.15; font-variant-numeric: tabular-nums;
  }
  .stats__top { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
  .stats__foot {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--muted); margin: 6px 0 0;
  }
  .results-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
  .results-head__title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
  .results-head .section-title { margin: 0; }
  .search-box { position: relative; display: flex; align-items: center; }
  .search-box__icon { position: absolute; left: 13px; font-size: 15px; color: var(--muted); pointer-events: none; }
  .search-box input { width: min(340px, 62vw); padding: 9px 14px 9px 36px; font-size: 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fffdf9; }
  .search-box input::-webkit-search-cancel-button { cursor: pointer; }
  .search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(193,68,14,0.15); background: #fff; }
  .search-box input:disabled { opacity: .5; cursor: not-allowed; }
  .summary { font-size: 13px; color: var(--ink-soft); margin: 0; }
  .summary strong { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
  .hint { color: var(--muted); font-weight: 400; }
  .table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fffdf9; }
  table { border-collapse: collapse; width: 100%; font-size: 13px; }
  thead th { position: sticky; top: 0; z-index: 2; background: var(--paper-2); }
  th {
    font-family: var(--font-body); font-weight: 600; font-size: 10.5px; letter-spacing: 0.07em;
    text-transform: uppercase; color: var(--ink-soft); text-align: left;
    padding: 11px 14px; border-bottom: 1px solid var(--line-strong);
    white-space: nowrap; user-select: none;
  }
  th.sortable { cursor: pointer; transition: color .12s, background .12s; }
  th.sortable:hover { color: var(--accent); background: #f6efe3; }
  th.sortable:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
  th .arrow { display: inline-block; margin-left: 6px; font-size: 9px; color: var(--accent); opacity: 0; transition: opacity .15s; }
  th.sorted { color: var(--accent); }
  th.sorted .arrow { opacity: 1; }
  td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  td.col-address { min-width: 220px; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr { transition: background .12s; animation: rise .34s ease both; }
  tbody tr:hover { background: #f7f1e6; }
  td.col-rating, td.col-phone, td.col-activity, td.col-web { white-space: nowrap; }
  a { color: var(--teal); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s, color .15s; }
  a:hover { color: var(--accent-ink); border-bottom-color: currentColor; }
  a.place-link { font-weight: 600; color: var(--ink); }
  a.place-link:hover { color: var(--accent); }
  .pill {
    display: inline-block; background: rgba(27,86,81,0.10); color: var(--teal);
    border: 1px solid rgba(27,86,81,0.22); border-radius: 999px;
    padding: 2px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
  }
  .pill + .pill { margin-left: 4px; }
  /* Clickable variant of .pill, used by the History top-search chips. */
  .pill--add {
    font-family: var(--font-body); cursor: pointer; box-shadow: none;
    background: rgba(27,86,81,0.10); color: var(--teal);
    border: 1px solid rgba(27,86,81,0.22); border-radius: 999px;
    padding: 2px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
    white-space: nowrap; transition: background .15s, color .15s;
  }
  .pill--add:hover { background: rgba(27,86,81,0.20); color: var(--teal); transform: none; }
  .pill--add:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
  .rating { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
  .rating .star { color: #d98a1f; }
  .rating small { color: var(--muted); font-weight: 400; }
  .empty { text-align: center; padding: 44px 18px; color: var(--ink-soft); }
  .empty__mark { font-size: 26px; color: var(--line-strong); display: block; margin-bottom: 8px; }
  .spinner {
    display: none; width: 16px; height: 16px; border: 2px solid var(--line-strong);
    border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
  }
  .spinner.show { display: inline-block; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  footer {
    width: 100%; margin: 0; padding: 4px 30px 34px;
    font-size: 12px; color: var(--muted);
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 4px 22px; flex-wrap: wrap;
  }
  /* Mirrors the .coord badge typography in the masthead. */
  .footer__meta {
    font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--teal);
  }
  .footer__meta strong { font-weight: 600; color: var(--accent-ink); }
  @media (max-width: 1080px) {
    .layout { grid-template-columns: 300px minmax(0, 1fr); padding: 0 22px; }
    .masthead__inner { padding: 20px 22px; }
    footer { padding: 4px 22px 30px; }
  }
  @media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; padding: 0 16px; }
    .panel { position: static; }
    .masthead__inner { padding: 18px 16px; }
    footer { padding: 4px 16px 28px; }
    th, td { padding: 10px 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
    body { background-attachment: scroll; }
  }
