* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #1f2933;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", sans-serif;
  overflow: hidden;
}

body:not(.share-page) {
  padding-top: 104px;
}

button,
select,
input {
  font: inherit;
}

button,
.file-button,
.open-editor {
  border: 1px solid #c8d0d8;
  border-radius: 6px;
  background: #fff;
  color: #1f2933;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.file-button:hover,
.open-editor:hover {
  background: #edf2f7;
}

select {
  width: 100%;
  border: 1px solid #c8d0d8;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  border: 1px solid #c8d0d8;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  color: #1f2933;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: #52616f;
  font-size: 12px;
  font-weight: 700;
}

.control-with-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid #9ca3af;
  border-radius: 999px;
  color: #6b7280;
  font-size: 12px;
  font-style: italic;
  font-weight: 700;
  cursor: help;
}

.info-icon .tooltip {
  display: none;
  position: absolute;
  top: 30px;
  right: 0;
  z-index: 20;
  width: 300px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.6;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.info-icon .tooltip b {
  color: #93c5fd;
}

.info-icon:hover .tooltip,
.info-icon:focus .tooltip {
  display: block;
}

.brush-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.brush-label {
  margin-top: 0;
}

.brush-control .help-text {
  margin-top: 2px;
}

.brush-count {
  margin-top: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  color: #52616f;
  display: inline-flex;
  width: fit-content;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 16px;
  height: 100%;
  padding: 16px;
}

.share-shell {
  height: 100vh;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.chart-pane,
.map-pane,
.control-panel,
.dvz-sidebar {
  background: #fff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  min-height: 0;
  overflow: hidden;
}

.chart-pane,
.map-pane {
  display: flex;
  flex-direction: column;
}

.chart-pane {
  position: relative;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e6ebf0;
}

.pane-header.compact {
  align-items: center;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 15px;
}

p {
  margin: 4px 0 0;
}

#app-subtitle,
#map-caption,
.help-text,
.source-line {
  color: #6b7785;
  font-size: 12px;
  line-height: 1.5;
}

.source-line:empty {
  display: none;
}

.counter {
  flex: 0 0 auto;
  border: 1px solid #d9e0e7;
  border-radius: 999px;
  padding: 6px 10px;
  color: #52616f;
  font-size: 12px;
  font-weight: 700;
}

.parallel-chart,
.map-frame {
  flex: 1;
  min-height: 0;
}

.parallel-chart {
  position: relative;
  padding: 8px 10px 6px;
}

.parallel-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis path,
.axis line {
  stroke: #9aa7b3;
  shape-rendering: crispEdges;
}

.axis text {
  fill: #52616f;
  font-size: 10px;
}

.axis-title {
  fill: #1f2933;
  font-size: 11px;
  font-weight: 700;
}

.pc-line {
  fill: none;
  stroke: #2f80c0;
  stroke-width: 1;
  stroke-opacity: 0.16;
}

.pc-line.is-selected {
  stroke: #0b6aa8;
  stroke-opacity: 0.52;
  stroke-width: 1.2;
}

.brush .selection {
  fill: #2f80c0;
  fill-opacity: 0.16;
  stroke: #0b6aa8;
}

.map-frame {
  position: relative;
  padding: 8px;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#map:active {
  cursor: grabbing;
}

.map-area {
  stroke: #fff;
  stroke-width: 0.8;
}

.map-area.is-muted {
  fill: #eef2f5;
}

.map-zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
}

.map-zoom-controls button {
  min-width: 34px;
  border: 0;
  border-right: 1px solid #d9e0e7;
  border-radius: 0;
  background: transparent;
  padding: 7px 10px;
  color: #1f2933;
  font-size: 13px;
  font-weight: 700;
  pointer-events: auto;
}

.map-zoom-controls button:last-child {
  border-right: 0;
}

.map-zoom-controls button:hover {
  background: #edf2f7;
}

.legend {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  gap: 3px;
  align-items: center;
}

.legend-swatch {
  height: 10px;
  border-radius: 2px;
}

.legend-label {
  grid-column: 1 / -1;
  color: #6b7785;
  font-size: 11px;
  text-align: right;
}

.dvz-sidebar {
  display: flex;
  width: 24rem;
  min-width: 0;
  flex-direction: column;
  border-left: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  overflow-x: hidden;
}

.sidebar-tabs {
  flex: 0 0 auto;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-tab-select-wrap {
  display: none;
  padding: 16px 20px 12px;
}

.sidebar-tab-select {
  appearance: none;
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  padding: 8px 32px 8px 12px;
  font-size: 14px;
}

.sidebar-tab-list {
  display: flex;
}

.sidebar-tab {
  flex: 1 1 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: #fff;
  padding: 12px 8px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-tab:hover {
  background: #fff;
  color: #374151;
  border-bottom-color: #d1d5db;
}

.border-indigo-500 {
  border-bottom-color: #6366f1 !important;
}

.border-transparent {
  border-bottom-color: transparent !important;
}

.text-indigo-600 {
  color: #4f46e5 !important;
}

.text-gray-500 {
  color: #6b7280 !important;
}

.sidebar-panels {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-panel {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-panel.hidden,
.hidden {
  display: none !important;
}

.sidebar-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-panel-footer {
  flex: 0 0 auto;
  border-top: 1px solid #e5e7eb;
  padding: 16px 20px;
}

.control-panel {
  overflow: auto;
}

.panel-section {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.panel-section h2 {
  margin-bottom: 12px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.file-button {
  display: inline-flex;
  margin-top: 12px;
}

.file-button input {
  display: none;
}

#sample-btn {
  margin-left: 8px;
}

.button-grid,
.button-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.button-grid {
  grid-template-columns: 1fr 1fr;
}

.button-stack {
  grid-template-columns: 1fr;
}

.button-stack button,
.sidebar-panel-footer button {
  width: 100%;
}

.primary-button {
  border-color: #111827;
  background: #111827;
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: #374151;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  max-width: 360px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #17212b;
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.share-page .control-panel {
  display: block;
}

.share-controls .panel-section {
  border-bottom: 0;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  body:not(.share-page) {
    padding-top: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .workspace {
    grid-template-rows: 360px 460px;
  }

  .dvz-sidebar {
    width: 100%;
  }

  .sidebar-tab-select-wrap {
    display: block;
  }

  .sidebar-tab-list {
    display: none;
  }
}
