:root {
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --border: #e5e7eb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.1);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #e5e3df;
}

/* ---------- Map (full viewport) ---------- */
.map-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.map-fullscreen iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Top-right info button ---------- */
.info-button {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--surface-solid);
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s;
}

.info-button:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

/* ---------- Agent banner (top center toast) ---------- */
.agent-banner {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-solid);
  color: #3730a3;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 120px);
}

.agent-banner[data-state="cancelled"] {
  color: #991b1b;
}

.agent-banner[data-state="done"] {
  color: #065f46;
}

.agent-banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ---------- Bottom sheet ---------- */
.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  width: min(820px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
}

.presets {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.presets::-webkit-scrollbar {
  display: none;
}

.preset {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-solid);
  color: var(--text);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, background 0.15s;
}

.preset:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  padding: 14px;
  background: var(--surface-solid);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}

.field {
  display: contents;
}

.search-form input {
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  outline: none;
  background: #f3f4f6;
  transition: background 0.15s, box-shadow 0.15s;
}

.search-form input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.search-form input:focus {
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.search-form input.typing {
  background: #eef2ff;
  box-shadow: 0 0 0 2px var(--accent);
}

.search-form button[type="submit"] {
  width: 56px;
  height: 56px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.search-form button[type="submit"] svg {
  width: 22px;
  height: 22px;
}

.search-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

.search-form button[type="submit"]:active {
  transform: scale(0.96);
}

/* WebMCP visual feedback */
form:tool-form-active {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}

button:tool-submit-active {
  outline: 2px dashed #ec4899;
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .search-form {
    grid-template-columns: 1fr auto;
    padding: 14px;
  }
  .search-form input[name="area"] {
    grid-column: 1 / -1;
  }
  .search-form input {
    padding: 14px 16px;
    font-size: 16px;
  }
  .search-form button[type="submit"] {
    width: 52px;
    height: 52px;
  }
  .search-hint {
    display: none;
  }
}

/* ---------- Info dialog ---------- */
.info-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 28px;
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.info-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.info-dialog[open] {
  animation: dialog-in 0.18s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-close:hover {
  background: #e5e7eb;
  color: var(--text);
}

.info-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.info-dialog h3 {
  margin: 18px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.info-dialog .lede {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.info-dialog a {
  color: var(--accent);
  text-decoration: none;
}

.info-dialog a:hover {
  text-decoration: underline;
}

.webmcp-status {
  display: inline-block;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 500;
}

.webmcp-status[data-state="ready"] {
  background: #ecfdf5;
  color: #065f46;
}

.webmcp-status[data-state="unavailable"] {
  background: #fff7ed;
  color: #9a3412;
}

.webmcp-status[data-state="error"] {
  background: #fef2f2;
  color: #991b1b;
}

.tool-list,
.steps {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.55;
}

.tool-list li,
.steps li {
  margin-bottom: 6px;
}

code {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hint {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
