/* === Design Tokens === */
:root {
  /* Base */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #111111;
  --muted: #5f6368;
  --border: rgba(17, 17, 17, 0.16);
  --border-solid: #d8d8d4;

  /* Brand / Primary — forest green from moss & leaves */
  --primary: #3d6b50;
  --primary-hover: #4a7d5e;
  --primary-weak: rgba(61, 107, 80, 0.14);

  /* Info — sharing / public states (steel blue from water) */
  --info: #4a7a8c;
  --info-weak: rgba(74, 122, 140, 0.14);

  /* Private / Neutral state — warm stone grey from bark */
  --private: #7b7368;
  --private-weak: rgba(123, 115, 104, 0.14);

  /* Premium — terracotta / warm sienna from platanus bark */
  --premium: #a07d56;
  --premium-weak: rgba(160, 125, 86, 0.18);

  /* Danger — destructive only */
  --danger: #8b2c2c;
  --danger-weak: rgba(139, 44, 44, 0.16);

  /* Radius */
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.1);

  /* --- Legacy aliases (keep old var names working) --- */
  --accent: var(--primary);
  --accent-weak: var(--primary-weak);
  --accent-hover: var(--primary-hover);
  --neutral: var(--private);
  --neutral-weak: var(--private-weak);
  --danger-text: #7a1f1f;

  /* Font */
  --font-family:
    'Source Sans 3', 'Hiragino Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
}

/* Font theme: Sans — base weight 400 */
body {
  font-weight: 400;
}
body * {
  font-weight: inherit !important;
}

/* === Dark Theme === */
[data-theme='dark'] {
  --bg: #1a1a1a;
  --surface: #242424;
  --text: #e0e0e0;
  --muted: #9e9e9e;
  --border: rgba(255, 255, 255, 0.12);
  --border-solid: #3a3a3a;

  --primary: #5a9e73;
  --primary-hover: #6db385;
  --primary-weak: rgba(90, 158, 115, 0.18);

  --info: #6aabbf;
  --info-weak: rgba(106, 171, 191, 0.18);

  --private: #9e9588;
  --private-weak: rgba(158, 149, 136, 0.18);

  --premium: #c4a070;
  --premium-weak: rgba(196, 160, 112, 0.22);

  --danger: #c04040;
  --danger-weak: rgba(192, 64, 64, 0.2);

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.3);

  --danger-text: #e06060;
  color-scheme: dark;
}

/* Font theme: Serif (Crimson Pro + Yu Mincho) */
body[data-font='serif'] {
  --font-family: 'Crimson Pro', 'Yu Mincho', 'YuMincho', 'Hiragino Mincho ProN', serif;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Blue monochrome tiles — light desaturated look */
/* Base filter; brightness/contrast updated by JS on zoom */
.bluegray-tiles {
  filter: saturate(0.15) brightness(1.1) contrast(0.85);
}
/* Color tiles — natural colors tuned to match CARTO Voyager transition */
/* Base filter; brightness/contrast updated by JS on zoom */
.vintage-tiles {
  filter: grayscale(5%) brightness(1.02) sepia(8%) saturate(1.3) contrast(0.95);
  opacity: 0.88;
}
/* Dark tiles — inverted dark mode with muted colors */
.dark-tiles {
  filter: invert(100%) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.3);
}

/* Layer control group headers */
.layer-group-header {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  padding: 4px 10px 2px;
  letter-spacing: 0.3px;
}
.layer-group-header:not(:first-child) {
  border-top: 1px solid #ddd;
  margin-top: 2px;
  padding-top: 6px;
}

/* Tabler Icons: inline SVG icons */
.ti-svg {
  display: inline-block;
  vertical-align: -0.125em;
  width: 1em;
  height: 1em;
  stroke: currentColor;
}
.tabler-spin {
  animation: tabler-spin 1s linear infinite;
}
@keyframes tabler-spin {
  100% {
    transform: rotate(360deg);
  }
}
body {
  font-family: var(--font-family);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* Splash screen */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out;
}
#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Login screen */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-screen.hidden {
  display: none;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 380px;
  border: 1px solid var(--border);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.login-card h1 {
  text-align: center;
  color: var(--text);
  margin: 0;
  font-size: 22px;
}
.login-tagline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 14px;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.login-error.show {
  display: block;
}
.login-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
}
.login-toggle a {
  color: var(--accent);
  text-decoration: none;
}
.login-toggle a:hover {
  text-decoration: underline;
}

/* Header bar */
.header-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  padding: 6px 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.header-logo {
  height: 1.75rem;
  max-height: 100%;
  flex: none;
}
.header-spacer {
  flex: 1;
}
.header-bar .bar-btn {
  flex: none;
}
#btn-reload,
#btn-notifications {
  padding: 6px 19px;
}

/* Footer bar */
.footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  padding: 4px 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Flat bar buttons */
.bar-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text);
  transition: background 0.15s;
  font-size: 10px;
}
.bar-btn i,
.bar-btn svg {
  font-size: 22px;
  width: 22px;
  height: 22px;
}
.bar-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}
.bar-btn.active {
  color: var(--primary);
}
.bar-btn.following {
  color: var(--danger);
}
.bar-btn.following i {
  animation: pulse-icon 2s ease-in-out infinite;
}
@keyframes pulse-icon {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

#map {
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  position: absolute;
  top: 0;
  left: 0;
}
.login-screen:not(.hidden) ~ .header-bar,
.login-screen:not(.hidden) ~ .footer-bar,
.login-screen:not(.hidden) ~ main #map {
  visibility: hidden;
  pointer-events: none;
}

/* Leaflet controls — offset for header/footer bars */
.leaflet-top.leaflet-right {
  top: 52px;
}
.leaflet-bottom.leaflet-right {
  bottom: 52px;
}

/* Leaflet zoom controls — match style */
.leaflet-bar a {
  background-color: #fefdfb !important;
  border-color: rgba(17, 17, 17, 0.08) !important;
  color: var(--text) !important;
}
.leaflet-bar a:hover {
  background-color: #faf9f7 !important;
}
.leaflet-bar {
  border: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 100vh;
  background: var(--surface);
  z-index: 1001;
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.05);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.sidebar.open {
  transform: translateX(0);
}
/* During driver.js tutorial: disable transform & transition to avoid stacking context / position issues */
.sidebar.open.driver-no-transform {
  transform: none !important;
  transition: none !important;
}
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
/* Section tabs bar (ピン / 描画) — above folder tabs */
.sidebar-section-tabs {
  flex-shrink: 0;
  background: var(--surface);
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section-tabs .section-tabs {
  margin-bottom: 0;
  border-bottom: none;
}
/* Folder tabs bar (below section tabs) — sticky-note style */
.sidebar-folder-tabs {
  flex-shrink: 0;
  background: var(--surface);
  padding: 0 4px;
  padding-top: 6px;
  border-bottom: 1px solid var(--border);
}
.sidebar-folder-tabs .folder-tabs {
  border-bottom: none;
  margin-bottom: 0;
}
.sidebar-folder-tabs .folder-tab {
  padding: 10px 0;
  font-size: 13px;
}

.sidebar-org-logos {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--surface);
}
.sidebar-org-logo-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition:
    border-color 0.15s,
    transform 0.15s;
  flex-shrink: 0;
}
.sidebar-org-logo-btn:hover {
  border-color: var(--primary);
  transform: scale(1.08);
}
.sidebar-org-logo-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-org-logo-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--surface);
  background: var(--primary);
  border-color: var(--primary);
}
.sidebar-org-logo-initial:hover {
  border-color: var(--accent, var(--primary));
}
.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding: 3px 0;
  padding-bottom: 80px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--surface);
}
.sidebar-footer-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 0;
  transition:
    color 0.15s,
    background 0.15s;
}
.sidebar-footer-btn:hover {
  color: var(--accent);
  background: rgba(0, 0, 0, 0.04);
}
.sidebar-footer-btn svg {
  width: 22px;
  height: 22px;
}

/* Forms */
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
}
.folder-select-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.folder-select-row select {
  flex: 1;
}
.btn-folder-add {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s;
}
.btn-folder-add:hover {
  background: var(--neutral-weak);
  color: var(--text);
}
.btn-folder-add .ti-svg {
  width: 18px;
  height: 18px;
}

/* Description mode tabs (free / table) */
.desc-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 6px;
}
.desc-mode-tab {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  transition:
    background 0.15s,
    color 0.15s;
}
.desc-mode-tab:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.desc-mode-tab:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}
.desc-mode-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Table input grid for pin description */
.desc-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.desc-table-input {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}
.desc-table-input td {
  padding: 0;
}
.desc-table-input input {
  width: 100%;
  min-width: 72px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.desc-table-input input:focus {
  outline: none;
  border-color: var(--primary);
  z-index: 1;
  position: relative;
}
.desc-table-input tr:first-child td:first-child input {
  border-top-left-radius: var(--radius);
}
.desc-table-input tr:first-child td:last-child input {
  border-top-right-radius: var(--radius);
}
.desc-table-input tr:last-child td:first-child input {
  border-bottom-left-radius: var(--radius);
}
.desc-table-input tr:last-child td:last-child input {
  border-bottom-right-radius: var(--radius);
}

/* Rendered table in popup */
.pin-desc-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  margin: 4px 0;
}
.pin-desc-table td {
  border: 1px solid var(--border);
  padding: 3px 6px;
  white-space: nowrap;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  transition:
    background 0.15s,
    filter 0.15s;
}
.btn:hover {
  filter: brightness(1.1);
}
.btn-primary,
.btn-green {
  background: var(--primary);
  color: white;
}
.btn-primary:hover,
.btn-green:hover {
  background: var(--primary-hover);
  filter: none;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg);
  filter: none;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* Settings menu */
.settings-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
}
.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius);
  transition: background 0.15s;
  color: var(--text);
}
.settings-menu-item:hover {
  background: var(--bg);
}
.settings-menu-item:active {
  background: var(--neutral-weak);
}
.settings-menu-item > i:first-child {
  width: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}
.settings-menu-item > span:first-of-type {
  flex: 1;
}
.settings-menu-arrow {
  color: var(--border-solid);
  font-size: 12px;
}
.settings-page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 16px;
}
.settings-page-header:hover {
  text-decoration: underline;
}

/* Font picker */
.font-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.font-option:hover {
  border-color: var(--muted);
}
.font-option.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.font-option-name {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.font-option-preview {
  font-size: 16px;
  color: var(--text);
  line-height: 1.5;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
#modal-register-success {
  z-index: 6000;
}
#modal-forgot-password {
  z-index: 6000;
}
#modal-reset-password {
  z-index: 6000;
}
#modal-kml-folder {
  z-index: 2500;
}
#modal-folder {
  z-index: 2500;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 450px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  margin-bottom: 16px;
  color: var(--text);
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}
.icon-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
/* Color palette picker */
.color-palette {
  display: grid;
  grid-template-columns: repeat(6, 28px);
  gap: 8px;
  padding: 4px 0;
  justify-content: start;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s;
  position: relative;
  flex-shrink: 0;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.selected {
  border-color: var(--text);
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--text);
}
.color-swatch.selected::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%);
}
.color-swatch-custom {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px dashed var(--border-solid);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--surface);
  transition: border-color 0.12s;
  position: relative;
  overflow: hidden;
}
.color-swatch-custom:hover {
  border-color: var(--text);
}
.color-swatch-custom input[type='color'] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.icon-picker-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  transition: all 0.15s;
}
.icon-picker-item:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}
.icon-picker-item.selected {
  border-color: var(--accent);
  background: var(--accent-weak);
}

/* Folder tree */
.folder-tree {
  list-style: none;
  padding-left: 0;
}
.folder-tree ul {
  list-style: none;
  padding-left: 20px;
}
.folder-item {
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.folder-item:hover {
  background: var(--bg);
}
.folder-item.selected {
  background: var(--accent-weak);
  color: var(--accent);
}
.folder-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.folder-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--muted);
}
.folder-actions button:hover {
  color: var(--text);
}

/* KML folder list */
.kml-folder-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: grab;
}
.kml-folder-item[draggable='true']:active {
  cursor: grabbing;
}
.kml-folder-item.dragging {
  opacity: 0.5;
}
.kml-folder-item.drag-over {
  border: 2px dashed var(--accent);
}

/* Folder name row */
.folder-name-row {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.folder-icon {
  color: var(--muted);
  font-size: 18px;
}

.kml-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.kml-folder-header .toggle-icon {
  transition: transform 0.2s;
  font-size: 10px;
  color: var(--muted);
}
.kml-folder-header.expanded .toggle-icon {
  transform: rotate(90deg);
}
.kml-folder-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}

.folder-badges {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.kml-folder-files {
  padding-left: 20px;
  margin-top: 6px;
  display: none;
}
.kml-folder-files.open {
  display: block;
}
.kml-file-item {
  padding: 4px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
}
.kml-file-item:hover {
  background: var(--bg);
}
.kml-file-name {
  flex: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kml-file-name:hover {
  color: var(--accent);
  text-decoration: underline;
}
.kml-file-actions {
  display: flex;
  gap: 2px;
}

/* KML file style editor (floating bottom panel on map) */
.kml-style-editor-float {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
  border-radius: 14px 14px 0 0;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}
.style-editor-name-input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--border-solid);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.style-editor-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.style-editor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.style-editor-row label {
  min-width: 56px;
  color: var(--muted);
  flex-shrink: 0;
}
.style-editor-row input[type='color'] {
  width: 30px;
  height: 26px;
  padding: 1px;
  border: 1px solid var(--border-solid);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}
.style-editor-row input[type='range'] {
  flex: 1;
  min-width: 0;
  height: 20px;
  cursor: pointer;
}
.style-editor-row span {
  min-width: 30px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
.style-editor-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Icon buttons */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--muted);
  border-radius: var(--radius);
  transition:
    background 0.15s,
    color 0.15s;
}
.icon-btn:hover {
  background: var(--neutral-weak);
  color: var(--text);
}
.icon-btn.active {
  color: var(--accent);
}
.btn-toggle-visibility {
  opacity: 0.35;
}
.btn-toggle-visibility.active {
  opacity: 1;
  color: var(--accent);
}
.btn-toggle-group-visibility.group-hidden {
  opacity: 0.35;
}
.icon-btn.delete:hover {
  background: var(--danger-weak);
  color: var(--danger);
}

/* Pin list */
.pin-folder-section {
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.pin-folder-section[draggable='true'] {
  cursor: grab;
}
.pin-folder-section[draggable='true']:active {
  cursor: grabbing;
}
.pin-folder-section.dragging {
  opacity: 0.5;
}
.pin-folder-section.drag-over {
  border: 2px dashed var(--accent);
}

.pin-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.pin-folder-header .toggle-icon {
  transition: transform 0.2s;
  font-size: 10px;
  color: var(--muted);
}
.pin-folder-header.expanded .toggle-icon {
  transform: rotate(90deg);
}
.pin-folder-content {
  padding-left: 12px;
  display: none;
  margin-top: 8px;
}
.pin-folder-content.open {
  display: block;
}

.pin-item {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pin-item:hover {
  border-color: var(--accent);
}
.pin-item-header {
  cursor: pointer;
}
.pin-item h4 {
  font-size: 14px;
  margin-bottom: 4px;
}
.pin-item p {
  font-size: 12px;
  color: var(--muted);
}
.pin-item .pin-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* Pin detail images */
.pin-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.pin-images img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border);
}
.pin-images img:hover {
  border-color: var(--accent);
}

/* Image lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
}
.lightbox.active {
  display: flex;
}
.lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  background: none;
  border: none;
}

/* Gallery Feed Viewer (Instagram-style, fullscreen feed) */
.gallery-feed {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 3100;
  display: none;
  flex-direction: column;
}
.gallery-feed.active {
  display: flex;
}
.gallery-feed__close {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 3110;
  color: #fff;
  font-size: 28px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-feed__scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.gallery-feed__item {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #000;
}
.gallery-feed__img {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
  object-fit: contain;
  background: #000;
}
.gallery-feed__header {
  flex-shrink: 0;
  padding: 2.8em 56px 8px 14px;
  color: #fff;
}
.gallery-feed__info {
  flex-shrink: 0;
  padding: 8px 14px 2.8em;
  color: #fff;
}
.gallery-feed__author {
  font-size: 13px;
  font-weight: 600;
}
.gallery-feed__date {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}
.gallery-feed__comment {
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.5;
  white-space: pre-wrap;
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-feed__comment.expanded {
  -webkit-line-clamp: unset;
  display: block;
}
.gallery-feed__more {
  font-size: 11px;
  opacity: 0.6;
  cursor: pointer;
  margin-top: 2px;
  display: none;
}
.gallery-feed__divider {
  display: none;
}
/* Gallery Feed Video Controls */
.gallery-feed__video-wrap {
  position: relative;
  cursor: pointer;
  background: #000;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.gallery-feed__video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.gallery-feed__video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.gallery-feed__video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 10;
  pointer-events: none;
}
.gallery-feed__video-play[hidden] {
  display: none;
}
.gallery-feed__video-mute {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}
.gallery-feed__video-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10;
}
.gallery-feed__video-loading[hidden] {
  display: none;
}
.gallery-feed__video-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  margin: 0 -14px 4px;
  flex-shrink: 0;
}
.gallery-feed__video-bar {
  height: 100%;
  background: #fff;
  width: 0%;
  transition: width 0.15s linear;
}
/* Upload progress bar */
.upload-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
  display: none;
}
.upload-progress.active {
  display: block;
}
.upload-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--primary, #4a90d9);
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(74, 144, 217, 0.5);
}
.upload-progress__bar.indeterminate {
  width: 30%;
  animation: upload-progress-slide 1.2s ease-in-out infinite;
}
@keyframes upload-progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* Comment chat (LINE-style) */
.comment-section {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.comment-header {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
}
/* Comment/Gallery tabs */
.comment-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.comment-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.comment-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
/* Gallery container - Instagram-style grid */
.comment-gallery {
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
  scroll-behavior: smooth;
}
.gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
}
.gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  color: #fff;
}
.gallery-item.active .gallery-overlay {
  opacity: 1;
}
.gallery-overlay-author {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-overlay-date {
  font-size: 9px;
  opacity: 0.8;
  margin-top: 1px;
}
.gallery-overlay-comment {
  font-size: 10px;
  margin-top: 3px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comment-chat {
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  scroll-behavior: smooth;
}
.comment-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.comment-msg-mine {
  align-self: flex-end;
  align-items: flex-end;
}
.comment-msg-other {
  align-self: flex-start;
  align-items: flex-start;
}
.comment-author {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 1px;
  padding: 0 6px;
}
.comment-bubble {
  padding: 6px 10px;
  border-radius: 14px;
  word-break: break-word;
  position: relative;
  line-height: 1.4;
}
.comment-bubble-mine {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--accent);
  border-bottom-right-radius: 4px;
}
.comment-bubble-other {
  background: var(--neutral-weak);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.comment-bubble-img {
  max-width: 180px;
  max-height: 140px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  margin-bottom: 2px;
  object-fit: cover;
}
.comment-bubble-mine .comment-bubble-img {
  border-radius: 8px;
}
.comment-bubble-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.comment-bubble-text a,
.popup-desc a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  opacity: 0.7;
  margin-top: 2px;
  justify-content: flex-end;
}
.comment-bubble-mine .comment-meta {
  color: var(--muted);
}
.comment-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 10px;
  opacity: 0.6;
  color: inherit;
}
.comment-delete-btn:hover {
  opacity: 1;
}
.comment-input-bar {
  margin-top: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.comment-image-btn {
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  padding: 2px 4px;
  border-radius: var(--radius);
  transition: color 0.15s;
}
.comment-image-btn:hover {
  color: var(--accent);
}
.comment-send-btn {
  padding: 4px 10px;
  border-radius: 16px;
}
.comment-send-btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}
.comment-spin {
  animation: comment-spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes comment-spin {
  to {
    transform: rotate(360deg);
  }
}
.comment-image-preview {
  margin-top: 4px;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--neutral-weak);
  border-radius: 6px;
}
.comment-image-preview img {
  max-width: 60px;
  max-height: 60px;
  object-fit: cover;
  border-radius: 4px;
}
.comment-image-preview-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 14px;
  padding: 2px;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  transition:
    color 0.15s,
    border-color 0.15s;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Visibility badge — solid fill, white text, no border */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  color: white;
}
.badge-public {
  background: var(--info);
}
.badge-private {
  background: var(--private);
}
.badge-shared {
  background: var(--info);
}
.badge-org {
  background: var(--private);
}
.badge-premium {
  background: var(--premium);
}
.badge-free {
  background: var(--private);
}

/* User info */
.user-info {
  padding: 12px;
  background: transparent;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.user-info span {
  font-weight: 600;
}

/* KML info */
.kml-info {
  padding: 10px;
  background: var(--primary-weak);
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--primary);
}

/* KML info popup on tap */
.kml-info-popup {
  font-size: 13px;
  line-height: 1.5;
}
.kml-info-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-word;
}
.kml-info-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}
.kml-info-row i {
  font-size: 14px;
  flex-shrink: 0;
}
.kml-info-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: visible;
}
.kml-info-popup-wrap .leaflet-popup-content {
  margin: 8px 10px;
  overflow: visible;
}

/* Info panel inside popups */
.popup-info-panel {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.6;
}
.popup-info-panel .info-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  white-space: nowrap;
}
.popup-info-panel .info-row i {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.popup-info-panel .info-label {
  color: var(--muted);
  flex-shrink: 0;
}
.popup-info-panel .info-coord-value {
  font-family: monospace;
  font-size: 11px;
  user-select: all;
}
.popup-info-panel .info-elev-value {
  font-family: monospace;
  font-size: 11px;
}
.info-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  vertical-align: middle;
}
.info-toggle-btn:hover {
  color: var(--accent);
}
.info-toggle-btn i {
  font-size: 13px;
  width: 13px;
  height: 13px;
}
.popup-action-btn.action-info {
  color: var(--muted);
}
.popup-action-btn.action-info:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.popup-action-btn.action-info i {
  font-size: 20px;
  width: 20px;
  height: 20px;
}
.kml-info-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.kml-info-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 16px;
  transition:
    background 0.15s,
    color 0.15s;
}
.kml-info-action-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.kml-info-action-delete:hover {
  background: var(--danger, #e53935);
  border-color: var(--danger, #e53935);
}

/* Checkbox style */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.checkbox-label input {
  width: 16px;
  height: 16px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-solid);
  transition: 0.3s;
  border-radius: 22px;
}
.toggle-slider:before {
  position: absolute;
  content: '';
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* Delete image btn */
.img-wrapper {
  position: relative;
  display: inline-block;
}
.img-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pin creation method grid */
.pin-method-grid {
  display: flex;
  margin-top: 16px;
}
.pin-method-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: none;
  border-right: 1px solid var(--border);
  background: none;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.pin-method-btn:last-child {
  border-right: none;
}
.pin-method-btn i,
.pin-method-btn .ti-svg {
  font-size: 22px;
  color: var(--accent);
}
.pin-method-btn:hover {
  background: var(--surface);
}

/* Invite method grid (reuses pin-method style) */
.invite-method-grid {
  display: flex;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}
.invite-method-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: none;
  border-right: 1px solid var(--border);
  background: none;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.invite-method-btn:last-child {
  border-right: none;
}
.invite-method-btn i {
  font-size: 18px;
}
.invite-method-btn:hover {
  background: var(--surface);
}
.invite-method-btn.active {
  color: var(--accent);
  background: var(--surface);
}
.invite-method-btn.active i {
  color: var(--accent);
}
.invite-panel {
  padding-top: 16px;
}
.pin-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pin-toggle-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Section divider */
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.section-title i {
  color: var(--muted);
}

/* Sidebar user header */
.sidebar-user-header {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.sidebar-user-header:first-child {
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-plan {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar-plan-notar {
  background: var(--border);
  color: var(--muted);
}
.sidebar-plan-notar-pro {
  background: var(--accent);
  color: #fff;
}

/* Section tabs (nota / drawing) — sticky-note style */
.section-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
}
.section-tab {
  flex: 1;
  text-align: center;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  transition:
    color 0.15s,
    background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: -1px;
  position: relative;
}
.section-tab:hover {
  color: var(--text);
}
.section-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
}
.section-tab i {
  font-size: 16px;
}

/* Folder tabs — sticky-note style */
.folder-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}
.folder-tab {
  flex: 1;
  text-align: center;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: -1px;
  position: relative;
  transition:
    color 0.15s,
    background 0.15s;
}
.folder-tab:hover {
  color: var(--text);
}
.folder-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
}
.folder-tab-content {
  display: none;
}
.folder-tab-content.active {
  display: block;
}
.folder-group {
  background: var(--bg);
  border-radius: var(--radius);
  margin: 6px 0;
  padding: 2px 0;
}
.folder-group-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 10px;
  margin: 0;
  background: none;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.folder-group-header:hover {
  background: var(--private-weak);
}
.btn-toggle-group-visibility {
  margin-left: auto;
  opacity: 0.5;
  transition: opacity 0.15s;
  font-size: 11px !important;
  padding: 2px 4px !important;
}
.folder-group-header:hover .btn-toggle-group-visibility {
  opacity: 1;
}
.folder-group-header .toggle-icon {
  transition: transform 0.2s;
  font-size: 10px;
}
.folder-group-header.expanded .toggle-icon {
  transform: rotate(90deg);
}
.group-icon-accent,
.tab-icon-accent {
  color: #a04040;
  stroke: #a04040;
}
.folder-tab.active .tab-icon-accent {
  color: var(--accent);
  stroke: var(--accent);
}
.folder-group-content {
  display: none;
}
.folder-group-content.open {
  display: block;
}
.sidebar-icon-grid > .folder-group {
  grid-column: 1 / -1;
}
.sidebar-icon-grid > .folder-group > .folder-group-content.open {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Sidebar action bar */
.sidebar-action-bar {
  display: flex;
  gap: 4px;
  padding: 4px 16px;
  align-items: center;
  flex-shrink: 0;
}
.sidebar-action-bar .btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 6px;
}
.sidebar-action-bar .btn:hover {
  background: var(--neutral-weak);
  color: var(--text);
}
.sidebar-action-bar .btn .ti-svg {
  width: 20px;
  height: 20px;
}
.sidebar-view-toggle-group {
  display: inline-flex;
  gap: 0;
  margin-left: auto;
}
.sidebar-view-toggle-group .sidebar-view-btn {
  border-radius: 0;
}
.sidebar-view-toggle-group .sidebar-view-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.sidebar-view-toggle-group .sidebar-view-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}
.sidebar-view-btn.active {
  background: var(--border);
  color: var(--muted);
  pointer-events: none;
}

/* Sidebar breadcrumb navigation */
.sidebar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 4px 0;
  flex-wrap: wrap;
}
.breadcrumb-item {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s;
}
.breadcrumb-item:hover {
  background: var(--accent-weak);
}
.breadcrumb-item.active {
  color: var(--text);
  cursor: default;
  font-weight: 600;
}
.breadcrumb-item.active:hover {
  background: none;
}
.breadcrumb-root {
  display: flex;
  align-items: center;
}
.breadcrumb-root i {
  font-size: 22px;
}
.breadcrumb-sep {
  color: var(--muted);
  font-size: 13px;
  padding: 0 1px;
  opacity: 0.7;
}
.breadcrumb-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.breadcrumb-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  display: flex;
  align-items: center;
}
.breadcrumb-btn:hover {
  color: var(--accent);
  background: var(--accent-weak);
}
.breadcrumb-visibility.active {
  color: var(--accent);
}
.breadcrumb-focus.active {
  color: var(--accent);
}
.breadcrumb-btn .ti-svg {
  width: 18px;
  height: 18px;
}

/* Sidebar folder row (single row, drill-down navigation) */
.sidebar-folder-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
}
.sidebar-folder-row:hover {
  border-color: var(--accent);
}
.sidebar-folder-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.sidebar-folder-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.sidebar-folder-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Folder badges (share count, owner name) */
.folder-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}
.folder-badge-members {
  background: var(--accent-weak, rgba(26, 115, 232, 0.1));
  color: var(--primary);
}
.folder-badge-members .ti {
  font-size: 10px;
  margin-right: 1px;
}
.folder-badge-owner {
  background: var(--bg-alt, #f0f0f0);
  color: var(--muted);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Pin last-editor meta line */
.pin-meta-editor {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.sidebar-folder-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 4px;
}
.sidebar-folder-actions .icon-btn .ti-svg {
  width: 18px;
  height: 18px;
}

/* Sidebar item row (pin/file single-row) */
.sidebar-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f6faf7;
  cursor: pointer;
  transition: border-color 0.15s;
}
.sidebar-item-row:hover {
  border-color: var(--accent);
}
.sidebar-item-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item-meta {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Sidebar file row (KML files in folder view) */
.sidebar-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.15s;
}
.sidebar-file-row:hover {
  border-color: var(--accent);
}
.sidebar-file-icon {
  font-size: 20px;
  color: var(--muted);
  flex-shrink: 0;
}
.sidebar-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.sidebar-file-name:hover {
  color: var(--accent);
}
.sidebar-file-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Sidebar icon grid view */
.sidebar-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sidebar-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
  position: relative;
}
.sidebar-icon-item:hover {
  background: var(--bg);
}
.sidebar-icon-folder {
  font-size: 36px;
  line-height: 1;
}
.sidebar-icon-file {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--muted);
}
.sidebar-icon-pin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-icon-count {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 10px;
  color: var(--muted);
}

/* Folder action row (sticky bottom) */
.sidebar-add-folder-row {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  background: var(--surface);
  margin: 8px -16px -16px;
}
.sidebar-add-folder-row .icon-btn {
  color: var(--muted);
  padding: 4px;
  font-size: 18px;
}
.sidebar-add-folder-row .icon-btn:hover {
  color: var(--accent);
}

/* Folder settings popup */
.folder-settings-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 180px;
  animation: fadeIn 0.12s ease;
}
.folder-settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  text-align: left;
  transition: background 0.15s;
}
.folder-settings-item:hover {
  background: var(--bg);
}
.folder-settings-item i {
  font-size: 16px;
  color: var(--muted);
  width: 18px;
  text-align: center;
}
.folder-settings-danger {
  color: var(--danger);
}
.folder-settings-danger i {
  color: var(--danger);
}
.folder-settings-danger:hover {
  background: var(--danger-weak);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Folder tree select component */
.folder-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  padding: 4px 0;
}
.folder-tree-group-header {
  display: flex;
  align-items: center;
  padding: 0 6px;
  min-height: 34px;
  cursor: pointer;
  user-select: none;
}
.folder-tree-group-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  transition: background 0.15s;
}
.folder-tree-group-header:hover .folder-tree-group-toggle {
  background: var(--neutral-weak);
}
.folder-tree-group-label {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.folder-tree-group-label.selectable {
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.folder-tree-group-label.selectable:hover {
  background: var(--bg);
}
.folder-tree-group-label.selectable.selected {
  background: var(--accent-weak);
  color: var(--accent);
}
.folder-tree-group-children {
  display: none;
}
.folder-tree-group-children.open {
  display: block;
}
.folder-tree-item {
  display: flex;
  align-items: center;
  padding: 0 6px;
  min-height: 32px;
}
.folder-tree-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  transition:
    background 0.15s,
    color 0.15s;
}
.folder-tree-toggle:hover {
  background: var(--neutral-weak);
  color: var(--text);
}
.folder-tree-toggle.empty {
  visibility: hidden;
}
.folder-tree-label {
  flex: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}
.folder-tree-label:hover {
  background: var(--bg);
}
.folder-tree-label.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.folder-tree-label.disabled:hover {
  background: transparent;
}
.folder-tree-label.selected {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}
.folder-tree-children {
  display: none;
}
.folder-tree-children.open {
  display: block;
}

/* Bulk operation toolbar */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  position: sticky;
  bottom: 46px;
  margin: 8px -16px 0;
  padding: 6px 16px;
  border-radius: 0;
  border-left: none;
  border-right: none;
}
.bulk-toolbar .bulk-count {
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
}
.bulk-toolbar button {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.bulk-toolbar button:hover {
  background: var(--bg);
}
.bulk-toolbar button.bulk-delete {
  color: var(--danger);
  border-color: var(--danger);
}
.bulk-toolbar button.bulk-delete:hover {
  background: var(--danger-weak);
}
.bulk-toolbar .bulk-icon-btn {
  padding: 3px 6px;
  border: none;
  background: none;
}
.bulk-toolbar .bulk-icon-btn .ti-svg {
  width: 20px;
  height: 20px;
}
.bulk-toolbar .bulk-icon-btn:hover {
  background: var(--bg);
}
.bulk-check {
  margin-right: 6px;
  cursor: pointer;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* Icon view bulk checkboxes */
.bulk-check-icon {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  margin: 0;
  width: 16px;
  height: 16px;
}
.sidebar-icon-item.bulk-active {
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color 0.15s;
}
.sidebar-icon-item.bulk-checked {
  outline-color: var(--accent);
  background: var(--accent-weak);
}

/* Focus Mode (集中モード) */
.field-view-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 4px;
  background: var(--accent-weak);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.field-view-banner .btn {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
}
.focus-mode-btn.active {
  color: var(--accent) !important;
}
.focus-section {
  margin-bottom: 10px;
}
.focus-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border-radius: var(--radius);
}
.focus-section-header label {
  margin-left: auto;
  font-weight: 400;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.focus-section-header label input {
  margin: 0;
}
.focus-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 0;
}
.focus-tab {
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
}
.focus-tab:hover {
  background: var(--surface);
}
.focus-tab.active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}
.focus-tab i {
  font-size: 12px;
}
.focus-tree {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
}
.focus-tree .fv-folder,
.focus-tree .fv-item {
  padding: 3px 4px;
  font-size: 12px;
}
.focus-tree .fv-folder label,
.focus-tree .fv-item label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.focus-tree .fv-check {
  margin: 0;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Bulk settings dropdown */
.bulk-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px !important;
}
.bulk-settings-btn i {
  font-size: 14px;
}
.bulk-settings-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
  animation: fadeIn 0.12s ease;
}
.bulk-settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  text-align: left;
  transition: background 0.15s;
}
.bulk-settings-item:hover {
  background: var(--bg);
}
.bulk-settings-item i {
  font-size: 16px;
  color: var(--muted);
  width: 18px;
  text-align: center;
}
.bulk-settings-danger {
  color: var(--danger);
}
.bulk-settings-danger i {
  color: var(--danger);
}
.bulk-settings-danger:hover {
  background: var(--danger-weak);
}

/* Passcode input */
.passcode-container {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 12px 0;
}
.passcode-container input {
  width: 38px;
  height: 46px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.passcode-container input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius);
  z-index: 3000;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s;
}
.notification-success {
  background: var(--primary);
  color: white;
}
.notification-error {
  background: var(--danger);
  color: white;
}
.notification-info {
  background: var(--bg-alt, #f0f0f0);
  color: var(--text);
  border: 1px solid var(--border, #ddd);
}
/* Account modal sections */
.account-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.account-section:last-child {
  border-bottom: none;
}
.account-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}
.account-plan-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-alt, #f8f8f8);
}
.account-plan-premium {
  background: linear-gradient(135deg, rgba(26, 115, 232, 0.05), rgba(26, 115, 232, 0.12));
  border: 1px solid rgba(26, 115, 232, 0.2);
}
/* Pin creation — Step 1 is normal modal, Step 2/3 expand to full screen */
#modal-pin .modal {
  transition: all 0.15s ease;
}
#modal-pin.pin-fullscreen .modal,
#modal-save-drawing .modal,
#modal-kml-upload-draw .modal {
  max-width: 100%;
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}
#pin-step-details,
#pin-step-folder,
#drawing-step-details,
#drawing-step-folder,
#kml-upload-step-details,
#kml-upload-step-folder {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.pin-fs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.pin-fs-back {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 20px;
  display: flex;
  align-items: center;
}
.pin-fs-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.pin-fs-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.pin-fs-bottom .pin-media-menu {
  margin-top: 0;
  border-top: none;
}
.pin-fs-footer {
  padding: 12px 16px;
  flex-shrink: 0;
}
.pin-fs-title {
  font-size: 18px;
  font-weight: 600;
  border: none;
  outline: none;
  width: 100%;
  padding: 8px 0;
  background: transparent;
  color: var(--text);
}
.pin-fs-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 8px;
}
.pin-fs-caption {
  border: none;
  outline: none;
  width: 100%;
  padding: 4px 0;
  background: transparent;
  color: var(--text);
  font-size: 15.5px;
  resize: none;
  min-height: 80px;
}
.media-limit-hint {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.kml-file-context-menu {
  z-index: 10000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 160px;
  padding: 4px 0;
}
.kml-file-context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}
.kml-file-context-menu button:hover {
  background: var(--bg-alt);
}
.kml-file-context-menu button.danger {
  color: var(--danger);
}
.pin-media-menu {
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.pin-media-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}
.pin-media-item:last-child {
  border-bottom: none;
}
.pin-media-item:active {
  background: var(--bg-alt);
}
.pin-media-arrow {
  margin-left: auto;
  color: var(--muted);
}
/* Pin folder selection */
.pin-folder-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pin-folder-tabs .folder-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--muted);
}
.pin-folder-tabs .folder-tab.active {
  color: white;
  background: var(--success, #3d6b50);
  border-bottom-color: var(--success, #3d6b50);
  border-radius: 4px 4px 0 0;
}
.pin-folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.pin-folder-row:active {
  background: var(--bg-alt);
}
.pin-folder-row.selected {
  background: rgba(26, 115, 232, 0.08);
}
#btn-save-pin:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#pin-step-folder .pin-fs-footer {
  border-top: 1px solid var(--border);
}
.pin-folder-row .folder-name {
  flex: 1;
  font-size: 14px;
}
.pin-folder-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.pin-folder-breadcrumb:empty {
  display: none;
}
.pin-folder-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
.pin-folder-breadcrumb span {
  color: var(--text);
  font-weight: 600;
}

/* Pin mode */
.pin-marker-circle {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 0;
}
.pin-marker-circle .ti-svg {
  display: block;
  width: auto;
  height: auto;
}

.pin-mode-active .leaflet-overlay-pane,
.pin-mode-active .leaflet-overlay-pane *,
.pin-mode-active .leaflet-marker-pane,
.pin-mode-active .leaflet-marker-pane * {
  pointer-events: none !important;
}

/* Sharing modal - user selection */
.user-select-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.user-select-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.user-select-item:last-child {
  border-bottom: none;
}
.user-select-item:hover {
  background: var(--bg);
}
.user-select-item.selected {
  background: var(--accent-weak);
}
.user-select-item input {
  width: 16px;
  height: 16px;
}

/* Preview images during pin creation */
.image-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.image-preview {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.pin-image-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.share-inherit-notice {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  margin: 4px 0 8px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  font-size: 12px;
  color: #6d4c00;
  line-height: 1.4;
}
.share-inherit-notice i {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Reorder list */
.reorder-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.reorder-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.reorder-item:last-child {
  border-bottom: none;
}
.reorder-item span {
  font-weight: 500;
}
.reorder-buttons {
  display: flex;
  gap: 4px;
}
.reorder-buttons .icon-btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* Admin panel */
.admin-btn {
  position: relative;
}
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
/* Notification tabs */
.notif-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.notif-tab {
  flex: 1;
  min-width: 0;
  padding: 6px 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  position: relative;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.notif-tab:hover {
  color: var(--text);
  background: var(--bg);
}
.notif-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.notif-tab-badge {
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
.pending-user-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.pending-user-item:last-child {
  border-bottom: none;
}
.pending-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pending-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Admin tabs */
.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.admin-tabs .tab {
  padding: 10px 20px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.admin-tabs .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.admin-tabs .tab:hover {
  color: var(--text);
}

/* Security logs */
.security-log-filter {
  margin-bottom: 12px;
}
.security-log-filter select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.security-log-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.security-log-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.security-log-item:last-child {
  border-bottom: none;
}
.security-log-item:hover {
  background: var(--bg);
}

/* Admin stats table */
.admin-stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
  font-size: 13px;
}
.admin-stats-table th {
  text-align: left;
  padding: 4px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.admin-stats-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.admin-stats-table td:first-child {
  text-align: left;
}
.admin-stats-table th:first-child {
  min-width: 100px;
}

/* Sidebar Usage Footer */
.sidebar-usage-footer {
  margin-top: 20px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.usage-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-title i {
  color: var(--muted);
}
.usage-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.usage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: calc(50% - 3px);
  padding: 4px 8px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 11px;
}
.usage-label {
  color: var(--muted);
}
.usage-value {
  font-weight: 600;
  color: var(--primary);
}
.usage-value.at-limit {
  color: var(--danger);
}
.upgrade-link {
  display: block;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--premium-weak);
  color: var(--premium);
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  transition: filter 0.15s;
}
.upgrade-link:hover {
  filter: brightness(1.1);
}
.upgrade-link i {
  margin-right: 4px;
}

/* Mobile drawing toolbar */
.draw-toolbar-mobile {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 60px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 1200;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.draw-toolbar-mobile button {
  padding: 10px 18px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.draw-toolbar-mobile .btn-draw-undo {
  background: var(--bg);
  color: var(--text);
}
.draw-toolbar-mobile .btn-draw-cancel {
  background: var(--bg);
  color: var(--danger);
}
.draw-toolbar-mobile .btn-draw-finish {
  background: var(--primary);
  color: white;
}
.draw-toolbar-mobile .btn-draw-finish:disabled {
  background: var(--neutral-weak);
  color: var(--muted);
}

/* GPS Tracking banner */
.tracking-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 60px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1200;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.tracking-banner .tracking-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: tracking-pulse 1.5s ease-in-out infinite;
}
@keyframes tracking-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}
.tracking-banner .tracking-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.tracking-banner .tracking-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tracking-banner .btn-tracking-stop {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: var(--danger);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tracking-banner .btn-tracking-stop:hover {
  filter: brightness(1.15);
}
#btn-route.recording {
  color: var(--danger);
  animation: tracking-pulse 1.5s ease-in-out infinite;
}
#btn-add-pin.active {
  color: var(--primary);
}

/* iOS install guide */
.ios-install-guide {
  padding: 4px 0;
}
.ios-install-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.ios-install-step:last-of-type {
  border-bottom: none;
}
.ios-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Install banner */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.install-banner.show {
  transform: translateY(0);
}
.install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}
.install-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
  min-width: 0;
}
.install-banner-text strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}
.install-banner-text span {
  font-size: 12px;
  opacity: 0.9;
}
.install-banner-text span i {
  margin-right: 2px;
}
.install-banner-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  flex-shrink: 0;
}
.install-banner-close:hover {
  opacity: 1;
}

/* My location marker with heading */
.my-location-icon {
  background: none;
  border: none;
}
.my-location-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4285f4;
  border: 3px solid white;
  box-shadow: 0 0 6px rgba(66, 133, 244, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.my-location-arrow {
  position: absolute;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  top: -10px;
  transform-origin: 50% calc(100% + 12px);
  filter: drop-shadow(0 0 2px rgba(66, 133, 244, 0.3));
}
.my-location-arrow::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 20px solid rgba(66, 133, 244, 0.55);
}

/* Onboarding slider */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 5500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.onboarding-overlay.active {
  opacity: 1;
}
.onboarding-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.onboarding-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  padding: 32px 24px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.onboarding-skip {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  z-index: 1;
}
.onboarding-skip:hover {
  color: var(--text);
}
.onboarding-back-btn {
  position: absolute;
  top: 12px;
  left: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: inherit;
}
.onboarding-back-btn:hover {
  color: var(--accent);
}
.onboarding-slide {
  text-align: center;
}
.onboarding-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.onboarding-icon i {
  color: var(--accent);
}
.onboarding-icon svg {
  width: 48px;
  height: 48px;
}
.onboarding-slide h2 {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 12px;
  font-weight: 600;
}
.onboarding-slide p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 8px;
}
.onboarding-start-btn {
  margin-top: 16px;
  padding: 12px 40px;
  font-size: 15px;
}
/* Guide menu (settings → usage guide) */
.onboarding-menu-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 16px;
}
.onboarding-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.onboarding-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s;
}
.onboarding-menu-item:hover {
  border-color: var(--accent);
}
.onboarding-menu-item i:first-child {
  color: var(--accent);
  font-size: 18px;
}
.onboarding-menu-arrow {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

/* Driver.js custom theme */
.fieldnota-driver-popover {
  font-family: inherit;
}
.fieldnota-driver-popover .driver-popover-title {
  font-size: 15px;
  font-weight: 600;
}
.fieldnota-driver-popover .driver-popover-description {
  font-size: 13px;
  line-height: 1.6;
}
.fieldnota-driver-popover .driver-popover-progress-text {
  font-size: 11px;
  color: var(--muted);
}
.fieldnota-driver-popover .driver-popover-next-btn,
.fieldnota-driver-popover .driver-popover-prev-btn,
.fieldnota-driver-popover .driver-popover-close-btn {
  font-family: inherit;
}
.fieldnota-driver-popover .driver-popover-next-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 6px 16px;
  font-size: 13px;
}
.fieldnota-driver-popover .driver-popover-prev-btn {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
}
.fieldnota-driver-popover.tutorial-auto-step .driver-popover-next-btn,
.fieldnota-driver-popover.tutorial-auto-step .driver-popover-prev-btn,
.fieldnota-driver-popover.tutorial-info-step .driver-popover-prev-btn {
  display: none !important;
}
.fieldnota-driver-popover.tutorial-complete-step .driver-popover-footer {
  display: none !important;
}

/* Icon reference page (onboarding page 4) */
#onboarding-page4 {
  max-height: 70vh;
  overflow-y: auto;
}
.icon-ref-header {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 28px;
}
.icon-ref-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  margin: 0;
}
.icon-ref-header-sep {
  color: var(--border);
  font-size: 14px;
}
.icon-ref-header-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  transition: color 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-ref-header-desc.has-desc {
  color: var(--text);
}
/* Section tabs — sticky-note index style */
.icon-ref-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 2px;
}
.icon-ref-tab {
  flex: 1;
  text-align: center;
  padding: 7px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: -1px;
  position: relative;
  transition:
    color 0.15s,
    background 0.15s;
  font-family: inherit;
}
.icon-ref-tab:hover {
  color: var(--text);
}
.icon-ref-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
}
/* Panels */
.icon-ref-panel {
  padding-top: 10px;
}
.icon-ref-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.icon-ref-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: inherit;
}
.icon-ref-item:hover {
  background: var(--accent-weak);
}
.icon-ref-item.active {
  background: var(--accent-weak);
}
.icon-ref-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}
.icon-ref-icon svg {
  width: 22px;
  height: 22px;
}
.icon-ref-icon i {
  color: var(--accent);
}
.icon-ref-item.active .icon-ref-icon i {
  color: var(--accent);
}
.icon-ref-label {
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}
.icon-ref-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.icon-ref-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.icon-ref-back:hover {
  color: var(--accent);
}
#onboarding-page4 .onboarding-start-btn {
  margin-top: 0;
  padding: 10px 32px;
  font-size: 14px;
}

/* Offline maps */
.offline-save-section {
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.offline-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--neutral-weak);
  border-radius: var(--radius);
  overflow: hidden;
}
.offline-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius);
  width: 0%;
  transition: width 0.2s;
}
.offline-area-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--surface);
  font-size: 13px;
}
.offline-area-item:hover {
  border-color: var(--accent);
}
.offline-area-info {
  flex: 1;
  min-width: 0;
}
.offline-area-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.offline-area-meta {
  font-size: 11px;
  color: var(--muted);
}

/* My Pins settings page */
.mypins-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 2px;
}
.mypins-tab {
  flex: 1;
  padding: 6px 4px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.15s;
}
.mypins-tab:hover {
  background: var(--surface);
  color: var(--text);
}
.mypins-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.mypins-tab-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}
.mypins-tab.active .mypins-tab-count {
  background: var(--primary-weak);
  color: var(--primary);
}
.mypins-list {
  max-height: 50vh;
  overflow-y: auto;
}
.mypins-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--surface);
}
.mypins-item:hover {
  border-color: var(--primary);
}
.mypins-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.mypins-item-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mypins-item-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mypins-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.mypins-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
}

/* Timeline */
.timeline-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child {
  border-bottom: none;
}
.timeline-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 14px;
}
.timeline-body {
  flex: 1;
  min-width: 0;
}
.timeline-meta {
  font-size: 13px;
  line-height: 1.4;
}
.timeline-author {
  font-weight: 600;
  margin-right: 4px;
}
.timeline-label {
  color: var(--muted);
}
.timeline-detail {
  font-size: 12px;
  color: var(--text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-item-parent {
  color: var(--muted);
  font-size: 11px;
}
.timeline-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.timeline-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  align-self: center;
}
.timeline-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 0;
}
.timeline-nav-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg);
}

/* Pin/KML/Drawing popup redesign */
.popup-wrap {
  position: relative;
  width: calc(100vw - 60px);
  max-width: 500px;
  box-sizing: border-box;
}
/* Normalise pin/drawing popup frame to match KML popup styling */
.leaflet-popup-content-wrapper:has(.popup-wrap) {
  overflow: visible;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.leaflet-popup-content:has(.popup-wrap) {
  margin: 8px 10px;
  overflow: visible;
}
.popup-badges {
  position: absolute;
  top: -14px;
  left: -14px;
  display: flex;
  gap: 3px;
  z-index: 10;
  pointer-events: none;
}
.popup-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: white;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.popup-badge-org {
  background: var(--private);
}
.popup-badge-public {
  background: var(--info);
}
.popup-badge-shared {
  background: var(--info);
}
.popup-badge-private {
  background: var(--private);
}
.popup-title {
  margin: 0 0 4px;
  font-size: 15px;
  padding-top: 14px;
}
.popup-folder-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
  line-height: 1.4;
}
.popup-folder-path .folder-crumb {
  cursor: pointer;
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.15s;
}
.popup-folder-path .folder-crumb:hover {
  opacity: 0.7;
}
.popup-folder-path .folder-sep {
  margin: 0 1px;
  color: var(--border-solid);
}
.popup-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}
.popup-meta {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
}
.popup-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.popup-images img,
.popup-video-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
}
.popup-media-wrap {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 60px;
  cursor: pointer;
}
.popup-media-wrap video,
.popup-media-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
/* Video badge overlay */
.video-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  padding: 1px 3px;
  line-height: 1;
  pointer-events: none;
}
.video-badge-sm {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 3px;
  font-size: 9px;
  padding: 1px 2px;
  line-height: 1;
  pointer-events: none;
}
.comment-video-wrap {
  position: relative;
  display: inline-block;
  max-width: 180px;
  cursor: pointer;
}
.comment-video-wrap video {
  max-width: 180px;
  max-height: 140px;
  border-radius: 8px;
  display: block;
  margin-bottom: 2px;
  object-fit: cover;
}
.gallery-item {
  position: relative;
}
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.edit-pin-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}
/* Lightbox custom video player */
.lightbox-video-wrap {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  min-width: 280px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 8px;
}
.lightbox-video-wrap video {
  width: 100%;
  height: 100%;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  background: #000;
  display: block;
  object-fit: contain;
}
.lightbox-video-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 2;
}
.lightbox-video-loading[hidden] {
  display: none;
}
.lightbox-video-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  z-index: 2;
}
.lightbox-video-bar {
  height: 100%;
  background: #fff;
  border-radius: 0 0 0 8px;
  width: 0%;
  transition: width 0.15s linear;
}
.popup-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.popup-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.popup-action-btn i,
.popup-action-btn svg {
  font-size: 22px;
  width: 22px;
  height: 22px;
}
.popup-action-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.popup-action-btn.action-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
}
.popup-action-btn.action-primary {
  color: var(--primary);
}
.popup-action-btn.action-navigate {
  width: auto;
  padding: 0 12px;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}
.popup-action-btn.action-edit i,
.popup-action-btn.action-edit svg {
  font-size: 18px;
  width: 18px;
  height: 18px;
}
.popup-action-btn.action-danger i,
.popup-action-btn.action-danger svg {
  font-size: 18px;
  width: 18px;
  height: 18px;
}
.popup-action-btn.action-navigate i {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

/* KML info popup updated */
.kml-info-popup .popup-actions {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

/* Responsive */
@media (max-width: 600px) {
  .sidebar {
    width: 100%;
  }
}

/* === Dark Mode Overrides for hardcoded colors === */
[data-theme='dark'] .header-bar,
[data-theme='dark'] .footer-bar {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme='dark'] .header-bar {
  border-bottom: 1px solid var(--border);
}
[data-theme='dark'] .footer-bar {
  border-top: 1px solid var(--border);
}

[data-theme='dark'] .bar-btn:hover,
[data-theme='dark'] .sidebar-footer-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme='dark'] .leaflet-bar a {
  background-color: var(--surface) !important;
  border-color: var(--border) !important;
}
[data-theme='dark'] .leaflet-bar a:hover {
  background-color: var(--bg) !important;
}
[data-theme='dark'] .leaflet-bar {
  box-shadow: var(--shadow) !important;
}

[data-theme='dark'] .sidebar-item-row {
  background: rgba(90, 158, 115, 0.06);
}

[data-theme='dark'] .comment-bubble-mine {
  background: var(--surface);
}

[data-theme='dark'] .layer-group-header {
  color: var(--muted);
}
[data-theme='dark'] .layer-group-header:not(:first-child) {
  border-top-color: var(--border);
}

[data-theme='dark'] .share-inherit-notice {
  background: rgba(196, 160, 112, 0.12);
  border-color: rgba(196, 160, 112, 0.3);
  color: var(--premium);
}

[data-theme='dark'] .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
}
[data-theme='dark'] .leaflet-popup-tip {
  background: var(--surface);
}
[data-theme='dark'] .leaflet-control-layers {
  background: var(--surface) !important;
  color: var(--text);
  border-color: var(--border);
}
[data-theme='dark'] .leaflet-control-layers label {
  color: var(--text);
}

/* Theme toggle in settings */
.theme-toggle-group {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.theme-option {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.theme-option:hover {
  border-color: var(--muted);
}
.theme-option.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.theme-option-icon {
  font-size: 20px;
}
.theme-option-label {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

/* Offline queue badge */
.offline-queue-badge {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: var(--warning, #f59e0b);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  animation: offlineBadgePulse 2s infinite;
}
@keyframes offlineBadgePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Auto-translate: translating indicator */
.translating {
  color: var(--muted, #999) !important;
  font-style: italic;
}

/* ==================== Sidebar Org Page ==================== */
.sidebar-org-page {
  padding-bottom: 8px;
}
.sidebar-org-page-header {
  margin: -4px -12px 0;
  height: 110px;
  overflow: hidden;
  background: var(--primary-weak);
}
.sidebar-org-page-header img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sidebar-org-page-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
}
.sidebar-org-page-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.sidebar-org-page-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}
.sidebar-org-page-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  margin: 4px 0 8px;
  line-height: 1.5;
}
.sidebar-org-page-links {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.sidebar-org-page-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}
.sidebar-org-page-links a:hover {
  text-decoration: underline;
}
.sidebar-org-page-folder {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.sidebar-org-page-folder:hover {
  border-color: var(--accent);
}
.sidebar-org-page-folder-banner {
  width: 72px;
  min-height: 48px;
  object-fit: cover;
  flex-shrink: 0;
}
.sidebar-org-page-folder-info {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.sidebar-org-page-folder-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-org-page-folder-desc {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-org-page-folder > .icon-btn {
  align-self: center;
  flex-shrink: 0;
  margin-right: 4px;
}
.sidebar-org-page-folder > .bulk-check {
  align-self: center;
  flex-shrink: 0;
  margin: 0 2px 0 8px;
}

/* Org logo as folder icon in sidebar list */
.sidebar-org-folder-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 6px;
}
.sidebar-org-folder-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

/* Folder page header (banner + description inside drilled-down folder) */
.sidebar-folder-page-header {
  margin: -4px -12px 8px;
}
.sidebar-folder-page-banner {
  height: 100px;
  overflow: hidden;
  background: var(--primary-weak);
}
.sidebar-folder-page-banner img {
  width: 100%;
  height: 100%;
  display: block;
}
.sidebar-folder-page-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 8px 12px;
}

/* Loading spinner animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Power saving: respect OS-level reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .bar-btn.following i,
  .tracking-banner,
  #btn-route.recording,
  .offline-badge,
  .tabler-spin,
  .comment-spin {
    animation: none !important;
  }
}

/* Power saving: pause decorative animations when tab is hidden */
body.tab-hidden .bar-btn.following i,
body.tab-hidden .tracking-banner,
body.tab-hidden #btn-route.recording,
body.tab-hidden .offline-badge {
  animation-play-state: paused;
}

/* ==================== Detail Modal ==================== */
.detail-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.detail-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.detail-modal {
  background: var(--surface);
  width: min(420px, 94vw);
  max-height: 80vh;
  min-height: 30vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.detail-modal-overlay.open .detail-modal {
  transform: translateY(0);
}

/* Close button */
.detail-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
}
.detail-modal-close:hover {
  background: var(--border);
}

/* Header */
.detail-modal-header {
  padding: 16px 16px 0;
  flex-shrink: 0;
}
.detail-modal-badges {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.detail-modal-title {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  padding-right: 36px;
}
.detail-modal-folder {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}
.detail-modal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.detail-modal-meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

/* Scrollable body */
.detail-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
}

/* Image slider */
.detail-slider-wrap {
  margin: 8px 0 12px;
  position: relative;
}
.detail-slider-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-tertiary);
}
.detail-slide-media {
  position: relative;
  cursor: pointer;
}
.detail-slide-media .detail-slider-img {
  cursor: pointer;
}

/* Centered play button for video slides */
.detail-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  pointer-events: none;
}
.detail-play-btn svg {
  width: 28px;
  height: 28px;
}

/* Slider dots */
.detail-slider-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.detail-slider-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.detail-slider-dot.active {
  background: var(--primary);
}

/* Description */
.detail-description {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-description a {
  color: var(--primary);
}

/* Geometry info */
.detail-geometry-info {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}
.detail-geometry-info i {
  vertical-align: -1px;
}

/* Info view */
.detail-info-content {
  padding: 8px 0;
}
.detail-info-content .info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-info-content .info-row:last-child {
  border-bottom: none;
}

/* Edit view */
.detail-edit-actions {
  padding: 16px 0;
}
.detail-edit-actions .btn {
  font-size: 15px;
  padding: 12px;
}

/* Comments in modal */
.detail-comment-chat {
  max-height: none !important;
  flex: 1;
  min-height: 120px;
}
.detail-modal-body .comment-tabs {
  margin: 0 -16px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
}
.detail-modal-body .comment-input-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

/* Footer */
.detail-modal-footer {
  display: flex;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  padding: 6px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.detail-footer-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.15s;
}
.detail-footer-btn i,
.detail-footer-btn svg {
  font-size: 22px;
  width: 22px;
  height: 22px;
}
.detail-footer-btn:hover,
.detail-footer-btn:active {
  color: var(--primary);
}

/* Highlight selected pin marker above the overlay */
.detail-highlight-marker {
  z-index: 2001 !important;
  filter: brightness(2) drop-shadow(0 0 10px white) drop-shadow(0 0 20px white) drop-shadow(0 0 40px white);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .detail-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
  }
}
