:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --surface-3: #e2e7ec;
  --text: #16212b;
  --muted: #5f6c78;
  --border: #d8dee4;
  --accent: #1c7f55;
  --accent-hover: #166a47;
  --accent-soft: #e2f3ea;
  --accent-text: #ffffff;
  --ok: #1c7f55;
  --ok-soft: #e2f3ea;
  --ng: #c2333d;
  --ng-soft: #fbe7e8;
  --warn-soft: #fff5d6;
  --warn-text: #6b5300;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 6px 20px rgba(16, 24, 32, .08);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1317;
    --surface: #172027;
    --surface-2: #1f2a32;
    --surface-3: #2a3640;
    --text: #e6ecf1;
    --muted: #94a2ae;
    --border: #2d3a44;
    --accent: #38b57d;
    --accent-hover: #4cc58e;
    --accent-soft: #173828;
    --accent-text: #08130d;
    --ok: #4cc58e;
    --ok-soft: #173828;
    --ng: #f06b73;
    --ng-soft: #3a1c1f;
    --warn-soft: #3a3115;
    --warn-text: #f1d77a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1317;
  --surface: #172027;
  --surface-2: #1f2a32;
  --surface-3: #2a3640;
  --text: #e6ecf1;
  --muted: #94a2ae;
  --border: #2d3a44;
  --accent: #38b57d;
  --accent-hover: #4cc58e;
  --accent-soft: #173828;
  --accent-text: #08130d;
  --ok: #4cc58e;
  --ok-soft: #173828;
  --ng: #f06b73;
  --ng-soft: #3a1c1f;
  --warn-soft: #3a3115;
  --warn-text: #f1d77a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
img { max-width: 100%; }
h2, h3 { margin: 0; line-height: 1.3; }
.muted { color: var(--muted); }
.grow { flex: 1; }

/* ---------- ボタン・入力 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--ng); border-color: var(--ng); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--ng); }
.btn-danger-ghost:hover { background: var(--ng-soft); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 28px; font-size: 16px; }
.btn-round { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 18px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 16px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.input, .select, input[type=text], input[type=email], input[type=password], input[type=search], textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; line-height: 1.6; }
.select { width: auto; padding-right: 32px; }
.input:focus, .select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 6px; border-radius: 999px;
  background: var(--surface-2); font-size: 13px; line-height: 1.6; white-space: nowrap;
}
.chip-more { padding-left: 10px; color: var(--muted); }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; padding: 4px 12px; cursor: pointer; }
.chip-btn:hover { background: var(--surface-2); }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-removable { padding-right: 4px; background: var(--accent-soft); }
.chip-removable button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; }
.chip-removable button:hover { background: var(--surface-3); color: var(--text); }
.flag { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); flex: none; }
.kbd, .kbd-inline {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px;
  border: 1px solid var(--border); border-radius: 5px; font-size: 12px; color: var(--muted); background: var(--surface-2);
}
.kbd-inline { margin-left: 8px; background: transparent; border-color: currentColor; color: inherit; opacity: .7; }

/* ---------- ログイン ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; text-align: center; }
.login-box form { text-align: left; }
.login-error { margin: 0; min-height: 1.2em; color: var(--ng); font-size: 14px; }

/* ---------- ヘッダー ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; letter-spacing: .02em; }
.brand-lg { justify-content: center; font-size: 22px; }
.brand-mark { font-size: 1.3em; }
.mode-box { display: flex; align-items: center; gap: 7px; flex: none; }
.mode-lbl { font-size: 13px; font-weight: 700; color: var(--muted); }
.mode-box[data-mode="world"] [data-mode-lbl="world"], .mode-box[data-mode="country"] [data-mode-lbl="country"] { color: var(--accent); }
.mode-switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; padding: 0; flex: none; transition: background .15s; }
.mode-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); transition: transform .15s; }
.mode-switch[aria-checked="true"] .mode-knob { transform: translateX(18px); }
.mode-switch[aria-checked="true"] { background: var(--accent-soft); }
.mode-pick { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted);
  text-decoration: none; font-weight: 500; white-space: nowrap;
}
.tab-icon { flex: none; }
/* タブの名前は開いているタブだけ（ほかはアイコンだけ） */
.tab-label { display: none; }
.tabs a.active .tab-label { display: inline; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.user-area { display: flex; align-items: center; gap: 10px; }
.user-label { font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-banner { background: var(--warn-soft); color: var(--warn-text); font-size: 13px; padding: 8px 24px; text-align: center; }

.view { max-width: 1100px; margin: 0 auto; padding: 20px 24px 64px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-sub { margin-top: -4px; }
.counter { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; background: var(--accent); transition: width .25s; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.section-title { margin: 28px 0 12px; font-size: 16px; }

/* ---------- カード表面・裏面 ---------- */
.front-img { position: relative; flex: 1; min-height: 0; background: #0b0f12; border-radius: var(--radius-sm); overflow: hidden; }
.front-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.img-missing { position: absolute; inset: 0; display: grid; place-items: center; color: #8996a1; }

/* ---------- 拡大・移動 ---------- */
.zoomable { touch-action: none; user-select: none; -webkit-user-select: none; }
.zoomable img { transform-origin: 0 0; will-change: transform; }
.zoomable.is-zoomed { cursor: grab; }
.zoomable.is-dragging { cursor: grabbing; }
.zoom-ctrls {
  position: absolute; right: 10px; bottom: 10px; z-index: 2; display: flex; gap: 2px;
  padding: 3px; border-radius: 10px; background: rgba(10, 14, 18, .62); backdrop-filter: blur(6px);
  opacity: .55; transition: opacity .15s;
}
.zoomable:hover .zoom-ctrls, .zoom-ctrls:focus-within, .zoomable.is-zoomed .zoom-ctrls { opacity: 1; }
.zoom-ctrls button {
  width: 34px; height: 34px; border: 0; border-radius: 7px; background: transparent;
  color: #fff; font-size: 17px; line-height: 1; cursor: pointer;
}
.zoom-ctrls button:hover { background: rgba(255, 255, 255, .18); }
@media (hover: none) { .zoom-ctrls { opacity: 1; } }

.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: #05080a; overflow: hidden;
}
.viewer::backdrop { background: #05080a; }
.viewer-stage { position: absolute; inset: 0; }
.viewer-close {
  position: absolute; top: 14px; right: 14px; z-index: 3; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 18px; cursor: pointer;
}
.viewer-close:hover { background: rgba(255, 255, 255, .26); }
.viewer-hint {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 2; margin: 0;
  padding: 6px 14px; border-radius: 999px; background: rgba(10, 14, 18, .6); color: #c9d2da; font-size: 12px;
  pointer-events: none; white-space: nowrap; max-width: calc(100vw - 96px); overflow: hidden; text-overflow: ellipsis;
}
.front-desc { margin: 14px 4px 0; font-size: 16px; line-height: 1.7; flex: none; max-height: 7.2em; overflow-y: auto; }

.answer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; font-weight: 900; line-height: 1.25; }
.answer-country { display: inline-flex; align-items: center; gap: .35em; }
.answer-lg { font-size: clamp(30px, 5.5vw, 52px); }
.answer-lg.answer-many { font-size: clamp(22px, 3.6vw, 34px); }
.answer-md { font-size: clamp(24px, 3.6vw, 36px); justify-content: flex-start; }
.answer-sm { font-size: 22px; justify-content: flex-start; }
.flag-answer { width: 1.25em; height: .875em; border-radius: 3px; }
.answer-area { margin: 8px 0 0; font-size: 18px; font-weight: 700; color: var(--muted); text-align: center; }
.answer-regions { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.answer-md ~ .answer-area, .answer-md ~ .answer-regions, .answer-sm ~ .answer-area, .answer-sm ~ .answer-regions { text-align: left; }
.notes {
  margin-top: 18px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); line-height: 1.8; text-align: left; overflow-wrap: anywhere;
}

/* ---------- 暗記カード ---------- */
.flash-wrap { perspective: 3600px; }
.flashcard {
  position: relative; height: min(72vh, 680px); min-height: 360px;
  transform-style: preserve-3d; cursor: pointer; outline: none;
}
.flashcard:focus-visible .face { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.flashcard.is-flipped { transform: rotateY(180deg); }
/* めくる: 少し持ち上げながら回転して、着地で軽く弾む */
.flashcard.anim-to-back { animation: flip-to-back .36s cubic-bezier(.3, .7, .25, 1) both; }
.flashcard.anim-to-front { animation: flip-to-front .36s cubic-bezier(.3, .7, .25, 1) both; }
/* 回転の途中は手前の辺が遠近で大きく見えるので、少し縮めて枠からはみ出さないようにする */
@keyframes flip-to-back {
  0%   { transform: rotateY(0) scale(1); }
  50%  { transform: rotateY(90deg) scale(.86); }
  100% { transform: rotateY(180deg) scale(1); }
}
@keyframes flip-to-front {
  0%   { transform: rotateY(180deg) scale(1); }
  50%  { transform: rotateY(90deg) scale(.86); }
  100% { transform: rotateY(0) scale(1); }
}
.flashcard.anim-to-back .face, .flashcard.anim-to-front .face { animation: flip-shadow .36s ease both; }
@keyframes flip-shadow {
  50% { box-shadow: 0 14px 30px rgba(0, 0, 0, .22); }
}
/* 万一重なってもボタン類が上に来るように */
.view > .toolbar, .view > .study-nav, .view > .hint { position: relative; z-index: 2; }
.flash-wrap { position: relative; z-index: 1; }
/* 前後のカードへ移動するときのスライド */
.flash-wrap.enter-next .flashcard { animation: slide-in-right .34s cubic-bezier(.2, .8, .2, 1) both; }
.flash-wrap.enter-prev .flashcard { animation: slide-in-left .34s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes slide-in-right { from { transform: translateX(70px) rotate(1.5deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-in-left { from { transform: translateX(-70px) rotate(-1.5deg); opacity: 0; } to { transform: none; opacity: 1; } }
.feedback { animation: pop-in .28s ease-out both; }
@keyframes pop-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column;
  border-top: 6px solid var(--cat, transparent);
}
.face-back { transform: rotateY(180deg); overflow-y: auto; padding: 28px; }
.back-actions { position: absolute; top: 14px; right: 14px; z-index: 3; display: flex; gap: 6px; }
.back-country-wrap { position: relative; }
.back-menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 4px; display: flex; flex-direction: column; z-index: 4;
}
.back-menu button {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; white-space: nowrap;
}
.back-menu button:hover, .back-menu button:focus-visible { background: var(--surface-2); outline: none; }
.back-inner { margin: auto 0; width: 100%; }
.back-answer { padding: 12px 0; }
.face-back .notes { max-width: 760px; margin-left: auto; margin-right: auto; }
.study-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 18px; }
.study-nav .btn-primary { min-width: 140px; min-height: 48px; }

/* ---------- タイル ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.tile:hover, .tile:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: none; }
.tile-img { position: relative; aspect-ratio: 4 / 3; background: #0b0f12; overflow: hidden; }
.tile-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tile-countries { display: flex; flex-wrap: wrap; gap: 4px; }
.tile-desc { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-given { margin: 0; font-size: 12px; color: var(--ng); }
.tile-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.tile-actions .btn { flex: 1; }

/* ---------- 検索 ---------- */
.search-bar { margin-bottom: 12px; }
.search-input { min-height: 52px !important; font-size: 17px !important; padding: 10px 18px !important; border-radius: 999px !important; }
.region-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.result-count { margin: 0 0 12px; font-size: 13px; }
.result-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.result-head .result-count { margin: 0; flex: 1; }
.sort-select { width: auto; max-width: 11em; }

/* ---------- クイズ ---------- */
.quiz-setup { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.setup-block { display: flex; flex-direction: column; gap: 10px; }
.setup-label { display: flex; align-items: baseline; gap: 12px; font-weight: 700; }
.setup-actions { display: flex; gap: 12px; margin-left: auto; }
.setup-row { display: flex; gap: 28px; flex-wrap: wrap; }
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.region-check {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
}
.region-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.region-check input { accent-color: var(--accent); }
.region-check .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.region-check.is-empty { opacity: .6; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); font: inherit; padding: 8px 16px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 1px solid var(--border); padding-top: 18px; }

.quiz-card {
  height: min(58vh, 560px); min-height: 280px; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.quiz-prompt { text-align: center; font-weight: 700; margin: 18px 0 10px; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 760px; margin: 0 auto; }
.choice {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; text-align: left;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .flag { width: 26px; height: 18px; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice.dim { opacity: .5; }
.choice:disabled { cursor: default; }
.input-answer { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.input-answer input { min-height: 48px; font-size: 16px; }
.feedback {
  max-width: 760px; margin: 18px auto 0; padding: 18px 20px; border-radius: var(--radius);
  border: 2px solid; background: var(--surface); display: flex; flex-direction: column; gap: 6px;
}
.feedback.ok { border-color: var(--ok); }
.feedback.ng { border-color: var(--ng); }
.feedback-title { font-size: 18px; font-weight: 900; }
.feedback.ok .feedback-title { color: var(--ok); }
.feedback.ng .feedback-title { color: var(--ng); }
.feedback .notes { margin-top: 8px; }
.feedback-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.feedback-head .btn { flex: none; }
.feedback-head .feedback-title { flex: 1; min-width: 0; }
.feedback-head { flex-wrap: nowrap; gap: 8px; }

.result { text-align: center; max-width: 560px; margin: 0 auto; }
.score { font-size: 64px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score span { font-size: 28px; color: var(--muted); }
.score-pct { color: var(--muted); margin-bottom: 20px; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- モーダル ---------- */
.modal {
  padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto;
}
.modal::backdrop { background: rgba(8, 12, 16, .6); }
.modal-wide { width: min(1080px, calc(100vw - 32px)); }
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-inner { padding: 20px 24px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.detail { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; }
.detail-front { display: flex; flex-direction: column; height: min(66vh, 620px); min-height: 300px; }
.detail-back { overflow-y: auto; max-height: min(66vh, 620px); }

/* ---------- エディタ ---------- */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.editor-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.dropzone {
  position: relative; aspect-ratio: 4 / 3; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  display: grid; place-items: center; overflow: hidden; cursor: pointer; background: var(--surface-2); text-align: center;
}
.dropzone:hover, .dropzone.over, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0b0f12; }
.dropzone-hint { color: var(--text); font-size: 14px; line-height: 1.9; padding: 16px; }
.selected-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; font-size: 13px; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.picker-region { border-bottom: 1px solid var(--border); }
.picker-region:last-child { border-bottom: 0; }
.picker-region summary {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 14px; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.picker-region summary::-webkit-details-marker { display: none; }
.picker-region summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.picker-region[open] summary::before { transform: rotate(90deg); }
.picker-region summary:hover { background: var(--surface-2); }
.picker-sel-count { font-size: 12px; font-weight: 500; color: var(--accent); }
.picker-all { margin-left: auto; }
.picker-countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px; padding: 4px 8px 10px; }
.picker-country { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.picker-country:hover { background: var(--surface-2); }
.picker-country input { accent-color: var(--accent); flex: none; }
.picker-country:has(input:checked) { background: var(--accent-soft); }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 1000;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--ng); color: #fff; }

/* ---------- スマホ ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 6px 12px; }
  .brand-text { font-size: 15px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tabs a { padding: 6px 10px; font-size: 14px; }
  .user-area { margin-left: auto; }
  .user-label { display: none; }
  .view { padding: 14px 16px 48px; }
  .demo-banner { padding: 8px 16px; }
  .flashcard { height: 68vh; min-height: 320px; }
  .face { padding: 10px; }
  .face-back { padding: 18px; }
  .front-desc { font-size: 15px; }
  .choices { grid-template-columns: 1fr; }
  .detail, .editor { grid-template-columns: 1fr; }
  .detail-front { height: 46vh; }
  .detail-back { max-height: none; }
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); width: calc(100vw - 16px) !important; }
  .modal-inner { padding: 16px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .panel { padding: 18px 16px; }
  .setup-foot { flex-direction: column; align-items: stretch; }
  .input-answer { flex-direction: column; }
}

/* ---------- カテゴリー ---------- */
.small { font-size: 13px; }
.cat-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--cat); color: var(--cat-text, #fff); font-size: 12px; font-weight: 700; line-height: 1.5;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.cat-on-img { position: absolute; top: 10px; left: 10px; z-index: 2; pointer-events: none; }
.cat-on-back { position: absolute; top: 16px; left: 16px; z-index: 2; }
.tile { border-top: 4px solid var(--cat, var(--border)); }
.tile .cat-on-img { top: 6px; left: 6px; font-size: 11px; padding: 2px 8px; }
.quiz-card { border-top: 6px solid var(--cat, transparent); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.chip-cat { display: inline-flex; align-items: center; gap: 6px; }
.chip-cat.on { background: var(--cat); border-color: var(--cat); color: var(--cat-text); }
.chip-cat.on .cat-dot { box-shadow: 0 0 0 2px var(--cat-text); }
.cat-check:has(input:checked) { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, var(--surface)); }
.cat-check input { accent-color: var(--cat); }
.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 13px; cursor: pointer; user-select: none;
}
.cat-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cat-opt:hover { background: var(--surface-2); }
.cat-opt:has(input:checked) { background: var(--cat); border-color: var(--cat); color: var(--cat-text); font-weight: 700; }
.cat-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-md { width: min(640px, calc(100vw - 32px)); }
.cat-rows { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; }
.cat-row { display: flex; align-items: center; gap: 6px; }
.cat-row .cat-name { flex: 1; min-width: 0; }
.cat-count { font-size: 12px; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.cat-color { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; flex: none; }
.cat-color::-webkit-color-swatch-wrapper { padding: 0; }
.cat-color::-webkit-color-swatch { border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); }
.cat-color::-moz-color-swatch { border: 2px solid var(--surface); border-radius: 50%; }
.cat-add { display: flex; gap: 6px; align-items: center; padding-top: 12px; border-top: 1px dashed var(--border); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-danger:hover { background: var(--ng-soft); }

/* ---------- 地図 ---------- */
.map-hint { margin-left: auto; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 14px minmax(240px, min(var(--panel-w, 360px), 70%)); gap: 0; height: calc(100vh - 170px); height: calc(100dvh - 170px); min-height: 460px; }
.map-box { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.map { position: absolute; inset: 0; }
/* タイルの読み込み前に見える背景を海の色に（白く抜けて見えないように） */
.map-box, .map.leaflet-container { background: #aad3df; }
.map-dark.leaflet-container { background: #1d2c33; }
:root[data-theme="dark"] .map-box { background: #1d2c33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .map-box { background: #1d2c33; } }
.leaflet-tile-container img { outline: 1px solid transparent; } /* タイル間の細い隙間対策 */
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); z-index: 500; }
.map-panel { overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.panel-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 10px; }
.panel-country + .panel-country { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.map-country-list { display: flex; flex-wrap: wrap; gap: 6px; }
.map-country-list .chip-btn { display: inline-flex; align-items: center; gap: 6px; }
.tiles-compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles-compact .tile-desc { -webkit-line-clamp: 1; }
.map-tip { font-family: inherit; font-weight: 700; }
.ext-link {
  margin-left: auto; display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 6px; color: var(--muted); text-decoration: none;
}
.ext-link:hover { color: var(--accent); background: var(--surface-2); }
/* Leaflet の .leaflet-marker-icon { display:block } に負けないよう詳細度を上げる */
.leaflet-marker-icon.map-count {
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 11px; line-height: 1;
  border: 1.5px solid var(--surface); box-shadow: 0 1px 5px rgba(0, 0, 0, .35); cursor: pointer;
  transition: transform .15s; font-variant-numeric: tabular-nums;
}
.leaflet-marker-icon.map-count span { display: block; text-align: center; }
.leaflet-marker-icon.map-count:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 1px 5px rgba(0, 0, 0, .35); }
.map-thumbs-icon { overflow: visible; }
.map-thumbs {
  background: var(--surface); color: var(--text); border-radius: 10px; padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35); cursor: default;
  transform-origin: 50% 20px; transform: scale(.58); transition: transform .2s ease-out;
}
.map-thumbs-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 0 2px 5px; white-space: nowrap; cursor: pointer; }
.map-thumbs-head .flag { width: 16px; height: 11px; }
.map-thumbs-n { margin-left: auto; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.map-thumbs-grid { display: grid; gap: 4px; }
.map-thumb {
  position: relative; z-index: 0; aspect-ratio: 4 / 3; border-radius: 5px; overflow: hidden; background: #0b0f12; cursor: pointer;
  border: 2px solid var(--cat, transparent);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1.2), box-shadow .18s;
}
.map-thumb:hover { transform: scale(1.12); z-index: 1; box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }
.map-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.map-thumbs-more { font-size: 11px; color: var(--muted); text-align: right; padding: 4px 2px 0; cursor: pointer; }
.leaflet-container { font-family: inherit; }
.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }

@media (max-width: 760px) {
  .map-layout { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; }
  .map-panel { max-height: none; }
  .map-hint { display: none; }
  .cat-row { flex-wrap: wrap; }
}

/* ---------- 国の基本情報 ---------- */
.country-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 2px 6px; margin: -2px -6px;
  border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 4px;
}
.country-link:hover { background: var(--surface-2); text-decoration-color: var(--accent); color: var(--accent); }
.cinfo-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.cinfo-flag { width: 120px; height: auto; max-height: 90px; object-fit: contain; border-radius: 4px; box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(0, 0, 0, .12); flex: none; }
.cinfo-name { font-size: 28px; font-weight: 900; line-height: 1.2; }
.cinfo-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cinfo-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12px; padding: 1px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.info-list { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.info-row { padding: 10px 0; border-top: 1px solid var(--border); min-width: 0; }
.info-row-wide { grid-column: 1 / -1; }
.info-row dt { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.info-row dd { margin: 0; overflow-wrap: anywhere; }
.info-row code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.drive { font-weight: 900; font-size: 16px; }
.drive-left { color: var(--ng); }
.drive-right { color: var(--accent); }
.nb-btn { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 4px 0; }
.lang-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.lang-btn::after { content: " ▾"; color: var(--muted); font-size: 11px; }
.lang-btn:hover { border-color: var(--accent); }
.lang-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.lang-btn[aria-expanded="true"]::after { content: " ▴"; color: inherit; }
.info-row-wide dd { position: relative; }
.lang-pop {
  --pop-bg: color-mix(in srgb, var(--accent) 12%, var(--surface));
  position: absolute; z-index: 20; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--pop-bg); border: 1.5px solid var(--accent); box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  animation: pop-in .16s ease-out both;
}
.lang-pop::before {
  content: ""; position: absolute; top: -8px; left: calc(var(--arrow-x, 24px) - 7px);
  width: 13px; height: 13px; background: var(--pop-bg);
  border-left: 1.5px solid var(--accent); border-top: 1.5px solid var(--accent); transform: rotate(45deg);
}
.lang-pop .lg-title { color: var(--accent); }
.lang-pop-close { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; font-size: 13px; }
.lang-pop .lg-title { padding-right: 28px; }
.lg-title { font-weight: 900; font-size: 16px; margin-bottom: 8px; }
.lg-list { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.lg-list dt { font-size: 12px; color: var(--muted); }
.lg-list dd { margin: 0; line-height: 1.7; }
.lg-chars { font-size: 20px; letter-spacing: .04em; }
.lg-countries-btn { margin-top: 12px; font-size: 13px; }
.lg-countries {
  display: flex; flex-wrap: wrap; align-content: flex-start; margin-top: 8px; max-height: 200px; padding-right: 4px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; /* 一覧の中だけスクロールし、端まで来ても詳細画面を動かさない */
}
.lg-countries::-webkit-scrollbar { display: block; width: 6px; }
.lg-countries::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.lg-countries .nb-btn { font-size: 13px; }
.lg-countries .is-current { opacity: .55; }
@media (max-width: 760px) {
  .info-list { grid-template-columns: 1fr; }
  .cinfo-flag { width: 84px; }
  .cinfo-name { font-size: 22px; }
}

/* ---------- 画面の高さに収めるレイアウト（暗記カード・クイズ出題中） ---------- */
.tab-short { display: none; }
#app.app-fit { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
#app.app-fit .topbar, #app.app-fit .demo-banner { flex: none; }
.view.view-fit { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; padding-bottom: 14px; }
.view-fit > .toolbar, .view-fit > .progress, .view-fit > .study-nav, .view-fit > .hint { flex: none; }
.view-fit .flash-wrap { flex: 1; min-height: 0; display: flex; }
.view-fit .flashcard { flex: 1; height: auto; min-height: 0; max-height: 720px; margin: 0 auto; width: 100%; }
.view-fit .empty { flex: 1; }
.view-fit .quiz-card { flex: 1; height: auto; min-height: 140px; max-height: 620px; }
.view-fit .quiz-bottom { flex: none; max-height: 55%; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 0; }
.view-fit .quiz-prompt { margin: 12px 0 8px; }
.view-fit .feedback { margin-top: 10px; }
.quiz-bottom.is-answered .choices { margin-top: 12px; }

@media (max-width: 760px) {
  .tab-long { display: none; }
  .tab-short { display: inline; }
  /* ヘッダーを1行に */
  .topbar { flex-wrap: nowrap; padding: 6px 10px; gap: 6px; }
  .brand-text { display: none; }
  .tabs { order: 0; flex: 1 1 0; min-width: 0; flex-basis: auto; gap: 0; }
  .tabs a { padding: 6px 7px; gap: 5px; font-size: 13px; flex: none; }
  .tabs a.active { padding: 6px 9px; }
  .user-area { margin-left: 0; gap: 0; flex: none; }
  .user-area .icon-btn { width: 32px; height: 32px; }
  #search-btn { padding: 0 8px; min-width: 0; }
  #logout-btn { min-height: 34px; padding: 0 10px; }
  .demo-banner { padding: 4px 12px; font-size: 12px; }

  .view-fit { padding: 10px 10px 10px; }
  .view-fit .toolbar { gap: 6px; margin-bottom: 8px; flex-wrap: nowrap; }
  .view-fit .toolbar .select { flex: 1 1 0; min-width: 0; min-height: 36px; font-size: 13px; padding: 4px 26px 4px 8px; }
  .view-fit .toolbar .btn { min-height: 36px; padding: 0 10px; }
  .view-fit .counter { font-size: 13px; white-space: nowrap; }
  .view-fit .progress { margin-bottom: 10px; }
  .view-fit .flashcard { min-height: 0; }
  .face { padding: 8px; }
  .face-back { padding: 44px 16px 16px; }
  .front-desc { font-size: 14px; margin-top: 8px; max-height: 4.8em; }
  .answer-lg { font-size: clamp(26px, 8vw, 40px); }
  .view-fit .study-nav { margin-top: 10px; gap: 12px; }
  .view-fit .study-nav .btn-round { width: 44px; height: 44px; }
  .view-fit .study-nav .btn-primary { min-height: 44px; min-width: 120px; }
  .view-fit .hint { margin-top: 6px; font-size: 11px; }

  .view-fit .quiz-card { padding: 8px; min-height: 120px; }
  .view-fit .quiz-prompt { margin: 8px 0 6px; font-size: 14px; }
  .view-fit .choices { grid-template-columns: 1fr 1fr; gap: 6px; }
  .view-fit .choice { min-height: 46px; padding: 6px 8px; font-size: 14px; gap: 6px; }
  .view-fit .choice .kbd { display: none; }
  .view-fit .choice .flag { width: 22px; height: 15px; }
  .view-fit .input-answer { flex-direction: row; }
  .view-fit .input-answer input { min-height: 44px; }
  .view-fit .feedback { padding: 12px 14px; margin-top: 8px; }
  .view-fit .feedback .kbd-inline { display: none; }
  .view-fit .feedback .notes { margin-top: 6px; padding: 10px 12px; font-size: 14px; }
  .answer-sm { font-size: 18px; }
}

/* ---------- クイズ: 複数回答 ---------- */
.multi-input {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 48px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: text;
}
.multi-input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.multi-input input { flex: 1; min-width: 140px; border: 0 !important; outline: none !important; min-height: 32px !important; padding: 0 4px !important; background: transparent; font-size: 16px; }
.q-chips { display: contents; }
.multi-note { text-align: center; margin: 8px 0 0; }
.given-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 760px; margin: 12px auto 0; }
.given { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; border: 2px solid; }
.given small { font-weight: 400; }
.given-hit { border-color: var(--ok); background: var(--ok-soft); }
.given-miss { border-color: var(--border); border-style: dashed; color: var(--muted); }
.given-wrong { border-color: var(--ng); background: var(--ng-soft); text-decoration: line-through; text-decoration-thickness: 1px; }
.feedback.fb-ok { border-color: var(--ok); }
.feedback.fb-ok .feedback-title { color: var(--ok); }
.feedback.fb-ng { border-color: var(--ng); }
.feedback.fb-ng .feedback-title { color: var(--ng); }
.feedback.fb-partial { border-color: #e8a317; }
.feedback.fb-partial .feedback-title { color: #c98a00; }
.feedback-title small { font-size: 14px; font-weight: 700; }

/* ---------- モーダルの戻る・国情報のカード一覧 ---------- */
.modal-head { gap: 8px; }
.modal-head h2 { flex: 1; }
.modal-back { flex: none; padding: 0 10px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.answer .country-link { margin: 0; padding: 2px 6px; font-weight: 900; }
.detail-hint { margin: 6px 0 0; }
.tag-link { text-decoration: none; color: var(--accent); background: var(--accent-soft); }
.tag-link:hover { text-decoration: underline; }
.cinfo-cards { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.cinfo-cards-title { font-size: 15px; margin-bottom: 10px; }
.cinfo-cards .cat-chips { margin-bottom: 12px; }

@media (max-width: 760px) {
  .view-fit .multi-input { min-height: 44px; }
  .view-fit .multi-note { font-size: 12px; margin-top: 4px; }
  .view-fit .given-list { margin-top: 6px; }
  .view-fit .given { font-size: 13px; padding: 3px 10px; }
}

/* ---------- スクロールバーを非表示（スクロール自体はできる） ---------- */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ---------- アニメーション オフ ---------- */
.no-anim *, .no-anim *::before, .no-anim *::after {
  animation-duration: 0s !important; animation-delay: 0s !important;
  transition-duration: 0s !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}

/* ---------- 設定 ---------- */
.gear-btn { display: inline-grid; place-items: center; }
.sound-btn { display: inline-grid; place-items: center; }
.sound-btn svg { display: block; }
.sound-btn .snd-off { display: none; }
.sound-btn.is-muted { color: var(--muted); }
.sound-btn.is-muted .snd-on { display: none; }
.sound-btn.is-muted .snd-off { display: inline; }
.gear-btn svg { display: block; transform-origin: 50% 50%; }
/* ホバー中はゆっくり回り続け、押すと1回転（アニメーション設定オフのときは止まる） */
.gear-btn:hover svg { animation: gear-spin 2.4s linear infinite; }
.gear-btn:active svg { animation: gear-spin .5s cubic-bezier(.3, .7, .3, 1) 1; }
@keyframes gear-spin { to { transform: rotate(360deg); } }

.modal-settings { width: min(520px, calc(100vw - 32px)); }
.set-layout { display: block; }
.set-toc { display: none; }
.set-dl-note { margin: 4px 0 8px; }
.modal-settings .set-group-title { scroll-margin-top: 74px; }
@media (min-width: 760px) {
  .modal-settings { width: min(780px, calc(100vw - 32px)); }
  .set-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 20px; align-items: start; }
  .set-toc { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; }
  .set-toc-item { text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
  .set-toc-item:hover { background: var(--surface-2); color: var(--text); }
  .set-toc-item.on { background: var(--surface-2); color: var(--accent); font-weight: 700; }
}
.modal-settings .modal-head { margin-bottom: 18px; }
.set-group-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px 4px; letter-spacing: .02em; }
.set-group {
  background: var(--surface-2); border-radius: var(--radius); padding: 2px 18px; margin-bottom: 22px;
}
.set-item { display: flex; align-items: center; gap: 20px; padding: 16px 0; }
.set-item + .set-item { border-top: 1px solid var(--border); }
.set-item-stacked { flex-direction: column; align-items: stretch; gap: 12px; }
.set-text { flex: 1; min-width: 0; }
.set-title { font-weight: 700; font-size: 15px; }
.set-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.set-item .seg { display: flex; width: 100%; background: var(--surface); }
.set-item .seg button { flex: 1; padding: 9px 8px; font-size: 14px; }
.set-note { text-align: center; margin: -6px 0 0; }
.set-foot { margin-top: 16px; }
.switch { position: relative; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { display: block; width: 50px; height: 30px; border-radius: 999px; background: var(--surface-3); transition: background .2s; position: relative; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 760px) {
  .set-group { padding: 2px 14px; }
  .gear-btn, .sound-btn { width: 34px; height: 34px; }
}

/* ---------- キー割り当て ---------- */
.set-key { padding: 10px 0; }
.set-key .set-title { font-weight: 500; font-size: 14px; }
.keycap {
  min-width: 56px; height: 34px; padding: 0 12px; flex: none;
  border: 1px solid var(--border); border-bottom-width: 3px; border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.keycap:hover { border-color: var(--accent); }
.keycap.is-capturing { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); animation: key-blink 1s ease-in-out infinite; }
@keyframes key-blink { 50% { opacity: .55; } }
.set-key-note { padding: 10px 0 14px; border-top: 1px solid var(--border); }

/* ---------- 検索（Spotlight 風） ---------- */
.spot-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s;
}
.spot-trigger:hover { border-color: var(--accent); color: var(--text); }
.spot-trigger kbd {
  font-family: inherit; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.spotlight {
  padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible;
  width: min(920px, calc(100vw - 32px)); max-width: none; max-height: none;
  margin: 8vh auto auto; position: fixed; inset: 0; height: fit-content;
}
.spotlight::backdrop { background: rgba(8, 12, 16, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.spotlight[open] { animation: spot-in .22s cubic-bezier(.2, .9, .3, 1.1) both; }
.spotlight[open]::backdrop { animation: fade-in .2s ease-out both; }
.spotlight.closing { animation: spot-out .15s ease-in both; }
.spotlight.closing::backdrop { animation: fade-out .15s ease-in both; }
@keyframes spot-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes spot-out { to { opacity: 0; transform: translateY(-8px) scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.spot-inner {
  display: flex; flex-direction: column; max-height: 80vh; max-height: 80dvh;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); overflow: hidden;
}
.spot-bar { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.spot-icon { color: var(--muted); flex: none; }
.spot-input {
  flex: 1; min-width: 0; border: 0 !important; outline: none !important; background: transparent !important;
  font-size: 22px !important; padding: 4px 0 !important; min-height: 40px !important;
}
.spot-filters { padding: 12px 18px 4px; display: flex; flex-direction: column; gap: 8px; }
.spot-filters .region-chips { margin: 0; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.spot-filters .chip-btn { flex: none; }
.spot-results { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px 16px; overscroll-behavior: contain; }
.spot-results .tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.spot-results .tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.spot-foot { font-size: 11px; text-align: center; padding: 8px; border-top: 1px solid var(--border); }
@media (max-width: 760px) {
  .spotlight { margin-top: 8px; width: calc(100vw - 16px); }
  .spot-inner { max-height: calc(100dvh - 16px); border-radius: 14px; }
  .spot-input { font-size: 17px !important; }
  .spot-bar { padding: 10px 10px 8px 14px; }
  .spot-filters { padding: 10px 12px 2px; }
  .spot-results { padding: 8px 12px 12px; }
  .spot-results .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .spot-foot { display: none; }
  .spot-trigger { width: 34px; padding: 0; justify-content: center; }
}

/* ---------- キー重複の警告 ---------- */
.keycap.is-dup { border-color: var(--ng); color: var(--ng); background: var(--ng-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ng) 35%, transparent); }
.key-dup-warn { margin: 6px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--ng-soft); color: var(--ng); font-size: 13px; font-weight: 700; }

/* ---------- キーのリセット ---------- */
.key-reset { width: 30px; height: 30px; font-size: 16px; flex: none; }
.key-reset:disabled { visibility: hidden; }
.key-reset-all-row { display: flex; justify-content: flex-end; padding: 10px 0 2px; border-top: 1px solid var(--border); }
.key-reset-all-row .btn:disabled { opacity: .4; }

/* ---------- 横スクロールのチップ列 ---------- */
.hscroll { position: relative; }
.hscroll .region-chips { cursor: grab; user-select: none; -webkit-user-select: none; }
.hscroll .region-chips.is-dragging { cursor: grabbing; }
.hscroll .region-chips.is-dragging .chip-btn { pointer-events: none; }
.hscroll.can-left .region-chips { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px); mask-image: linear-gradient(to right, transparent 0, #000 48px); }
.hscroll.can-right .region-chips { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 48px); mask-image: linear-gradient(to left, transparent 0, #000 48px); }
.hscroll.can-left.can-right .region-chips { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%); }
.hs-btn {
  position: absolute; top: 50%; z-index: 2; width: 28px; height: 28px; margin-top: -15px;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  display: none; place-items: center; padding: 0 0 2px;
}
.hs-btn:hover { border-color: var(--accent); color: var(--accent); }
.hs-left { left: -4px; }
.hs-right { right: -4px; }
.hscroll.can-left .hs-left, .hscroll.can-right .hs-right { display: grid; }
@media (hover: none) { .hs-btn { display: none !important; } }

.tile-snippet { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-snippet mark { background: color-mix(in srgb, #f5c400 45%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* ---------- 入力欄のインライン補完（PC: 検索・クイズ） ---------- */
.spot-field { position: relative; flex: 1; min-width: 0; display: flex; }
.ghost-field { position: relative; flex: 1; min-width: 0; display: flex; }
.ghost-field > input { position: relative; z-index: 1; flex: 1; min-width: 0; background: transparent !important; }
.ghost {
  position: absolute; inset: 0; display: flex; align-items: center; pointer-events: none;
  white-space: pre; overflow: hidden; z-index: 0;
}
.g-typed { color: transparent; }
.g-rest { color: var(--muted); opacity: .6; }
.g-hint { color: var(--muted); opacity: .75; font-size: .75em; margin-left: .4em; }
.g-tab {
  margin-left: 10px; font-family: inherit; font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); line-height: 1.4;
}
.spot-input::-webkit-search-cancel-button { position: relative; z-index: 2; }
.multi-input .ghost-field { min-width: 160px; }

/* ---------- 起動エラー表示 ---------- */
.boot-error { max-width: 560px; margin: 12vh auto; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--ng); box-shadow: var(--shadow); }
.boot-error h2 { color: var(--ng); margin-bottom: 10px; }
.boot-error pre, .err-pre { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: 8px; text-align: left; overflow-wrap: anywhere; }

/* ---------- 地図の国検索バー ---------- */
.map-top {
  position: absolute; top: 10px; left: 56px; right: 10px; z-index: 1050; display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.map-top > * { pointer-events: auto; }
.map-search {
  position: relative; flex: 0 1 360px; min-width: 0; z-index: 1001;
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; height: 40px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
/* 検索バーの右の、ストリートビューのボタン（アイコンだけ） */
.map-sv-btn {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; border-radius: 50%;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.map-sv-btn:hover { color: var(--text); border-color: var(--accent); }
.map-sv-btn.is-on { background: #1c7ed6; border-color: #1c7ed6; color: #fff; }
.map-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), 0 2px 10px rgba(0, 0, 0, .18); }
.map-search svg { flex: none; }
.map-search input { flex: 1; min-width: 0; border: 0 !important; outline: none !important; background: transparent !important; padding: 0 !important; min-height: 36px !important; font-size: 15px; color: var(--text); }
.map-search .ghost-field { flex: 1; }
.map-search-help {
  flex: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border); font-size: 11px; font-weight: 700; cursor: help;
}
@media (max-width: 760px) {
  .map-top { left: 50px; }
  .map-search { height: 38px; }
  .map-sv-btn { width: 38px; height: 38px; }
}

/* ---------- 地図の右パネル: 上段 = 国の情報、下段 = カード / 表示中の国 ---------- */
.map-panel { display: flex; flex-direction: column; padding: 0 !important; overflow: hidden !important; }
.pinfo {
  flex: 0 0 var(--pinfo-h, 36%); min-height: 0; overflow-y: auto; padding: 14px 14px 12px;
  background: var(--surface-2); position: relative;
}
.pinfo-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-align: center; font-weight: 700; }
.pinfo-empty small { font-weight: 400; font-size: 12px; opacity: .8; }
.pinfo-globe { font-size: 32px; opacity: .6; }
.plist { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 14px; }
.plist .focus-cats { margin-bottom: 10px; }
.list-title { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.clist { display: flex; flex-direction: column; gap: 2px; }
.crow { padding: 6px 6px; border-radius: 8px; }
.crow:hover { background: var(--surface-2); }
.crow-head { display: flex; align-items: center; gap: 6px; }
.crow-name {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; flex: 1; padding: 2px 0; border: 0; background: none;
  color: var(--text); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; text-align: left;
}
.crow-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-name:hover { color: var(--accent); }
.crow-n { font-size: 12px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.crow .ext-link { width: 24px; height: 24px; margin-left: 0; }
.crow-thumbs { display: flex; gap: 4px; margin-top: 5px; overflow: hidden; }
.crow-thumb {
  position: relative; flex: none; width: 52px; height: 39px; padding: 0; border-radius: 5px; overflow: hidden; cursor: pointer;
  border: 2px solid var(--cat, var(--border)); background: #0b0f12; transition: transform .15s;
}
.crow-thumb:hover { transform: scale(1.08); }
.crow-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.crow-more { flex: none; height: 39px; padding: 0 8px; border: 1px dashed var(--border); border-radius: 5px; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
@media (max-width: 760px) {
  .map-panel { overflow: visible !important; }
  .pinfo { flex: none; }
  .pinfo.is-empty { display: none; }
  .plist { overflow: visible; }
}
.sum-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sum-flag { width: 44px; height: auto; max-height: 32px; object-fit: contain; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); flex: none; }
.sum-names { flex: 1; min-width: 0; }
.sum-name { font-size: 18px; font-weight: 900; line-height: 1.2; }
.sum-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-head .ext-link { margin-left: 0; }
.sum-more { flex: none; min-height: 28px; padding: 0 10px; }
.sum-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; align-items: baseline; }
.sum-row { display: contents; }
.sum-row dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sum-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sum-row code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; background: var(--surface); padding: 0 5px; border-radius: 4px; }
.sum-row .drive { font-size: 13px; }
.sum-row .chip-btn { padding: 1px 9px; font-size: 12px; margin: 0 3px 3px 0; display: inline-flex; align-items: center; gap: 5px; }
.sum-row .chip-btn .flag { width: 16px; height: 11px; }
@media (max-width: 760px) {
      }
.pinfo-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; font-size: 13px; z-index: 1; }
.pinfo:has(.pinfo-close) .sum-head { padding-right: 32px; }

/* 右パネル上段: 選んでいる国は黄、プレビューの吹き出しは青 */
.pinfo { transition: background .15s, box-shadow .15s; }
.pinfo.is-focused {
  background: color-mix(in srgb, #f5c400 13%, var(--surface));
  box-shadow: inset 4px 0 0 #f5c400;
}
/* ---------- 地図: プレビューの吹き出し（カーソル追尾） ---------- */
/* 外側は透明な入れ物。見た目は .hb-body が持つ（扇状のカードを本体の後ろに置くため） */
.hover-bubble {
  position: fixed; left: 0; top: 0; z-index: 3000; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity .12s;
}
.hover-bubble.show { opacity: 1; visibility: visible; }
.hb-body {
  position: relative; z-index: 1; color: var(--text);
  background: color-mix(in srgb, #3b82f6 11%, var(--surface));
  border: 1px solid color-mix(in srgb, #3b82f6 45%, var(--border)); border-left: 4px solid color-mix(in srgb, #3b82f6 75%, transparent);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.hover-bubble.is-compact { width: max-content; max-width: 320px; }
.hb-compact { display: flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; padding: 5px 10px; }
.hb-compact .flag { width: 20px; height: 14px; }
.hb-n { font-size: 11px; color: var(--muted); }
.hover-bubble.is-full { width: 300px; }
/* 小さい表示から詳しい表示へ: カーソル側を起点に広がる */
.hover-bubble .hb-body { transform-origin: var(--origin, top left); }
.hover-bubble.anim-in .hb-body { animation: hb-expand .22s cubic-bezier(.2, .8, .25, 1) both; }
.hover-bubble.anim-out .hb-body { animation: hb-collapse .18s cubic-bezier(.2, .8, .25, 1) both; }
@keyframes hb-collapse { from { transform: scale(1.9); opacity: .25; } }
@keyframes hb-expand { from { transform: scale(.35); opacity: .2; } }
.hover-bubble.is-full .hb-body { padding: 12px 14px; }
@keyframes hb-grow { from { opacity: .4; } }
.hover-bubble .sum-more, .hover-bubble .ext-link { display: none; }
.hover-bubble .sum-row .chip-btn { pointer-events: none; }
.hover-bubble.has-fan .sum-head { padding-right: 120px; }
/* 扇状のカード: 下端より下を軸に回転させて広げ、下半分は本体に隠れる */
.hb-fan { position: absolute; top: -52px; right: 40px; width: 110px; height: 60px; z-index: 0; }
.hb-card {
  position: absolute; left: 50%; top: 0; width: 56px; height: 62px; margin-left: -28px;
  border-radius: 6px; overflow: hidden; background: #0b0f12;
  border: 2px solid var(--cat, var(--border)); box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  transform-origin: 50% 230%; transform: rotate(var(--a));
  animation: hb-fan-in .28s cubic-bezier(.2, .8, .25, 1.1) both;
}
.hb-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes hb-fan-in { from { transform: rotate(0deg) translateY(16px); opacity: 0; } }
.hb-fan-more {
  position: absolute; right: -14px; top: 6px; z-index: 9; font-size: 11px; font-weight: 700;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px;
}
.pinfo-close { right: 8px; }

/* お知らせはポップオーバー（最前面の層）。ブラウザ既定の popover の配置を打ち消す */
.toast[popover] { inset: auto; left: 50%; bottom: 24px; top: auto; margin: 0; border: 0; overflow: visible; }

/* ---------- 地図のサムネイル: 状態ごとの見え方 ---------- */
.map-thumbs { transition: transform .2s ease-out, opacity .2s; }
.map-thumbs.is-dim { opacity: .5; }
.map-thumbs.is-dim:hover { opacity: 1; }
.map-thumbs-more { user-select: none; }
.map-thumbs-more:hover { color: var(--accent); }
/* 「ほか N 枚」で広げたとき: 1 行 3 枚、長いときは欄の中でスクロール */
.map-thumbs.is-expanded .map-thumbs-grid { max-height: 210px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; scrollbar-width: thin; }
.map-thumbs.is-expanded .map-thumbs-grid::-webkit-scrollbar { display: block; width: 6px; }
.map-thumbs.is-expanded .map-thumbs-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.map-thumbs.is-expanded .map-thumb:hover { transform: scale(1.06); }

/* ---------- 地図の右パネル: カードは 1 行 3 枚 ---------- */
.plist .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.plist .tile-body { padding: 6px 7px 8px; gap: 4px; }
.plist .tile .chip { font-size: 11px; padding: 1px 7px 1px 4px; }
.plist .tile .chip .flag { width: 15px; height: 10px; }
.plist .tile-desc { font-size: 11.5px; -webkit-line-clamp: 2; }
.plist .tile .cat-on-img { font-size: 10px; padding: 1px 6px; top: 4px; left: 4px; }

/* ---------- 国のメモ ---------- */
.cinfo-memo { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.memo-input { width: 100%; min-height: 72px; line-height: 1.7; background: color-mix(in srgb, #f5c400 6%, var(--surface)); }
.memo-view { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); line-height: 1.7; overflow-wrap: anywhere; }
.memo-status { font-weight: 400; margin-left: 6px; }
.sum-memo {
  margin-top: 8px; padding: 6px 9px; border-radius: 7px; font-size: 12.5px; line-height: 1.6;
  background: color-mix(in srgb, #f5c400 14%, var(--surface)); border-left: 3px solid #f5c400; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- チャット形式のメモ（右下） ---------- */
.chat-fab {
  position: fixed; inset: auto 20px 20px auto; margin: 0; z-index: 4000;
  width: 54px; height: 54px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3); transition: transform .15s, box-shadow .15s;
  overflow: visible;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 24px rgba(0, 0, 0, .35); }
.chat-fab.active { transform: rotate(-8deg); }
.chat-fab[hidden] { display: none; }
.chat-badge { position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ng); border: 2px solid var(--surface); }
.chat-panel {
  position: fixed; inset: 64px 14px auto auto; margin: 0; z-index: 4000; padding: 0;
  width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - 90px)); height: min(560px, calc(100dvh - 90px));
  display: none; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.chat-panel.open { display: flex; animation: chat-in .2s cubic-bezier(.2, .8, .25, 1.1) both; transform-origin: top right; }
@keyframes chat-in { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--border); }
.chat-head b { font-size: 15px; }
.chat-count { font-size: 12px; margin-right: auto; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 6px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.8; }
.chat-day { display: flex; justify-content: center; margin: 6px 0 2px; }
.chat-day span { font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; }
.chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.other { align-self: flex-start; }
.chat-author { font-size: 11px; color: var(--muted); margin: 0 0 2px 4px; }
.chat-row { display: flex; align-items: flex-end; gap: 5px; }
.chat-msg.mine .chat-row { flex-direction: row-reverse; }
.chat-bubble {
  padding: 8px 12px; border-radius: 16px; line-height: 1.6; font-size: 14px; overflow-wrap: anywhere; white-space: normal;
  background: var(--surface); border: 1px solid var(--border);
}
.chat-msg.mine .chat-bubble { background: var(--accent); color: var(--accent-text); border-color: var(--accent); border-bottom-right-radius: 5px; }
.chat-msg.other .chat-bubble { border-bottom-left-radius: 5px; }
.chat-msg.mine .chat-bubble a { color: inherit; }
.chat-meta { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); flex: none; }
.chat-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; width: 20px; height: 20px; border-radius: 50%; opacity: 0; transition: opacity .15s; }
.chat-msg:hover .chat-del, .chat-del:focus-visible { opacity: 1; }
.chat-del:hover { background: var(--ng-soft); color: var(--ng); }
@media (hover: none) { .chat-del { opacity: .6; } }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input { flex: 1; min-height: 40px !important; max-height: 140px; resize: none; border-radius: 20px !important; padding: 9px 14px !important; line-height: 1.5; }
.chat-send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); cursor: pointer; display: grid; place-items: center; }
.chat-send:hover { filter: brightness(1.08); }
@media (max-width: 760px) {
  .chat-fab { inset: auto 14px 14px auto; width: 50px; height: 50px; }
  .chat-panel { inset: 60px 8px auto 8px; width: auto; height: min(78dvh, calc(100dvh - 76px)); }
  /* 暗記カード・クイズ（画面いっぱい）のときは、ボタンを少し小さく半透明に */
  .app-fit ~ .chat-fab { opacity: .85; }
}

.chat-me { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; border-radius: 999px; padding: 2px 10px; cursor: pointer; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-me:hover { color: var(--text); border-color: var(--accent); }

/* ---------- 複数選択のドロップダウン（暗記カードの地域・カテゴリー） ---------- */
.mpick { position: relative; }
.mpick-btn { display: inline-flex; align-items: center; gap: 8px; padding-right: 12px; cursor: pointer; max-width: 220px; text-align: left; }
.mpick-btn.is-set { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.mpick-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpick-arrow { color: var(--muted); font-size: 12px; }
.mpick-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(440px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25); padding: 10px; animation: pop-in .14s ease-out both;
}
.mpick-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mpick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; max-height: min(360px, 55vh); overflow-y: auto; overscroll-behavior: contain; }
.mpick-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.mpick-item:hover { background: var(--surface-2); }
.mpick-item input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.mpick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpick-n { font-size: 12px; color: var(--muted); }
.mpick-item.is-empty { opacity: .5; }
@media (max-width: 520px) { .mpick-list { grid-template-columns: 1fr; } .mpick-btn { max-width: 118px; } }

/* ---------- カード詳細: 並びの前 / 次へ ---------- */
.card-pager { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; margin-right: 6px; }
.pager-btn { font-size: 24px; line-height: 1; padding-bottom: 3px; }
.pager-btn:disabled { opacity: .3; cursor: default; background: none; }
.pager-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: center; }
.detail.enter-next { animation: detail-in-next .22s ease-out; }
.detail.enter-prev { animation: detail-in-prev .22s ease-out; }
@keyframes detail-in-next { from { opacity: 0; transform: translateX(28px); } }
@keyframes detail-in-prev { from { opacity: 0; transform: translateX(-28px); } }
.no-anim .detail.enter-next, .no-anim .detail.enter-prev { animation: none; }

/* ---------- 編集画面: カードの複数選択 ---------- */
#manage-list .tile { position: relative; }
.tile-check {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; background: rgba(0, 0, 0, .45); cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.tile-check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
#manage-list .tile:hover .tile-check, #manage-list.is-selecting .tile-check, .tile.is-selected .tile-check { opacity: 1; }
@media (hover: none) { .tile-check { opacity: 1; } }
#manage-list .tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#manage-list .tile.is-selected .tile-img img { opacity: .8; }
.sel-bar {
  position: sticky; top: 8px; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 8px 10px 8px 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1.5px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: pop-in .14s ease-out both;
}
.sel-bar[hidden] { display: none; }
.select-sm { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }

/* ---------- 暗記カード: 表と裏を並べて表示 ---------- */
.flashcard.split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  transform: none; transform-style: flat; cursor: default;
}
.flashcard.split .face { position: relative; inset: auto; transform: none; min-height: 0; backface-visibility: visible; -webkit-backface-visibility: visible; }
.flashcard.split .face-back { padding-top: 64px; }
@media (max-width: 760px) {
  .flashcard.split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
  .flashcard.split .face-back { padding-top: 52px; }
}

/* ---------- GeoGuessr に出題されない国 ---------- */
.no-play-tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; vertical-align: middle;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted);
  background: color-mix(in srgb, var(--muted) 18%, transparent); border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
}
.tag.no-play-tag { margin-left: 0; font-size: 12px; }
.is-no-play { color: var(--muted); opacity: .75; }
.hover-bubble.no-play .hb-body {
  background: color-mix(in srgb, #8a9099 12%, var(--surface));
  border-color: color-mix(in srgb, #8a9099 45%, var(--border)); border-left-color: color-mix(in srgb, #8a9099 80%, transparent);
}
.hover-bubble.no-play .hb-compact b { color: var(--muted); }

/* 絞り込みの欄を開いている段を、下の段（ボタン・選択の帯など）より手前に */
.view > .toolbar:has(.mpick-pop:not([hidden])) { z-index: 40; }
.mpick-btn.is-none { border-color: var(--ng); color: var(--ng); }
.mpick-head .btn { min-height: 28px; padding: 0 10px; font-size: 12px; }
.map-layout { position: relative; z-index: 1; } /* 地図の層（Leaflet の z-index）を絞り込みの欄より奥に */

/* ---------- 画面に収める（編集以外のタブ） ---------- */
.view-fit.view-scroll { display: block; overflow-y: auto; overscroll-behavior: contain; }
.view-fit .map-layout { flex: 1; min-height: 0; height: auto; }
@media (max-width: 760px) {
  .view-fit .map-layout { grid-template-rows: minmax(0, 1.5fr) minmax(0, 1fr); }
  .view-fit .map-panel { overflow-y: auto !important; }
}
/* ---------- 編集画面: 検索・絞り込み・ボタンを画面上部に追従 ---------- */
.manage-head {
  position: sticky; top: var(--topbar-h, 57px); z-index: 15;
  margin: 0 -24px 6px; padding: 12px 24px 2px; background: var(--bg);
  box-shadow: 0 6px 10px -8px rgba(0, 0, 0, .35);
}
.manage-head .sel-bar { position: static; margin-bottom: 10px; }
@media (max-width: 760px) { .manage-head { margin: 0 -16px 6px; padding: 10px 16px 2px; } }

/* 詳細などの画面: 見出し（戻る・✕）はスクロールしても上に残す */
.modal .modal-inner > .modal-head:first-child {
  position: sticky; top: 0; z-index: 5; background: var(--surface);
  margin: -20px -24px 14px; padding: 16px 24px 10px;
}
@media (max-width: 760px) {
  .modal .modal-inner > .modal-head:first-child { margin: -16px -16px 12px; padding: 12px 16px 8px; }
}

/* ---------- カードの背景はカテゴリーの色を薄く ---------- */
:root { --card-tint: 9%; }
:root[data-theme="dark"] { --card-tint: 12%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --card-tint: 12%; } }
.face, .tile, .quiz-card, .modal.modal-card, .modal.modal-card .modal-inner > .modal-head:first-child {
  background: color-mix(in srgb, var(--cat, transparent) var(--card-tint), var(--surface));
}

/* ---------- 暗記カード: 覚えた / まだ・復習 ---------- */
.study-nav .btn-mark { display: none; min-height: 48px; padding: 0 18px; gap: 8px; font-weight: 700; }
.view.is-back .study-nav .btn-mark { display: inline-flex; align-items: center; }
.view.is-back .study-nav #study-flip { display: none; }
.btn-mark kbd { font: 600 11px/1 inherit; padding: 3px 6px; border-radius: 5px; background: rgba(0, 0, 0, .14); }
.mark-ok { background: color-mix(in srgb, var(--ok, #2f9e44) 18%, var(--surface)); border-color: color-mix(in srgb, var(--ok, #2f9e44) 55%, var(--border)); }
.mark-ng { background: color-mix(in srgb, var(--ng) 14%, var(--surface)); border-color: color-mix(in srgb, var(--ng) 50%, var(--border)); }
.mark-ok:hover { background: color-mix(in srgb, var(--ok, #2f9e44) 28%, var(--surface)); }
.mark-ng:hover { background: color-mix(in srgb, var(--ng) 22%, var(--surface)); }
.badge-n { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text, #fff); font-size: 12px; line-height: 20px; text-align: center; }
.srs-row { display: flex; justify-content: center; margin-top: 4px; }
.srs-level { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.srs-level i { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--muted) 30%, transparent); }
.srs-level i.on { background: var(--accent); }
.srs-text { margin-left: 6px; }
@media (max-width: 760px) {
  .study-nav .btn-mark { padding: 0 12px; min-height: 44px; }
  .btn-mark kbd { display: none; }
}

/* ---------- クイズ: 地図で答える ---------- */
.qm-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; min-height: 0; }
.view-fit .qm-layout { flex: 1; }
.qm-layout .quiz-card { height: auto; min-height: 0; max-height: none; }
.qm-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.quiz-map { position: relative; flex: 1; min-height: 240px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #aad3df; }
.quiz-map .map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #234; font-size: 13px; z-index: 500; }
.qm-side .quiz-prompt { margin: 0; flex: none; }
.qm-side .feedback { flex: none; max-height: 46%; overflow-y: auto; overscroll-behavior: contain; margin-top: 0; }
.qm-dist { margin: 6px 0 0; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .qm-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 0.75fr) minmax(0, 1.25fr); gap: 8px; }
  .quiz-map { min-height: 0; }
  .qm-side .feedback { max-height: 50%; }
}

/* ---------- 国の比較 ---------- */
.tag-btn { border: 0; font: inherit; font-size: 12px; cursor: pointer; }
.cmp-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.cmp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; font-size: 14px; }
.cmp-name { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.cmp-name:hover { text-decoration: underline; }
.cmp-rm { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 12px; }
.cmp-rm:hover { color: var(--ng); }
.cmp-input { width: 220px !important; min-height: 36px !important; padding: 6px 12px !important; }
.cmp-pick .ghost-field { width: 220px; }
.cmp-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.cmp-suggest .chip-btn { display: inline-flex; align-items: center; gap: 5px; }
.cmp-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.cmp-table { display: flex; flex-direction: column; gap: 12px; min-width: calc(110px + var(--cols) * 170px); }
.cmp-row { display: grid; grid-template-columns: 110px repeat(var(--cols), minmax(0, 1fr)); gap: 10px; align-items: start; }
.cmp-headrow { position: sticky; top: 0; z-index: 2; }
.cmp-colhead { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; padding: 6px 4px; border-bottom: 2px solid var(--border); }
.cmp-colhead .muted { margin-left: auto; font-weight: 500; }
.cmp-cat { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding-top: 6px; position: sticky; left: 0; }
.cmp-cell { min-width: 0; }
.cmp-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.cmp-none { display: block; color: var(--muted); text-align: center; padding: 18px 0; border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.cmp-empty { padding: 24px 0; text-align: center; }
@media (max-width: 760px) {
  .cmp-table { min-width: calc(80px + var(--cols) * 150px); }
  .cmp-row { grid-template-columns: 80px repeat(var(--cols), minmax(0, 1fr)); }
  .cmp-cat { font-size: 12px; }
}
.cmp-pick .ghost-field { flex: 0 1 240px; width: 240px; }
.cmp-pick .ghost-field .cmp-input { width: 100% !important; }
.qm-side .feedback { width: 100%; max-width: none; box-sizing: border-box; }
/* スマホ: 暗記カードの上の段は 2 行（絞り込み / ボタンと枚数） */
@media (max-width: 520px) {
  .view-fit .toolbar:has(#study-review) { flex-wrap: wrap; row-gap: 6px; }
  .toolbar:has(#study-review) .mpick { flex: 1 1 40%; min-width: 0; }
  .toolbar:has(#study-review) .mpick-btn { max-width: none; width: 100%; }
}

/* ---------- 地図のインフォグラフィック ---------- */
.map-legend {
  position: absolute; left: 10px; bottom: 26px; z-index: 600; max-width: min(300px, calc(100% - 20px)); max-height: 45%;
  overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); font-size: 12px; backdrop-filter: blur(4px);
}
.map-legend .lg-title { font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.lg-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.lg-item b { margin-left: auto; color: var(--muted); font-weight: 600; }
.lg-empty, .lg-hint { color: var(--muted); }
.lg-hint { margin-top: 6px; font-size: 11px; }
.sw { display: inline-block; width: 22px; height: 14px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.sw-multi { display: inline-flex; width: 22px; height: 14px; border-radius: 3px; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.sw-multi i { flex: 1; }
.chev-sign { display: block; flex: none; }
.fact-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.fact-chip .chev-sign { width: 30px; height: 20px; }
.fact-chip.is-none { color: var(--muted); font-weight: 500; }
.seed-tag { font-size: 10px; font-weight: 600; color: var(--muted); border: 1px dashed var(--muted); border-radius: 999px; padding: 0 6px; }
.hb-compact .fact-chip { font-size: 12px; }
.pfact { position: relative; margin: -2px 0 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border: 1px solid var(--border); }
.pfact-head { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.pfact-note { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; }
.pfact-edit { position: absolute; top: 8px; right: 8px; }
.hb-fact { margin: 0 0 10px; }
.pinfo .pfact { margin-right: 32px; }
.fgroup { margin-bottom: 14px; }
.fgroup-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fgroup-head .muted { margin-left: auto; }
.fgroup-codes { display: flex; flex-wrap: wrap; gap: 4px; }
.fgroup-codes .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.fgroup-codes .chip.is-off { opacity: .55; }
@media (max-width: 760px) {
  .map-legend { bottom: 18px; max-height: 38%; font-size: 11px; }
}
/* 値の編集 */
.fact-preview { display: flex; justify-content: center; padding: 8px 0 14px; }
.fact-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.fact-label { width: 72px; font-size: 13px; font-weight: 700; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch-btn { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--border); background: var(--sw); cursor: pointer; }
.swatch-btn.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.guard-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.guard-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.guard-item:hover { background: var(--surface-2); }
.guard-item input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.fact-note { margin-top: 6px; }

.pfact-alt { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.pfact-alt > span:first-child { margin-right: 4px; }
.alt-sign .chev-sign { width: 27px; height: 18px; }

/* ---------- 地図の表示モードの選択・凡例の開閉 ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.map-mode-pick .select { font-weight: 700; min-width: 170px; }
.map-legend .lg-title { display: flex; align-items: center; gap: 6px; width: 100%; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; text-align: left; }
.lg-toggle { margin-left: auto; color: var(--muted); transition: transform .15s; }
.map-legend.is-open .lg-toggle { transform: rotate(180deg); }
.lg-desc { color: var(--muted); font-size: 11px; margin: 2px 0 6px; }
.map-legend:not(.is-open) .lg-items, .map-legend:not(.is-open) .lg-hint, .map-legend:not(.is-open) .lg-desc { display: none; }
.map-legend:not(.is-open) .lg-title { margin: 0; }
@media (min-width: 761px) { .map-legend:not(.is-open) { padding: 8px 12px; } }
@media (max-width: 760px) { .map-mode-pick { flex: 1; } .map-mode-pick .select { width: 100%; min-width: 0; } }
/* プレビューの小さい吹き出し: 長い値は折り返して枠に収める */
.hover-bubble.is-compact { max-width: min(340px, calc(100vw - 24px)); }
.hb-compact { white-space: normal; flex-wrap: wrap; row-gap: 4px; }
.hb-compact > b { white-space: nowrap; }
.hb-compact .fact-chip { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.hb-compact .fact-chip > span:not(.sw):not(.sw-multi) { white-space: normal; overflow-wrap: anywhere; }
.hb-compact .no-play-tag { margin-left: 0; }

/* ---------- 比較タブ ---------- */
.compare .cmp-title { font-size: 18px; margin: 0 8px 0 0; }
.compare .cmp-pick { margin-bottom: 8px; }
.compare .cmp-headrow { top: 0; background: var(--bg); padding-top: 4px; }
/* ---------- 国の特徴クイズ ---------- */
.quiz-setup.is-fact .cards-only { display: none; }
.seg-wrap { flex-wrap: wrap; }
.fact-card { align-items: center; justify-content: center; text-align: center; gap: 6px; }
.fact-flag { width: min(220px, 50%); max-height: 46%; object-fit: contain; border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
.fact-country { font-size: clamp(24px, 5vw, 40px); font-weight: 900; }
.fact-choices .choice { justify-content: flex-start; text-align: left; gap: 10px; }
.fact-choices .choice .chev-sign { width: 48px; height: 32px; }
.fact-choices .choice .sw, .fact-choices .choice .sw-multi { width: 34px; height: 20px; }
.fact-wrong { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.fw-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.fw-country { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.fw-given { color: var(--ng); font-size: 13px; }
.fw-right .pfact-body { margin: 0; }
@media (max-width: 760px) { .fw-row { grid-template-columns: 1fr; gap: 4px; } }

.sw-line { position: relative; display: inline-flex; align-items: center; justify-content: space-around; padding: 0 3px; }
.sw-line i { display: block; width: 3px; height: 10px; border-radius: 1px; box-shadow: 0 0 0 .5px rgba(0,0,0,.4); }

/* 比較: 開閉式の項目 */
.cmp-table { display: block; }
.cmp-cells { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 10px; }
.cmp-headrow.cmp-cells { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 4px 0 2px; }
.cmp-sec { margin-top: 12px; }
.cmp-sec > summary { cursor: pointer; font-weight: 900; font-size: 16px; padding: 8px 4px; border-bottom: 2px solid var(--border); list-style: none; }
.cmp-item { border-bottom: 1px solid var(--border); padding: 4px 0 8px; }
.cmp-item > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 6px 4px; list-style: none; color: var(--muted); }
.cmp-sec > summary::-webkit-details-marker, .cmp-item > summary::-webkit-details-marker { display: none; }
.cmp-sec > summary::before, .cmp-item > summary::before { content: '▸'; display: inline-block; width: 1em; transition: transform .15s; }
.cmp-sec[open] > summary::before, .cmp-item[open] > summary::before { transform: rotate(90deg); }
.cmp-item[open] > summary { color: var(--text); }
.cmp-fact { padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.cmp-fact .fact-chip { flex-wrap: wrap; }
.cmp-table { min-width: calc(var(--cols) * 170px); }
@media (max-width: 760px) { .cmp-table { min-width: calc(var(--cols) * 150px); } }
.bollard-sign { display: block; flex: none; }
.fact-chip .bollard-sign { width: 12px; height: 22px; }

/* 地図: 条件で絞り込み */
.map-legend:has(.match-form) { max-height: 70%; width: min(330px, calc(100% - 20px)); max-width: none; }
.match-form { display: flex; flex-direction: column; gap: 6px; }
.match-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.match-row .select { width: 100%; min-width: 0; padding-right: 22px; }
.match-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; }
.match-foot .btn { margin-left: auto; }

/* ---------- 学習記録 ---------- */
.stats-btn { display: inline-grid; place-items: center; }
@media (max-width: 760px) { .stats-btn { width: 34px; height: 34px; } }
.st-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.st-tile { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.st-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.st-num { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.2; }
.st-num small { font-size: 14px; color: var(--muted); font-weight: 600; }
.st-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.st-meter { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 25%, transparent); overflow: hidden; margin-top: 6px; }
.st-meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.st-title { font-size: 14px; margin: 6px 0 8px; }
.st-chart { position: relative; margin-bottom: 18px; }
.st-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.st-chart text { font-size: 10px; fill: var(--muted); font-family: inherit; }
.st-axis { stroke: var(--border); stroke-width: 1; }
.st-goal { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.st-bar path { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.st-bar.is-goal path { fill: var(--accent); }
.st-bar:hover path { fill: color-mix(in srgb, var(--accent) 80%, var(--text)); }
.st-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap; pointer-events: none; }
.st-regions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.st-region { display: grid; grid-template-columns: 120px minmax(0, 1fr) 44px 52px; align-items: center; gap: 8px; font-size: 13px; }
.st-rbar { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 20%, transparent); overflow: hidden; }
.st-rbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.st-rpct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.st-rn { font-size: 12px; text-align: right; }
.st-goal-input { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.st-goal-input input { width: 70px !important; min-height: 32px !important; padding: 4px 8px !important; }
@media (max-width: 760px) { .st-tiles { grid-template-columns: 1fr; } .st-region { grid-template-columns: 90px minmax(0, 1fr) 40px; } .st-rn { display: none; } }

/* カードの地図データ */
.card-facts { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border: 1px solid var(--border); text-align: left; }
.card-facts-head { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.card-fact-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding: 4px 0; border-top: 1px dashed var(--border); }
.card-fact-row:first-of-type { border-top: 0; }
.cf-country { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; min-width: 110px; }
.card-fact-row .pfact-body, .card-fact-row .pfact-note, .card-fact-row .pfact-alt { margin: 0; }
.card-facts .btn { margin-top: 6px; }
.face-back .card-facts { max-width: 760px; margin-left: auto; margin-right: auto; }
/* 暗記の裏面: 地図のデータは右下に小さくたたむ（押すと上に広がる） */
.face-back .card-facts-mini {
  position: absolute; right: 12px; bottom: 12px; z-index: 3; margin: 0; padding: 0;
  background: none; border: 0; max-width: calc(100% - 24px);
}
.card-facts-mini > summary {
  list-style: none; cursor: pointer; margin-left: auto; width: max-content;
  font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid var(--border);
}
.card-facts-mini > summary::-webkit-details-marker { display: none; }
.card-facts-mini > summary:hover { color: var(--text); }
.card-facts-mini[open] > summary { color: var(--accent); }
.card-facts-pop {
  position: absolute; right: 0; bottom: calc(100% + 6px); width: min(420px, calc(100vw - 48px));
  max-height: min(60vh, 420px); overflow-y: auto; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border: 1px solid var(--border); box-shadow: var(--shadow);
}
/* 暗記の裏面の画像（表面より小さく、国名の上） */
.back-img { display: flex; justify-content: center; padding-top: 8px; }
.back-img-box { position: relative; max-width: min(100%, 360px); border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); line-height: 0; }
.back-img img { display: block; max-width: 100%; max-height: min(26vh, 220px); width: auto; height: auto; object-fit: contain; }
.back-img .back-layer { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; object-fit: fill; pointer-events: none; }
/* 逆向きクイズ: 見本を大きく */
.rev-swatch { display: flex; justify-content: center; margin: 10px 0 4px; }
.rev-swatch .chev-sign { width: 132px; height: 88px; }
.rev-swatch .sw, .rev-swatch .sw-multi { width: 110px; height: 64px; border-radius: 8px; }
.rev-swatch .bollard-sign { width: 44px; height: 80px; }
.rev-label { font-size: clamp(20px, 3.4vw, 32px); }
.fact-choices .choice .bollard-sign { width: 16px; height: 30px; }
.rev-answers { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; }
.rev-answers .chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }

/* 比較: その国・カテゴリーでカードを作成 */
.cmp-add-card { display: block; width: 100%; margin-top: 6px; padding: 6px 8px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.cmp-add-card:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cmp-fact .cmp-add-card { display: inline-block; width: auto; padding: 2px 8px; }

/* 地図: 参考写真 */
.photo-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; cursor: pointer; }
.photo-switch .switch { transform: scale(.85); }
.map-thumb.is-photo { border-color: #fff; }
.pphotos { margin: -4px 0 12px; }
.pphotos-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.pphotos-head a { margin-left: auto; }
.pphotos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pphoto { position: relative; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #0b0f12; cursor: zoom-in; }
.pphoto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pphoto:hover { border-color: var(--accent); }
.pfact-link { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--accent); }

.photo-credit { margin: 6px 2px 0; }
.photo-credit a { color: inherit; }

/* 国の詳細: 地図のデータ */
.cinfo-facts { margin: 14px 0 6px; }
.cinfo-facts > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.cinfo-facts > summary::-webkit-details-marker { display: none; }
.cinfo-facts > summary::before { content: '▸'; transition: transform .15s; color: var(--muted); }
.cinfo-facts[open] > summary::before { transform: rotate(90deg); }
.cfacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 8px; }
.cfacts-row { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.cfacts-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cfacts-head .link-btn { margin-left: auto; font-size: 11px; }
.cfacts-body .fact-chip { flex-wrap: wrap; }
.cfacts-photos { display: flex; gap: 4px; margin-top: 6px; overflow-x: auto; }
.cfacts-photo { flex: none; width: 56px; height: 42px; padding: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #0b0f12; cursor: pointer; }
.cfacts-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cfacts-photo:hover { border-color: var(--accent); }

/* 国の詳細: メモは国名の右 */
.cinfo-hero > div:not(.cinfo-memo) { flex: none; }
.cinfo-memo-side { flex: 1; min-width: 0; margin: 0 0 0 auto; padding: 0; border: 0; align-self: stretch; display: flex; flex-direction: column; max-width: 360px; }
.cinfo-memo-side .memo-title { font-size: 13px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.cinfo-memo-side .memo-input { flex: 1; min-height: 64px; font-size: 13px; resize: vertical; }
.cinfo-memo-side .memo-view { flex: 1; font-size: 13px; }
@media (max-width: 760px) {
  .cinfo-hero { flex-wrap: wrap; }
  .cinfo-hero > div:not(.cinfo-memo) { flex: 1 1 0; min-width: 0; }
  .cinfo-memo-side { flex-basis: 100%; max-width: none; margin: 4px 0 0; }
}

.photo-info { margin: 4px 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.photo-desc { margin: 0 0 8px; line-height: 1.7; white-space: pre-wrap; }
.photo-map { text-decoration: none; }

/* 画像への書き込み */
.annot { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: rgba(8, 12, 16, .92); padding: 12px; gap: 8px; }
.annot-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.annot-colors { display: flex; gap: 6px; }
.annot-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); background: var(--c); cursor: pointer; }
.annot-color.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.annot-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; border-radius: 6px; background: rgba(0, 0, 0, .25); }
.annot-stage canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; touch-action: none; cursor: crosshair; display: block; }
.annot-stage.is-pan canvas, .annot-stage.is-space canvas { cursor: grab; }
.annot-stage.is-panning canvas { cursor: grabbing; }
.annot-zoom {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; display: flex; align-items: center; gap: 2px;
  background: rgba(20, 24, 28, .85); border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; padding: 3px;
}
.annot-zoom button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: #fff; font: inherit; font-size: 16px; cursor: pointer; }
.annot-zoom button:hover { background: rgba(255, 255, 255, .15); }
.annot-zoom-n { color: #ddd; font-size: 12px; min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.annot-hint { margin: 0; text-align: center; color: #ccc; font-size: 12px; }
/* まとめて追加 */
.bulk-common { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.bulk-drop { min-height: 90px; display: grid; place-items: center; text-align: center; padding: 14px; margin-bottom: 10px; }
.bulk-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.bulk-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1.4fr) 36px; gap: 8px; align-items: center; }
.bulk-row img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: #0b0f12; }
@media (max-width: 760px) { .bulk-common { grid-template-columns: 1fr; } .bulk-row { grid-template-columns: 60px minmax(0, 1fr) 36px; } .bulk-row .bulk-d { grid-column: 2; } }
#photo-to-card { margin: 0 0 12px; }

/* クイズ: 参考写真・タイムアタック */
.quiz-setup.is-fact .not-fact, .quiz-setup.is-photo .cards-only { display: none; }
.quiz-setup.is-sv .cards-only, .quiz-setup.is-sv .not-sv { display: none; }
.qt-counter b { font-variant-numeric: tabular-nums; }
.qt-counter.is-hurry { color: var(--ng); }
.ta-best { margin: 6px 0 12px; font-weight: 800; color: var(--accent); }
/* 学習記録: よく間違える組み合わせ */
.st-pairs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.st-pair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.st-pair-names { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; flex: 1; min-width: 200px; }

.og-export { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 10px; }
.og-export .muted { flex-basis: 100%; }
#q-og-site { width: auto; }
.og-export .og-site { width: auto; margin-left: 6px; }

.og-all { text-decoration: none; flex-basis: auto; }
/* 地図のサムネイル: Leaflet の標準スタイル（マーカー内の画像は width: auto）に負けないように、枠いっぱい・中央に */
.leaflet-container .leaflet-marker-pane .map-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; }

/* 写真ごとのメモ */
.photo-pnote { padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, #f5c400 12%, transparent); }
.photo-note-edit { margin: 0 0 10px; }
.photo-note-edit textarea { min-height: 64px; background: color-mix(in srgb, #f5c400 6%, var(--surface)); }
.pphoto.has-note::after, .cfacts-photo.has-note::after { content: '📝'; position: absolute; top: 2px; right: 3px; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.cfacts-photo { position: relative; }

/* 地図の右パネル: 上下の高さを変える仕切り */
.psplit { flex: none; height: 9px; margin: -4px 0; position: relative; z-index: 2; cursor: row-resize; touch-action: none; }
.psplit::before { content: ''; position: absolute; left: 0; right: 0; top: 4px; border-top: 1px solid var(--border); }
.psplit::after { content: ''; position: absolute; left: 50%; top: 2px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--border); opacity: .9; transition: background .15s; }
.psplit:hover::after, .psplit:focus-visible::after, .psplit.is-dragging::after { background: var(--accent); }
.psplit:focus-visible { outline: none; }
@media (max-width: 760px) { .psplit { display: none; } }

.photo-desc.photo-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* ---------- 画像編集: レイヤー（表面 / 裏面だけ） ---------- */
.annot-layer button { white-space: nowrap; }
.annot.is-back-layer .annot-stage canvas { box-shadow: 0 0 0 3px #f59f00; }
.annot.is-back-layer .annot-layer [data-layer="back"].on { background: #f59f00; color: #1a1300; }
.annot-hint.is-error { color: #ff8787; }
/* 編集画面の画像プレビュー: 裏面だけの書き込みを重ねて表示 */
.ed-img-wrap { position: absolute; inset: 0; }
.dropzone .ed-back { background: transparent; pointer-events: none; }
.ed-back-tag {
  position: absolute; left: 8px; top: 8px; z-index: 2; font-size: 11px; font-weight: 700;
  background: #f59f00; color: #1a1300; border-radius: 999px; padding: 2px 8px;
}
/* カード詳細: 裏面だけの書き込みを画像に重ねる（ボタンで表示 / 非表示） */
.front-img img.layer-back { background: transparent; pointer-events: none; }
.front-img.hide-layer img.layer-back { display: none; }
.layer-toggle {
  position: absolute; left: 8px; bottom: 8px; z-index: 3; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
  background: #f59f00; color: #1a1300; border: 0; border-radius: 999px; padding: 3px 9px;
}
.front-img.hide-layer .layer-toggle { background: rgba(0, 0, 0, .55); color: #fff; }
/* 関連カード */
.related { margin: 14px auto 0; max-width: 760px; text-align: left; }
.related-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.related-list { display: flex; flex-wrap: wrap; gap: 6px; }
.related-item, .rel-hit {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit; color: var(--text); text-align: left;
  background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--surface)); border: 1px solid var(--border);
  border-left: 3px solid var(--cat, var(--border)); border-radius: 8px; max-width: 100%;
}
.related-item:hover, .rel-hit:hover { border-color: var(--accent); }
.related-thumb { width: 44px; height: 32px; border-radius: 5px; overflow: hidden; background: #0b0f12; flex: none; }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.related-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.related-country { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.related-country .flag { width: 16px; height: 11px; }
.related-cat { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ed-related { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.rel-chip { gap: 5px; }
.rel-chip-img { width: 28px; height: 20px; object-fit: cover; border-radius: 3px; }
.ed-rel-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.ed-rel-results .rel-hit { width: 100%; }
/* 追加日時・最終編集日時 */
.card-dates { margin: 12px 0 0; }
.ed-dates { margin: 0 0 0 8px; }

/* ---------- 言語タブ ---------- */
.lang-view { max-width: 1100px; margin: 0 auto; }
.lang-title { font-size: 18px; margin: 0 4px 0 0; white-space: nowrap; }
.lang-toolbar .input { min-width: 0; }
.lang-picked { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; min-height: 30px; }
.lang-palette { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.lang-group { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.lang-group > summary { cursor: pointer; padding: 7px 12px; font-size: 13px; font-weight: 700; }
.lang-chars { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 10px; }
.lang-ch {
  min-width: 34px; height: 34px; padding: 0 8px; font: inherit; font-size: 17px; line-height: 1; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
}
.lang-ch:hover:not(:disabled) { border-color: var(--accent); }
.lang-ch.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.lang-ch:disabled { opacity: .25; cursor: default; }
.lang-picked .lang-ch { height: 30px; font-size: 15px; }
.lang-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.lang-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.lang-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.lang-name { font-size: 16px; }
.lang-script { margin-left: auto; font-size: 11px; }
.lang-row { display: flex; gap: 8px; margin: 4px 0; font-size: 13px; line-height: 1.6; }
.lang-k { flex: none; font-size: 11px; font-weight: 700; color: var(--muted); width: 2.6em; padding-top: 2px; }
.lang-chars-text { font-size: 15px; }
.lang-row mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.lang-countries { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.lang-countries .chip { font-size: 12px; }
@media (max-width: 640px) { .lang-list { grid-template-columns: 1fr; } .lang-title { display: none; } }

/* 画像編集: アイコンだけのツール・太さ */
.seg.seg-icons button { display: inline-flex; align-items: center; justify-content: center; padding: 6px 9px; }
.annot-width { display: inline-flex; align-items: center; gap: 6px; color: #fff; padding: 0 4px; }
.annot-width input { width: 92px; accent-color: var(--accent); }
.btn.btn-icon { padding: 5px 9px; display: inline-flex; align-items: center; }
.annot-stage.is-select canvas { cursor: default; }

/* ---------- 地図: ストリートビュー ---------- */
.map.sv-on, .map.sv-on .leaflet-interactive, .map.sv-on .leaflet-marker-icon { cursor: crosshair !important; }
.sv-banner {
  position: absolute; bottom: 30px; right: 10px; z-index: 1100; width: max-content; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.3;
  background: rgba(28, 126, 214, .92); color: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}
.sv-banner[hidden], .sv-panel[hidden] { display: none; }
.sv-banner span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sv-banner svg { flex: none; }
.sv-banner .link-btn { color: #fff; text-decoration: underline; white-space: nowrap; font-size: 11px; }
.sv-banner svg { width: 14px; height: 14px; }
.sv-panel {
  position: fixed; left: 12px; bottom: 12px; z-index: 2500; display: flex; flex-direction: column;
  width: min(520px, calc(100vw - 24px)); height: min(400px, 60vh); min-width: 280px; min-height: 220px; max-width: 100vw; max-height: 100vh;
  resize: both; overflow: hidden; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
}
.sv-panel.is-max { inset: 12px !important; width: auto !important; height: auto !important; resize: none; }
.sv-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; cursor: move; user-select: none; background: var(--surface-2); touch-action: none; }
.sv-title { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.sv-coord { margin-right: auto; font-variant-numeric: tabular-nums; }
.sv-btn { width: 30px; height: 30px; font-size: 15px; display: inline-grid; place-items: center; text-decoration: none; cursor: pointer; }
.sv-panel iframe { flex: 1; min-height: 0; width: 100%; border: 0; background: #0b0f12; }
.sv-note { flex: none; margin: 0; padding: 3px 12px; font-size: 11px; }
.sv-pin { background: none; border: 0; }
.sv-pin span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #e8590c; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(232, 89, 12, .5), 0 2px 8px rgba(0, 0, 0, .5); }
@media (max-width: 760px) {
  .sv-panel { left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; width: auto !important; height: 58vh !important; max-width: none; resize: none; border-radius: 12px 12px 0 0; }
  .sv-panel.is-max { inset: 0 !important; border-radius: 0; }
  .sv-banner { bottom: 26px; right: 8px; }
  .sv-head { cursor: default; }
  .sv-title { white-space: nowrap; }
  .sv-coord { display: none; }
  .sv-head .sv-btn:first-of-type { margin-left: auto; }
  .sv-note { display: none; }
}

/* スマホ: 地図の上の操作が増えたので、入り切らないときは 2 行にする（地図の表示の選択が潰れないように） */
@media (max-width: 760px) {
  .view-fit .map-toolbar { flex-wrap: wrap; }
  .view-fit .map-toolbar .map-mode-pick { flex: 1 1 100%; }
  .view-fit .map-toolbar .map-mode-pick .select { width: 100%; }
}

/* ストリートビューのある道路（青い線）を目立たせる */
.sv-coverage { filter: saturate(1.4) brightness(1.5) drop-shadow(0 0 1px rgba(255, 255, 255, .7)); }
.sv-banner { transition: background .2s; }

/* 学習記録の同期 */
.sync-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; width: 100%; }
.sync-input { flex: 1 1 220px; min-width: 0; font-family: ui-monospace, monospace; }
.sync-code { font-family: ui-monospace, monospace; letter-spacing: .04em; }
.sync-msg { margin-top: 8px; }
.sync-msg.is-error { color: var(--danger, #e03131); }
.sync-msg.is-ok { color: var(--accent); }

/* ストリートビューの練習 */
.sv-setup-note { margin: 0 0 10px; }
.front-img.sv-front { background: #0b0f12; }
.sv-quiz-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sv-cover {
  position: absolute; left: 0; top: 0; width: min(380px, 80%); height: 84px; z-index: 2; display: grid; place-items: center;
  background: linear-gradient(135deg, #1f2933 60%, rgba(31, 41, 51, .85)); color: #adb5bd; font-size: 28px; font-weight: 800;
  border-bottom-right-radius: 14px;
}
.sv-cover-fs { position: absolute; right: 0; top: 0; width: 68px; height: 68px; z-index: 2; background: #1f2933; border-bottom-left-radius: 14px; }
.sv-front .cat-on-img { z-index: 3; top: 92px; }

/* クリックしたら開く場所（いちばん近い道路）の印 */
.sv-ghost { background: none; border: 0; }
.sv-ghost span { display: block; width: 24px; height: 24px; border-radius: 50%; border: 3px solid #fff; background: rgba(232, 89, 12, .45); box-shadow: 0 0 0 2px #e8590c, 0 2px 8px rgba(0, 0, 0, .5); }
.map.sv-on.sv-hot, .map.sv-on.sv-hot .leaflet-interactive, .map.sv-on.sv-hot .leaflet-marker-icon { cursor: pointer !important; }

/* 一時的な縮小: ヘッダーだけ（映像は隠す。位置は変えない） */
.sv-panel.is-min { height: auto !important; min-height: 0; resize: none; }
.sv-panel.is-min iframe, .sv-panel.is-min .sv-note { display: none; }

/* スマホで、ストリートビューを開いている間は、ダイアログをモーダルにしない（ストリートビューを操作できるように）。画面の中央に固定して表示 */
.modal.is-nonmodal[open] { position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 30; box-shadow: 0 0 0 100vmax rgba(8, 12, 16, .35), 0 20px 60px rgba(0, 0, 0, .35); }

/* ---------- 浮かぶウィンドウ（PC: カード・国・写真の詳細） ---------- */
.modal.is-window[open] {
  display: flex; flex-direction: column; overflow: hidden; resize: both; min-width: 380px; min-height: 120px; max-width: 100vw; max-height: 100vh;
  border: 1px solid var(--border); box-shadow: 0 14px 44px rgba(0, 0, 0, .5);
}
.modal.is-window .modal-inner { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal.is-window .modal-inner > .modal-head:first-child { cursor: move; user-select: none; touch-action: none; }
/* 見出しは、スクロールする .modal-inner の上の余白（20px）の分だけ上に寄せて貼りつける（そうしないと、余白の部分から画像がはみ出して見える） */
.modal.is-window .modal-inner > .modal-head:first-child { top: -20px; }
.modal.is-window .detail { grid-template-columns: 1fr; }
.modal.is-window .detail-front { height: min(46vh, 420px); }
.modal.is-window .detail-back { max-height: none; overflow: visible; }
.win-btn { width: 30px; height: 30px; font-size: 15px; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.modal.is-window.is-max[open] { inset: 12px !important; width: auto !important; height: auto !important; resize: none; }
.modal.is-window.is-min[open] { height: auto !important; min-height: 0; resize: none; }
.modal.is-window.is-min .modal-inner > :not(.modal-head:first-child) { display: none; }
.modal.is-window.is-min .modal-inner { overflow: hidden; }

/* ---------- 画面分割: ウィンドウを左右のはしに入れたとき（ヘッダーは分割せず、その下の部分だけ） ---------- */
body[data-split] .view { margin: 0 0 0 calc(var(--split-l, 0) * 100vw); width: calc((1 - var(--split-l, 0) - var(--split-r, 0)) * 100vw); max-width: none; }
.is-snap { border-radius: 0 !important; resize: none !important; box-shadow: none !important; }
.modal.is-window.is-snap[open] { border-top: 0; border-bottom: 0; }
.snap-preview {
  position: fixed; z-index: 2790; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 22%, transparent); border: 2px solid var(--accent); box-sizing: border-box;
}
.split-bar { position: fixed; width: 10px; cursor: col-resize; touch-action: none; background: transparent; }
.split-bar::after { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.split-bar:hover::after, .split-bar:active::after { background: var(--accent); width: 4px; left: 3px; }
/* 分割中の（狭くなった）ページ側 */
body[data-split] .map-hint { display: none; }
body[data-split] .view { padding-left: 14px; padding-right: 14px; }

/* 地図と右パネルの境界線（ドラッグで幅を変える） */
.vsplit { position: relative; cursor: col-resize; touch-action: none; z-index: 2; }
.vsplit::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 0; border-left: 1px solid transparent; }
.vsplit::after { content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 44px; margin: -22px 0 0 -2.5px; border-radius: 3px; background: var(--border); opacity: .9; transition: background .12s, height .12s; }
.vsplit:hover::after, .vsplit:focus-visible::after, .vsplit.is-dragging::after { background: var(--accent); height: 64px; margin-top: -32px; }
.vsplit:hover::before, .vsplit.is-dragging::before { border-left-color: var(--accent); }
.vsplit:focus-visible { outline: none; }
@media (max-width: 760px) { .vsplit { display: none; } }

/* 隣接国などが 3 行以上のときの折りたたみ */
.nb-fold.is-folded { overflow: hidden; }
.fold-toggle { font-size: 12px; margin: 0 0 3px; }

/* 右のパネル（国の情報）を隠す */
.map-box { position: relative; }
.map-panel-toggle { position: absolute; top: 10px; right: 10px; z-index: 800; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.map-panel-toggle:hover { border-color: var(--accent); color: var(--accent); }
.map-panel-toggle[aria-pressed="true"] { background: var(--accent); color: #0b1a12; border-color: var(--accent); }
.map-layout.panel-hidden { grid-template-columns: minmax(0, 1fr); }
.map-layout.panel-hidden .vsplit, .map-layout.panel-hidden .map-panel { display: none; }
@media (max-width: 760px) { .map-layout.panel-hidden { grid-template-rows: minmax(0, 1fr); } .view-fit .map-layout.panel-hidden { grid-template-rows: minmax(0, 1fr); } }

/* ストリートビュー練習（写真の地点）の答え: その地点の参考写真 */
.sv-ref-answer { margin: 0 0 10px; }
.sv-ref-answer img { display: block; max-width: 100%; max-height: min(42vh, 380px); margin: 0 auto; border-radius: 10px; border: 1px solid var(--border); }
.sv-ref-answer figcaption { text-align: center; margin-top: 4px; }

/* 地図で答えるとき（PC）: GeoGuessr のように、右下に小さな地図を重ね、カーソルを合わせると広がる。答えたあとは、いつもの大きな表示 */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .qm-layout.qm-float { grid-template-columns: minmax(0, 1fr); position: relative; }
  .qm-layout.qm-float .quiz-card { min-height: min(64vh, 600px); }
  .view-fit .qm-layout.qm-float .quiz-card { min-height: 0; }
  .qm-layout.qm-float .qm-side { position: absolute; right: 14px; bottom: 14px; z-index: 5; width: min(320px, 38%); align-items: stretch; pointer-events: none; transition: width .18s ease; }
  .qm-layout.qm-float .qm-side:hover, .qm-layout.qm-float .qm-side:focus-within { width: min(780px, 92%); }
  .qm-layout.qm-float .quiz-map { flex: none; height: 210px; min-height: 0; pointer-events: auto; box-shadow: 0 6px 24px rgba(0,0,0,.5); opacity: .92; transition: height .18s ease, opacity .18s; }
  .qm-layout.qm-float .qm-side:hover .quiz-map, .qm-layout.qm-float .qm-side:focus-within .quiz-map { height: min(520px, calc(100vh - 260px)); opacity: 1; }
  .qm-layout.qm-float .qm-side .quiz-prompt { order: 2; margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; text-align: center; pointer-events: auto; }
}

.qm-side .qm-guess { flex: none; width: 100%; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { .qm-layout.qm-float .qm-side .qm-guess { order: 3; margin-top: 6px; pointer-events: auto; } }

/* リアルタイム対戦 */
.battle { max-width: 760px; margin: 0 auto; }
.bt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.bt-head h2 { margin: 0; font-size: 18px; }
.bt-room { font-family: ui-monospace, monospace; letter-spacing: .15em; background: var(--surface-2); padding: 2px 10px; border-radius: 8px; color: var(--accent); }
.bt-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.bt-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.bt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bt-code { max-width: 220px; text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, monospace; }
.bt-players { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.bt-players li { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.bt-players li.me, .bt-board li.me { border-color: var(--accent); color: var(--accent); }
.bt-choices { margin-top: 12px; }
.bt-choices .choice { display: flex; align-items: center; gap: 8px; }
.bt-choices .choice.picked { outline: 2px solid var(--accent); }
.bt-who { margin-left: auto; font-size: 12px; color: var(--muted); }
.bt-sub { margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.bt-board { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bt-board li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.bt-rank { width: 2em; text-align: center; }
.bt-pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-wait { text-align: center; padding: 40px 0; font-size: 18px; }
.bt-input-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.bt-input-row .input { flex: 1; min-width: 200px; }
.bt-chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.bt-qm { min-height: min(66vh, 620px); margin-top: 8px; }
.bt-answer { margin: 10px 0; }
.bt-results li { gap: 8px; }
.bt-res { width: 1.4em; text-align: center; font-weight: 700; }
.bt-res.res-ok { color: var(--accent); }
.bt-res.res-partial { color: #fab005; }
.bt-res.res-ng { color: #e03131; }
.bt-label { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 対戦のチャット・参加者 */
.bt-chat { position: fixed; left: 14px; bottom: 14px; z-index: 900; width: min(320px, calc(100vw - 28px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.45); overflow: hidden; }
.bt-chat-toggle { width: 100%; display: flex; align-items: center; gap: 6px; padding: 10px 12px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.bt-chat-arrow { margin-left: auto; color: var(--muted); }
.bt-unread { background: #e03131; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.bt-chat-body { display: flex; flex-direction: column; max-height: min(55vh, 420px); }
.bt-members { list-style: none; margin: 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); max-height: 140px; overflow-y: auto; }
.bt-members li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bt-members li.me .bt-mname { color: var(--accent); font-weight: 700; }
.bt-mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-mbtn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 6px; font-size: 11px; padding: 2px 6px; cursor: pointer; }
.bt-mbtn:hover { border-color: var(--accent); }
.bt-kick:hover { border-color: #e03131; color: #e03131; }
.bt-msgs { flex: 1; min-height: 90px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; overscroll-behavior: contain; }
.bt-msg b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.bt-msg.mine b { color: var(--accent); }
.bt-sys { color: var(--muted); font-size: 12px; text-align: center; }
.bt-chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.bt-chat-form .input { flex: 1; min-width: 0; }
.bt-scope { display: flex; flex-direction: column; gap: 8px; }
.bt-scope-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bt-scope-row > .muted { width: 5.5em; flex: none; }

.battle { max-width: 1000px; }
.bt-settings { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 4px; }
.bt-settings .setup-block { margin: 12px 0; }
/* 対戦のストリートビューは大きく（映像が見やすいように） */
.battle .quiz-card:has(.sv-front) { height: min(72vh, 720px); min-height: 360px; }
.battle .bt-qm .quiz-card:has(.sv-front) { height: auto; min-height: min(70vh, 700px); }

/* ストリートビューの問題・答え: 映像を右に大きく、答えや選択肢は左に */
.sv-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 14px; align-items: start; }
.sv-split > .quiz-card, .battle .sv-split > .quiz-card:has(.sv-front), .sv-split > .quiz-card:has(.sv-front) { order: 2; height: min(76vh, 780px); min-height: 380px; }
.sv-split > :not(.quiz-card) { order: 1; min-width: 0; }
@media (max-width: 900px) {
  .sv-split { grid-template-columns: minmax(0, 1fr); }
  .sv-split > .quiz-card, .battle .sv-split > .quiz-card:has(.sv-front) { order: 0; height: 55vh; min-height: 280px; }
  .sv-split > :not(.quiz-card) { order: 1; }
}
.sv-split > :not(.quiz-card) { max-height: min(76vh, 780px); overflow-y: auto; overscroll-behavior: contain; }
.sv-split .feedback { max-height: none; overflow: visible; }
.sv-split > .quiz-bottom { max-height: min(76vh, 780px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 900px) { .sv-split > :not(.quiz-card) { max-height: none; overflow: visible; } }

/* 公開された対戦の部屋のポップアップ */
.bt-popups { position: fixed; top: 76px; right: 14px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 28px)); }
.bt-popup { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: bt-pop .25s ease; }
.bt-popup-text { flex: 1; min-width: 0; font-size: 14px; }
.bt-popup-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px; }
@keyframes bt-pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
/* ストリートビューのクイズ（ソロ・対戦）: 映像を画面の左右いっぱいに拡げる */
body:has(.sv-front) { overflow-x: clip; }
.quiz-card:has(.sv-front):not(.sv-split > .quiz-card), .qm-layout:has(.sv-front), .sv-split {
  position: relative; left: 50%; transform: translateX(-50%); width: calc(100vw - 24px); max-width: none; box-sizing: border-box;
}
.quiz-card:has(.sv-front):not(.sv-split > .quiz-card):not(.qm-layout .quiz-card), .battle .quiz-card:has(.sv-front):not(.sv-split > .quiz-card):not(.qm-layout .quiz-card) { height: min(76vh, 820px); min-height: 420px; }
@media (max-width: 900px) { .quiz-card:has(.sv-front):not(.sv-split > .quiz-card), .qm-layout:has(.sv-front), .sv-split { width: 100%; left: 0; transform: none; } }

.bt-pubroom { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 12px; margin: 6px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.bt-pubroom .bt-room { font-size: 12px; }
/* 対戦: ストリートビューのときは、枠（パネル）ごと画面の左右いっぱいに拡げ、中の映像は枠いっぱいにする（枠からはみ出さない） */
.battle:has(.sv-front) { max-width: none; width: calc(100vw - 24px); position: relative; left: 50%; transform: translateX(-50%); box-sizing: border-box; }
.battle .quiz-card:has(.sv-front):not(.sv-split > .quiz-card), .battle .qm-layout:has(.sv-front), .battle .sv-split { left: 0; transform: none; width: 100%; }
@media (max-width: 900px) { .battle:has(.sv-front) { width: 100%; left: 0; transform: none; } }
/* 上の「はみ出し」方式をやめ、ストリートビューのあるときは画面（#view）そのものを左右いっぱいにする */
.view:has(.sv-front) { max-width: none; }
.quiz-card:has(.sv-front), .qm-layout:has(.sv-front), .sv-split, .battle:has(.sv-front) { left: 0 !important; transform: none !important; width: 100% !important; }

/* 上のバーのメモボタン（設定・ミュートと同じ並び） */
.chat-btn { position: relative; }
.chat-btn.active { color: var(--accent); }
.chat-btn .chat-badge { top: 4px; right: 4px; width: 9px; height: 9px; }

/* 対戦の問題画面: 単独プレイと同じ（枠をなくし、画面いっぱいに問題カード、下に選択肢） */
.battle.bt-play { max-width: none; background: transparent; border: 0; box-shadow: none; padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.battle.bt-play #bt-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.battle.bt-play .quiz-card { flex: 1; min-height: 0; }

.battle.bt-play { margin: 0; width: 100%; }

.bt-gain { color: var(--accent); font-size: 12px; white-space: nowrap; }
.bt-results .bt-score { min-width: 3.5em; text-align: right; }

@media (max-width: 900px) { .sv-split > .quiz-bottom { max-height: none; overflow: visible; } }

/* ストリートビューの 4 択・入力: 選択肢・解答欄を映像の下部に重ね、触れていないときは半透明 */
.sv-overlay-wrap { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sv-overlay-wrap > .quiz-card { flex: 1; min-height: 0; }
.sv-overlay-wrap > .quiz-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 34px; width: min(800px, calc(100% - 56px)); max-height: none; overflow: visible; z-index: 6; opacity: .38; transition: opacity .18s ease; padding: 0; }
.sv-overlay-wrap > .quiz-bottom:hover, .sv-overlay-wrap > .quiz-bottom:focus-within { opacity: 1; }
.sv-overlay-wrap > .quiz-bottom .choices { margin: 0; }
.sv-overlay-wrap > .quiz-bottom .choice, .sv-overlay-wrap > .quiz-bottom .bt-input-row { backdrop-filter: blur(4px); background-color: rgba(18, 26, 33, .82); }
.sv-overlay-wrap > .quiz-card:has(.sv-front) { height: auto !important; max-height: none !important; min-height: 420px; flex: 1 1 auto; }

.bt-slider { display: flex; align-items: center; gap: 12px; }
.bt-slider input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.bt-slider output { min-width: 4.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.cl-group { margin: 6px 0 18px; }
.cl-date { font-size: 15px; margin: 0 0 8px; }
.cl-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; line-height: 1.7; }

.bt-head-actions { display: flex; align-items: center; gap: 8px; }

.cl-version { margin: 6px 0 22px; }
.cl-ver { font-size: 18px; margin: 0 0 8px; }
.cl-now { font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent); border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
.cl-group { margin: 10px 0 14px; }
.cl-date { font-size: 14px; margin: 0 0 6px; color: var(--muted); }

/* 対戦: 答えたあと、自分が選んだ選択肢を目立たせ、ほかは薄くする */
.bt-choices.answered .choice { opacity: .5; }
.bt-choices.answered .choice.picked { opacity: 1; outline: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); position: relative; }
.bt-choices.answered .choice.picked::after { content: '✔ あなたの回答'; margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* 対戦の答え合わせ（地図で答える問題）: 画像・ストリートビューの下に、自分の答えと正解の地図 */
.sv-split > .bt-media { order: 2; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bt-media > .quiz-card, .sv-split > .bt-media > .quiz-card:has(.sv-front), .battle .sv-split > .bt-media > .quiz-card:has(.sv-front) { height: min(46vh, 480px) !important; min-height: 240px; order: 0; }
.bt-media > .bt-rmap { flex: none; height: min(34vh, 360px); min-height: 220px; }
.bt-media > .quiz-card { flex: none !important; }

/* 答えの表示: ストリートビューの開閉 */
.sv-split.sv-collapsed { grid-template-columns: minmax(0, 1fr); }
.sv-split.sv-collapsed .quiz-card:has(.sv-front), .qm-layout.sv-collapsed .quiz-card:has(.sv-front) { display: none; }
.qm-layout.sv-collapsed { grid-template-columns: minmax(0, 1fr); }

/* 答えの表示: ストリートビューは、地図の上の吹き出し（初めは閉じている） */
.bt-rmap-big { height: min(72vh, 740px) !important; }
.quiz-map:has(> .sv-bubble) { position: relative; }
.sv-bubble { position: absolute; left: 3%; right: 3%; top: 2.5%; height: 60%; z-index: 1200; filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .55)); }
.sv-bubble[hidden] { display: none; }
.sv-bubble-inner { position: absolute; inset: 0; border-radius: 16px; overflow: hidden; border: 2px solid var(--accent); background: #0b0f12; }
.sv-bubble-inner > .quiz-card { position: absolute !important; inset: 0; left: 0 !important; transform: none !important; width: 100% !important; height: 100% !important; min-height: 0 !important; max-height: none !important; margin: 0 !important; border: 0 !important; border-radius: 0 !important; padding: 0 !important; background: transparent !important; box-shadow: none !important; }
.sv-bubble-inner .front-img { height: 100%; border-radius: 0; }
.sv-bubble-tail { position: absolute; left: 50%; bottom: -13px; width: 26px; height: 26px; margin-left: -13px; transform: rotate(45deg); background: #0b0f12; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.sv-bubble-x { position: absolute; top: 8px; right: 8px; z-index: 3; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }
.qm-layout.sv-no-card { grid-template-columns: minmax(0, 1fr); }
.qm-layout.sv-no-card .qm-side .quiz-map { min-height: min(60vh, 560px); }
.sv-bubble-x { top: -12px; right: -12px; border: 2px solid var(--accent); background: #0b0f12; }
.sv-split .feedback-head { flex-wrap: wrap; row-gap: 8px; }
.sv-split .feedback-title { white-space: nowrap; }

/* 写真メモ一覧 */
.pn-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pn-item { display: flex; gap: 12px; text-align: left; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; }
.pn-item:hover { border-color: var(--accent); }
.pn-item img { width: 110px; height: 80px; object-fit: cover; border-radius: 8px; background: #0b0f12; flex: none; }
.pn-body { min-width: 0; flex: 1; }
.pn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pn-note { font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; }
/* 比較表の印刷 */
@media print {
  .print-compare .topbar, .print-compare #demo-banner, .print-compare .banner, .print-compare .cmp-pick, .print-compare .cmp-suggest, .print-compare .bt-popups, .print-compare .chat-panel, .print-compare #toast, .print-compare .chat-btn { display: none !important; }
  .print-compare, .print-compare body, .print-compare #app, .print-compare #view { background: #fff !important; color: #000 !important; overflow: visible !important; height: auto !important; max-width: none !important; }
  .print-compare .compare { color: #000; }
  .print-compare .cmp-scroll { overflow: visible !important; }
  .print-compare table { width: 100%; border-collapse: collapse; }
  .print-compare th, .print-compare td { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; padding: 4px 6px; font-size: 11px; }
  .print-compare details { break-inside: avoid; }
  .print-compare img { max-height: 90px; }
}

/* 対戦: 成績・チーム・ヒント・観戦・パスワード */
.bt-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 8px 0; }
.bt-stats div { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.bt-stats b { font-size: 18px; } .bt-stats span { font-size: 11px; color: var(--muted); }
.bt-hist { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.bt-pass { max-width: 200px; }
.bt-speclabel { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.bt-hint { margin: 6px 0; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, #fab005 18%, var(--surface)); border: 1px solid #fab005; font-size: 14px; font-weight: 600; }
.bt-teams { display: flex; gap: 8px; margin: 6px 0; }
.bt-team { flex: 1; display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.bt-team.lead { border-color: var(--accent); }
.bt-final-note { font-size: 18px; font-weight: 800; text-align: center; margin: 6px 0 10px; }
.bt-spec .bt-choices, .bt-spec .bt-input-row, .bt-spec .qm-side .quiz-map, .bt-spec .qm-guess { pointer-events: none; opacity: .6; }
@media (max-width: 700px) { .bt-stats { grid-template-columns: repeat(3, 1fr); } }

/* ===== スマホ向けの調整（v3） ===== */
@media (max-width: 760px) {
  /* 上のバー: 1 段目にロゴ・検索・ボタン、2 段目にタブ（ボタンが増えても重ならない） */
  .topbar { flex-wrap: wrap !important; padding: 6px 10px; gap: 4px 8px; }
  .brand { order: 0; }
  .mode-box { order: 0; gap: 5px; }
  .mode-pick { max-width: 110px; padding: 3px 8px; }
  .user-area { order: 1; margin-left: auto; }
  .tabs { order: 2; flex: 1 1 100% !important; justify-content: space-between; overflow-x: auto; }
  .tabs a { flex: 1 1 0; justify-content: center; }
  .user-area .icon-btn { width: 34px; height: 34px; }
  /* 対戦: チャットは画面の下に細く置き、内容が隠れないよう下に余白を取る */
  .battle { padding-bottom: 76px; }
  .battle.bt-play { padding-bottom: 0; }
  .bt-chat { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .bt-chat-body { max-height: min(52dvh, 380px); }
  .battle .seg { flex-wrap: wrap; }
  .battle .seg button { flex: 1 1 auto; white-space: nowrap; }
  .bt-settings .setup-row { display: block; }
  .bt-head { flex-wrap: wrap; gap: 6px; }
  .bt-head-actions { flex-wrap: wrap; }
  .bt-pubroom { flex-wrap: wrap; }
  .bt-code, .bt-pass { max-width: none; flex: 1 1 120px; }
  .bt-row { flex-wrap: wrap; }
  /* 対戦の問題画面の上のバー */
  .battle.bt-play .toolbar { flex-wrap: wrap; row-gap: 4px; }
  .bt-results li, .bt-board li { gap: 6px; padding: 6px 8px; }
  .bt-label { display: none; }
  .bt-popups { top: auto; bottom: 70px; right: 8px; left: 8px; width: auto; }
  .chat-panel { inset: 96px 8px auto 8px; }
}

@media (max-width: 760px) {
  /* チャットは、閉じているときは丸いボタンだけにする */
  .bt-chat:not(.open) { left: auto; right: 10px; bottom: 10px; width: auto; border-radius: 999px; }
  .bt-chat:not(.open) .bt-chat-toggle { padding: 10px 14px; background: var(--accent); color: var(--accent-text); border-radius: 999px; }
  .bt-chat:not(.open) .bt-chat-label, .bt-chat:not(.open) .bt-chat-arrow { display: none; }
  .battle, .battle.bt-play { padding-bottom: 64px; }
}

/* スマホ: ストリートビューの問題（地図・ピン）は、映像を画面いっぱいにして、地図は開閉式（開くと下から出る） */
.qm-maptoggle { display: none; }
@media (max-width: 900px), (pointer: coarse) {
  .qm-layout.qm-float:has(.sv-front) { display: block; position: relative; height: calc(100dvh - var(--topbar-h, 110px) - 120px); min-height: 380px; }
  .qm-layout.qm-float:has(.sv-front) > .quiz-card { position: absolute; inset: 0; left: 0 !important; transform: none !important; width: 100% !important; height: 100% !important; min-height: 0 !important; max-height: none !important; margin: 0; }
  .qm-layout.qm-float:has(.sv-front) .qm-side { position: absolute !important; left: 0; right: 0; bottom: 0; top: auto; width: auto !important; height: 54%; z-index: 8; display: none; flex-direction: column; gap: 6px; padding: 8px; background: var(--surface); border-top: 2px solid var(--accent); border-radius: 14px 14px 0 0; pointer-events: auto; }
  .qm-layout.qm-float.map-open:has(.sv-front) .qm-side { display: flex; }
  .qm-layout.qm-float:has(.sv-front) .qm-side .quiz-map { flex: 1; height: auto !important; min-height: 0; opacity: 1; box-shadow: none; }
  .qm-layout.qm-float:has(.sv-front) .qm-side .qm-guess { order: 3; margin: 0; }
  .qm-maptoggle { display: block; position: absolute; right: 10px; bottom: 10px; z-index: 9; padding: 10px 14px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); cursor: pointer; }
  .qm-layout.map-open .qm-maptoggle { bottom: calc(54% + 10px); }
}
@media (max-width: 760px) { .user-area .icon-btn { width: 32px; height: 32px; } }
@media (max-width: 760px) {
  .quiz-setup .seg { flex-wrap: wrap; }
  .quiz-setup .seg button { flex: 1 1 auto; }
  #q-kind button { flex: 1 1 100%; text-align: left; }
}
/* 答えの表示（映像を吹き出しに移したあと）: 地図とフィードバックを縦に並べ、余白ができないように */
.qm-layout.sv-no-card { display: block !important; height: auto !important; min-height: 0 !important; }
.qm-layout.sv-no-card .qm-side { height: auto !important; }
.qm-layout.sv-no-card .qm-side .quiz-map { height: min(60vh, 520px); flex: none; }

/* ---------- AI アシスタント ---------- */
.ai-btn { position: relative; }
.ai-btn.active { color: var(--accent); }
.ai-panel {
  position: fixed; inset: 64px 14px auto auto; margin: 0; z-index: 4000; padding: 0;
  width: min(440px, calc(100vw - 24px)); height: min(680px, calc(100vh - 90px)); height: min(680px, calc(100dvh - 90px));
  display: none; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.ai-panel.open { display: flex; animation: chat-in .2s cubic-bezier(.2, .8, .25, 1.1) both; transform-origin: top right; }
.ai-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); }
.ai-head b { font-size: 15px; }
.ai-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ai-empty { margin: auto 0; text-align: center; line-height: 1.7; padding: 8px 4px; }
.ai-empty p { margin: 4px 0; }
.ai-suggest { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 12px; }
.ai-suggest .chip-btn { text-align: left; white-space: normal; justify-content: flex-start; }
.ai-msg { display: flex; flex-direction: column; max-width: 94%; gap: 4px; }
.ai-user { align-self: flex-end; align-items: flex-end; }
.ai-bot { align-self: flex-start; }
.ai-bubble { padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.ai-user .ai-bubble { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.ai-bot .ai-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-bubble p { margin: 0 0 .55em; }
.ai-bubble > :last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 0 0 .55em; padding-left: 1.4em; }
.ai-bubble li { margin: .15em 0; }
.ai-bubble code { font-size: 12.5px; background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }
.ai-bubble .ai-h { font-weight: 700; margin-top: .4em; }
.ai-error { background: color-mix(in srgb, var(--ng, #e03131) 10%, var(--surface)) !important; border-color: color-mix(in srgb, var(--ng, #e03131) 45%, var(--border)) !important; }
.ai-user-img { max-width: 180px; max-height: 140px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-dot 1.1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
/* 答えの中の [C1] [P2] [国:PL] → 押すとそのカード・写真・国を開く */
.ai-ref {
  display: inline-flex; align-items: center; gap: 3px; margin: 0 2px; padding: 0 8px; min-height: 22px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; vertical-align: baseline;
}
.ai-ref:hover { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.ai-src { font-size: 12px; color: var(--muted); }
.ai-src summary { cursor: pointer; padding: 2px 4px; }
.ai-src-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0 0; }
.ai-pinned, .ai-attach { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-top: 1px solid var(--border); font-size: 13px; }
.ai-pinned[hidden], .ai-attach[hidden] { display: none; }
.ai-pinned span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-attach img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ai-attach span { flex: 1; }
.ai-form { flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); }
.ai-input { flex: 1; min-height: 40px !important; max-height: 140px; resize: none; border-radius: 20px !important; padding: 9px 14px !important; line-height: 1.5; }
.ai-send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); cursor: pointer; display: grid; place-items: center; }
.ai-send:hover { filter: brightness(1.08); }
.ai-stop-icon { display: none; }
.ai-panel.is-busy .ai-send-icon { display: none; }
.ai-panel.is-busy .ai-stop-icon { display: block; }
.ai-foot { flex: none; margin: 0; padding: 0 14px 8px; font-size: 11px; line-height: 1.5; }
@media (max-width: 760px) {
  .ai-panel { inset: 60px 8px auto 8px; width: auto; height: min(82dvh, calc(100dvh - 76px)); }
}
@media print { .ai-panel, .ai-btn { display: none !important; } }

.ai-head .ai-model { flex: 1; min-width: 0; max-width: 210px; margin-left: auto; font-size: 12px; }
.ai-meta { font-size: 11px; color: var(--muted); padding: 0 4px; }

/* ---------- 地図: 都市の検索の候補・目印 ---------- */
.map-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1002; max-height: min(340px, 50vh); overflow-y: auto; padding: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.map-suggest[hidden] { display: none; }
.sug-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sug-row:hover, .sug-row.is-hi { background: var(--accent-soft); }
.sug-row .flag { flex: none; width: 22px; height: 15px; }
.sug-ico { flex: none; width: 22px; text-align: center; }
.sug-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sug-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-main small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-pop { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sug-more { border-top: 1px solid var(--border); border-radius: 0 0 9px 9px; margin-top: 2px; }
.sug-status { padding: 8px 10px; font-size: 12px; color: var(--muted); }
/* 選んだ都市の目印（点と、名前のカード） */
.city-pin { background: none; border: 0; }
.city-dot { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: #e8590c; border: 3px solid #fff; box-shadow: 0 0 0 3px rgba(232, 89, 12, .45), 0 2px 8px rgba(0, 0, 0, .5); }
.city-card {
  position: absolute; left: 14px; top: -16px; display: flex; align-items: center; gap: 7px; white-space: nowrap; padding: 4px 4px 4px 9px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); font-size: 13px;
}
.city-card .flag { width: 18px; height: 12px; }
.city-name { display: flex; flex-direction: column; line-height: 1.25; }
.city-name small { font-size: 10.5px; color: var(--muted); }
.city-x { width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.city-x:hover { background: var(--surface-2); color: var(--text); }

/* 都市の名前: 日本語に続けて、英語・現地の言語（薄い文字） */
.sug-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.sug-title b { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.sug-alt, .city-alt { font-style: normal; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.sug-alt + .sug-alt::before, .city-alt + .city-alt::before { content: '·'; margin-right: 8px; color: var(--muted); }
.city-title { display: flex; align-items: baseline; gap: 7px; }
.city-title b { font-size: 13px; }

/* カードの地名（都市・町） */
.answer-places { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 0; }
.place-link {
  display: inline-flex; align-items: baseline; gap: 7px; padding: 3px 11px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid var(--border);
}
.place-link:hover { border-color: var(--accent); }
.place-link .flag { align-self: center; width: 16px; height: 11px; }
.place-link em, .place-chip em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.place-link em + em::before, .place-chip em + em::before { content: '·'; margin-right: 6px; }
.ed-places { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.place-chip { gap: 6px; align-items: baseline; }
.ed-place-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 280px; overflow-y: auto; }
.pl-hit { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pl-hit:hover { border-color: var(--accent); }
.pl-hit .flag { flex: none; width: 20px; height: 14px; }
.pl-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pl-title { display: flex; align-items: baseline; gap: 8px; }
.pl-title b { font-size: 13.5px; }
.pl-title em { font-style: normal; font-size: 12px; color: var(--muted); }
.pl-main small { font-size: 11px; color: var(--muted); }
.pl-more { color: var(--accent); }

/* ---------- ウィンドウを開く・閉じるアニメーション（アニメーション オフのときは、.no-anim で 0 秒になる） ---------- */
@keyframes win-open { 0% { opacity: 0; transform: scale(.05); } 30% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes win-close { to { opacity: 0; transform: translateY(12px) scale(.95); } }
.modal.is-window.is-closing[open], .sv-panel.is-closing:not([hidden]) { animation: win-close .16s ease-in forwards; pointer-events: none; }

/* ---------- 読み込み中のアニメーション ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes loader-run { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid color-mix(in srgb, var(--accent, #1c7f55) 25%, transparent); border-top-color: var(--accent, #1c7f55); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -4px; }
.page-loading { display: flex; align-items: center; justify-content: center; gap: 10px; }
.map-loading::before { content: ''; width: 16px; height: 16px; margin-right: 8px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; opacity: .6; animation: spin .8s linear infinite; }
.map-loading { grid-auto-flow: column; justify-content: center; align-content: center; }
/* 通信中の進行バー（画面の一番上） */
#top-loader { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 99999; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .25s; }
#top-loader.on { opacity: 1; }
#top-loader i { position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--accent, #1c7f55); border-radius: 0 3px 3px 0; animation: loader-run 1.1s ease-in-out infinite; }
/* 画像: 読み込み中は光る下地（代替テキストは隠す）、読み込めたらふわっと表示 */
img.img-loading {
  color: transparent;
  background: linear-gradient(100deg, color-mix(in srgb, var(--muted, #888) 14%, transparent) 30%, color-mix(in srgb, var(--muted, #888) 32%, transparent) 50%, color-mix(in srgb, var(--muted, #888) 14%, transparent) 70%) 200% 0 / 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
img.img-loaded { animation: fade-in .35s ease-out; }
/* 起動中の表示 */
#boot { position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg, #0e1418); transition: opacity .35s; }
#boot.gone { opacity: 0; pointer-events: none; }
#boot .spinner { width: 26px; height: 26px; }

/* ---------- ストリートビュータブ（保存した場所） ---------- */
.sv-view { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 24px; }
.sv-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sv-hint { margin: 0; }
.sv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.sv-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.sv-item { position: relative; }
.sv-check { position: absolute; top: 10px; right: 10px; z-index: 1; opacity: 0; }
.sv-check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
.sv-item:hover .sv-check, .sv-list:has(.is-selected) .sv-check, .sv-item.is-selected .sv-check { opacity: 1; }
@media (hover: none) { .sv-check { opacity: 1; } }
.sv-item.is-selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.sv-selbar { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.sv-selbar[hidden] { display: none; }
.sv-item-main { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.sv-item-flag img { width: 40px; height: auto; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }
.sv-item-flag { flex: none; min-width: 40px; font-size: 24px; text-align: center; }
.sv-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sv-item-text b { font-size: 15px; }
.sv-item-sep { color: var(--muted); font-weight: 400; }
.sv-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sv-list > .empty { grid-column: 1 / -1; }
.sv-btn.is-saved { color: var(--accent); }
.sv-btn.is-saved svg { fill: currentColor; }
.ed-sv-toggle { align-self: flex-start; margin-top: 6px; }
.ed-sv-picker { margin-top: 6px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.sv-pick { display: flex; flex-direction: column; gap: 2px; }
.sv-pick-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; font: inherit; }
.sv-pick-item:hover { background: var(--surface-2); }
.sv-pick-item .pl-flag img { width: 26px; }

/* 地図の上の、保存したストリートビューの目印 */
.sv-saved-pin span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #1c7ed6; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); cursor: pointer; }
.sv-saved-pin svg { width: 15px; height: 15px; }
.sv-saved-pin:hover span { background: #1971c2; transform: scale(1.12); }

/* 保存したストリートビューの名前の変更・関連カード・カードからの関連ストリートビュー */
.sv-rename { width: 100%; max-width: 280px; font-size: 14px; padding: 4px 8px; }
.sv-item-cards { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sv-card-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
.sv-card-chip:hover { border-color: var(--accent); }
.sv-card-chip img { width: 18px; height: auto; border-radius: 2px; }
.sv-card-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-link-list { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-link { display: inline-flex; align-items: center; gap: 6px; }
.sv-link img { width: 20px; height: auto; border-radius: 2px; }
.sv-link .muted { font-weight: 400; font-size: 12px; }

/* 解説の枠の中の、関連ストリートビュー・関連カード */
.notes .related { max-width: none; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.notes > .related:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.notes .related + .related { margin-top: 12px; }

/* ストリートビューのウィンドウから出るポップアップ（保存した一覧・カードの選択） */
.sv-pop { position: fixed; width: 340px; max-width: calc(100vw - 16px); max-height: min(60vh, 460px); display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 36px rgba(0, 0, 0, .45); animation: pop-in .14s ease-out; }
.sv-pop-q { width: 100%; }
.sv-pop-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.sv-pop-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sv-pop-item[hidden] { display: none; }
.sv-pop-item:hover { background: var(--surface-2); }
.sv-pop-item img.flag, .sv-pop-item > img:not(.sv-pop-thumb) { width: 22px; height: auto; border-radius: 2px; flex: none; }
.sv-pop-thumb { width: 44px; height: 32px; object-fit: cover; border-radius: 5px; flex: none; }
.sv-pop-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sv-pop-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-pop-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-pop-empty { margin: 8px; }

/* カードの選択（関連付け）: 編集画面の関連カードと同じ見た目。ポップアップの幅いっぱいに並べる */
.sv-pop-cards .sv-pop-list { gap: 4px; }
.sv-pop-card { width: 100%; }
.sv-pop-card .related-cat { max-width: 200px; }
/* ストリートビューのウィンドウのヘッダー: ボタンが増えても、題名・座標が折り返さない（座標は入りきらなければ省略） */
.sv-head .sv-title { white-space: nowrap; flex: none; }
.sv-head .sv-coord { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-head .sv-btn { flex: none; }

/* カードの選択（関連付け）: カードタブのタイルを小さくして並べる */
.sv-pop.sv-pop-cards { width: 480px; }
.sv-pop-cards .sv-pop-list.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; padding: 2px; align-content: start; }
.sv-pop-cards .tile { cursor: pointer; }
.sv-pop-cards .tile-body { padding: 6px 8px 8px; gap: 4px; }
.sv-pop-cards .tile .chip { font-size: 11px; padding: 2px 6px; }
.sv-pop-cards .tile-desc { font-size: 12px; -webkit-line-clamp: 1; }
.sv-pop-cards .sv-pop-linked { font-size: 11px; color: var(--accent); }
/* 行が内容の高さを保つように（カードが多いと、行が縮んで縦幅が小さくなっていた） */
.sv-pop-cards .sv-pop-list.tiles { grid-auto-rows: max-content; }
.sv-pop-cards .tile { flex: none; min-height: 150px; }

/* 保存した場所にいるときは、題名にその名前を出す（長ければ省略） */
.sv-head .sv-title { flex: 0 1 auto; min-width: 0; max-width: 60%; }
.sv-head .sv-title #sv-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-panel.is-named .sv-title { color: var(--accent); }
/* 名前を出すときも座標は出す（名前が長ければ名前を省略する） */
.sv-head .sv-title { flex: 1 1 auto; max-width: none; }
.sv-head .sv-coord { flex: 0 1 auto; }
.sv-panel.is-nearby .sv-title { color: var(--text); }
/* ヘッダーのボタンが多いので、間隔と座標の文字を少し小さくして、名前と座標が両方入るように */
.sv-head { gap: 3px; }
.sv-head .sv-btn { width: 28px; }
.sv-head .sv-coord { font-size: 11px; }

/* 保存した場所の削除のポップアップ */
.sv-pop.sv-pop-delete { width: 280px; padding: 12px; gap: 8px; }
.sv-pop-msg { margin: 0; line-height: 1.5; }

/* 「〜 付近」の題名は、押すと保存した場所へ移動できる */
.sv-head .sv-title.is-link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.sv-head .sv-title.is-link:hover { color: var(--accent); }

/* 保存した場所の名前も、押せる題名（保存した位置へ戻る） */
.sv-panel.is-named .sv-title.is-link { text-decoration: underline dotted; }
/* 押せる題名は、文字がある部分だけ（余った幅は座標の欄に回して、題名を文字の幅に収める） */
.sv-head .sv-title { flex: 0 1 auto; max-width: 100%; }
.sv-head .sv-coord { flex: 1 1 0; min-width: 0; }
/* 画面分割中は、ページの左右の余白が 14px なので、カードタブの上部の帯も 14px 分だけはみ出させる（24px のままだと、横にスクロールできてしまう） */
body[data-split] .manage-head { margin: 0 -14px 6px; padding: 12px 14px 2px; }

/* 更新の通知（右上のポップアップ） */
#update-notice { position: fixed; top: 68px; right: 16px; z-index: 99990; width: min(340px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); animation: un-in .35s cubic-bezier(.2, .8, .3, 1); }
#update-notice.is-out { opacity: 0; transform: translateX(24px); transition: opacity .25s, transform .25s; }
@keyframes un-in { from { opacity: 0; transform: translateX(36px); } }
#update-notice .un-head { display: flex; align-items: center; gap: 8px; }
#update-notice .un-head b { flex: 1; font-size: 14px; }
#update-notice .un-x { background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
#update-notice .un-x:hover { background: var(--surface-2); color: var(--text); }
#update-notice .un-ver { margin: 6px 0 0; font-weight: 700; color: var(--accent); font-size: 13px; }
#update-notice .un-list { margin: 8px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.6; color: var(--text); }
#update-notice .un-foot { display: flex; justify-content: flex-end; margin-top: 10px; }

.sv-pop-field { display: flex; flex-direction: column; gap: 4px; }
.sv-pop-delete .sv-pop-name { width: 100%; }

/* 閉じるまでの残り時間のバー（通知の下端。左へ縮む） */
#update-notice { overflow: hidden; }
#update-notice .un-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--accent) 18%, transparent); }
#update-notice .un-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left center; }

/* 関連付け済みのカードは薄暗く（もう一度押すと解除） */
.sv-pop-cards .tile.is-linked { opacity: .45; filter: saturate(.6); }
.sv-pop-cards .tile.is-linked:hover { opacity: .75; }

/* カードのプレビュー（関連カードなどにポインターを合わせたとき。PC のみ） */
#card-preview { position: fixed; z-index: 99980; width: 260px; border-radius: 12px; overflow: hidden; pointer-events: none; background: color-mix(in srgb, var(--cat, transparent) 10%, var(--surface)); border: 1px solid var(--border); border-top: 4px solid var(--cat, var(--border)); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); animation: pop-in .14s ease-out; }
#card-preview .cp-img { position: relative; aspect-ratio: 4 / 3; background: #0b0f12; }
#card-preview .cp-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#card-preview .cp-img .cat-on-img { top: 6px; left: 6px; font-size: 11px; padding: 2px 8px; }
#card-preview .cp-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 5px; }
#card-preview .cp-countries { display: flex; flex-wrap: wrap; gap: 4px; }
#card-preview .cp-desc { margin: 0; font-size: 13px; font-weight: 700; }
#card-preview .cp-notes { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- ウィンドウをしまう場所（左下の角）---------- */
.modal.is-docked, .sv-panel.is-docked { display: none !important; }
.snap-preview.is-dock { border-radius: 0 28px 0 0; border-left: 0; border-bottom: 0; display: grid; place-items: center; font-size: 34px; }
.snap-preview.is-dock::after { content: '🗂'; }
#win-dock { position: fixed; left: 0; bottom: 0; width: 100vw; height: 0; z-index: 99000; pointer-events: none; }
#win-dock .dock-hot { position: fixed; left: 0; bottom: 0; width: 88px; height: 88px; pointer-events: auto; }
#win-dock .dock-stack { position: fixed; left: 10px; bottom: 10px; width: 54px; height: 66px; pointer-events: auto; cursor: pointer; }
#win-dock .dock-stack[hidden] { display: none; }
.dock-mini { position: absolute; left: 0; bottom: 0; width: 44px; height: 58px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0, 0, 0, .4); display: grid; place-items: center; font-size: 20px; transform-origin: bottom left; }
.dock-mini.m3 { transform: rotate(-14deg); opacity: .6; }
.dock-mini.m2 { transform: rotate(-7deg); opacity: .85; }
.dock-mini.m1 { background: var(--surface); border-color: var(--accent); }
.dock-count { position: absolute; right: 0; top: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
#win-dock .dock-fan { position: fixed; left: 0; bottom: 0; width: 100vw; height: 230px; pointer-events: none; }
.dock-card { position: absolute; left: var(--x, 24px); bottom: 0; width: 150px; height: 198px; border-radius: 12px; overflow: hidden; background: color-mix(in srgb, var(--cat, transparent) 12%, var(--surface)); border: 1px solid var(--border); border-top: 4px solid var(--cat, var(--accent)); box-shadow: 0 10px 28px rgba(0, 0, 0, .5); cursor: pointer; pointer-events: none; transform-origin: 50% 140%; transform: translateY(120%) rotate(0deg); opacity: 0; transition: transform .32s cubic-bezier(.2, .8, .3, 1), opacity .2s; transition-delay: calc(var(--i, 0) * 25ms); }
#win-dock.is-open .dock-card { pointer-events: auto; opacity: 1; transform: translateY(18px) rotate(var(--rot, 0deg)); }
#win-dock.is-open .dock-card:hover { transform: translateY(-8px) rotate(0deg); z-index: 999 !important; transition-delay: 0s; }
.dock-thumb { height: 128px; background: #0b0f12; display: grid; place-items: center; overflow: hidden; }
.dock-thumb img { width: 100%; height: 100%; object-fit: contain; }
.dock-emoji { font-size: 44px; }
.dock-label { padding: 7px 9px; font-size: 12px; line-height: 1.4; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dock-x { position: absolute; right: 4px; top: 4px; z-index: 2; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; cursor: pointer; opacity: 0; }
.dock-card:hover .dock-x { opacity: 1; }

/* しまったウィンドウは、ドラッグして取り出す */
.dock-card { cursor: grab; touch-action: none; }
.dock-ghost { position: fixed !important; left: 0; top: 0; bottom: auto !important; width: 150px; height: 198px; z-index: 99995 !important; pointer-events: none; opacity: 1 !important; transform: rotate(-3deg) scale(1.04) !important; cursor: grabbing; box-shadow: 0 18px 44px rgba(0, 0, 0, .6); }
#win-dock.is-dragging { cursor: grabbing; }
#win-dock img, .dock-ghost img { -webkit-user-drag: none; user-select: none; }

/* ---------- 国の情報: 国名の右の「地図で表示」ボタン（アイコンのみ） ---------- */
.cinfo-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cinfo-title-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cinfo-map-btn { flex: none; width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px; color: var(--muted); }
.cinfo-map-btn:hover { color: var(--accent); background: var(--accent-soft); }

/* ---------- Plonkit のガイド（日本語に翻訳。画像ごとに、右に説明） ---------- */
.modal-plonkit .modal-head .pk-title { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.modal-plonkit .modal-head .pk-title .muted { font-weight: 400; }
.pk-toc-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.modal-plonkit .modal-head .icon-btn { text-decoration: none; display: inline-grid; place-items: center; }
.pk-toc { position: absolute; right: 12px; top: calc(100% - 4px); z-index: 6; width: min(300px, calc(100% - 24px)); max-height: min(60vh, 440px); overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.pk-toc[hidden] { display: none; }
.pk-toc-item { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.pk-toc-item.lv1 { font-weight: 700; margin-top: 4px; }
.pk-toc-item.lv2 { padding-left: 22px; color: var(--muted); font-size: 13px; }
.pk-toc-item:hover { background: var(--surface-2); color: var(--accent); }
.pk-body { container-type: inline-size; }
.pk-state { padding: 28px 8px; text-align: center; }
.pk-note { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-text); font-size: 13px; }
.pk-hero img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 14px; }
.pk-step { margin-bottom: 26px; scroll-margin-top: 70px; }
.pk-step-title { font-size: 20px; margin: 4px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); scroll-margin-top: 70px; }
.pk-div { font-size: 16px; margin: 22px 0 10px; color: var(--accent); scroll-margin-top: 70px; }
.pk-tip { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pk-tip:last-child { border-bottom: 0; }
.pk-img { position: relative; flex: 0 0 var(--w, 40%); max-width: var(--w, 40%); margin: 0; }
.pk-img img, .pk-wide img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); background: var(--surface-2); }
.pk-img img.pk-sv, .pk-img img.pk-zoom { cursor: pointer; }
.pk-img img.pk-sv:hover { outline: 3px solid var(--accent); outline-offset: -3px; }
.pk-badge { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; pointer-events: none; }
.pk-wide { margin: 8px 0; }
.pk-text { flex: 1; min-width: 0; line-height: 1.7; font-size: 14.5px; }
.pk-text p { margin: 0 0 8px; }
.pk-callout { background: #fff4c2; border: 1.5px solid #f2b705; border-radius: 8px; padding: 8px 12px; color: #4a3800; }
p.pk-callout { margin: 8px 0; }
ul .pk-callout { list-style-position: inside; }
:root[data-theme="dark"] .pk-callout { background: #3b3210; border-color: #b48a00; color: #ffe9a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pk-callout { background: #3b3210; border-color: #b48a00; color: #ffe9a3; } }
.pk-text ul { margin: 0 0 8px; padding-left: 20px; }
.pk-text li { margin-bottom: 4px; }
.pk-text a { color: var(--accent); }
.pk-sv-link { white-space: nowrap; }
.pk-tip.is-text .pk-text { max-width: 70ch; }
.pk-img.is-zoom { position: fixed; inset: 0; z-index: 9999; max-width: none; flex: none; display: grid; place-items: center; background: rgba(0, 0, 0, .85); padding: 16px; cursor: zoom-out; }
.pk-img.is-zoom img { width: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.pk-img.is-zoom .pk-badge { display: none; }
.pk-credit { margin-top: 20px; }
@container (max-width: 520px) {
  .pk-tip { flex-direction: column; }
  .pk-img { flex: none; max-width: 100%; width: 100%; }
}

/* ---------- AI・メモを、ウィンドウの中に入れたとき ---------- */
.modal-panelwin.is-window .modal-inner { display: flex; flex-direction: column; overflow: hidden; padding: 0 24px 0; }
.modal-panelwin.is-window .modal-inner > .modal-head:first-child { flex: none; top: 0; margin-bottom: 0; }
.pw-host { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 -24px; }
.chat-panel.is-embedded, .ai-panel.is-embedded { position: static; inset: auto; width: auto; height: auto; flex: 1; min-height: 0; z-index: auto; border: 0; border-radius: 0; box-shadow: none; animation: none; display: flex; }
.chat-panel.is-embedded .chat-head > b, .ai-panel.is-embedded .ai-head > b, .is-embedded .chat-close, .is-embedded .ai-close, .is-embedded .chat-pop, .is-embedded .ai-pop { display: none; }
.chat-panel.is-embedded .chat-head { justify-content: flex-end; }
.chat-panel.is-embedded .chat-count { margin-right: auto; }
@media not all and (min-width: 900px) and (pointer: fine) { .chat-pop, .ai-pop { display: none; } }

/* スマホで、ストリートビューを最前面の層（popover）に出すときの、ブラウザ既定の配置を打ち消す */
.sv-panel[popover] { margin: 0; padding: 0; color: var(--text); overflow: hidden; }

/* ---------- ナンバープレートのカードの画像を、全体ぼかす（設定） ---------- */
.plate-blur-on img[data-plate] { filter: blur(var(--plate-blur, 16px)); }

/* Plonkit の画像: 読み込み中・失敗しても、高さを保って、仕切りの線やバッジと重ならないようにする */
.pk-pic { min-height: 110px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.pk-pic.is-loaded { min-height: 0; background: none; overflow: visible; }
.pk-pic img:not([src]) { visibility: hidden; }
.pk-pic:not(.is-loaded):not(.is-failed) { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%) 0 0 / 200% 100%; animation: pk-shimmer 1.4s linear infinite; }
@keyframes pk-shimmer { to { background-position: -200% 0; } }
.pk-pic.is-failed { display: grid; place-items: center; cursor: pointer; min-height: 110px; }
.pk-pic.is-failed img { display: none; }
.pk-pic.is-failed::after { content: '画像を読み込めませんでした（押すと再試行）'; padding: 12px; text-align: center; font-size: 12px; color: var(--muted); }
.pk-pic:not(.is-loaded) .pk-badge { display: none; }
.pk-tip { padding: 14px 0; }

/* Plonkit の画像から、カードを作るボタン（編集者のみ。画像にポインターを乗せると出る） */
.pk-pic { position: relative; }
.pk-add { position: absolute; top: 6px; right: 6px; z-index: 2; padding: 3px 10px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; cursor: pointer; opacity: 0; transition: opacity .15s; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.pk-pic:hover .pk-add, .pk-add:focus-visible { opacity: 1; }
.pk-pic:not(.is-loaded) .pk-add { display: none; }
@media (hover: none) { .pk-add { opacity: .92; } }

/* 検索: 国の候補（カードの上に 1 つ。小さく横長に 1 行） */
.tile.tile-country { flex-direction: row; display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 5px 12px; min-height: 0; height: auto; border: 1px solid var(--border); border-top-width: 1px; border-left: 3px solid var(--accent); border-radius: 999px; background: var(--surface); cursor: pointer; outline: none; width: fit-content; max-width: 100%; }
.tile.tile-country:hover, .tile.tile-country:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); transform: none; }
.tile-country-flag { width: 28px; height: 19px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); flex: none; }
.tile-country-body { display: flex; flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
.tile-country-body b { font-size: 14px; }
.tile-country-body .muted { overflow: hidden; text-overflow: ellipsis; }
.tile-country-hint { color: var(--accent); }
.tile-country-hint::before { content: '→ '; }

.tile.tile-country { border-top: 1px solid var(--border); }
.tile.tile-country:hover, .tile.tile-country:focus-visible { border-top-color: var(--accent); }

/* 設定: ナンバープレートのぼかしの強さ */
.blur-range { display: flex; align-items: center; gap: 12px; width: 100%; }
.blur-range input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.blur-range output { min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.blur-sample { padding: 2px 10px; border-radius: 4px; background: #f2f2f2; color: #111; font: 700 16px/1.4 monospace; letter-spacing: .08em; filter: blur(var(--plate-blur, 16px)); overflow: hidden; }

/* ストリートビューのウィンドウ: 場所を選ぶ小さい地図 */
.sv-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.sv-minimap { position: absolute; left: 8px; bottom: 34px; z-index: 5; width: min(360px, calc(100% - 16px)); height: min(280px, calc(100% - 80px)); border: 2px solid var(--surface); border-radius: 10px; overflow: hidden; box-shadow: 0 6px 24px rgba(0, 0, 0, .55); background: #0b0f12; }
.sv-minimap[hidden] { display: none; }
.sv-minimap-map { position: absolute; inset: 0; cursor: crosshair; }
.sv-minimap-map .leaflet-container, .sv-minimap-map.leaflet-container { cursor: crosshair; }
.sv-minimap-close { position: absolute; top: 4px; right: 4px; z-index: 1000; width: 26px; height: 26px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 50%; }
.sv-minimap-tip { position: absolute; left: 6px; bottom: 6px; z-index: 1000; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; pointer-events: none; }
.sv-panel.is-min .sv-minimap { display: none; }

.sv-minimap-pop .leaflet-popup-content { margin: 8px 12px; font-size: 12px; font-weight: 700; color: #b02a2a; white-space: nowrap; }

/* ---------- Windows 版: 外に出したウィンドウ（?popout=…）。中身のウィンドウを、Windows のウィンドウいっぱいに表示する ---------- */
.is-popout .topbar, .is-popout #demo-banner, .is-popout:not(.is-tabwin) #view, .is-popout .banner, .is-popout .chat-btn, .is-popout .ai-btn, .is-popout #dock-root { display: none !important; }
.is-popout body, .is-popout { overflow: hidden; }
.is-popout dialog.modal.is-window[open] { position: fixed !important; inset: 0 !important; left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; max-height: none !important; margin: 0 !important; resize: none; transform: none !important; box-shadow: none !important; }
.is-popout #win-min, .is-popout #win-max, .is-popout #win-pop, .is-popout #sv-pop, .is-popout #sv-min, .is-popout #sv-max { display: none !important; }
.is-popout .modal.is-window .modal-inner > .modal-head:first-child { cursor: default; }
.is-popout .sv-panel { position: fixed !important; inset: 0 !important; left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; max-width: none; max-height: none; resize: none; box-shadow: none !important; }
.is-popout .sv-head { cursor: default; }

/* 外に出したウィンドウ: 枠がないので、見出しを、ドラッグで動かせる・ダブルクリックで最大化できるタイトルバーにする */
.is-popout dialog.modal.is-window[open] { background: var(--surface) !important; } /* 中身は、いつも不透明に */
.is-popout, .is-popout body { background: transparent !important; } /* ウィンドウの外側は透明（アプリ内のウィンドウの形・角の丸みのまま） */
.is-popout.is-popout-max dialog.modal.is-window[open], .is-popout.is-popout-max .sv-panel { border-radius: 0; }
#po-resize { position: fixed; inset: 0; z-index: 99999; pointer-events: none; }
.po-grip { position: absolute; pointer-events: auto; -webkit-app-region: no-drag; }
.is-popout-max #po-resize { display: none; }
.is-popout .modal.is-window .modal-inner > .modal-head:first-child, .is-popout .sv-head { -webkit-app-region: drag; }
.is-popout .modal-head button, .is-popout .modal-head a, .is-popout .modal-head input, .is-popout .modal-head select, .is-popout .sv-head button, .is-popout .sv-head a, .is-popout .sv-title.is-link { -webkit-app-region: no-drag; }
.is-popout .win-btn.is-on, .is-popout .sv-btn.is-on { background: var(--accent-soft); color: var(--accent); }

/* 設定: Windows 版の全体のショートカット */
.set-keys { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.set-key-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-key-row > span:first-child { flex: 1 1 220px; min-width: 0; font-size: 14px; }
.key-btn { min-width: 150px; font-family: 'Cascadia Mono', Consolas, monospace; }
.key-btn.is-listening { outline: 2px solid var(--accent); background: var(--accent-soft); }
.key-btn.is-bad { border-color: var(--ng); }
.key-warn { color: var(--ng); flex-basis: 100%; }

/* 検索のウィンドウ（ショートカットで、外に出たウィンドウとして開く）: 検索パネルを、ウィンドウいっぱいに */
.is-search #spotlight[open] { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border-radius: 14px; }
.is-search #spotlight::backdrop { background: transparent; backdrop-filter: none; }
.is-search .spot-bar { -webkit-app-region: drag; }
.is-search .spot-bar input, .is-search .spot-bar button, .is-search .spot-field { -webkit-app-region: no-drag; }

/* ストリートビュー: 外に出したウィンドウで、リンクから開いたときの「← 戻る」 */
.sv-back { flex: none; margin-right: 6px; white-space: nowrap; -webkit-app-region: no-drag; }
.sv-back[hidden] { display: none; }

/* 検索の「!」コマンド */
.cmd-ghost .cmd-hint { opacity: .5; }
.cmd-panel { display: flex; flex-direction: column; gap: 8px; }
.cmd-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.cmd-item { display: flex; align-items: baseline; gap: 10px; text-align: left; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.cmd-item b { font-weight: 600; white-space: nowrap; }
.cmd-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item:hover, .cmd-item.on { background: var(--accent-soft); }
.cmd-err { margin: 0; color: var(--ng); font-weight: 600; }
.cmd-out { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.cmd-out.is-err { border-color: var(--ng); background: var(--ng-soft); }
.cmd-out p { margin: 0; }
.cmd-help-row { display: flex; gap: 12px; align-items: baseline; padding: 4px 0; flex-wrap: wrap; }
.cmd-help-row code { font-family: 'Cascadia Mono', Consolas, monospace; color: var(--accent); white-space: nowrap; }
.cmd-help-sub { padding: 2px 0 2px 14px; font-size: 13px; }
.cmd-none { margin: 4px 2px; }
.cmd-foot { margin: 0; }

/* ストリートビューの見出し: 座標が隠れているときも、ボタンを右に寄せる */
.sv-spacer { flex: 1 1 0; min-width: 0; align-self: stretch; }

/* 外に出したタブ（地図・比較など）: 上のバー（移動・操作）と、その下のタブの画面。ウィンドウの角は丸く、背景は透明 */
.is-tabwin #app { position: fixed; inset: 0; border-radius: 14px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); display: flex; flex-direction: column; }
.is-tabwin.is-popout-max #app { border-radius: 0; }
.is-tabwin { --topbar-h: 40px !important; }
#po-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 3000; height: 38px; display: flex; align-items: center; gap: 2px; padding: 0 6px 0 14px; background: var(--surface); border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; -webkit-app-region: drag; user-select: none; }
.is-popout-max #po-bar { border-radius: 0; }
#po-bar .po-title { font-weight: 700; font-size: 14px; }
#po-bar .po-sp { flex: 1; }
#po-bar .icon-btn { -webkit-app-region: no-drag; width: 30px; height: 30px; }
#po-bar .icon-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.is-tabwin #view { margin-top: 38px; flex: 1; min-height: 0; overflow: auto; }
.is-tabwin #app.app-fit { height: 100%; }

/* Plonkit の AI のカード提案 */
.pk-ai-btn:disabled { opacity: .4; }
.modal-aicards { width: min(820px, calc(100vw - 16px)); }
.aic-state { display: flex; align-items: center; gap: 10px; padding: 18px 4px; }
.aic-err { color: var(--ng); font-weight: 600; padding: 12px 4px; }
.aic-note { margin: 0 0 8px; }
.aic-list { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.aic-card { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.aic-card.is-done { opacity: .5; border-color: var(--accent); }
.aic-card.is-ng { border-color: var(--ng); }
.aic-check { padding-top: 4px; }
.aic-img { width: 150px; max-height: 110px; object-fit: contain; background: #0b0f12; border-radius: 6px; flex: none; }
.aic-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.aic-fields .input { width: 100%; box-sizing: border-box; }
.aic-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.aic-row .aic-area { flex: 1; min-width: 120px; width: auto; }
.aic-foot { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.aic-foot .grow { flex: 1; }
@media (max-width: 640px) { .aic-card { flex-wrap: wrap; } .aic-img { width: 100%; } }

.aic-model-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }

.aic-svrow { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); }

.aic-imgbox { display: flex; flex-direction: column; gap: 4px; flex: none; width: 150px; }
.aic-imgbox .aic-img { width: 100%; }
.aic-imgedit { align-self: stretch; }
@media (max-width: 640px) { .aic-imgbox { width: 100%; } }

.aic-auto { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }
.aic-imgbox { gap: 4px; }

.aic-also { display: flex; flex-direction: column; gap: 2px; }

.aic-score { color: var(--muted); }
.aic-score b { color: #e0a800; letter-spacing: 1px; }
.aic-hidden { margin: 0 0 4px; }
.aic-hidden:empty { display: none; }

/* 地図を一括で消す */
.bmr-opts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.bmr-list { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; }
.bmr-row { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.bmr-row.is-done { opacity: .5; border-color: var(--accent); }
.bmr-thumb { position: relative; flex: none; display: inline-block; line-height: 0; }
.bmr-thumb img { height: 96px; max-width: 200px; object-fit: contain; display: block; background: #0b0f12; }
.bmr-box { position: absolute; box-sizing: border-box; border: 2px solid #ff3b30; background: rgba(255, 59, 48, .18); }
.bmr-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bt-voicebar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
/* 国を選ぶポップアップ（js/countrypick.js） */
.cp-dialog { width: min(760px, calc(100vw - 24px)); }
.cp-inner { display: flex; flex-direction: column; gap: 10px; }
.cp-inner .modal-head { margin-bottom: 0; }
.cp-map { height: min(52vh, 420px); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.cp-chips { min-height: 28px; }
.cp-inner .modal-foot { margin-top: 4px; }

.tile-scope { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 4px; }
.scope-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.scope-tag.is-region { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ed-scope-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
/* 国モードの地図（js/regionmap.js） */
.rm-bar { gap: 10px; }
.rm-countries { display: flex; flex-wrap: wrap; gap: 4px; }
.rm-modes { display: inline-flex; align-items: center; gap: 6px; }
.rm-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; }
.rm-map { height: min(68vh, 640px); min-height: 360px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.rm-side { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); max-height: min(68vh, 640px); overflow-y: auto; }
.rm-title { display: flex; align-items: center; gap: 6px; font-size: 17px; margin: 0 0 2px; }
.rm-fact { padding: 8px 0; border-top: 1px solid var(--border); }
.rm-fact-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.rm-cards { padding-top: 8px; border-top: 1px solid var(--border); }
.rm-card { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 4px; margin: 3px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: inherit; font: inherit; cursor: pointer; }
.rm-card img { width: 52px; height: 36px; object-fit: cover; border-radius: 4px; flex: none; }
.rm-legend { margin-top: 10px; }
.rm-legend .map-legend { position: static; display: block; max-width: 420px; }
@media (max-width: 760px) { .rm-body { grid-template-columns: 1fr; } .rm-map { height: 50vh; min-height: 280px; } .rm-side { max-height: none; } }

/* 国・地域をクリックしたときの四角い枠（フォーカスの枠）を出さない */
.cp-map .leaflet-interactive, .rm-map .leaflet-interactive, .cp-map path, .rm-map path { outline: none !important; }
.cp-map.leaflet-container { background: #aad3df; }
.cp-map.map-dark.leaflet-container { background: #1d2c33; }
.cp-map .leaflet-tooltip, .rm-map .leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--border); }
.map-dark .leaflet-control-zoom a { background: #2b3640; color: #e6edf2; border-color: #46535d; }

/* 国モードの地図: 世界モードと同じ並び（左に地図、右にパネル） */
.rm-layout { min-height: 460px; }
.rm-box { height: 100%; }
.rm-layout .rm-map { position: absolute; inset: 0; height: auto; min-height: 0; border: 0; border-radius: 0; }
.rm-layout .map-top { z-index: 1050; }
.rm-layout .rm-legend { position: absolute; left: 10px; bottom: 28px; z-index: 900; margin: 0; }
.rm-info { padding: 12px 14px; }
.rm-flagbox { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 8px 0; }
.rm-flagbox img { max-width: 100%; max-height: 120px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.rm-flag-icon { background: none !important; border: 0 !important; }
.rm-flag-icon img { display: block; height: auto; border: 1px solid rgba(0, 0, 0, .45); border-radius: 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); cursor: pointer; background: #fff; }
.rm-flag-s { height: 14px; width: auto; border: 1px solid rgba(0, 0, 0, .3); border-radius: 2px; }

.rm-plates { padding: 8px 0; border-top: 1px solid var(--border); }
.rm-plates.is-none .rm-plate-list { opacity: .8; }
.rm-plate-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rm-plate-list.muted { display: block; }
.rm-plate { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.rm-plate img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.rm-flagbox img { max-height: 84px; }

/* 国モードの地図: サムネイルのまとまりの真ん中を、地域の中心に置く */
.map-thumbs.rm-c { transform-origin: 50% 50%; }
.scope-where { background: var(--surface); color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.scope-where:empty { display: none; }

/* 旗・ナンバープレートをまとめてカードにする: 作る画像の一覧 */
.bc-dialog { width: min(960px, calc(100vw - 24px)); }
.bc-review { margin-top: 12px; }
.bc-review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.bc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; max-height: min(52vh, 460px); overflow-y: auto; padding: 2px; }
.bc-tile { position: relative; margin: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.bc-tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #0b0f12; }
.bc-tile figcaption { padding: 4px 6px; font-size: 12px; font-weight: 700; line-height: 1.3; }
.bc-tile figcaption small { display: block; font-weight: 400; color: var(--muted); }
.bc-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.bc-x:hover { background: #e03131; }

/* 「国の地域」のカードの裏面: 地名を大きく、国名を小さく */
.answer-place { font-size: inherit; }
.answer-sub { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 2px 0 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
.answer-sub-country { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 0; color: inherit; font: inherit; }
button.answer-sub-country { cursor: pointer; text-decoration: underline dotted; }
.answer-sub-country .flag { width: 18px; height: auto; }

/* ===== ガイド（ユーザーが書く記事） ===== */
.gd-view { max-width: 920px; margin: 0 auto; }
.gd-toolbar { gap: 8px; }
.gd-hint { margin: 0 0 10px; }
.gd-warn { margin: 6px 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn-text); font-size: 13px; }
.gd-selbar { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.gd-selbar[hidden] { display: none; }
.gd-list { display: flex; flex-direction: column; gap: 10px; }
.gd-folder { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.gd-folder-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; background: var(--surface-2); }
.gd-fold-toggle, .gd-fold-static { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.gd-fold-static { cursor: default; }
.gd-caret { display: inline-block; transition: transform .15s; color: var(--muted); }
.gd-folder.is-open .gd-caret { transform: rotate(90deg); }
.fold-ico { font-size: 20px; line-height: 1; }
.fold-ico-img, .fold-ico-img img { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; }
.gd-folder-body { display: flex; flex-direction: column; }
.gd-row { display: flex; align-items: center; gap: 6px; padding: 2px 8px 2px 4px; border-top: 1px solid var(--border); }
.gd-row:hover { background: var(--surface-2); }
.gd-row.is-selected { background: var(--accent-soft); }
.gd-check { display: grid; place-items: center; width: 34px; flex: none; }
.gd-check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.gd-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 9px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.gd-row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-row-snip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-empty { padding: 10px 14px; margin: 0; }
.gd-loose .gd-folder-body .gd-row:first-child { border-top: 0; }
/* 編集 */
.modal-guide-ed { width: min(1200px, calc(100vw - 24px)); }
.gd-ed { display: flex; flex-direction: column; gap: 10px; }
.gd-ed-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gd-title { flex: 1; min-width: 200px; font-size: 18px; font-weight: 700; }
.gd-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.gd-tools button { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.gd-tools button:hover { border-color: var(--accent); }
.gd-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.gd-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 340px; }
.gd-body { min-height: 340px; height: min(56vh, 520px); resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.6; }
.gd-preview { height: min(56vh, 520px); overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; background: var(--surface); }
@media (max-width: 900px) { .gd-split { grid-template-columns: 1fr; } .gd-preview { height: 280px; } }
.gd-rel .related-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.art-rel-item { display: inline-flex; align-items: center; gap: 4px; }
/* 選ぶ画面 */
.gd-pick { width: min(520px, calc(100vw - 24px)); }
.gd-pick-q { width: 100%; margin-bottom: 8px; }
.gd-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 56vh; overflow-y: auto; }
.gd-pick-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.gd-pick-row:hover { border-color: var(--accent); }
.gd-pick-thumb { width: 52px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 5px; overflow: hidden; background: var(--surface); }
.gd-pick-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gd-pick-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* フォルダの編集 */
.fd-icon-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fd-now { width: 40px; height: 40px; display: grid; place-items: center; font-size: 26px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.fd-now .fold-ico-img, .fd-now img { width: 32px; height: 32px; }
.fd-icon-row .input { width: 130px; }
.fd-emojis { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; max-height: 150px; overflow-y: auto; }
.fd-emojis button { height: 36px; font-size: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.fd-emojis button:hover { border-color: var(--accent); }
/* 記事の本文（読む・プレビュー） */
.art-content, .gd-preview { line-height: 1.8; font-size: 15px; overflow-wrap: anywhere; }
.art-title { font-size: 26px; margin: 4px 0 2px; }
.art-date { margin: 0 0 14px; }
.art-content h2, .gd-preview h2 { font-size: 22px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.art-content h3, .gd-preview h3 { font-size: 18px; margin: 20px 0 8px; }
.art-content h4, .gd-preview h4 { font-size: 16px; margin: 16px 0 6px; }
.art-content h5, .gd-preview h5 { font-size: 15px; margin: 14px 0 6px; color: var(--muted); }
.art-content p, .gd-preview p { margin: 0 0 12px; }
.art-content ul, .art-content ol, .gd-preview ul, .gd-preview ol { margin: 0 0 12px; padding-left: 24px; }
.art-content li, .gd-preview li { margin-bottom: 3px; }
.art-content blockquote, .gd-preview blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--muted); }
.art-content code, .gd-preview code { padding: 1px 6px; border-radius: 5px; background: var(--surface-2); font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.art-content pre, .gd-preview pre { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; }
.art-content pre code, .gd-preview pre code { padding: 0; background: none; }
.art-content hr, .gd-preview hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.art-content a, .gd-preview a { color: var(--accent); }
.art-table { overflow-x: auto; margin: 0 0 12px; }
.art-table table { border-collapse: collapse; min-width: 50%; }
.art-table th, .art-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.art-table th { background: var(--surface-2); }
.art-fig { margin: 0 0 14px; }
.art-fig figcaption { margin-top: 4px; font-size: 13px; color: var(--muted); text-align: center; }
.art-zoom { display: block; position: relative; overflow: hidden; border-radius: 10px; background: #0b0f12; margin: 4px 0; max-width: 100%; }
.art-zoom img { position: static !important; width: 100%; height: auto; max-height: 78vh; object-fit: contain; display: block; }
p .art-zoom, li .art-zoom { display: inline-block; max-width: min(100%, 420px); vertical-align: middle; }
.art-img-missing { color: var(--muted); font-size: 13px; }
.art-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.art-content p .related-item, .gd-preview p .related-item, .art-content p .sv-link { vertical-align: middle; margin: 2px 4px 2px 0; }
.art-link-gone { color: var(--muted); font-size: 13px; }
.art-chip-ico { display: grid; place-items: center; font-size: 20px; background: var(--surface-2); }
.art-chip-ico .fold-ico-img, .art-chip-ico img { width: 28px; height: 28px; }
.art-related, .art-backlinks { margin-top: 18px; }

/* 書く画面の「入力欄だけ」: 枠の中で、タイトル・ツールバー・プレビュー・関連記事を隠して、入力欄を広く */
.modal-guide-ed.gd-focus .gd-ed-top, .modal-guide-ed.gd-focus .gd-tools, .modal-guide-ed.gd-focus .gd-preview, .modal-guide-ed.gd-focus .gd-rel { display: none; }
.modal-guide-ed.gd-focus .gd-split { grid-template-columns: 1fr; flex: 1; min-height: 0; }
.modal-guide-ed.gd-focus .gd-ed { flex: 1; min-height: 0; }
.modal-guide-ed.gd-focus .gd-body { height: 100%; min-height: 0; resize: none; }
.modal-guide-ed .modal-head .icon-btn { display: inline-grid; place-items: center; }
/* 編集画面は、ウィンドウの中では、枠いっぱいに */
.modal.is-window.modal-guide-ed .modal-inner { display: flex; flex-direction: column; }
.modal.is-window.modal-guide-ed .gd-ed { flex: 1; min-height: 0; overflow-y: auto; }
/* 書く欄とプレビューは、枠の大きさに合わせて、それぞれ、枠の中でスクロールする */
.modal.is-window.modal-guide-ed .gd-split { flex: 1 1 auto; min-height: 260px; grid-template-rows: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
@media (max-width: 900px) { .modal.is-window.modal-guide-ed .gd-split { min-height: 440px; } }
.modal.is-window.modal-guide-ed .gd-body, .modal.is-window.modal-guide-ed .gd-preview { height: 100%; min-height: 0; max-height: none; overflow-y: auto; resize: none; }
/* 文章の途中に入れたカード・ストリートビューは、行に収まるように、小さく（行だけに置いたときは、これまでどおりの大きさ） */
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .related-item {
  display: inline-flex; gap: 4px; padding: 0 8px 0 3px; margin: 0 2px; line-height: 1.5; font-size: inherit; border-radius: 6px; vertical-align: baseline; max-width: 100%;
}
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .related-item .related-thumb { width: 22px; height: 16px; border-radius: 3px; }
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .related-item .related-text { flex-direction: row; align-items: center; gap: 6px; }
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .related-item .related-cat { display: none; }
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .related-item .related-country { font-size: 0.92em; }
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .sv-link { padding: 0 8px; min-height: 0; line-height: 1.5; font-size: 0.92em; margin: 0 2px; vertical-align: baseline; }
:is(.art-content, .gd-preview) :is(p, li, td, th, h1, h2, h3, h4) .sv-link .muted { display: none; }
.modal.is-window.modal-guide-ed .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; z-index: 2; } /* 保存ボタンは、下に固定 */
/* 記事の画像の大きさ（「![説明|50%](…)」）とその選び方 */
.art-fig .art-zoom[style] { display: block; margin-left: auto; margin-right: auto; }
.gd-preview [data-art-img] { cursor: pointer; }
.modal-guide-ed { position: relative; }
.gd-sizepop { position: absolute; z-index: 20; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); max-width: 420px; }
.gd-sizepop input { width: 72px; }
.gd-pick-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.gd-pick-filters select { flex: 1 1 140px; min-width: 0; }
.gd-pick-count { margin-bottom: 4px; }
/* AI で記事を書く */
.gd-ai-btn { font-weight: 700; }
.gd-ai { width: min(1100px, calc(100vw - 24px)); }
.gd-ai-step { display: flex; flex-direction: column; gap: 12px; }
.gd-ai-step[hidden] { display: none; }
.gd-ai textarea.input { width: 100%; resize: vertical; }
.gd-ai-uses { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.gd-ai-chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.gd-ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gd-ai-row .input { flex: 1 1 220px; min-width: 0; }
.gd-ai-review { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 0; }
.gd-ai-edit, .gd-ai-prev { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gd-ai-body { flex: 1; min-height: 340px; height: 46vh; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.6; }
.gd-ai-prev .gd-preview { height: 46vh; min-height: 340px; }
.gd-ai-apply { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gd-ai-warn { color: var(--warn, #e8a33d); }
@media (max-width: 760px) { .gd-ai-review { grid-template-columns: 1fr; } }
/* 行に単独で入れたストリートビューは、記事の中に埋め込む */
.art-sv { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2, var(--surface)); }
.art-sv-frame { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 70vh; border: 0; background: #0b0f12; }
.art-sv-cap { padding: 6px 8px; }
.art-sv-ph { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
/* 同じ行に入れた複数の画像: 1 行に収まるように、余白をあけて、幅を自動で調節する（大きさを指定した画像は、その幅を目安に、収まらなければ縮む） */
.art-imgrow { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; }
.art-imgrow > .art-fig { flex: 1 1 0; min-width: 0; margin: 0; }
.art-imgrow > .art-fig[style] { max-width: 100%; }
.art-imgrow .art-zoom { display: block; width: 100%; max-width: none; }
.art-imgrow .art-zoom img { width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
/* 画像の大きさを、ウィンドウ・機種（記事の幅）に合わせる */
.art-content, .gd-preview { container-type: inline-size; }
.art-fig > .art-zoom:not([style]) { width: min(100%, 760px); margin-left: auto; margin-right: auto; }
.art-zoom img { max-height: 78vh; max-height: min(78vh, 78dvh); }
p .art-zoom, li .art-zoom { max-width: min(100%, 420px); max-width: min(100%, clamp(140px, 50cqw, 420px)); }
/* スマホ（タッチ）: 記事の画像に、拡大・縮小のボタンを重ねない（ピンチで拡大できる）。全画面のボタンだけを、小さく薄く残す */
@media (hover: none), (pointer: coarse) {
  .art-zoom .zoom-ctrls button:not([data-z="full"]) { display: none; }
  .art-zoom .zoom-ctrls { padding: 2px; gap: 0; opacity: .75; }
  .art-zoom .zoom-ctrls button { width: 28px; height: 28px; font-size: 14px; }
}
/* 対戦: ホスト以外が見る、部屋の設定（編集できない。ホストの変更が、すぐ反映される） */
fieldset.bt-settings { border: 0; border-top: 1px solid var(--border); margin-inline: 0; min-width: 0; }
.bt-ro { pointer-events: none; }
.bt-ro button:disabled, .bt-ro input:disabled, .bt-ro select:disabled { opacity: 1; color: inherit; cursor: default; }
.bt-ro .seg button:not(.on), .bt-ro .region-check:not(:has(input:checked)) { opacity: .6; }
.bt-ro input[type="range"] { opacity: .8; }
/* ストリートビューの問題: 解答用の地図は、右下から少し左にずらして、ストリートビューのコンパス・ズームのボタン（右下）に重ねない */
.qm-layout.qm-float:has(.sv-front) .qm-side { right: 96px; }
@media (max-width: 900px), (pointer: coarse) { .qm-layout.qm-float:has(.sv-front) .qm-maptoggle { right: 84px; } }
/* 今開いている人の数 */
.online-btn { width: auto; min-width: 36px; padding: 0 8px; gap: 4px; display: inline-flex; align-items: center; }
.online-btn[hidden] { display: none; }
.online-btn .on-n { font-size: 13px; font-variant-numeric: tabular-nums; }
.online-btn .on-away { font-size: 11px; color: var(--muted); }
.on-pop { position: fixed; z-index: 2000; width: min(300px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 32px rgba(0,0,0,.45); padding: 10px 12px; }
.on-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.on-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.on-list li { display: flex; align-items: center; gap: 8px; }
.on-list li.is-away { opacity: .65; }
.on-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.on-name em { font-style: normal; color: var(--muted); font-size: 12px; }
.on-note { margin: 8px 0 0; }
/* 地図クイズ（名前 ↔ 地図の場所） */
.gq { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.gq-bar { flex: none; }
.gq-prompt { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.gq-q { font-size: 20px; display: inline-flex; align-items: center; gap: 8px; }
.gq-q .flag { height: 20px; width: auto; }
.gq-mapbox { flex: 1; min-height: 280px; position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.gq-map { position: absolute; inset: 0; }
.gq-err { padding: 16px; }
.gq-side { flex: none; }
.gq-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.gq-choice { justify-content: flex-start; text-align: left; }
.gq-choice kbd { margin-right: 6px; }
.gq-input { display: flex; gap: 8px; }
.gq-input .input { flex: 1; min-width: 0; }
.gq-fb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.gq-fb.ok { border-color: #2f9e44; background: color-mix(in srgb, #2f9e44 12%, var(--surface)); }
.gq-fb.ng { border-color: #e03131; background: color-mix(in srgb, #e03131 10%, var(--surface)); }
.gq-fb .btn { margin-left: auto; }
.gq-result { max-width: 640px; margin: 0 auto; }
.gq-score { font-size: 22px; }
.gq-miss { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
/* 不具合の記録 */
.set-btns { display: inline-flex; gap: 6px; flex: none; }
.err-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.err-item { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); }
.err-item summary { cursor: pointer; }
.err-pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; margin: 6px 0 0; max-height: 240px; overflow: auto; color: var(--muted); }
/* ガイド: タグ・検索 */
.gd-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gd-tag-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.gd-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.gd-tag.on { background: var(--accent-soft, var(--surface-2)); color: var(--accent); border-color: var(--accent); }
.gd-tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font: inherit; line-height: 1; }
.gd-tag-in { width: 160px; flex: none; }
.gd-tagbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.gd-tagchip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.gd-tagchip:hover { border-color: var(--accent); }
.gd-tagchip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.gd-tagchip.on .muted { color: inherit; opacity: .8; }
.gd-row-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.gd-row mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
/* スマホの調整: 今開いている人のボタン・ガイドの検索欄・タグの入力 */
.user-area .online-btn { width: auto; min-width: 36px; padding: 0 8px; white-space: nowrap; flex: none; border-radius: 18px; }
.gd-tag-in { flex: 1 1 120px; width: auto; min-width: 100px; }
@media (max-width: 700px) {
  .gd-toolbar { flex-wrap: wrap !important; }
  .gd-toolbar #gd-q { order: 9; flex: 1 1 100% !important; width: 100% !important; min-width: 0; }
}
.gd-ai select { max-width: 100%; min-width: 0; }
.gd-ai-row select { flex: 1 1 200px; }
/* 共有リンク */
.gd-share { width: min(560px, calc(100vw - 24px)); }
.gd-share-box { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.gd-share-row { display: flex; gap: 6px; align-items: center; }
.gd-share-row .input { flex: 1; min-width: 0; }
.gd-share-note { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
/* 記事の画像: 上でも、ページをスクロールできる（スマホは、1 本指でスクロール。拡大したあとは、画像を動かす） */
.zoomable.zoom-scroll { touch-action: pan-x pan-y; }
.zoomable.zoom-scroll.is-zoomed { touch-action: none; }
.report-btn { display: inline-grid; place-items: center; }
.online-btn svg { flex: none; }
.gd-report { width: min(520px, calc(100vw - 24px)); }
.gd-report textarea { width: 100%; resize: vertical; }

/* ---------- アニメーション（画面の切り替え・開く・答える。設定「アニメーション」がオフのときは、.no-anim で 0 秒になる） ---------- */
@keyframes view-slide-next { from { opacity: 0; transform: translateX(26px); } }
@keyframes view-slide-prev { from { opacity: 0; transform: translateX(-26px); } }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes q-card-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes q-bottom-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes ans-ok { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes ans-ng { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.view-in-next { animation: view-slide-next .28s cubic-bezier(.2, .8, .2, 1); }
.view-in-prev { animation: view-slide-prev .28s cubic-bezier(.2, .8, .2, 1); }
.view-in-next .gd-row, .view-in-prev .gd-row, .view-in-next .tiles > *, .view-in-prev .tiles > * { animation: row-in .35s cubic-bezier(.2, .8, .2, 1) both; }
.view-in-next .gd-row:nth-child(1), .view-in-prev .gd-row:nth-child(1), .view-in-next .tiles > :nth-child(1), .view-in-prev .tiles > :nth-child(1) { animation-delay: 0.035s; }
.view-in-next .gd-row:nth-child(2), .view-in-prev .gd-row:nth-child(2), .view-in-next .tiles > :nth-child(2), .view-in-prev .tiles > :nth-child(2) { animation-delay: 0.070s; }
.view-in-next .gd-row:nth-child(3), .view-in-prev .gd-row:nth-child(3), .view-in-next .tiles > :nth-child(3), .view-in-prev .tiles > :nth-child(3) { animation-delay: 0.105s; }
.view-in-next .gd-row:nth-child(4), .view-in-prev .gd-row:nth-child(4), .view-in-next .tiles > :nth-child(4), .view-in-prev .tiles > :nth-child(4) { animation-delay: 0.140s; }
.view-in-next .gd-row:nth-child(5), .view-in-prev .gd-row:nth-child(5), .view-in-next .tiles > :nth-child(5), .view-in-prev .tiles > :nth-child(5) { animation-delay: 0.175s; }
.view-in-next .gd-row:nth-child(6), .view-in-prev .gd-row:nth-child(6), .view-in-next .tiles > :nth-child(6), .view-in-prev .tiles > :nth-child(6) { animation-delay: 0.210s; }
.view-in-next .gd-row:nth-child(7), .view-in-prev .gd-row:nth-child(7), .view-in-next .tiles > :nth-child(7), .view-in-prev .tiles > :nth-child(7) { animation-delay: 0.245s; }
.view-in-next .gd-row:nth-child(8), .view-in-prev .gd-row:nth-child(8), .view-in-next .tiles > :nth-child(8), .view-in-prev .tiles > :nth-child(8) { animation-delay: 0.280s; }
.view-in-next .gd-row:nth-child(9), .view-in-prev .gd-row:nth-child(9), .view-in-next .tiles > :nth-child(9), .view-in-prev .tiles > :nth-child(9) { animation-delay: 0.315s; }
.view-in-next .gd-row:nth-child(10), .view-in-prev .gd-row:nth-child(10), .view-in-next .tiles > :nth-child(10), .view-in-prev .tiles > :nth-child(10) { animation-delay: 0.350s; }
.view-in-next .gd-row:nth-child(11), .view-in-prev .gd-row:nth-child(11), .view-in-next .tiles > :nth-child(11), .view-in-prev .tiles > :nth-child(11) { animation-delay: 0.385s; }
.view-in-next .gd-row:nth-child(12), .view-in-prev .gd-row:nth-child(12), .view-in-next .tiles > :nth-child(12), .view-in-prev .tiles > :nth-child(12) { animation-delay: 0.420s; }
.q-in .quiz-card { animation: q-card-in .32s cubic-bezier(.2, .8, .2, 1) both; }
.q-in .quiz-bottom, .q-in .toolbar, .q-in .quiz-prompt { animation: q-bottom-in .34s cubic-bezier(.2, .8, .2, 1) .04s both; }
.choice.correct { animation: ans-ok .42s ease; }
.choice.wrong { animation: ans-ng .42s ease; }
.gq-fb.ok { animation: ans-ok .42s ease; }
.gq-fb.ng { animation: ans-ng .42s ease; }
.gq .gq-prompt { animation: pop-in .26s ease-out both; }
.gq .gq-fb, .gq .gq-choices, .gq .gq-input { animation: pop-in .24s ease-out both; }
.gd-pick[open], .gd-share[open], .gd-ai[open], .gd-report[open] { animation: dlg-in .22s cubic-bezier(.2, .8, .2, 1); }
.gd-pick[open]::backdrop, .gd-share[open]::backdrop, .gd-ai[open]::backdrop, .gd-report[open]::backdrop { animation: fade-in .22s ease-out; }
.gd-ai-step:not([hidden]) { animation: pop-in .22s ease-out both; }
.on-pop, .gd-sizepop { animation: pop-in .16s ease-out both; }
.gd-folder-body { animation: pop-in .22s ease-out both; }
.gd-tag, .gd-tagchip { transition: background-color .15s, color .15s, border-color .15s, transform .12s; }
/* ボタン・タブ・切り替えの、押したときの反応 */
:where(.btn, .icon-btn, .seg button, .chip-btn, .tabs a, .choice) { transition: background-color .16s ease, color .16s ease, border-color .16s ease, transform .12s ease, box-shadow .16s ease; }
:where(.btn:not(:disabled), .icon-btn:not(:disabled), .choice:not(:disabled)):active { transform: scale(.96); }
:where(.btn:not(:disabled)):hover { transform: translateY(-1px); }
.tabs a:active { transform: scale(.95); }
/* ---------- 画面の整え（レイアウト調整） ---------- */
/* 画面に収める表示（view-fit）でも、内容が、はみ出したら、枠の中で、スクロールできるように（答え合わせの欄が、下で切れないように） */
.view.view-fit:not(.view-scroll) { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
/* 国モードの、地図・ピンで答えるクイズ: 答え合わせの欄を、地図の下に、きれいに並べる */
.qm-side .qm-dist { margin: 8px 0 0; text-align: center; }
.qm-side .given-list { justify-content: center; margin: 6px 0; }
.qm-side .quiz-bottom { width: 100%; max-width: none; }
.qm-layout .qm-side > .quiz-bottom.is-answered { margin-top: 8px; }
/* クイズ設定の「出題内容」: 6 つのボタンが、1 列に詰まって、文字が折れていたので、カードのように並べる */
#q-kind { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; border: 0; background: none; overflow: visible; }
#q-kind button { border: 1px solid var(--border); border-radius: 10px; text-align: left; line-height: 1.45; padding: 10px 12px; }
#q-kind button:last-child { border-right: 1px solid var(--border); }
#q-kind button.on { border-color: var(--accent); }
/* 上のバーが、狭い（〜1500px）とき: 検索は、アイコンだけにして、タブが、切れないようにする */
@media (min-width: 761px) and (max-width: 1500px) {
  #search-btn .tab-long, #search-btn kbd, #search-btn > span { display: none; }
  #search-btn { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 50%; }
}
/* スマホ: 答え合わせの画面（ストリートビュー + 地図）が、つぶれないように、高さを決める */
@media (max-width: 900px), (pointer: coarse) {
  .qm-layout:not(.qm-float) .quiz-card:has(.sv-front) { min-height: min(54vh, 440px); }
  .qm-layout:not(.qm-float) .qm-side .quiz-map { min-height: 300px; }
  .qm-layout:not(.qm-float) { grid-template-rows: auto auto; }
}
