:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: 'Outfit', var(--font-family);
  
  /* Color Palette */
  --bg-primary: #12181d;
  --bg-secondary: #1a2229;
  --bg-tertiary: #232d37;
  --text-primary: #ffffff;
  --text-secondary: #9aa8b6;
  --text-muted: #5e6f80;
  --accent-color: #126d62;
  --accent-hover: #178b7d;
  
  /* Status Colors */
  --color-sell: #f44336;       /* 赤 */
  --color-rent: #ff9800;       /* オレンジ */
  --color-expand: #2196f3;     /* 青 */
  --color-yobo: #03a9f4;       /* 水色 */
  --color-shrink: #4caf50;     /* 緑 */
  --color-abandoned: #9c27b0;  /* 紫 */
  --color-other: #9e9e9e;      /* グレー */
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* App Container */
.app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Floating Search Header */
.floating-header {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 10;
  max-width: 500px;
  margin: 0 auto;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 34, 41, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-md);
}

.home-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.home-button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0 40px 0 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(18, 109, 98, 0.3);
}

.clear-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.clear-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Suggestions Dropdown */
.search-suggestions {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
}

.suggestion-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.suggestion-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.suggestion-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.suggestion-badge {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  font-weight: 500;
}

/* Map View */
#map-view {
  flex: 1;
  width: 100%;
  height: 100%;
}

.map-loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(26, 34, 41, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px 24px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  z-index: 5;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: opacity 0.3s ease;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Quick Filters */
.quick-filters {
  position: absolute;
  top: 80px;
  left: 16px;
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: auto;
}

/* デスクトップ表示の時はヘッダーに合わせて位置を調整 */
@media (min-width: 769px) {
  .quick-filters {
    left: 50%;
    transform: translateX(-50%);
    top: 80px;
  }
}

.filter-chip {
  background: rgba(26, 34, 41, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.filter-chip::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip-color, #fff);
  opacity: 0.6;
}

.filter-chip[data-type="all"]::before {
  display: none;
}

.filter-chip:hover {
  background: rgba(26, 34, 41, 0.95);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.filter-chip.active::before {
  opacity: 1;
}

/* Bottom Sheet */
.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: transform;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* モバイルでの高さを決定 */
@media (max-width: 768px) {
  .bottom-sheet {
    transform: translateY(100%); /* 初期はJSで制御 */
    max-height: 85%;
  }
}

/* デスクトップではサイドパネル化 */
@media (min-width: 769px) {
  .bottom-sheet {
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 16px;
    right: auto;
    width: 380px;
    border-radius: var(--radius-md);
    transform: none !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .sheet-handle-area {
    display: none !important;
  }
}

.sheet-handle-area {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.sheet-handle-area:active {
  cursor: grabbing;
}

.sheet-bar {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 24px 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

/* Legend Styles */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

.legend-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: transparent;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.legend-checkbox:checked {
  background: var(--accent-color);
  border-color: var(--accent-color);
}

.legend-checkbox:checked::after {
  content: '\2713'; /* Checkmark symbol */
  color: #fff;
  font-size: 11px;
  font-weight: bold;
}

.legend-item:hover .legend-checkbox {
  border-color: rgba(255, 255, 255, 0.4);
}

.legend-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.legend-color {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
}

.legend-pattern-blue {
  background: repeating-linear-gradient(
    45deg,
    rgba(3, 169, 244, 0.4),
    rgba(3, 169, 244, 0.4) 3px,
    rgba(3, 169, 244, 0.8) 3px,
    rgba(3, 169, 244, 0.8) 6px
  );
  border: 1.5px solid #0288d1;
}

.legend-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.legend-item:hover .legend-label {
  color: var(--text-primary);
}

/* Detail Info Styles */
.details-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.detail-chiban {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.9rem;
}

.details-table th, .details-table td {
  padding: 8px 0;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.details-table th {
  width: 100px;
  font-weight: 500;
  color: var(--text-secondary);
}

.details-table td {
  color: var(--text-primary);
  font-weight: 600;
}

.details-table tr:last-child th, .details-table tr:last-child td {
  border-bottom: none;
}

/* Actions */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.action-btn svg {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.action-btn:hover svg {
  color: var(--text-primary);
}

/* Buttons */
.primary-button {
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.panel-meta-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Utilities */
.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Custom styles for ArcGIS Zoom widget in bottom right */
.esri-ui-bottom-right {
  bottom: 80px !important; /* ボトムシートと被らないように調整 */
}

@media (max-width: 768px) {
  .esri-ui-bottom-right {
    bottom: 140px !important; /* モバイルではさらに上にずらす */
  }
}
.esri-zoom {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
.esri-widget--button {
  background-color: rgba(26, 34, 41, 0.95) !important;
  color: var(--text-secondary) !important;
  transition: background-color 0.2s, color 0.2s;
}
.esri-widget--button:hover {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}
.esri-attribution {
  display: none !important; /* attributionを非表示にして地図を広くする */
}

/* Basemap Control */
.basemap-control {
  position: absolute;
  bottom: 20px;
  left: 412px; /* デスクトップでは左側のサイドパネル(380px)のすぐ右側に配置 */
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .basemap-control {
    left: 16px;
    bottom: 140px; /* モバイルでボトムシートが引っ込んだときにズーム等と同様に被らないように上げる */
  }
}

.basemap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(26, 34, 41, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  outline: none;
}

.basemap-btn:hover, .basemap-btn.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

.basemap-menu {
  display: flex;
  gap: 6px;
  background: rgba(26, 34, 41, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 4px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  animation: fadeInRight 0.2s ease forwards;
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.basemap-option {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  outline: none;
}

.basemap-option:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.basemap-option.active {
  background: var(--accent-color);
  color: #fff;
}

/* Inline Filter Buttons in Details Table */
.attribute-filter-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.inline-filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  flex-shrink: 0;
}

.inline-filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.inline-filter-btn.active {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 0 8px rgba(18, 109, 98, 0.4);
}

/* Filter Result Section */
.filter-result-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.filter-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.filter-result-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.filter-result-count {
  font-size: 0.85rem;
  font-weight: 700;
  background-color: rgba(18, 109, 98, 0.2);
  color: #52b788;
  padding: 2px 8px;
  border-radius: 12px;
}

.filter-result-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background-color: rgba(0, 0, 0, 0.2);
}

.filter-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background-color 0.2s;
}

.filter-result-item:last-child {
  border-bottom: none;
}

.filter-result-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.filter-result-item.is-active {
  background-color: rgba(18, 109, 98, 0.15);
  border-left: 3px solid var(--accent-color);
}

.result-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-item-no {
  font-size: 0.75rem;
  font-weight: bold;
  background-color: #5e6f80;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-result-item.is-active .result-item-no {
  background-color: var(--accent-color);
}

.result-item-chiban {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.result-item-dist {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
