:root {
  color-scheme: light;
  --primary: #0f6cbd;
  --primary-hover: #0958b5;
  --primary-soft: #eaf3fb;
  --surface: #ffffff;
  --background: #f5f7f9;
  --border: #dfe4e8;
  --border-strong: #cbd3d9;
  --text: #17202a;
  --muted: #66737f;
  --quiet: #8a97a2;
  --danger: #dc4545;
  --focus: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 44, 0.07);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--surface);
}

body {
  margin: 0;
  height: 100%;
  min-width: 320px;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="file"],
label[for] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--focus) 70%, white);
  outline-offset: 2px;
}

button {
  min-height: 44px;
}

.app {
  position: fixed;
  inset: 104px 0 0;
  display: flex;
  min-height: 0;
  overflow: clip;
  background: var(--surface);
}

.main-area {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: clip;
}

.tool-intro {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--primary);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
.chart-option strong {
  font-family: "IBM Plex Sans JP", "Noto Sans JP", sans-serif;
}

h1 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.tool-intro__title {
  min-width: 0;
}

.data-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.13);
}

.data-summary.is-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 69, 69, 0.13);
}

.chart-switcher {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  margin: 8px 16px 0;
  padding: 7px 8px;
  border-radius: 10px;
  background: #eef0f4;
}

.control-label {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.chart-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.chart-option:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
}

.chart-option.is-active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 32, 44, 0.12);
}

.chart-option-icon {
  position: relative;
  flex: 0 0 20px;
  width: 20px;
  height: 16px;
  overflow: hidden;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.8;
}

.chart-option-icon i {
  position: absolute;
  display: block;
  border: 1px solid currentColor;
}

.icon-treemap i:nth-child(1) { inset: -1px 54% 42% -1px; }
.icon-treemap i:nth-child(2) { inset: 54% 54% -1px -1px; }
.icon-treemap i:nth-child(3) { inset: -1px -1px 58% 50%; }
.icon-treemap i:nth-child(4) { inset: 46% -1px -1px 50%; }
.icon-icicle i:nth-child(1) { inset: -1px 73% -1px -1px; }
.icon-icicle i:nth-child(2) { inset: -1px 42% 46% 24%; }
.icon-icicle i:nth-child(3) { inset: 50% 42% -1px 24%; }
.icon-icicle i:nth-child(4) { inset: -1px -1px -1px 55%; }
.icon-radial,
.icon-sunburst {
  border-radius: 50%;
}
.icon-radial::before,
.icon-radial::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 12px;
  height: 1px;
  background: currentColor;
  content: "";
  transform-origin: left center;
  transform: rotate(36deg);
}
.icon-radial::after { transform: rotate(144deg); }
.icon-radial i,
.icon-sunburst i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}
.icon-radial i:nth-child(1) { top: 6px; left: 8px; }
.icon-radial i:nth-child(2) { top: 1px; right: 3px; }
.icon-radial i:nth-child(3) { right: 2px; bottom: 2px; }
.icon-radial i:nth-child(4) { left: 2px; bottom: 3px; }
.icon-sunburst i:nth-child(1) {
  inset: 3px;
  width: auto;
  height: auto;
  border-radius: 50%;
  background: transparent;
}
.icon-sunburst i:nth-child(2) {
  inset: 6px;
  width: auto;
  height: auto;
  border-radius: 50%;
  background: currentColor;
}

.sidebar {
  display: flex;
  flex: 0 0 384px;
  flex-direction: column;
  width: 384px;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.panel-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-tabs button {
  position: relative;
  min-height: 64px;
  padding: 0 2px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
}

.panel-tabs button[aria-selected="true"] {
  color: var(--primary);
  font-weight: 700;
  background: var(--surface);
}

.panel-tabs button[aria-selected="true"]::after {
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  content: "";
}

.settings-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
}

.settings-panel[hidden] {
  display: none;
}

.panel-heading,
.section-title-row,
.range-label,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2,
.section-title-row h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.text-button {
  min-height: 32px;
  padding: 4px 6px;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover {
  text-decoration: none;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 12px;
  border: 1px dashed #aab8c4;
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong,
.drop-zone small {
  display: block;
}

.drop-zone strong {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 0.84rem;
}

.drop-zone small {
  font-size: 0.68rem;
}

.drop-icon {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 1.25rem;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--quiet);
  font-size: 0.65rem;
}

.section-divider::before,
.section-divider::after {
  height: 1px;
  flex: 1;
  background: var(--border);
  content: "";
}

.field-label,
.range-label label {
  display: block;
  margin-bottom: 8px;
  color: var(--quiet);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field-help {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.55;
}

textarea,
input[type="text"],
input[type="url"],
select {
  width: 100%;
  min-height: 37px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  font-size: 0.875rem;
}

textarea,
input[type="text"],
input[type="url"] {
  padding: 8px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

#data-input {
  min-height: 160px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  white-space: pre;
}

select {
  height: 38px;
  min-height: 38px;
  padding: 8px 34px 8px 12px;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.65rem;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  transition: filter 150ms ease, background 150ms ease;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.secondary-button {
  border: 1px solid var(--border-strong);
  color: #34414d;
  background: #fff;
}

.primary-button:hover,
.secondary-button:hover {
  filter: brightness(0.88);
}

.secondary-button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.75rem;
}

.mapping-section {
  margin: 0;
  padding: 0;
}

.section-heading {
  margin: 20px -20px 16px;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}

.section-heading h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.format-badge {
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--primary);
  background: var(--primary-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 700;
}

.hierarchy-fields {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.hierarchy-field {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 5px;
}

.level-number {
  color: var(--quiet);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  text-align: center;
}

.reorder-button {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
}

.reorder-button:hover {
  color: var(--primary);
  border-color: #aaccea;
  background: var(--primary-soft);
}

.reorder-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.control-group + .control-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.range-label {
  margin-bottom: 7px;
}

.range-label label {
  margin-bottom: 0;
}

.range-label output {
  color: var(--primary);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.67rem;
}

input[type="range"] {
  width: 100%;
  height: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.switch-row + .switch-row {
  border-top: 1px solid #edf0f2;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  margin-bottom: 2px;
  color: #38444f;
  font-size: 0.6875rem;
}

.switch-row small {
  color: var(--muted);
  font-size: 0.625rem;
  line-height: 1.35;
}

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch-row i {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #bec7ce;
  transition: background 150ms ease;
}

.switch-row i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 150ms ease;
}

.switch-row input:checked + i {
  background: var(--primary);
}

.switch-row input:checked + i::after {
  transform: translateX(16px);
}

.switch-row input:focus-visible + i {
  outline: 2px solid color-mix(in srgb, var(--focus) 70%, white);
  outline-offset: 2px;
}

.palette-preview {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  height: 18px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.chart-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 4px 12px 4px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.breadcrumb-button {
  position: relative;
  min-height: 36px;
  padding: 0 19px 0 5px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  white-space: nowrap;
}

.breadcrumb-button::after {
  position: absolute;
  top: 9px;
  right: 6px;
  color: #b0bac2;
  content: "›";
  font-size: 1rem;
}

.breadcrumb-button:last-child {
  color: var(--text);
  font-weight: 700;
  pointer-events: none;
}

.breadcrumb-button:last-child::after {
  display: none;
}

.breadcrumb-button:hover {
  color: var(--primary);
  text-decoration: underline;
}

.icon-button {
  display: grid;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--muted);
  background: #fff;
  font-size: 1.1rem;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.annotation-block {
  flex: 0 0 auto;
  padding: 12px 20px 0;
}

.annotation-block:has(h2:empty):has(p:empty) {
  display: none;
}

.annotation-block h2 {
  margin-bottom: 4px;
  font-size: 1.15rem;
}

.annotation-block p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.chart-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
  font-family: "Noto Sans JP", "Hiragino Sans", sans-serif;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 32px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state > span {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 1.8rem;
}

.empty-state h2 {
  margin-bottom: 7px;
  color: var(--text);
  font-size: 1rem;
}

.empty-state p {
  max-width: 380px;
  margin-bottom: 0;
  font-size: 0.76rem;
  line-height: 1.7;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 280px;
  padding: 9px 11px;
  border: 1px solid rgba(19, 31, 43, 0.15);
  border-radius: 8px;
  color: #fff;
  background: rgba(19, 31, 43, 0.94);
  box-shadow: 0 6px 18px rgba(18, 31, 44, 0.16);
  font-size: 0.7rem;
  line-height: 1.5;
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: #d8e0e6;
}

.chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 18px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.68rem;
}

.chart-footer p {
  margin-bottom: 0;
}

.chart-footer a {
  color: var(--primary);
  text-decoration: underline;
}

.chart-footer a:hover {
  text-decoration: none;
}

.export-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.export-actions .primary-button,
.export-actions .secondary-button {
  width: 100%;
  gap: 8px;
}

.site-link {
  flex: 0 0 28px;
  padding: 7px 16px;
  color: var(--quiet);
  font-size: 0.62rem;
  text-align: center;
}

.site-link a {
  color: inherit;
  text-decoration: none;
}

.site-link a:hover {
  color: var(--muted);
  text-decoration: underline;
}

.node {
  cursor: pointer;
}

.node:focus-visible {
  outline: none;
}

.node:focus-visible .focus-ring {
  stroke: var(--focus);
  stroke-width: 2px;
}

.node-label {
  fill: #111827;
  pointer-events: none;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.node-value {
  opacity: 0.76;
}

.radial-link {
  fill: none;
  stroke: #c9d2d9;
  stroke-opacity: 0.9;
}

.radial-node circle {
  stroke: #fff;
  stroke-width: 1.5px;
}

.radial-node text {
  fill: #111827;
  font-size: 11px;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.center-control {
  cursor: pointer;
}

.center-control circle {
  fill: #fff;
  stroke: var(--border-strong);
  stroke-width: 1.5px;
}

.center-control text {
  fill: var(--primary);
  font-weight: 700;
  text-anchor: middle;
}

@media (max-width: 1100px) {
  .app {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .main-area {
    min-height: 720px;
  }

  .sidebar {
    width: 100%;
    min-height: 620px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .settings-panel {
    min-height: 540px;
  }

  .chart-stage,
  #chart {
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  .tool-intro {
    gap: 8px;
    padding-inline: 12px;
  }

  .data-summary {
    white-space: normal;
  }

  .chart-switcher {
    overflow-x: auto;
    margin-inline: 10px;
    scrollbar-width: thin;
  }

  .chart-option {
    flex: 0 0 auto;
  }

  .main-area {
    min-height: 680px;
  }

  .chart-stage,
  #chart {
    min-height: 450px;
  }
}

@media (max-width: 480px) {
  .tool-intro {
    min-height: 54px;
    padding: 6px 8px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 0.86rem;
  }

  .data-summary {
    max-width: 52%;
    font-size: 0.62rem;
  }

  .control-label {
    display: none;
  }

  .chart-option {
    padding-inline: 8px;
    font-size: 0.66rem;
  }

  .settings-panel {
    padding: 16px 14px;
  }

  .panel-tabs button {
    font-size: 0.7rem;
  }

  .input-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .secondary-button.compact {
    width: 100%;
  }

  .main-area {
    min-height: 640px;
  }

  .chart-stage,
  #chart {
    min-height: 420px;
  }

  .chart-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
