/* 本当の大きさマップ — スタイル */
:root {
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-border: #d8dde3;
  --text: #26313c;
  --text-dim: #7a8794;
  --accent: #2d6cdf;
  --shadow: 0 2px 10px rgba(20, 30, 40, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--text);
}

#map {
  position: absolute;
  inset: 0;
  background: #eef3f7; /* 海の色（タイル不使用の下地） */
}

/* ---- 上部バー: タイトル + 検索 ---- */
#topbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none; /* 子要素だけ操作可能に */
  z-index: 10;
}

#app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  white-space: nowrap;
}

#search-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
  pointer-events: auto;
}

#search-box {
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  outline: none;
}
#search-box:focus { border-color: var(--accent); }

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 55vh;
  overflow-y: auto;
  z-index: 20;
}
#search-results[hidden] { display: none; }

#search-results .result-level {
  flex: none;
  font-size: 10px;
  color: var(--text-dim);
  background: #eef2f6;
  border-radius: 4px;
  padding: 2px 5px;
  white-space: nowrap;
}

#search-results .result-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search-results .result-item {
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
#search-results .result-item:hover,
#search-results .result-item.active { background: #eaf1fd; }

#search-results .result-area {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---- 右上ボタン（言語切替・使い方） ---- */
#topbar-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
  pointer-events: auto;
}

#topbar-buttons button {
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
#topbar-buttons button:hover { border-color: var(--accent); color: var(--accent); }

#help-toggle {
  width: 38px;
  font-weight: 700;
}

/* ---- 使い方パネル ---- */
#help-panel {
  position: absolute;
  top: 64px;
  right: 10px;
  width: 320px;
  max-width: calc(100vw - 20px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  z-index: 11;
}
#help-panel[hidden] { display: none; }
#help-panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
}
#help-panel ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.8;
}

/* ---- 配置済みパネル ---- */
#shape-panel {
  position: absolute;
  right: 10px;
  top: 64px;
  width: 250px;
  max-height: calc(100% - 130px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 9;
  padding: 8px;
}

#shape-panel-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 6px;
  line-height: 1.6;
}

#shape-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#shape-list:empty { display: none; }

#shape-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 6px;
  font-size: 13px;
}
#shape-list li:hover { background: #f0f4f8; }

#shape-list .swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

#shape-list .shape-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#shape-list .shape-area {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

#shape-list .remove-btn,
#shape-list .rotate-btn {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  flex: none;
}
#shape-list .remove-btn:hover { background: #e2e8ee; color: #c0392b; }
#shape-list .rotate-btn { font-size: 16px; padding: 2px 3px; }
#shape-list .rotate-btn:hover { background: #e2e8ee; color: var(--accent); }

#shape-panel-empty kbd {
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 0 3px;
  font-size: 10px;
  background: #f5f7f9;
}

/* ---- 図形ラベル（Marker 要素。glyphs 不要で日本語も確実に出す） ---- */
.shape-label {
  pointer-events: none;
  text-align: center;
  text-shadow: 0 0 3px #fff, 0 0 5px #fff;
  color: #222c36;
  transform: translateZ(0);
}
.shape-label-name {
  font-size: 12px;
  font-weight: 700;
}
.shape-label-area {
  font-size: 10px;
  color: #45525f;
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 48, 56, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  z-index: 100;
}

/* ---- 帰属表示 ---- */
#attribution {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 8;
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 8px;
  border-top-left-radius: 6px;
  max-width: 100%;
}
#attribution a { color: var(--text-dim); }

/* ---- モバイル ---- */
@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; gap: 8px; }
  #app-title { font-size: 13px; padding: 8px 10px; }
  #search-wrap { max-width: none; flex-basis: 100%; }
  #shape-panel {
    top: auto;
    bottom: 24px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 30vh;
  }
}
