* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "system-ui", "Yu Gothic", "Hiragino Sans", sans-serif;
  color: #1f2933;
}

body {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
}

#sidebar {
  overflow-y: auto;
  padding: 20px;
  border-right: 1px solid #e3e8ee;
  background: #fafbfc;
}

#sidebar h1 {
  font-size: 18px;
  margin: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.lang-toggle {
  background: #fff;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: #4b5563;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.lang-toggle:hover {
  background: #f0f6ff;
  border-color: #2A7DE1;
  color: #2A7DE1;
}

.hint {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 12px;
  line-height: 1.6;
}

/* ----- Tabs ----- */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e3e8ee;
}

.tab {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 4px;
  font-size: 12px;
  cursor: pointer;
  color: #6b7280;
}

.tab:hover { color: #1f2933; }

.tab.active {
  color: #2A7DE1;
  border-bottom-color: #2A7DE1;
  font-weight: 600;
}

.panel { margin-bottom: 16px; }

/* ----- Form ----- */
form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

form label {
  font-size: 12px;
  color: #4b5563;
}

form input[type="text"],
form input[type="number"],
form select {
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #fff;
}

form input:focus,
form select:focus {
  outline: 2px solid #2A7DE1;
  outline-offset: -1px;
  border-color: #2A7DE1;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

form button[type="submit"] {
  padding: 10px;
  background: #2A7DE1;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
form button[type="submit"]:hover { background: #1f63b8; }

button.secondary {
  padding: 8px;
  background: #fff;
  color: #2A7DE1;
  border: 1px solid #2A7DE1;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
button.secondary:hover { background: #f0f6ff; }
button.secondary.picking {
  background: #2A7DE1;
  color: #fff;
}

/* ----- Result / error blocks ----- */
.error {
  background: #fdecea;
  color: #b71c1c;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.info-block {
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.info-block dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

.info-block dt {
  color: #6b7280;
  font-weight: normal;
}

.info-block dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #1f2933;
  overflow-wrap: anywhere;
}

.result {
  margin-bottom: 12px;
}

#radius-result p {
  margin: 0 0 8px;
  font-size: 13px;
}

#radius-csv {
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #2AB37D;
  color: #2AB37D;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}
#radius-csv:hover { background: #e8f5ef; }

.mesh-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #e3e8ee;
  border-radius: 6px;
  background: #fff;
}

.mesh-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid #f0f3f7;
}
.mesh-list li:last-child { border-bottom: 0; }

.mesh-list code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.mesh-list .dist {
  color: #6b7280;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ----- Details ----- */
details {
  margin-bottom: 12px;
  font-size: 13px;
}

details summary {
  cursor: pointer;
  color: #4b5563;
  padding: 4px 0;
}

details ul {
  margin: 8px 0;
  padding-left: 20px;
  line-height: 1.8;
  color: #4b5563;
}

.samples {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.samples li { margin: 4px 0; }

.samples button {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #e3e8ee;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.samples button:hover {
  background: #f0f6ff;
  border-color: #2A7DE1;
}

#map { height: 100%; }

@media (max-width: 720px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #sidebar {
    max-height: 55vh;
    border-right: 0;
    border-bottom: 1px solid #e3e8ee;
  }
}
