/* ============================================================
   沖縄水土里GIS 農道マップ - モダンスタイルシート
   ============================================================ */

:root {
  --font-sans: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --color-primary: #0d5c4e;
  --color-primary-dark: #0a4a3e;
  --color-secondary: #0a4a7a;
  --color-bg: #f0f4f8;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-border: #d8e2ea;
  --color-border-light: #e8eef3;
  --color-text: #1a2530;
  --color-text-muted: #4a5d6e;
  --color-text-faint: #8a9baa;
  --header-height: 54px;
  --side-panel-width: 320px;
  --shadow-sm: 0 1px 4px rgba(10,30,50,0.08);
  --shadow-md: 0 4px 16px rgba(10,30,50,0.10);
  --shadow-lg: 0 8px 32px rgba(10,30,50,0.14);
  --radius: 8px;
  --transition: 0.2s ease;
  --color-ta: #2196f3;
  --color-hata: #ff9800;
  --color-abandoned: #f44336;
  --color-other: #9e9e9e;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
}

input, select, button {
  font: inherit;
}

/* ============================================================
   アプリシェルレイアウト
   ============================================================ */
.parcel-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============================================================
   ヘッダー
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-height);
  padding: 0 16px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.home-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.home-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.title-block {
  flex: 1;
  min-width: 0;
}

.title-block h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-block p {
  font-size: 0.73rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 1px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   メインワークスペース
   ============================================================ */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.workspace.is-side-panel-collapsed .side-panel {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  border-right: none;
}

.workspace.is-side-panel-collapsed .workspace-resizer {
  display: none;
}

/* ============================================================
   サイドパネル
   ============================================================ */
.side-panel {
  width: var(--side-panel-width, 320px);
  min-width: 280px;
  max-width: 500px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}

/* メインタブ */
.sidebar-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-tab-button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  user-select: none;
}

.sidebar-tab-button:hover {
  color: var(--color-primary);
  background-color: rgba(13, 92, 78, 0.04);
}

.sidebar-tab-button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background-color: var(--color-surface);
}

.side-panel::-webkit-scrollbar {
  width: 5px;
}
.side-panel::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.tool-section {
  padding: 16px;
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.tool-section.active {
  display: flex;
}

.tool-section h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 12px;
}

.section-resizer {
  height: 5px;
  background: var(--color-border-light);
  cursor: row-resize;
  transition: background var(--transition);
  flex-shrink: 0;
  z-index: 5;
}

.section-resizer:hover,
.section-resizer:active {
  background: var(--color-primary);
}

/* ============================================================
   地番検索スタイル
   ============================================================ */

/* 検索コンテナ（地番・事業）: パネルの余剰高さを result-list に伝える */
#parcel-search-container,
#business-search-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.search-tabs {
  flex-shrink: 0;
}

.search-mode {
  display: flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.search-mode label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}

.search-mode label:has(input[type="radio"]:checked) {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.search-mode input[type="radio"] {
  display: none;
}

.search-selects {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.search-selects label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.search-selects select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.84rem;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234a5d6e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-selects select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 92, 78, 0.12);
}

.search-selects label:has(select:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.search-selects select:disabled {
  background-color: var(--color-surface-2);
  color: var(--color-text-faint);
  cursor: not-allowed;
  border-color: var(--color-border);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a9baa' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.search-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-top: 4px;
}

.search-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  margin: 0;
  cursor: pointer;
}

.text-search-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.text-search-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.text-search-form input[type="search"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.text-search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 92, 78, 0.12);
}

.text-search-form button {
  width: 100%;
  padding: 8px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}

.text-search-form button:hover {
  background: var(--color-primary-dark);
}

.status {
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 8px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.status[data-kind="error"] {
  color: #dc2626;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--color-surface-2);
}

.result-item {
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--transition), color var(--transition);
}

.result-item:hover {
  background: rgba(13, 92, 78, 0.08);
  color: var(--color-primary);
}

.result-item.is-active {
  background: var(--color-primary);
  color: white;
}

/* ============================================================
   詳細表示セクション
   ============================================================ */
.details-section {
  min-height: 120px;
  overflow-y: auto;
}

.details-section h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-links {
  display: flex;
  gap: 6px;
}

.map-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-2);
  transition: background var(--transition), border-color var(--transition);
}

.map-links a:hover {
  background: var(--color-border-light);
  border-color: var(--color-text-faint);
}

.empty-state {
  font-size: 0.82rem;
  color: var(--color-text-faint);
  text-align: center;
  padding: 30px 16px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  line-height: 1.5;
}

/* 詳細タブ切り替え */
.details-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border-light);
  margin-bottom: 12px;
  gap: 2px;
  flex-shrink: 0;
}

.tab-button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  margin-bottom: -2px;
  user-select: none;
}

.tab-button:hover {
  color: var(--color-primary);
  background-color: rgba(13, 92, 78, 0.04);
}

.tab-button.active {
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

/* 検索タブ切り替え */
.search-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border-light);
  margin-bottom: 12px;
  gap: 2px;
  flex-shrink: 0;
}

.search-tab-button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  margin-bottom: -2px;
  user-select: none;
}

.search-tab-button:hover {
  color: var(--color-primary);
  background-color: rgba(13, 92, 78, 0.04);
}

.search-tab-button.active {
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

/* 詳細データリスト */
.details-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  overflow-y: auto;
}

.details-list::-webkit-scrollbar {
  width: 4px;
}
.details-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.details-list > div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border-light);
}

.details-list > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.details-list > div.highlight-button-row {
  display: block;
  border-bottom: none;
  padding-bottom: 0;
}

.details-list dt {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-faint);
  white-space: nowrap;
}

.details-list dd {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  word-break: break-all;
}

.details-list.is-hidden {
  display: none !important;
}

.inline-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.inline-filter-btn:hover,
.inline-filter-btn.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

.filter-result-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background var(--transition);
}

.filter-result-item:hover {
  background: rgba(13, 92, 78, 0.07);
}

.filter-result-item.is-current {
  background: rgba(13, 92, 78, 0.11);
}

.filter-result-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.filter-result-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.filter-result-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.filter-result-land-use {
  color: var(--color-primary);
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-result-area,
.filter-result-status {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
}

.filter-result-area {
  border-color: #d8e2ea;
  background: #eef2f7;
  color: #475569;
}

.filter-result-status {
  border-color: #bfdbfe;
  background: #dbeafe;
  color: #1d4ed8;
}

.filter-result-status.is-current {
  border-color: #a7f3d0;
  background: #d1fae5;
  color: #047857;
}

.filter-result-address {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-result-list {
  max-height: min(52vh, 560px) !important;
}

/* ============================================================
   表示設定セクション
   ============================================================ */
.style-section {
  background: transparent;
  border-top: none;
  margin-top: 0;
  overflow-y: auto;
}

.style-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 4px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--color-surface-2);
}

.style-group legend {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary);
  padding: 0 6px;
}

.style-controls label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.style-controls select {
  width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.8rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234a5d6e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color var(--transition);
}

.style-controls select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.style-controls input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 1px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--color-surface);
}

.style-controls input[type="range"] {
  width: 110px;
  height: 4px;
  border-radius: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.style-controls input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  margin: 0;
  cursor: pointer;
}

/* ============================================================
   ワークスペースリサイザー
   ============================================================ */
.workspace-resizer {
  width: 5px;
  flex-shrink: 0;
  background: var(--color-border-light);
  cursor: col-resize;
  transition: background var(--transition);
  position: relative;
  z-index: 10;
}

.workspace-resizer:hover,
.workspace-resizer:active {
  background: var(--color-primary);
}

/* ============================================================
   地図パネル
   ============================================================ */
.map-panel {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

.side-panel-toggle {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  z-index: 50;
  width: 24px;
  height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.side-panel-toggle:hover {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.map-status {
  position: absolute;
  top: 16px;
  left: 48px;
  z-index: 50;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-status::before {
  content: "";
  display: none;
  width: 10px;
  height: 10px;
  border: 2px solid var(--color-text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: map-status-spin 0.6s linear infinite;
  flex-shrink: 0;
}

.map-status[data-kind="error"]::before {
  border-color: #dc2626;
  border-top-color: transparent;
}

.map-status.is-updating::before {
  display: inline-block;
}

@keyframes map-status-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.map-status[data-kind="error"] {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.zoom-level {
  position: absolute;
  bottom: 36px;
  right: 58px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
}

/* ============================================================
   ESRIウィジェットカスタマイズ
   ============================================================ */
.esri-ui-bottom-right {
  bottom: 56px !important;
}

.esri-zoom {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--color-border) !important;
}

.esri-widget--button {
  border-radius: 0 !important;
}

.esri-zoom .esri-widget--button:first-child {
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.esri-zoom .esri-widget--button:last-child {
  border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* ============================================================
   レスポンシブデザイン
   ============================================================ */
@media (max-width: 640px) {
  .side-panel {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  .workspace.is-side-panel-collapsed .side-panel {
    transform: translateX(-100%);
    width: var(--side-panel-width) !important;
    overflow: auto;
    transition: transform 0.2s ease;
  }
}

/* ============================================================
   汎用ヘルパー
   ============================================================ */
:focus-visible {
  outline: 3px solid rgba(13, 92, 78, 0.4);
  outline-offset: 2px;
}

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

/* ローディングスピナー */
.parcel-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(13, 92, 78, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: parcel-spin 0.75s linear infinite;
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 6px;
}

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

.parcel-spinner.is-hidden {
  display: none !important;
}

.style-reset-button {
  margin-top: 16px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.style-reset-button:hover {
  background: var(--color-surface-3);
  border-color: var(--color-text-muted);
}

/* ── ランキングモーダル ── */
.ranking-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ranking-modal.is-hidden {
  display: none !important;
}

.ranking-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.ranking-modal-content {
  position: relative;
  background-color: #ffffff;
  border-radius: 8px;
  width: 90%;
  max-width: 700px;
  height: 80%;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  animation: modal-fadeIn 0.25s ease-out;
}

@keyframes modal-fadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ranking-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ranking-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

.ranking-modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  font-weight: bold;
  color: #888888;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.ranking-modal-close:hover {
  color: #333333;
}

.ranking-modal-body {
  flex: 1;
  overflow: hidden;
  padding: 20px;
  position: relative;
}

.ranking-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.ranking-table-wrapper {
  height: 100%;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ranking-table th, 
.ranking-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.88rem;
}

.ranking-table th {
  background-color: var(--color-surface-2);
  color: var(--color-text-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--color-border);
}

.ranking-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s;
}

.ranking-table tbody tr:hover {
  background-color: var(--color-border-light);
}

.ranking-table tr.is-selected {
  background-color: #e1f5fe !important;
  font-weight: 700;
  color: var(--color-secondary);
}

.ranking-table tr.is-selected td {
  border-top: 1.5px solid var(--color-secondary);
  border-bottom: 1.5px solid var(--color-secondary);
}

.rank-badge {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.78rem;
}

.rank-badge-1 { background-color: #ffd700; color: #333333; }
.rank-badge-2 { background-color: #c0c0c0; color: #333333; }
.rank-badge-3 { background-color: #cd7f32; color: #ffffff; }
.rank-badge-other { background-color: #f1f3f4; color: var(--color-text-faint); }

.rank-button {
  background-color: #e1f5fe;
  border: 1px solid #b3e5fc;
  color: #0288d1;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.rank-button:hover {
  background-color: #b3e5fc;
  color: #01579b;
  transform: scale(1.08);
}

.rank-button svg {
  width: 14px;
  height: 14px;
}

/* ── 年表（タイムライン）モーダル ── */
.timeline-chart-container {
  padding: 10px;
  min-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-header-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 8px;
  position: sticky;
  top: 0;
  background-color: #ffffff;
  z-index: 10;
}

.timeline-years-grid {
  display: flex;
  position: relative;
  height: 20px;
  width: 100%;
}

.timeline-year-tick {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  position: absolute;
  transform: translateX(-50%);
}

.timeline-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--color-border-light);
  padding: 8px 0;
  cursor: pointer;
  transition: background-color 0.15s;
}

.timeline-row:hover {
  background-color: #f0f4f6;
}

.timeline-row.is-selected {
  background-color: #e1f5fe !important;
  font-weight: 700;
  color: var(--color-secondary);
}

.timeline-info {
  padding-right: 12px;
  overflow: hidden;
}

.timeline-info-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-info-sub {
  font-size: 0.72rem;
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-bar-container {
  position: relative;
  height: 24px;
  background-color: #f1f3f4;
  border-radius: 12px;
}

.timeline-bar {
  position: absolute;
  height: 18px;
  top: 3px;
  background: linear-gradient(90deg, #2e8b57 0%, #9acd32 100%);
  border-radius: 9px;
  color: #111;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  white-space: nowrap;
  padding: 0 8px;
  overflow: visible;
}

.timeline-bar.is-selected {
  background: linear-gradient(90deg, #0288d1 0%, #26c6da 100%);
}
