/* ===== Grundlayout ===== */
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }

/* ===== Obere Leiste ===== */
.topbar {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}

.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 14px 0 9px;
  border-radius: 999px;
  text-align: left;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-family: var(--font-serif); font-weight: 600; font-size: 1.02rem; letter-spacing: .01em; }
.brand-sub { font-size: .8rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-chevron { margin-left: auto; color: var(--ink-2); display: flex; }
.brand-chevron svg { width: 20px; height: 20px; }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
}
.icon-btn.glass { width: 52px; height: 52px; }
.icon-btn:active { transform: scale(.94); }

/* ===== Kartensteuerung rechts ===== */
.map-controls {
  position: absolute;
  right: 12px;
  top: calc(var(--safe-top) + 76px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.fab-sm {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
}
.fab-sm svg { transition: transform .25s var(--ease); }
.fab-sm:active { transform: scale(.94); }
#btn-compass:not(.is-rotated) { opacity: .78; }

/* ===== Statusanzeige der Karte ===== */
.map-status {
  position: absolute;
  top: calc(var(--safe-top) + 76px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 140px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .88rem;
  z-index: 9;
}
.map-status[data-state='loading']::before {
  content: '';
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.map-status[data-state='error'] { color: var(--ink); }
.map-status .btn { padding: 6px 12px; min-height: 34px; font-size: .85rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tab-Leiste ===== */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 6px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  z-index: 20;
  border-radius: 0;
  border-width: 1px 0 0;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: .72rem;
  font-weight: 500;
  color: var(--ink-2);
  position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current='page'] { color: var(--ink); }
.tab[aria-current='page']::after {
  content: '';
  position: absolute;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.tab-lens { justify-content: flex-end; padding-bottom: 7px; color: var(--ink); font-weight: 600; }
.tab-lens::after { display: none; }
.lens-orb {
  position: absolute;
  top: -22px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  border: 4px solid var(--bg);
  box-shadow: 0 6px 18px rgba(200, 67, 43, .35);
  transition: transform .15s var(--ease);
}
.lens-orb svg { width: 28px; height: 28px; }
.tab-lens:active .lens-orb { transform: scale(.94); }
.tab-lens[aria-current='page']::after { display: none; }

/* MapLibre-Steuerelemente über der Tab-Leiste platzieren */
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 4px) !important; }
.maplibregl-ctrl-scale {
  background: var(--glass) !important;
  border-color: var(--ink-2) !important;
  color: var(--ink) !important;
  font-family: var(--font-sans);
}
.maplibregl-ctrl-attrib {
  background: var(--glass) !important;
  color: var(--ink-2);
}
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
:root[data-theme='dark'] .maplibregl-ctrl-attrib-button { filter: invert(1); }

/* ===== Bottom-Sheet ===== */
#sheet-root { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, .32);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
#sheet-root.open .sheet-backdrop { opacity: 1; }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(82dvh, 760px);
  margin: 0 auto;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(102%);
  transition: transform .28s var(--ease);
  outline: none;
  overflow: hidden;
}
#sheet-root.open .sheet { transform: translateY(0); }

/* dezentes Seigaiha-Wellenmuster am oberen Rand */
.sheet::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 70px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16' viewBox='0 0 32 16'%3E%3Cg fill='none' stroke='%23C8432B' stroke-opacity='.22' stroke-width='1'%3E%3Cpath d='M0 16a16 16 0 0 1 32 0M5 16a11 11 0 0 1 22 0M10 16a6 6 0 0 1 12 0'/%3E%3Cpath d='M-16 8a16 16 0 0 1 32 0M16 8a16 16 0 0 1 32 0'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
  mask-image: linear-gradient(to bottom, #000, transparent);
  opacity: .7;
  pointer-events: none;
}

.sheet-handle {
  position: relative;
  width: 40px;
  height: 5px;
  margin: 9px auto 0;
  border-radius: 3px;
  background: var(--line);
  flex: none;
  touch-action: none;
}
.sheet-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px 10px 20px;
  touch-action: none;
}
.sheet-titles { flex: 1; padding-top: 6px; }
.sheet-title { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; }
.sheet-sub { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.sheet-body {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ===== Listen ===== */
.list { list-style: none; margin: 0 -8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.list-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
}
.list-item:active, .list-item[aria-current='true'] { background: var(--surface-2); }
.list-ja {
  width: 44px;
  flex: none;
  font-size: 1.15rem;
  color: var(--accent);
  font-weight: 500;
}
.list-main { flex: 1; font-weight: 500; }
.list-check { color: var(--accent); display: flex; }

/* ===== Einstellungen ===== */
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.section-title {
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  gap: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}
.seg {
  min-height: 42px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 500;
  color: var(--ink-2);
}
.seg[aria-checked='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.privacy-row { display: flex; gap: 12px; align-items: flex-start; }
.privacy-icon { color: var(--indigo); flex: none; display: flex; margin-top: 1px; }
.privacy-title { font-weight: 500; }
.privacy-row .muted { font-size: .88rem; }

.services { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.service { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.service:not(.is-active) { opacity: .72; }
.service-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.service-name { font-weight: 600; }
.service .muted { font-size: .84rem; }
.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge-on { background: var(--accent-soft); color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.btn:active { transform: scale(.98); }
.btn-danger { color: var(--danger); }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ===== Beschriftungs-Auswahl ===== */
.radio-cards { display: flex; flex-direction: column; gap: 10px; }
.radio-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  text-align: left;
}
.radio-card[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); }
.label-preview {
  width: 84px;
  flex: none;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-2);
  line-height: 1.15;
}
.lp-latin { font-weight: 600; font-size: .95rem; }
.label-preview .lp-latin + .lp-ja { font-size: .8rem; color: var(--ink-2); }
.lp-ja:only-child { font-size: 1.05rem; font-weight: 600; }
.rc-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.rc-title { font-weight: 600; }
.rc-hint { font-size: .85rem; color: var(--ink-2); }
.rc-check { color: var(--accent); display: flex; visibility: hidden; }
.radio-card[aria-checked='true'] .rc-check { visibility: visible; }

/* ===== Roadmap ===== */
.roadmap { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.roadmap li { position: relative; padding-left: 20px; }
.roadmap li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: .58em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

/* ===== Toast ===== */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 44px);
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.toast {
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: .9rem;
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: none; }

/* Breitere Bildschirme: Leisten zentriert */
@media (min-width: 720px) {
  .tabbar { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 12px; border-radius: 22px; border-width: 1px; padding-bottom: 0; height: var(--tabbar-h); }
  .maplibregl-ctrl-bottom-left { bottom: 8px !important; }
  .topbar { right: auto; width: min(520px, calc(100% - 24px)); }
}
