:root {
  color-scheme: dark;
  --bg: #10131a;
  --panel: #191e29;
  --panel-hover: #222a39;
  --text: #f5f7fb;
  --muted: #a8b0c0;
  --line: #30394a;
  --accent: #8ee5bd;
  --accent-strong: #4fcf98;
  --danger: #ff9b9b;
  font-family: "Noto Sans JP", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background: radial-gradient(circle at top right, #1c2838 0, var(--bg) 42rem);
  color: var(--text);
}

.container {
  width: min(100% - 32px, 1060px);
  margin: 0 auto;
  padding: 56px 0 80px;
}

.inference-page { width: min(100% - 32px, 1440px); }

.menu-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.page-header { margin-bottom: 32px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .16em; margin: 0 0 12px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(30px, 6vw, 52px); letter-spacing: -.04em; margin-bottom: 12px; }
.page-header > p:last-child { color: var(--muted); line-height: 1.8; }

.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.menu-card {
  display: block;
  min-height: 260px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(25, 30, 41, .9);
  color: inherit;
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.menu-card:hover, .menu-card:focus-visible { border-color: var(--accent-strong); background: var(--panel-hover); transform: translateY(-3px); }
.menu-card__number { color: var(--accent); font-size: 13px; font-weight: 700; }
.menu-card h2 { margin: 42px 0 12px; font-size: 24px; }
.menu-card p { min-height: 54px; color: var(--muted); line-height: 1.7; }
.menu-card__link { display: inline-block; margin-top: 16px; color: var(--accent); font-weight: 700; }

.back-link { display: inline-block; margin-bottom: 56px; color: var(--muted); text-decoration: none; }
.back-link:hover, .back-link:focus-visible { color: var(--accent); }
.tool-panel, .result-panel { padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: rgba(25, 30, 41, .92); }
.tool-panel { margin-bottom: 20px; }
label { display: block; margin-bottom: 10px; font-weight: 700; }
input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f131a;
  color: var(--text);
  font-size: 18px;
  letter-spacing: .12em;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.7; }
button {
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  background: var(--accent-strong);
  color: #08120e;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}
button:hover, button:focus-visible { background: var(--accent); }
.button-secondary { background: #2b3546; color: var(--text); white-space: nowrap; }
.button-secondary:hover, .button-secondary:focus-visible { background: #3c4b63; }
.button-danger { background: #55333d; color: #ffd7dc; }
.button-danger:hover, .button-danger:focus-visible { background: #713d4b; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.data-actions + .message { min-height: 0; margin: 0 0 20px; color: var(--accent); font-size: 13px; }
.text-output-panel { margin-top: 20px; }
.text-output-panel textarea { width: 100%; min-height: 130px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f131a; color: var(--text); font: inherit; line-height: 1.7; resize: vertical; }
.text-output-panel textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-output-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.text-output-actions .hint { margin: 0; color: var(--accent); }
.bulk-monster-dialog { width: min(100% - 32px, 520px); padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); }
.bulk-monster-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.bulk-monster-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.bulk-monster-dialog textarea { width: 100%; min-height: 220px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f131a; color: var(--text); font: inherit; line-height: 1.7; resize: vertical; }
.bulk-monster-dialog textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.equipment-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.equipment-empty { min-height: 1px; }
.equipment-row { display: grid; grid-template-columns: 70px max-content minmax(0, 1fr); align-items: start; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #0f131a; }
.equipment-row label { margin: 0; font-size: 13px; color: var(--muted); }
.equipment-name { padding: 10px 0; color: var(--text); font-weight: 700; white-space: nowrap; }
.equipment-filter-toggle { display: flex; align-items: center; gap: 8px; }
.equipment-filter-toggle input { width: auto; padding: 0; }
.equipment-fixed-select { width: max-content; padding: 9px 10px; font-size: 13px; letter-spacing: normal; }
.equipment-attributes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.equipment-attribute { display: flex; align-items: center; gap: 3px; margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.equipment-attribute input { width: auto; padding: 0; }
.condition-mode-toggle { margin: 4px 0 20px; }
.condition-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.condition-heading label { margin: 0; }
.condition-heading .condition-mode-toggle { margin: 0; padding: 8px 12px; font-size: 13px; }
.attribute-picker { display: flex; gap: 10px; }
select { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #0f131a; color: var(--text); font: inherit; }
select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.attribute-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.attribute-rate-filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.attribute-rate-filter { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.attribute-rate-filter input { margin-top: 6px; padding: 9px 10px; font-size: 14px; letter-spacing: normal; }
.attribute-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: #202838; color: var(--text); font-size: 14px; }
.attribute-button:hover, .attribute-button:focus-visible { border-color: var(--accent-strong); background: #2c4050; color: var(--accent); }
.attribute-checkboxes { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.attribute-checkbox { position: relative; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 64px; margin-bottom: 0; padding: 12px 10px; border: 1px solid var(--line); border-radius: 12px; background: #0f131a; cursor: pointer; white-space: nowrap; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.attribute-checkbox span { display: inline-block; width: auto; white-space: nowrap; }
.attribute-checkbox:has(input:checked) { border-color: var(--accent-strong); background: #19382e; color: var(--accent); }
.attribute-checkbox input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent-strong); }
.attribute-checkbox .attribute-tooltip { position: absolute; z-index: 2; top: calc(100% + 8px); left: 50%; display: block; width: max-content; max-width: min(280px, 90vw); padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #252d3b; color: var(--text); box-shadow: 0 8px 20px rgba(0, 0, 0, .28); font-size: 12px; font-weight: 400; line-height: 1.6; white-space: normal; text-align: left; pointer-events: none; opacity: 0; visibility: hidden; transform: translate(-50%, -4px); transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
.attribute-checkbox:hover .attribute-tooltip, .attribute-checkbox:focus-within .attribute-tooltip { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.attribute-chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 12px; margin-top: 12px; }
.attribute-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 9px 8px 14px; border: 1px solid #3c6e5a; border-radius: 999px; background: #19382e; color: var(--accent); font-size: 14px; }
.attribute-chip__remove { padding: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.attribute-chip__remove:hover, .attribute-chip__remove:focus-visible { background: transparent; color: var(--text); }
.message { margin: 18px 0 0; }
.message--error { color: var(--danger); }
.result-panel h2 { margin-bottom: 20px; font-size: 20px; }
.result-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.result-list li { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.result-list li:last-child { border-bottom: 0; }
.result-value { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 800; }
.result-list li.result-item--stacked { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: center; }
.result-item__heading { display: flex; justify-content: flex-start; gap: 16px; align-items: center; }
.result-rank { color: var(--accent); font-weight: 800; white-space: nowrap; }
.result-details { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 24px; margin-top: 0; color: var(--muted); font-size: 13px; }
.result-details > span { white-space: nowrap; }
.result-details__selected { color: var(--danger); }
.result-note { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.inference-actions { justify-content: flex-start; }
.inference-table-wrap { overflow: visible; border: 1px solid var(--line); border-radius: 12px; }
.inference-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; }
.inference-table th, .inference-table td { padding: 8px 3px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.inference-table thead th { padding: 12px 8px; background: #222a39; color: var(--muted); font-size: 13px; }
.inference-table thead th:not(:first-child):not(:last-child) { position: relative; cursor: help; }
.inference-table thead th:not(:first-child):not(:last-child):focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.inference-attribute-tooltip { position: absolute; z-index: 3; top: calc(100% + 7px); left: 50%; display: grid; gap: 3px; width: max-content; max-width: 180px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #252d3b; color: var(--text); box-shadow: 0 8px 20px rgba(0, 0, 0, .3); font-size: 11px; font-weight: 400; line-height: 1.5; text-align: left; pointer-events: none; opacity: 0; visibility: hidden; transform: translate(-50%, -4px); transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
.inference-attribute-tooltip span:first-child { color: var(--accent); }
.inference-attribute-tooltip span:last-child { color: var(--danger); }
.inference-table thead th:hover .inference-attribute-tooltip, .inference-table thead th:focus .inference-attribute-tooltip { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.inference-name-heading span { font-size: 11px; font-weight: 400; }
.inference-table thead th:first-child, .inference-table tbody th:first-child { width: 35%; background: #151b25; }
.inference-name-content { display: flex; align-items: center; gap: 5px; }
.inference-row-handle { flex: 0 0 18px; width: 18px; height: 28px; padding: 0; border-radius: 5px; background-color: transparent; background-image: radial-gradient(circle, var(--muted) 1.5px, transparent 1.7px); background-position: 3px 4px; background-size: 6px 7px; cursor: grab; }
.inference-row-handle:hover, .inference-row-handle:focus-visible { background-color: #2b3546; }
.inference-row-handle:active { cursor: grabbing; }
.inference-table thead th:nth-last-child(2), .inference-table tbody td:nth-last-child(2) { width: 15%; }
.inference-table thead th:last-child, .inference-table tbody td:last-child { width: 7%; }
.inference-table tr:last-child th, .inference-table tr:last-child td { border-bottom: 0; }
.inference-table th:last-child, .inference-table td:last-child { border-right: 0; }
.inference-table td { background: #0f131a; }
.inference-table select { width: 100%; min-width: 0; padding: 8px 2px; font-size: 12px; }
.inference-column-select { min-width: 0 !important; width: 100%; padding: 5px 1px !important; font-size: 12px !important; }
.inference-column-remove { margin-left: 4px; padding: 4px 7px; border-radius: 50%; background: transparent; color: var(--muted); font-size: 14px; }
.inference-column-remove:hover, .inference-column-remove:focus-visible { background: #55333d; color: var(--danger); }
.inference-table .monster-name { flex: 1 1 auto; width: 0; min-width: 0; padding: 9px 5px; font-size: 14px; letter-spacing: normal; }
.inference-result { display: inline-block; min-width: 88px; color: var(--accent); font-weight: 800; line-height: 1.6; }
.inference-result--empty { color: var(--muted); font-weight: 400; }
.inference-result--normal { color: #b7c5d9; }
.inference-result--error { color: var(--danger); }
.inference-row-remove { padding: 6px 8px; border: 1px solid #65414b; border-radius: 7px; background: transparent; color: #e7aeb8; font-size: 12px; }
.inference-row-remove:hover, .inference-row-remove:focus-visible { background: #55333d; color: #ffd7dc; }
.inference-table tbody tr { cursor: default; }
.inference-table tbody tr.is-dragging { opacity: .45; }

@media (max-width: 640px) {
  .container { width: min(100% - 24px, 1060px); padding-top: 32px; }
  .menu-page { justify-content: flex-start; padding-top: 64px; }
  .menu-grid { grid-template-columns: 1fr; }
  .menu-card { min-height: 0; }
  .tool-panel, .result-panel { padding: 20px; }
  .back-link { margin-bottom: 36px; }
  .attribute-checkboxes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .equipment-list { grid-template-columns: 1fr; }
  .equipment-empty { display: none; }
  .equipment-row { grid-template-columns: 70px minmax(0, 1fr); }
  .equipment-row .equipment-attributes { grid-column: 1 / -1; }
  .attribute-rate-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .result-list li.result-item--stacked { grid-template-columns: 1fr; gap: 10px; }
  .result-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
