:root {
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #eef2f4;
  color: #18242d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.parcel-app {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  height: 100vh;
}

.app-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #d4dbe1;
  display: flex;
  gap: 18px;
  min-width: 0;
  padding: 0 18px;
  z-index: 2;
}

.home-link {
  color: #126d62;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
}

.title-block p {
  color: #607080;
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  min-height: 0;
}

.parcel-app--resizable .workspace {
  grid-template-columns: minmax(280px, var(--side-panel-width, 380px)) 7px minmax(0, 1fr);
}

.parcel-app--resizable .workspace.is-side-panel-collapsed {
  grid-template-columns: 0 0 minmax(0, 1fr);
}

.parcel-app--resizable .side-panel {
  grid-column: 1;
}

.parcel-app--resizable .workspace-resizer {
  grid-column: 2;
}

.parcel-app--resizable .map-panel {
  grid-column: 3;
}

.side-panel {
  background: #fff;
  border-right: 1px solid #d4dbe1;
  display: grid;
  grid-template-rows: minmax(210px, auto) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.parcel-app--resizable .side-panel {
  grid-template-rows:
    minmax(132px, var(--search-panel-height, 38%))
    7px
    minmax(96px, var(--details-panel-height, 1fr))
    7px
    minmax(132px, 1fr);
}

.parcel-app--resizable .workspace.is-side-panel-collapsed .side-panel {
  border-right: 0;
  pointer-events: none;
  visibility: hidden;
}

.tool-section {
  border-bottom: 1px solid #e2e7eb;
  padding: 16px;
}

.parcel-app--resizable .tool-section {
  min-height: 0;
  overflow: auto;
}

.section-resizer,
.workspace-resizer {
  background: #eef2f4;
  position: relative;
}

.section-resizer {
  border-bottom: 1px solid #d4dbe1;
  border-top: 1px solid #d4dbe1;
  cursor: row-resize;
}

.workspace-resizer {
  border-left: 1px solid #d4dbe1;
  border-right: 1px solid #d4dbe1;
  cursor: col-resize;
}

.section-resizer::before,
.workspace-resizer::before {
  background: #9eabb6;
  border-radius: 999px;
  content: "";
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.section-resizer::before {
  height: 2px;
  width: 34px;
}

.workspace-resizer::before {
  height: 34px;
  width: 2px;
}

.section-resizer:hover,
.section-resizer:focus-visible,
.workspace-resizer:hover,
.workspace-resizer:focus-visible {
  background: #dce8e5;
  outline: none;
}

.workspace.is-side-panel-collapsed .workspace-resizer {
  opacity: 0;
  pointer-events: none;
}

.tool-section h2 {
  color: #41505e;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 10px;
}

.search-mode {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.search-mode label {
  align-items: center;
  border: 1px solid #d9e0e6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 7px;
  min-width: 0;
  padding: 8px 10px;
}

.search-mode input {
  flex: 0 0 auto;
}

.search-mode label:has(input:checked) {
  background: #e8f3f0;
  border-color: #7aa89f;
  color: #126d62;
  font-weight: 700;
}

.search-selects {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.search-selects label,
.search-form label {
  color: #41505e;
  display: grid;
  font-size: 0.84rem;
  font-weight: 700;
  gap: 5px;
}

.search-form {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 72px;
  padding-top: 10px;
}

.search-form label {
  min-width: 0;
}

.search-selects select,
.search-form input {
  border: 1px solid #aeb8c2;
  border-radius: 6px;
  min-width: 0;
  padding: 10px 11px;
  width: 100%;
}

.search-selects select:disabled {
  background: #f1f4f6;
  color: #7b8792;
}

.search-selects .search-toggle {
  align-items: center;
  border: 1px solid #d9e0e6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  font-size: 0.88rem;
  gap: 8px;
  padding: 9px 10px;
}

.search-toggle input {
  flex: 0 0 auto;
}

.search-selects button,
.search-form button {
  background: #126d62;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 11px;
}

.search-selects button:disabled {
  background: #aeb8c2;
  cursor: not-allowed;
}

.status {
  color: #5b6975;
  font-size: 0.84rem;
  line-height: 1.45;
  min-height: 1.45em;
  padding-top: 8px;
}

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

.result-list {
  display: grid;
  gap: 8px;
  max-height: 34vh;
  overflow: auto;
  padding-top: 6px;
}

.result-button {
  background: #f7f9fa;
  border: 1px solid #d9e0e6;
  border-radius: 6px;
  color: #18242d;
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 10px;
  text-align: left;
}

.result-button:hover {
  border-color: #7aa89f;
}

.result-button strong {
  font-size: 0.94rem;
  line-height: 1.35;
}

.result-button span {
  color: #617080;
  font-size: 0.8rem;
  line-height: 1.35;
}

.details-section {
  border-bottom: 0;
  min-height: 0;
  overflow: auto;
}

.parcel-app--resizable .details-section {
  border-bottom: 1px solid #e2e7eb;
}

.style-section {
  min-height: 0;
  overflow: auto;
}

.style-controls {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.style-controls label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: #41505e;
}

.style-controls input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  border: 1px solid #aeb8c2;
  border-radius: 6px;
  cursor: pointer;
}

.style-controls input[type="range"] {
  width: 100%;
}

.style-controls input[type="number"] {
  width: 100%;
  padding: 6px 11px;
  border: 1px solid #aeb8c2;
  border-radius: 6px;
}

.empty-state {
  color: #667482;
  font-size: 0.92rem;
  padding: 12px 0;
}

.empty-state[data-kind="loading"] {
  color: #126d62;
  font-weight: 700;
}

.empty-state[data-kind="error"] {
  color: #b3261e;
}

.details-list {
  display: grid;
  gap: 0;
}

.details-list div {
  border-top: 1px solid #edf0f2;
  display: grid;
  gap: 3px;
  padding: 10px 0;
}

.details-list dt {
  color: #667482;
  font-size: 0.78rem;
  font-weight: 700;
}

.details-list dd {
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.map-panel {
  min-height: 0;
  position: relative;
}

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

.map-status {
  background: rgb(255 255 255 / 92%);
  border: 1px solid #d9e0e6;
  border-radius: 6px;
  box-shadow: 0 8px 22px rgb(20 31 40 / 14%);
  color: #40505e;
  font-size: 0.84rem;
  left: 14px;
  max-width: min(360px, calc(100% - 28px));
  padding: 6px 10px;
  position: absolute;
  top: 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.copy-coords-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.copy-coords-btn:hover {
  transform: scale(1.1);
}

.copy-coords-btn:active {
  transform: scale(0.95);
}

.parcel-app--resizable .map-status {
  left: 58px;
  max-width: min(360px, calc(100% - 72px));
}

.side-panel-toggle {
  align-items: center;
  background: rgb(255 255 255 / 95%);
  border: 1px solid #cfd8df;
  border-radius: 6px;
  box-shadow: 0 8px 22px rgb(20 31 40 / 14%);
  color: #126d62;
  cursor: pointer;
  display: flex;
  font-size: 1.1rem;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  left: 14px;
  line-height: 1;
  padding: 0;
  position: absolute;
  top: 14px;
  width: 34px;
  z-index: 2;
}

.side-panel-toggle:hover,
.side-panel-toggle:focus-visible {
  background: #e8f3f0;
  outline: none;
}

.zoom-level {
  background: rgb(255 255 255 / 95%);
  border: 1px solid #cfd8df;
  border-radius: 6px;
  bottom: 18px;
  box-shadow: 0 8px 22px rgb(20 31 40 / 14%);
  color: #40505e;
  font-size: 0.84rem;
  font-weight: 700;
  left: 14px;
  line-height: 1.2;
  padding: 8px 10px;
  position: absolute;
  z-index: 1;
  white-space: nowrap;
  pointer-events: none;
}

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

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #8ac4ff;
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .parcel-app {
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .app-header {
    gap: 12px;
    padding: 0 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 320px;
  }

  .parcel-app--resizable .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(280px, 38vh);
  }

  .parcel-app--resizable .workspace.is-side-panel-collapsed {
    grid-template-rows: minmax(0, 1fr) 0;
  }

  .workspace-resizer {
    display: none;
  }

  .parcel-app--resizable .map-panel {
    grid-column: 1;
  }

  .parcel-app--resizable .side-panel {
    grid-column: 1;
  }

  .map-panel {
    grid-row: 1;
  }

  .side-panel {
    border-right: 0;
    border-top: 1px solid #d4dbe1;
    grid-row: 2;
    grid-template-rows: minmax(142px, auto) minmax(0, 1fr);
  }

  .parcel-app--resizable .side-panel {
    grid-template-rows:
      minmax(124px, var(--search-panel-height, 40%))
      7px
      minmax(92px, var(--details-panel-height, 1fr))
      7px
      minmax(118px, 1fr);
  }

  .result-list {
    max-height: 118px;
  }
}

.details-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-links {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.map-links.is-hidden {
  display: none;
}

.map-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: transform 0.2s, opacity 0.2s;
}

.map-links a:hover {
  transform: scale(1.1);
  opacity: 0.85;
}

/* Work Badges Styles */
.work-badges-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.work-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  color: white;
}

.work-badge--water {
  background-color: #1e90ff; /* DodgerBlue */
}

.work-badge--irrigation {
  background-color: #00bfff; /* DeepSkyBlue */
}

.work-badge--farmland {
  background-color: #2e8b57; /* SeaGreen */
}

.work-badge-desc {
  font-size: 0.85rem;
  color: #555;
  font-weight: normal;
}

/* Legend Panel Styles */
.legend-panel {
  background: #f7f9fa;
  border: 1px solid #dde4ea;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 15px;
}

.legend-panel h3 {
  font-size: 0.82rem;
  color: #5d6d7e;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.legend-list li {
  display: flex;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 650;
  color: #2c3e50;
}

.legend-color {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  margin-right: 8px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Work Checkboxes Styles */
.work-filter-group {
  margin-bottom: 12px;
}

.filter-group-label {
  display: block;
  font-size: 0.94rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #17202a;
}

.work-checkboxes {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #f7f9fa;
  border: 1px solid #dde4ea;
  border-radius: 6px;
  padding: 8px 12px;
}

.work-checkboxes .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: #2c3e50;
}

.work-checkboxes input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
}

/* ── 筆境界読み込み中スピナー ── */
@keyframes parcel-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.parcel-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(2, 136, 209, 0.25);
  border-top-color: #0288D1;
  border-radius: 50%;
  animation: parcel-spin 0.75s linear infinite;
  flex-shrink: 0;
  vertical-align: middle;
}

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

/* ── ランキングモーダル ── */
.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 #d4dbe1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ranking-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a252c;
}

.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: #5b6975;
  font-weight: 600;
}

.ranking-table-wrapper {
  height: 100%;
  overflow-y: auto;
  border: 1px solid #d4dbe1;
  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 #edf0f2;
  font-size: 0.88rem;
}

.ranking-table th {
  background-color: #f7f9fa;
  color: #41505e;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 #d4dbe1;
}

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

.ranking-table tbody tr:hover {
  background-color: #f0f4f6;
}

.ranking-table tr.is-selected {
  background-color: #e8f4fd !important;
  font-weight: 700;
  color: #0288D1;
}

.ranking-table tr.is-selected td {
  border-top: 1.5px solid #0288D1;
  border-bottom: 1.5px solid #0288D1;
}

.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: #5b6975; }

.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 #d4dbe1;
  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: #41505e;
  position: absolute;
  transform: translateX(-50%);
}

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

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

.timeline-row.is-selected {
  background-color: #e8f4fd !important;
  font-weight: 700;
  color: #0288D1;
}

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

.timeline-info-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a252c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-info-sub {
  font-size: 0.72rem;
  color: #5b6975;
  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%);
}

.share-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-value {
  font-family: monospace;
  font-size: 0.95rem;
}

.copy-share-btn {
  background-color: #f0f4f8;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  color: #126d62;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 8px;
  line-height: 1.4;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.copy-share-btn:hover {
  background-color: #e8f3f0;
  border-color: #7aa89f;
}

.copy-share-btn:active {
  transform: scale(0.95);
}

.copy-share-btn.copied {
  background-color: #126d62;
  border-color: #126d62;
  color: #ffffff;
}
