:root {
  --bg: #f5f3ef;
  --ink: #1e2428;
  --muted: #667078;
  --line: #d8d3ca;
  --panel: #fffcf6;
  --accent: #0f7a78;
  --accent-2: #b2472f;
  --field: #ffffff;
  --shadow: 0 20px 60px rgba(31, 35, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  min-height: 100vh;
}

.control-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, transparent 47%, rgba(255, 255, 255, 0.72) 48% 52%, transparent 53%),
    linear-gradient(135deg, #0f7a78, #b2472f);
  box-shadow: 0 8px 22px rgba(15, 122, 120, 0.24);
}

h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-section {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: #31383d;
  font-weight: 700;
  font-size: 13px;
}

.accordion-section {
  display: block;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  color: #31383d;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  list-style: none;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.accordion-summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #c9c1b6;
  border-radius: 50%;
  color: var(--muted);
  background: #f3ece2;
  font-weight: 800;
}

.accordion-section[open] .accordion-summary {
  margin-bottom: 10px;
}

.accordion-section[open] .accordion-summary::after {
  content: "-";
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.tooltip {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 1px solid #b9b1a5;
  border-radius: 50%;
  background: #f3ece2;
  color: #485158;
  cursor: help;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.tooltip::before,
.tooltip::after {
  display: none;
}

.tooltip:hover,
.tooltip:focus {
  border-color: var(--accent);
  background: #e2f1ee;
  color: var(--accent);
  outline: none;
}

.tooltip:hover::before,
.tooltip:hover::after,
.tooltip:focus::before,
.tooltip:focus::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip-bubble {
  position: fixed;
  z-index: 100;
  max-width: min(270px, calc(100vw - 24px));
  padding: 9px 10px;
  border-radius: 7px;
  background: #263035;
  color: #fff;
  box-shadow: 0 12px 34px rgba(31, 35, 38, 0.22);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

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

.tooltip-bubble::before {
  content: "";
  position: absolute;
  top: -7px;
  left: var(--arrow-x, 18px);
  border-right: 7px solid transparent;
  border-bottom: 7px solid #263035;
  border-left: 7px solid transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfc8be;
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

input {
  height: 34px;
  padding: 6px 8px;
}

select {
  height: 34px;
  padding: 6px 28px 6px 8px;
}

.preset-field {
  margin-bottom: 10px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-field {
  align-content: end;
}

.inspection-layout {
  display: grid;
  gap: 11px;
}

.inspection-main {
  max-width: 170px;
}

.fence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 72px;
  gap: 9px;
  align-items: end;
}

.fence-row input[type="number"] {
  min-width: 0;
}

.fence-row .check-field {
  justify-items: start;
}

.mini-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.mini-actions button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

textarea {
  min-height: 132px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 120, 0.12);
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.actions {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 0 -2px 8px;
  padding: 10px 2px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

button#runButton {
  color: #fff;
  background: var(--accent);
}

button.secondary {
  color: var(--ink);
  background: #e8e2d8;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.toolbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 243, 239, 0.88);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, auto));
  gap: 12px;
}

.stat-strip div {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.55);
}

.stat-strip span {
  display: block;
  font-weight: 800;
  font-size: 18px;
}

.stat-strip small {
  color: var(--muted);
  font-size: 11px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.legend b {
  display: block;
  width: 140px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #177e89, #f2c14e, #b2472f);
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  padding: 18px;
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  box-shadow: var(--shadow);
}

.inspection-panel {
  position: absolute;
  top: 32px;
  right: 32px;
  z-index: 10;
  width: min(430px, calc(100% - 64px));
  max-height: min(330px, calc(100% - 64px));
  overflow: auto;
  border: 1px solid rgba(207, 200, 190, 0.95);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.96);
  box-shadow: 0 18px 46px rgba(31, 35, 38, 0.18);
}

.inspection-panel.is-collapsed {
  width: 180px;
  max-height: none;
  overflow: hidden;
}

.inspection-panel.is-collapsed .inspection-tabs,
.inspection-panel.is-collapsed .inspection-warning,
.inspection-panel.is-collapsed .inspection-table {
  display: none;
}

.histogram-panel {
  position: absolute;
  top: 86px;
  right: 52px;
  z-index: 12;
  width: min(560px, calc(100% - 64px));
  overflow: hidden;
  border: 1px solid rgba(207, 200, 190, 0.95);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.98);
  box-shadow: 0 22px 58px rgba(31, 35, 38, 0.22);
}

.histogram-panel.is-hidden {
  display: none;
}

.inspection-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(235, 229, 220, 0.92);
  cursor: move;
  user-select: none;
}

.panel-tools {
  display: flex;
  gap: 6px;
}

.inspection-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 10px 0;
}

.inspection-tabs button {
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid #d4cdc3;
  border-radius: 6px;
  color: #485158;
  background: #f6f1e9;
  font-size: 12px;
}

.inspection-tabs button.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.inspection-panel-header h2 {
  margin: 0;
  color: #31383d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  border: 1px solid #c9c1b6;
  border-radius: 6px;
  color: var(--muted);
  background: #fffcf6;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus {
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 122, 120, 0.12);
}

.details {
  display: grid;
  grid-template-columns: minmax(220px, 0.34fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.74);
}

.status-stack {
  display: grid;
  gap: 10px;
}

#status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 7px;
  font-size: 12px;
}

.inspection-table {
  font-size: 11px;
}

.inspection-panel .inspection-table {
  min-width: 420px;
}

.inspection-warning {
  margin: 8px 10px 0;
  padding: 7px 8px;
  border: 1px solid #e0c893;
  border-radius: 6px;
  color: #705423;
  background: #fff6d8;
  font-size: 11px;
  line-height: 1.45;
}

.histogram-button {
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid #c9c1b6;
  border-radius: 6px;
  color: #31383d;
  background: #fffcf6;
  font-size: 11px;
  white-space: nowrap;
}

.histogram-button:hover,
.histogram-button:focus {
  color: #fff;
  background: var(--accent);
  outline: none;
}

.histogram-body {
  padding: 10px;
}

.histogram-meta,
.histogram-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.histogram-meta {
  margin-bottom: 8px;
}

.histogram-note {
  margin-top: 8px;
}

#histogramCanvas {
  display: block;
  width: 100%;
  height: 260px;
  min-height: 0;
  border-radius: 6px;
  box-shadow: none;
}

th,
td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th {
  color: #59636b;
  background: #ebe5dc;
  font-weight: 700;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}


.brand-copy {
  min-width: 0;
  flex: 1;
}

.help-button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #c9c1b6;
  border-radius: 6px;
  color: #31383d;
  background: #e8e2d8;
  font-size: 12px;
  white-space: nowrap;
}

.help-button:hover,
.help-button:focus {
  color: #fff;
  background: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 122, 120, 0.12);
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(30, 36, 40, 0.44);
}

.modal-backdrop.is-hidden {
  display: none;
}

.method-modal {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid rgba(207, 200, 190, 0.98);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 76px rgba(31, 35, 38, 0.3);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(235, 229, 220, 0.94);
}

.modal-header h2 {
  margin: 0;
  color: #31383d;
  font-size: 18px;
  letter-spacing: 0;
}

.method-modal-body {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding: 18px;
}

.method-modal-body section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.method-modal-body section:first-child {
  border-top: 0;
  padding-top: 0;
}

.method-modal-body h3 {
  margin: 0 0 8px;
  color: #31383d;
  font-size: 14px;
}

.method-modal-body p,
.method-modal-body li {
  color: #485158;
  font-size: 13px;
  line-height: 1.75;
}

.method-modal-body p {
  margin: 0 0 8px;
}

.method-modal-body p:last-child {
  margin-bottom: 0;
}

.method-modal-body ul {
  margin: 0;
  padding-left: 20px;
}

.method-modal-body li + li {
  margin-top: 5px;
}
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar,
  .details {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .inspection-panel {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 12px;
  }

  .histogram-panel {
    position: static;
    width: 100%;
    margin-top: 12px;
  }

  .inspection-panel-header {
    cursor: default;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .grid.two,
  .fence-row,
  .stat-strip {
    grid-template-columns: 1fr;
  }

  .inspection-main {
    max-width: none;
  }

  .details {
    grid-template-columns: 1fr;
    overflow-x: auto;
  }

  .inspection-panel .inspection-table {
    min-width: 430px;
  }

  #histogramCanvas {
    height: 230px;
  }
}


