:root {
  --navy: #102d3f;
  --navy-soft: #183f54;
  --teal: #159bb1;
  --teal-dark: #087f93;
  --ink: #152635;
  --muted: #61717d;
  --line: #d6e0e6;
  --surface: #ffffff;
  --soft: #f3f7f9;
  --focus: #ffbf47;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f8fafb;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f8fafb; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button, label, input, textarea { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 850; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--teal); color: white; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.secondary-action { padding: 10px 14px; border: 1px solid var(--line); border-radius: 9px; font-weight: 700; font-size: 14px; }
.favorite-shortcut { min-width: 56px; height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); cursor: pointer; }
.favorite-shortcut span { color: var(--teal-dark); font-size: 21px; line-height: 1; }
.favorite-shortcut strong { min-width: 18px; font-size: 13px; }
.nav-link small { margin-left: auto; min-width: 22px; padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,.14); text-align: center; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0,1fr); min-height: calc(100vh - 68px); }
.sidebar { position: sticky; top: 68px; height: calc(100vh - 68px); padding: 18px 12px; display: flex; flex-direction: column; justify-content: space-between; background: var(--navy); color: white; }
.sidebar nav { display: grid; gap: 6px; }
.nav-link { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 9px; color: rgba(255,255,255,.82); font-size: 14px; font-weight: 700; }
.nav-link span { width: 22px; text-align: center; font-size: 18px; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(255,255,255,.12); }

main { min-width: 0; padding: 34px clamp(20px,4vw,64px) 56px; }
.intro { max-width: 820px; margin-bottom: 26px; }
.eyebrow { display: inline-block; margin-bottom: 9px; color: var(--teal-dark); font-size: 13px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(32px,4vw,48px); line-height: 1.08; letter-spacing: -.035em; }
.intro p { margin: 13px 0 0; max-width: 720px; color: var(--muted); font-size: 17px; line-height: 1.6; }

.workspace { display: grid; grid-template-columns: minmax(500px,680px) minmax(360px,1fr); align-items: start; gap: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(16,45,63,.06); }
.search-card { padding: clamp(20px,3vw,30px); }
fieldset { margin: 0 0 26px; padding: 0; border: 0; }
legend, .field > label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 800; }
.type-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.type-option { position: relative; min-height: 76px; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; transition: .18s ease; }
.type-option:hover { border-color: var(--teal); background: #f3fbfc; }
.type-option:has(input:checked) { border: 2px solid var(--teal); padding: 12px; background: #effbfc; box-shadow: 0 0 0 3px rgba(21,155,177,.1); }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-option strong, .type-option small { display: block; }
.type-option small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.type-icon { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: var(--soft); color: var(--teal-dark); font-size: 20px; font-weight: 850; }
.type-option:has(input:checked) .type-icon { background: var(--teal); color: white; }

.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px 14px; }
.full-width { margin-bottom: 20px; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid #bdcbd3;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  transition: border-color .16s, box-shadow .16s;
}
.field input { min-height: 48px; padding: 0 13px; }
.field textarea { min-height: 92px; padding: 12px 13px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(21,155,177,.15); }
.field small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.4; }
::placeholder { color: #73848f; opacity: 1; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.form-actions button { min-height: 48px; padding: 0 20px; border-radius: 9px; font-weight: 800; cursor: pointer; }
.reset-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.search-button { display: inline-flex; align-items: center; gap: 9px; border: 0; background: var(--teal); color: white; }
.search-button:hover { background: var(--teal-dark); }

.result-card { min-height: 510px; padding: clamp(22px,3vw,30px); }
.result-card.empty { display: grid; place-items: center; }
.empty-state { max-width: 360px; text-align: center; }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--teal-dark); font-size: 38px; }
.empty-state h2 { margin: 0; font-size: 24px; }
.empty-state p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.result-content h2 { margin: 0; font-size: 26px; }
.result-kicker { margin: 0 0 8px; color: var(--teal-dark); font-size: 13px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.result-summary { margin: 12px 0 22px; color: var(--muted); line-height: 1.6; }
.criteria { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.criterion { padding: 7px 10px; border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 700; }
.research-links { display: grid; gap: 11px; }
.research-link { display: block; padding: 15px; border: 1px solid var(--line); border-radius: 10px; transition: .16s; }
.research-link:hover { border-color: var(--teal); background: #f3fbfc; transform: translateY(-1px); }
.research-link strong { display: block; margin-bottom: 4px; }
.research-link span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.result-note { margin: 22px 0 0; padding: 13px; border-radius: 9px; background: #fff8e8; color: #674c14; font-size: 13px; line-height: 1.5; }
.error-message { margin: 16px 0 0; color: #a02d2d; font-size: 14px; font-weight: 700; }

.loading-state { min-height: 430px; display: grid; place-items: center; text-align: center; }
.loading-spinner { width: 48px; height: 48px; margin: 0 auto 18px; border: 4px solid #d9edf1; border-top-color: var(--teal); border-radius: 50%; animation: spin .85s linear infinite; }
.loading-state h2 { margin: 0; font-size: 23px; }
.loading-state p { max-width: 340px; margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
@keyframes spin { to { transform: rotate(360deg); } }

.results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.results-head h2 { margin: 0; font-size: 25px; line-height: 1.2; }
.results-head p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.view-favorites { min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-weight: 750; cursor: pointer; white-space: nowrap; }
.results-map { height: 230px; margin: 20px 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--soft); }
.map-unavailable { height: 100%; display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.results-note { margin: -7px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.results-list { display: grid; gap: 10px; }
.place-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: white; transition: border-color .16s, transform .16s; }
.place-card:hover { border-color: #86cbd6; transform: translateY(-1px); }
.place-main { min-width: 0; cursor: pointer; }
.place-main { padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.place-main h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.place-meta { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.place-status { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; padding: 5px 8px; border-radius: 7px; font-size: 12px; font-weight: 800; }
.place-status.yes { background: #e4f6ed; color: #146b47; }
.place-status.limited { background: #fff3d8; color: #79530c; }
.place-status.no { background: #fde9e7; color: #963b30; }
.place-status.unknown { background: var(--soft); color: #52636f; }
.favorite-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--teal-dark); font-size: 23px; cursor: pointer; }
.favorite-button.saved { background: #e7f7f9; border-color: #82c9d4; }
.no-results { padding: 28px 12px; text-align: center; }
.no-results h2 { margin: 0; }
.no-results p { margin: 9px auto 0; max-width: 380px; color: var(--muted); line-height: 1.55; }
.recent-searches { width: 100%; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); text-align: left; }
.recent-searches strong { display: block; margin-bottom: 8px; font-size: 13px; }
.recent-searches button { width: 100%; display: block; margin-top: 7px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); text-align: left; font-size: 13px; font-weight: 700; cursor: pointer; }

.detail-dialog { width: min(620px,calc(100vw - 28px)); max-height: min(760px,calc(100vh - 28px)); padding: 0; border: 0; border-radius: 14px; color: var(--ink); box-shadow: 0 24px 80px rgba(5,25,35,.3); }
.detail-dialog::backdrop { background: rgba(6,31,43,.62); backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); background: white; }
.dialog-head h2 { margin: 0; font-size: 25px; line-height: 1.2; }
.dialog-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-size: 28px; line-height: 1; cursor: pointer; }
#detail-content { padding: 22px 24px 28px; }
.detail-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.detail-row { min-height: 76px; padding: 13px; border-bottom: 1px solid var(--line); }
.detail-row:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-row dt { color: var(--muted); font-size: 12px; font-weight: 750; }
.detail-row dd { margin: 5px 0 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 700; line-height: 1.45; }
.detail-source { margin: 18px 0 0; padding: 13px; border-radius: 9px; background: #eff7f8; color: #31505d; font-size: 13px; line-height: 1.5; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.detail-actions a, .detail-actions button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-weight: 750; cursor: pointer; }
.detail-actions .primary-detail { border-color: var(--teal); background: var(--teal); color: white; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .result-card { min-height: 330px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .secondary-action { display: none; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  main { padding: 24px 16px 40px; }
  .type-grid, .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions button { width: 100%; justify-content: center; }
  .results-map { height: 210px; }
  .results-head { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-row:nth-child(odd) { border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
