/* Single-character comparison page */

.b3-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(520px, 1fr) minmax(320px, 420px);
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 76px);
}

.b3-library-pane,
.b3-formation-pane,
.b3-results-pane {
  min-height: 0;
  overflow: hidden;
}

.b3-library-pane,
.b3-results-pane {
  display: flex;
  flex-direction: column;
}

.b3-formation-pane {
  overflow: auto;
}

.b3-candidate-list,
.b3-formation-list,
.b3-result-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.b3-candidate-list,
.b3-result-list {
  display: grid;
  gap: 8px;
}

.b3-candidate-card.active {
  border-color: var(--accent);
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.b3-candidate-check {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.b3-candidate-card.active .b3-candidate-check {
  display: grid;
}

.b3-candidate {
  display: grid;
  grid-template-columns: auto 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.b3-candidate:hover {
  border-color: var(--accent);
}

.b3-candidate input {
  width: 18px;
  height: 18px;
}

.b3-thumb,
.b3-mini-thumb,
.b3-result-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.b3-thumb {
  width: 54px;
  height: 54px;
}

.b3-mini-thumb {
  width: 44px;
  height: 44px;
}

.b3-result-thumb {
  width: 50px;
  height: 50px;
}

.b3-thumb img,
.b3-mini-thumb img,
.b3-result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.b3-candidate-meta,
.b3-formation-title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.b3-candidate-meta strong,
.b3-formation-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-candidate-meta span,
.b3-formation-title span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-manual-add,
.b3-compare-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.b3-compare-controls {
  width: 100%;
  grid-template-columns: max-content max-content minmax(180px, 260px) minmax(max-content, 1fr);
  align-items: center;
}

.b3-compare-controls .status-pill {
  justify-self: end;
}

.b3-axis-pane-head {
  align-items: stretch;
  padding: 8px 14px;
}

.b3-axis-tabs {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 7px;
}

.b3-axis-tab {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 5px 12px 5px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.b3-axis-tab > span:last-child {
  white-space: nowrap;
}

.b3-axis-tab:hover,
.b3-axis-tab:focus-visible {
  border-color: var(--accent);
}

.b3-axis-tab.active {
  border-color: var(--accent);
  background: var(--panel-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.b3-axis-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--panel-soft);
}

.b3-axis-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.material-theme .saved-formation-card.b3-saved-comparison-card {
  padding: 14px;
  gap: 10px;
}

.b3-compare-controls .profile-toggle {
  min-width: 150px;
  justify-content: center;
  white-space: nowrap;
}

.b3-mode-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.b3-mode-select {
  min-width: 0;
  width: 100%;
  height: 34px;
  padding: 0 10px;
}

.b3-bulk-replace {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.b3-common-formation {
  display: grid;
  grid-template-columns: max-content max-content max-content;
  justify-content: start;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.b3-common-formation > strong {
  white-space: nowrap;
}

.b3-common-formation .b3-formation-icons {
  grid-template-columns: repeat(5, 58px);
  gap: 7px;
}

.b3-common-formation .b3-mini-thumb {
  width: 58px;
  height: 58px;
}

.b3-common-formation-slot {
  width: 58px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: grab;
}

.b3-common-formation-slot:active {
  cursor: grabbing;
}

.b3-common-formation-slot.dragging {
  opacity: 0.45;
}

.b3-common-formation-slot.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.b3-common-rotation {
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.b3-common-rotation:empty {
  display: none;
}

.b3-common-rotation .formation-rotation-panel {
  width: 100%;
}

.b3-scenario-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.b3-scenario-summary.is-hidden {
  display: none;
}

.b3-scenario-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.b3-template-action-label {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 13px;
}

.b3-template-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.b3-template-action-buttons > button {
  width: 172px;
  min-width: 172px;
  justify-content: center;
}

.b3-scenario-actions.is-hidden,
.b3-scenario-actions .is-hidden,
.catalog-visible-actions.is-hidden {
  display: none;
}

.b3-scenario-burst-time {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.b3-scenario-burst-time input {
  width: 150px;
  height: 32px;
}

.b3-template-picker-panel {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
}

.b3-template-picker-panel > .b3-result-modal-head,
.b3-template-save-panel > .b3-result-modal-head,
.b3-overload-template-panel > .b3-result-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.b3-template-picker-list {
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 14px;
}

.b3-template-picker-list .saved-formation-card {
  width: 100%;
  min-height: 48px;
  text-align: left;
  cursor: pointer;
}

.b3-template-save-panel {
  width: min(520px, calc(100vw - 32px));
}

.b3-template-save-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.b3-template-save-body label,
.b3-overload-template-name {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.b3-template-save-body input,
.b3-overload-template-name input,
.b3-overload-template-card-head input {
  width: 100%;
  min-width: 0;
  height: 38px;
}

.b3-template-save-body .primary-button,
.b3-overload-template-save {
  justify-self: end;
}

.b3-template-library-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.b3-template-library-card > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.b3-template-library-card span,
.b3-template-library-card small {
  color: var(--muted);
}

.b3-template-library-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-template-library-card > div:last-child {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.b3-overload-template-panel {
  width: min(1180px, calc(100vw - 32px));
  height: min(900px, calc(100dvh - 32px));
  max-height: min(900px, calc(100vh - 32px));
  max-height: min(900px, calc(100dvh - 32px));
  overflow: hidden;
}

.b3-overload-template-body {
  min-height: 0;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 14px;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.b3-overload-template-toolbar {
  display: flex;
  justify-content: flex-end;
}

.b3-overload-template-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.b3-overload-bulk-editor {
  display: grid;
  gap: 12px;
}

.b3-overload-bulk-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.b3-overload-bulk-controls label {
  min-width: 150px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.b3-overload-bulk-controls select {
  height: 38px;
}

.b3-overload-bulk-controls p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.b3-overload-bulk-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.b3-overload-bulk-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
}

.b3-overload-bulk-table th,
.b3-overload-bulk-table td {
  height: 48px;
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}

.b3-overload-bulk-table th:first-child {
  width: 220px;
  text-align: left;
}

.b3-overload-bulk-table th:last-child,
.b3-overload-bulk-table td:last-child {
  width: 78px;
  border-right: 0;
}

.b3-overload-bulk-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.b3-overload-bulk-table tbody tr:last-child th,
.b3-overload-bulk-table tbody tr:last-child td {
  border-bottom: 0;
}

.b3-overload-bulk-table td input[type="number"] {
  width: 64px;
  height: 34px;
  margin: 0 auto;
  padding: 0 6px;
  text-align: right;
}

.b3-overload-bulk-pattern {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.b3-overload-bulk-pattern input {
  width: 100%;
  min-width: 0;
  height: 34px;
}

.b3-overload-bulk-total {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.b3-overload-bulk-total.complete {
  color: var(--accent-strong);
}

.b3-overload-template-card {
  min-width: 0;
  min-height: max-content;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.b3-overload-template-card-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.b3-overload-template-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.b3-manual-add select,
.b3-bulk-replace select {
  min-height: 34px;
  padding: 0 10px;
}

.b3-compare-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

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

.b3-compare-title input {
  height: 36px;
  padding: 0 10px;
}

.b3-options-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}

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

.b3-options-summary span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}

.b3-options-body {
  padding: 0 14px 14px;
}

.b3-global-buffs {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.b3-global-buffs h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.b3-formation-card {
  overflow: hidden;
}

.b3-formation-card + .b3-formation-card {
  margin-top: 10px;
}

.b3-formation-card.expanded {
  border-color: var(--accent);
}

.b3-formation-head {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(140px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.b3-formation-icons {
  display: grid;
  grid-template-columns: repeat(5, 44px);
  gap: 6px;
  align-items: center;
}

.b3-formation-damage,
.b3-result-damage {
  color: var(--accent-strong);
  white-space: nowrap;
}

.b3-formation-detail {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fbfcfc;
}

.b3-formation-detail > * {
  min-width: 0;
  max-width: 100%;
}

.b3-formation-detail h3 {
  margin: 0;
  font-size: 13px;
}

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

.b3-name-control input {
  height: 36px;
  padding: 0 10px;
}

.b3-formation-tools {
  display: flex;
  justify-content: flex-end;
}

.b3-result-list > .b3-result-row {
  grid-template-columns: 44px minmax(0, 1fr);
}

.b3-result-list > .b3-result-row:disabled {
  opacity: 1;
  cursor: default;
}

.b3-result-list > .b3-result-row:disabled:hover {
  border-color: var(--line);
  background: var(--panel);
}


.b3-graph-modal-panel {
  max-width: min(1460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  position: relative;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.b3-graph-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.b3-graph-canvas-wrap {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: #eef4f3;
}

.b3-graph-canvas-wrap canvas {
  display: block;
  max-width: none;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(12, 22, 21, 0.18);
}

.b3-graph-display-controls {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7faf9;
}

.b3-graph-display-controls[hidden] {
  display: none;
}

.b3-graph-display-item {
  flex: 0 0 auto;
  min-width: 178px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.b3-graph-display-item.disabled {
  opacity: 0.58;
}

.b3-graph-display-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.b3-graph-display-item input[type="color"] {
  width: 32px;
  height: 28px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.b3-graph-popover[hidden] {
  display: none;
}

.b3-graph-popover {
  position: fixed;
  z-index: 80;
  width: 230px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(12, 22, 21, 0.26);
}

.b3-graph-popover strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-graph-popover label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.b3-graph-popover input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}


.b3-result-row-modal {
  grid-template-columns: 42px minmax(250px, auto) minmax(0, 1fr) auto;
}

.b3-modal-formation-icons {
  display: grid;
  grid-template-columns: repeat(5, 50px);
  gap: 6px;
}

.b3-modal-result-name {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.b3-modal-result-name span {
  color: var(--muted);
  font-size: 12px;
}

.b3-modal-character-damages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.b3-character-damage-button,
.b3-damage-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}

.b3-character-damage-button {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  text-align: left;
}

.b3-character-damage-button.target {
  border-color: var(--accent);
  background: var(--panel-soft);
}

.b3-character-damage-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-character-damage-button strong {
  color: var(--accent-strong);
  font-size: 13px;
}

.b3-damage-link {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: right;
}
