:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #57463f;
  background: #fff7eb;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  --bg: #fff7eb;
  --panel: #fffdf8;
  --panel2: #fff5e8;
  --border: #efdccd;
  --border-strong: #e8c8b8;
  --ink: #57463f;
  --muted: #927e74;
  --accent: #f15b86;
  --accent2: #ff8dac;
  --accent-soft: #ffe1e9;
  --good: #6f9b7c;
  --warn: #b58a54;
  --bad: #d66b7e;
  --shadow: 0 12px 30px rgba(128, 82, 68, .10);
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #fff7eb;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 20% 20%, rgba(241, 91, 134, .08) 0 2px, transparent 3px), radial-gradient(circle at 75% 35%, rgba(224, 165, 132, .09) 0 2px, transparent 3px);
  background-size: 48px 48px, 64px 64px;
  opacity: .45
}

.wrap {
  --wrap-block-pad: 14px;
  --wrap-inline-pad: 12px;
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--wrap-block-pad) var(--wrap-inline-pad);
  padding: calc(var(--wrap-block-pad) + env(safe-area-inset-top, 0px)) calc(var(--wrap-inline-pad) + env(safe-area-inset-right, 0px)) calc(var(--wrap-block-pad) + env(safe-area-inset-bottom, 0px)) calc(var(--wrap-inline-pad) + env(safe-area-inset-left, 0px))
}

.title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px
}

/* 画像認識を再表示する場合は、このルールを削除してください。 */
#ocrBtn {
  display: none;
}

.title-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

#tutorialHelpButton,
#achievementsButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  min-width: 68px;
  height: 30px;
  box-sizing: border-box;
  padding: 0 10px;
  border-radius: 13px;
  white-space: nowrap;
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.achievement-recorded-notice {
  margin-top: 8px;
  color: #a43d60;
  font-size: 12px;
  font-weight: 800;
}

.modal.achievement-modal {
  width: min(94vw, 780px);
  max-height: min(88vh, 780px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.achievement-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.achievement-heading h3 { margin: 0; }

.achievement-close {
  width: auto;
  padding: 7px 13px;
}

.achievement-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.achievement-summary > div {
  padding: 10px;
  border: 1px solid #ead3c7;
  border-radius: 12px;
  background: #fff8f3;
  text-align: center;
}

.achievement-summary span,
.achievement-summary b { display: block; }
.achievement-summary span { color: #947c72; font-size: 11px; }
.achievement-summary b { margin-top: 2px; color: #684c42; font-size: 18px; }

.achievement-list {
  overflow: auto;
  border-top: 1px solid #eedbd2;
}

.achievement-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 64px minmax(190px, auto);
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid #f1e3dc;
  font-size: 13px;
}

.achievement-name { min-width: 0; font-weight: 800; color: #654a43; }
.achievement-level { color: #9a8077; text-align: center; }
.achievement-values { color: #765e55; text-align: right; font-variant-numeric: tabular-nums; }
.achievement-empty { padding: 24px 4px; text-align: center; }

@media(max-width:560px) {
  .title { align-items: flex-start; }
  .title-actions { gap: 5px; margin-top: 7px; }
  #tutorialHelpButton,
  #achievementsButton { width: 58px; min-width: 58px; height: 28px; padding: 0 7px; font-size: 11px; }
  .modal.achievement-modal { width: 100%; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 13px; }
  .achievement-row { grid-template-columns: minmax(0, 1fr) 48px; gap: 5px 8px; }
  .achievement-values { grid-column: 1 / -1; text-align: left; font-size: 12px; }
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  isolation: isolate;
}

.tutorial-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tutorial-mask path {
  fill: rgba(45, 43, 47, .68);
  fill-rule: evenodd;
}

.tutorial-mask rect {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.tutorial-bubble {
  position: absolute;
  width: min(330px, calc(100% - 24px));
  padding: 12px 16px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
  outline: none;
}

.tutorial-bubble::before {
  content: '';
  position: absolute;
  top: -7px;
  left: calc(var(--tutorial-arrow-x, 50%) - 7px);
  width: 12px;
  height: 12px;
  background: var(--panel);
  border-top: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  transform: rotate(45deg);
}

.tutorial-bubble.tutorial-above::before {
  top: auto;
  bottom: -7px;
  transform: rotate(225deg);
}

.tutorial-top,
.tutorial-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}

.tutorial-bottom {
  justify-content: flex-end;
}

.tutorial-message {
  margin: 10px 0 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.tutorial-close {
  padding: 0;
  width: 28px;
  min-height: 28px;
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 22px;
}

.tutorial-previous,
.tutorial-next {
  padding: 7px 14px;
  white-space: nowrap;
  font-size: 12px;
}

.title h1 {
  font-size: 20px;
  margin: 2px 0 0;
  color: #57463f;
  letter-spacing: .01em
}

.title span {
  font-size: 11px
}

.muted {
  color: var(--muted);
  font-size: 13px
}

.grid {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(400px, 1.45fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start
}

.grid>* {
  min-width: 0
}

.left-column {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0
}

.item-column,
.user-column,
.history-column,
.state-column {
  align-self: start
}

.history-column {
  padding: 12px 14px
}

.history-title {
  color: #756159;
  font-size: 12px;
  font-weight: 750;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px
}

.history-export {
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 750
}

.operation-history {
  max-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  font-size: 12px;
  line-height: 1.45;
  color: #786760;
}

@media(max-width:560px) {
  .operation-history {
    font-size: 14px;
  }
}

.history-entry {
  min-height: 16px;
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.history-entry::before {
  content: "- ";
  color: #a68f85
}

.history-entry.undone {
  text-decoration: line-through;
  opacity: .55
}

.history-empty {
  color: #ad9c94
}

.history-reset {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  font-weight: 750
}

.decision-column {
  display: grid;
  gap: 14px;
  align-content: start
}

#next {
  margin-top: 3px;
  font-weight: bold;
}

.recommend-alternatives {
  display: grid;
  gap: 3px;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
  color: #79665e;
}

.card {
  background: rgba(255, 254, 249, .95);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 17px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px)
}

label {
  display: block;
  font-size: 12px;
  color: #876f64;
  margin-bottom: 7px;
  font-weight: 700
}

select,
input,
button {
  font: inherit
}

select,
input {
  width: 100%;
  background: #fffdf8;
  color: var(--ink);
  border: 1px solid #e8d3c5;
  border-radius: 11px;
  padding: 9px 10px;
  outline: none;
  transition: .16s ease
}

select:focus,
input:focus {
  border-color: #f187a5;
  box-shadow: 0 0 0 3px rgba(241, 91, 134, .13)
}

.numeric-input {
  appearance: textfield
}

button {
  background: #fff0e9;
  color: #684e45;
  border: 1px solid #edcfc3;
  border-radius: 11px;
  padding: 8px;
  cursor: pointer;
  transition: .16s ease;
  box-shadow: 0 3px 8px rgba(128, 82, 68, .06)
}

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover {
    transform: translateY(-1px);
    background: #ffe8e2;
    border-color: #e8b9ad
  }
}

button:active {
  transform: translateY(0)
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
  box-shadow: none
}

.row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

.controls {
  display: grid;
  gap: 13px
}

.item-tools {
  display: grid;
  gap: 10px
}

.part-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px
}

.part-tabs button {
  padding: 8px 5px;
  background: #fff5ed;
  border-color: #eeddd2;
  color: #826b61;
  font-size: 12px;
}

.part-tabs button.active {
  background: linear-gradient(135deg, #ff8fac, #f15b86);
  border-color: #e94f7a;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 13px rgba(241, 91, 134, .22)
}

.result-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #958077;
  font-size: 12px;
  gap: 8px
}

.result-count select {
  max-width: 260px
}

.toggle-label {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px
}

.toggle-note {
  font-size: 11px;
  color: #a38d83;
  margin-bottom: 7px
}

.choice-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px
}

.choice-group.special {
  grid-template-columns: repeat(4, 1fr)
}

.choice-btn {
  position: relative;
  padding: 8px 2px;
  font-size: 12px;
  font-weight: 750;
  background-color: #fff8f3;
  border-color: #eeddd3;
  color: #806a61;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.choice-btn.active {
  background-color: #e94e7b;
  background-image: linear-gradient(135deg, #f77a9d, #e94e7b);
  border-color: #df466f;
  color: #fff;
  box-shadow: 0 6px 13px rgba(233, 78, 123, .22);
}

.choice-btn[data-value="crit"].active,
.choice-btn[data-value="focus15"].active {
  background-color: #f15b86;
  background-image: linear-gradient(135deg, #ff9bb4, #f15b86);
  border-color: #e9507b;
}

.choice-btn[data-value="half"].active {
  background-color: #c97765;
  background-image: linear-gradient(135deg, #e8957e, #c97765);
  border-color: #c06e5d;
}

#specialChoices .choice-btn:disabled {
  cursor: default;
  opacity: 1;
}

.cells {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  grid-auto-rows: minmax(78px, auto);
  gap: 10px;
  margin-top: 10px;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto
}

.cell {
  position: relative;
  background: linear-gradient(180deg, #fffdf8, #fff5e9);
  border: 2px solid #ead8ca;
  border-radius: 13px;
  padding: 9px;
  text-align: center;
  min-height: 74px;
  align-self: stretch;
  box-shadow: inset 0 1px rgba(255, 255, 255, .8), 0 0 0 0 transparent;
  transition: .18s ease
}

.cell.basted::after {
  content: "しつけ";
  position: absolute;
  right: 5px;
  bottom: 4px;
  padding: 1px 4px;
  border: 1px solid #d9896f;
  border-radius: 999px;
  background: rgba(255, 247, 235, .94);
  color: #ad5f49;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
  pointer-events: none
}

.cell .idx {
  font-size: 11px;
  color: #9b877d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  white-space: nowrap
}

.cell .label {
  font-weight: 900;
  color: #6d554b
}

.cell .remain {
  color: #9b877d
}

.cell input {
  margin-top: 8px;
  text-align: center;
  padding: 7px 6px;
  font-weight: 800;
  background: #fffdf9
}

.cell.recommended {
  border-color: #ed5d86;
  box-shadow: 0 0 0 3px rgba(237, 93, 134, .17), 0 6px 16px rgba(237, 93, 134, .13);
  background: linear-gradient(180deg, #fffafa, #ffe9ee)
}

.cell.affected {
  border-color: #f59ab2;
  box-shadow: 0 0 0 3px rgba(245, 154, 178, .14), 0 6px 14px rgba(245, 154, 178, .10);
  background: linear-gradient(180deg, #fffaf9, #fff0f2)
}

.cell.recommended.affected {
  border-color: #ed5d86;
  box-shadow: 0 0 0 3px rgba(237, 93, 134, .17), 0 6px 16px rgba(237, 93, 134, .13)
}

.cell .target-mark {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 10px;
  font-weight: 900;
  color: #e94f7b
}

.cell.affected .target-mark {
  color: #e87896
}

.action-note {
  margin-top: 8px;
  font-size: 11px;
  color: #97827a;
  line-height: 1.55
}

.candidate-row {
  cursor: pointer
}

.candidate-row:hover td {
  background: #fff3ef
}

.selected-row td {
  background: #ffe9ed
}

.candidate-target {
  font-weight: 800;
  color: #cf4b70
}

@keyframes power2Pulse {

  0%,
  100% {
    background: #fff0ad;
    box-shadow: 0 0 0 3px rgba(238, 170, 65, .28), 0 6px 16px rgba(238, 143, 65, .18)
  }

  50% {
    background: #ffc6d5;
    box-shadow: 0 0 0 5px rgba(241, 91, 134, .30), 0 8px 20px rgba(220, 70, 113, .22)
  }
}

.cell.power2-target {
  border-color: #ed638a;
  animation: power2Pulse .8s ease-in-out infinite
}

@media(prefers-reduced-motion:reduce) {
  .cell.power2-target {
    animation: none;
    background: #ffd7e1;
    box-shadow: 0 0 0 4px rgba(237, 99, 138, .28)
  }
}

.shape-head-food {
  grid-template-areas: ' . c1 .' 'c2 c3 c4'
}

.shape-grid6 {
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  grid-template-rows: repeat(3, minmax(78px, auto));
  grid-template-areas: 'c1 c4' 'c2 c5' 'c3 c6'
}

.shape-grid9 {
  grid-template-areas: 'c1 c2 c3' 'c4 c5 c6' 'c7 c8 c9'
}

.cell[data-area] {
  grid-area: var(--area)
}

.recommend {
  border: 1px solid #ead3c7;
  background: linear-gradient(180deg, rgba(255, 253, 248, .96), rgba(255, 241, 233, .95));
  border-radius: 18px;
  padding: 17px;
  box-shadow: var(--shadow)
}

.badge {
  display: inline-block;
  border: 1px solid #efcfd4;
  background: #ffe8ed;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  color: #b85672;
  font-weight: 750
}

.reason {
  color: #79665e;
  line-height: 1.7
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px
}

.metric {
  background: #fffdf8;
  border: 1px solid #eee0d6;
  border-radius: 12px;
  padding: 10px
}

.metric b {
  display: block;
  font-size: 18px;
  margin-top: 3px;
  color: #604c43
}

#nextSub,
#metrics {
  display: none !important
}

.table {
  margin-top: 14px;
  width: 100%;
  border-collapse: collapse
}

.table th,
.table td {
  padding: 9px;
  border-bottom: 1px solid #eee1d8;
  text-align: left;
  font-size: 13px
}

.table th {
  color: #917c72
}

.good {
  color: var(--good);
  font-weight: 700
}

.warn {
  color: var(--warn);
  font-weight: 700
}

.bad {
  color: var(--bad);
  font-weight: 700
}

.small {
  font-size: 12px
}

.footer {
  margin-top: 14px;
  text-align: right;
  color: #97847b;
  font-size: 11px;
  line-height: 1.6
}

.footer a {
  color: inherit;
  text-underline-offset: 3px;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--ink);
}

.hidden {
  display: none
}

#reset {
  font-weight: 750;
  background: #fff2eb
}

@media(max-width:1120px) and (min-width:901px) {
  .wrap {
    --wrap-block-pad: 10px;
    --wrap-inline-pad: 8px;
  }

  .grid,
  .left-column {
    gap: 9px;
  }

  .grid {
    grid-template-columns:
      minmax(0, .8fr)
      minmax(0, 1.45fr)
      minmax(0, 1fr);
  }

  .grid > *,
  .left-column > *,
  .row > *,
  .row2 > *,
  .level-needle-row > * {
    min-width: 0;
  }

  .level-needle-row {
    grid-template-columns:
      minmax(0, .8fr)
      minmax(0, 1.2fr);
  }

  .card,
  .recommend {
    padding: 12px;
  }

  .part-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .choice-group {
    gap: 5px;
  }

  .choice-btn {
    font-size: 11px;
  }
}

@media(max-width:900px) {
  .grid {
    grid-template-columns: 1fr
  }

  .left-column {
    order: 1
  }

  .state-column {
    order: 2
  }

  .decision-column {
    order: 3
  }

  .cells {
    max-width: none
  }

  .part-tabs {
    grid-template-columns: repeat(3, 1fr)
  }
}

@media(max-width:560px) and (orientation:portrait) {
  .left-column {
    display: contents
  }

  .item-column {
    order: 1
  }

  .user-column {
    order: 2
  }

  .state-column {
    order: 3
  }

  .decision-column {
    order: 4
  }

  .history-column {
    order: 5
  }

  .history-reset {
    order: 6
  }
}

@media(max-width:560px) {
  .search-row {
    grid-template-columns: 1fr
  }

  .part-tabs {
    grid-template-columns: repeat(3, 1fr)
  }

  .cells {
    gap: 7px
  }

  .cell {
    min-height: 68px;
    padding: 8px
  }

  .cell .idx {
    font-size: 12px
  }

  .cell input {
    margin-top: 7px;
    padding: 6px 4px
  }

  .choice-group {
    grid-template-columns: repeat(2, 1fr)
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr)
  }
}

.confirm-area {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 10px
}

.confirm-area button {
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 750
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px
}

.focus-now {
  box-sizing: border-box;
  width: 92px;
  padding: 5px 8px;
  text-align: right;
  font-size: 20px;
  font-weight: 850;
  color: #604c43;
  background: #fffdf8
}

.focus-now:disabled {
  opacity: .72;
  cursor: not-allowed
}

.pending-chip {
  font-size: 11px;
  color: #b05270;
  color: #604c43;
  border: 1px solid #efcfd8;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap
}

.compact-note {
  font-size: 11px;
  color: #9c8980;
  margin-top: 4px
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(87, 65, 56, .24);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) calc(18px + env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
  z-index: 1000
}

.modal {
  width: min(92vw, 380px);
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(94, 61, 49, .20);
  padding: 18px
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #604940
}

.modal p {
  margin: 0;
  color: #7a675f;
  line-height: 1.55
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px
}

.modal-actions button:last-child {
  background: linear-gradient(135deg, #ffd5df, #f7a2b8);
  border-color: #ef91aa;
  color: #654a43;
  font-weight: 800
}

.cell.soft {
  border-color: #e3c8bb
}

.mental-active {
  border: 1px solid #efc5d0;
  background: #ffe9ee;
  color: #a6536b;
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 750;
  margin-top: 8px;
  text-align: center
}

.next-sub {
  font-size: 12px;
  color: #917c74;
  font-weight: 700;
  margin-top: -2px
}

.metrics.compact {
  grid-template-columns: repeat(3, 1fr)
}

.metric b.compact {
  font-size: 16px
}

@media(max-width:560px) {
  .metrics.compact {
    grid-template-columns: repeat(3, 1fr)
  }

  .metric {
    padding: 8px 7px
  }

  .metric b.compact {
    font-size: 14px
  }
}

@media(max-width:1120px) and (min-width:901px) {
  .confirm-area {
    gap: 5px
  }

  .confirm-area button {
    font-size: 11px
  }
}

@media(max-width:560px) {
  .confirm-area {
    grid-template-columns: repeat(3, 1fr)
  }
}

.level-needle-row {
  display: grid;
  grid-template-columns: minmax(70px, .8fr) minmax(130px, 1.2fr);
  gap: 8px
}

.level-needle-row div {
  font-size: 13px;
}

.level-needle-row label {
  white-space: nowrap
}

.status-line>label {
  margin: 0 0 0 auto
}

.status-line .muted b {
  font-size: 15px;
  color: #604c43
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px
}

.field-label-row label {
  margin: 0
}

.input-tools {
  display: flex;
  align-items: stretch;
  gap: 7px
}

.input-mode-segment {
  display: inline-flex;
  height: 32px;
  padding: 2px;
  border: 1px solid #d9c9e7;
  border-radius: 9px;
  background: #f7f2fb
}

.input-mode-segment button {
  min-height: 26px;
  padding: 2px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #725f7c;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: none
}

.input-mode-segment button.active {
  background: #a879ca;
  color: #fff;
  font-weight: 800
}

.input-mode-segment button[aria-pressed="false"] {
  opacity: 0.5;
}

.ocr-launch {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap
}

.cells.differential-input .cell {
  cursor: pointer
}

.cells.differential-input .numeric-input {
  pointer-events: none;
  background: #faf7fd;
  cursor: pointer
}

.modal.differential-input-modal {
  width: min(92vw, 430px)
}

.differential-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px
}

.differential-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px
}

.critical-toggle,
.regeneration-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  margin: 0;
  border-radius: 9px;
  font-weight: 800
}

.critical-toggle {
  border: 1px solid #d7bd72;
  background: #fff9e8;
  color: #7a5a08
}

.regeneration-toggle {
  border: 1px solid #b9d9c2;
  background: #f1faf3;
  color: #39734a
}

.critical-toggle input,
.regeneration-toggle input,
.critical-toggle input:focus,
.regeneration-toggle input:focus {
  width: auto;
  padding: 0;
  border: none;
  box-shadow: none
}

.critical-toggle input {
  accent-color: #c59618
}

.regeneration-toggle input {
  accent-color: #4a9660
}

.differential-value-title {
  margin-top: 14px;
  color: #604940;
  font-size: 13px;
  font-weight: 800
}

.differential-candidates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 7px;
  margin-top: 7px
}

.differential-candidates button {
  min-height: 42px;
  padding: 7px 5px;
  border-color: #d9c9e7;
  background: #f7f1fb;
  color: #644c70;
  font-weight: 800
}

.regeneration-mode .differential-candidates button {
  border-color: #9ecbae;
  background: #eaf7ee;
  color: #27683d
}

.regeneration-mode .differential-value-title {
  color: #27683d
}

.critical-mode .differential-candidates button {
  border-color: #d8b751;
  background: #fff5cf;
  color: #765400
}

.critical-mode .differential-value-title {
  color: #765400
}

.differential-empty {
  grid-column: 1 / -1;
  padding: 10px;
  border-radius: 8px;
  background: #f6f2ef;
  color: #806e66;
  font-size: 12px
}

.differential-free {
  margin-top: 14px
}

.differential-free > label {
  color: #806e66;
  font-size: 12px;
  font-weight: 700
}

.differential-free > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 5px
}

.differential-free input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #dccfc8;
  border-radius: 8px;
  font-size: 16px
}

@media(max-width:560px) {
  .field-label-row {
    align-items: flex-end;
    flex-wrap: wrap
  }

  .input-tools {
    margin-left: auto
  }

  .input-mode-segment button {
    padding-inline: 7px
  }
}

.modal.ocr-modal {
  width: min(92vw, 560px)
}

.ocr-help {
  font-size: 12px;
  color: #917c72;
  margin: 0 0 10px;
  line-height: 1.55
}

.ocr-file-name {
  border: 1px solid #ead8cd;
  border-radius: 10px;
  background: #fffaf5;
  padding: 9px 10px;
  font-size: 12px;
  color: #715d54;
  overflow-wrap: anywhere
}

.ocr-progress {
  margin-top: 10px;
  min-height: 20px;
  color: #b35d76;
  font-size: 12px;
  font-weight: 700
}

.ocr-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-height: 42vh;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid #ead8cd;
  border-radius: 10px;
  background: #fff;
  color: #51433d;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace
}

.ocr-error {
  color: #c75c72
}

.ocr-modal button.busy {
  cursor: wait
}

.ocr-note {
  font-size: 11px;
  color: #9c8980;
  margin-top: 8px
}

@media(max-width:560px) {
  .modal.ocr-modal {
    padding: 14px
  }
}

.flow-panel {
  border: 1px solid var(--border);
  background: #fff8f1;
  border-radius: 13px;
  padding: 10px
}

.flow-summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #876f64
}

.flow-summary b {
  color: #684e45
}

.power-sequence {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 1px 2px;
  scrollbar-width: thin
}

.power-chip {
  flex: 0 0 auto;
  border: 1px solid #ead7cb;
  background: #fffdf8;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 750;
  color: #876f64
}

.power-chip.current {
  background: linear-gradient(135deg, #f77a9d, #e94e7b);
  border-color: #df466f;
  color: #fff
}

.cloth-notice {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.45;
  color: #ad687c
}

.manual-panel {
  border: 1px solid #ead1c7;
  background: rgba(255, 254, 249, .95);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow)
}

.manual-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px
}

.manual-heading b {
  font-size: 14px;
  color: #704f45
}

.manual-heading span {
  font-size: 10px;
  color: #9c8980
}

.command-info-button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border-color: #d8b8ad;
  background: #fffaf4;
  color: #8a6559;
  font: 800 14px/1 Georgia, serif;
  box-shadow: none
}

.command-info-button:hover,
.command-info-button:focus-visible {
  background: #f8e8e1;
  border-color: #c99f92
}

.modal.command-info-modal {
  width: min(96vw, 1120px);
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden
}

.command-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto
}

.command-info-header p {
  font-size: 12px
}

.command-info-close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1
}

.command-info-table-wrap {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid #ead1c7;
  border-radius: 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch
}

.command-info-table {
  width: 100%;
  min-width: 970px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  line-height: 1.35
}

.command-info-table th,
.command-info-table td {
  padding: 7px;
  border-right: 1px solid #efddd5;
  border-bottom: 1px solid #efddd5;
  text-align: left;
  vertical-align: top;
  white-space: nowrap
}

.command-info-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7e8e1;
  color: #674c43
}

.command-info-table tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fffaf5;
  color: #704f45
}

.command-info-table thead th:first-child {
  left: 0;
  z-index: 4
}

.command-info-table tr:last-child th,
.command-info-table tr:last-child td {
  border-bottom: 0
}

.command-info-table th:last-child,
.command-info-table td:last-child {
  border-right: 0
}

.command-info-lines {
  display: block;
  line-height: 1.55
}

.command-info-note {
  flex: 0 0 auto;
  margin-top: 10px !important;
  font-size: 11px;
  line-height: 1.45 !important
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 7px
}

.manual-command {
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.manual-command.active {
  background: linear-gradient(135deg, #f77a9d, #e94e7b);
  border-color: #df466f;
  color: #fff;
  box-shadow: 0 6px 13px rgba(233, 78, 123, .22)
}

.manual-command .manual-cost {
  font-size: 10px;
  font-weight: 650;
  color: #9a8077
}

.manual-command.active .manual-cost {
  color: #fff
}

.manual-command:disabled .manual-cost {
  color: inherit
}

.manual-status {
  min-height: 18px;
  margin-top: 8px;
  font-size: 11px;
  color: #937c73;
  line-height: 1.45
}

@media(max-width:560px) {
  .modal-backdrop.command-info-backdrop {
    align-items: flex-start;
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px))
  }

  .modal.command-info-modal {
    width: 100%;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 13px;
    border-radius: 14px
  }

  .command-info-table {
    min-width: 900px;
    font-size: 10px
  }

  .command-info-table th,
  .command-info-table td {
    padding: 6px
  }

  .manual-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }
}

/* 頭だけ特殊形状。ほかの部位の既存レイアウトには干渉しない。 */
.dqx-board[data-board-shape="head"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.dqx-board[data-board-shape="head"] > *:first-child {
  grid-column: 2;
  grid-row: 1;
}

.dqx-board[data-board-shape="head"] > *:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

.dqx-board[data-board-shape="head"] > *:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.dqx-board[data-board-shape="head"] > *:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.cells {
  grid-template-areas: none !important;
}

.cells > .cell {
  grid-area: auto;
}

@media(max-width:560px) {
  .wrap,
  .grid,
  .state-column,
  .state-column .controls,
  .state-column .controls > div,
  .flow-panel,
  .field-label-row,
  .input-tools,
  .choice-group,
  .cells,
  .confirm-area {
    min-width: 0;
    max-width: 100%
  }

  .card {
    width: 100%;
    min-width: 0;
    padding: 12px
  }

  .choice-group#powerChoices {
    grid-template-columns: repeat(5, minmax(0, 1fr))
  }
  .choice-group#specialChoices {
    grid-template-columns: repeat(4, minmax(0, 1fr))
  }

  .choice-btn,
  .confirm-area button {
    min-width: 0
  }

  .cells {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }

  .shape-grid6 {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .confirm-area {
    grid-template-columns: repeat(4, minmax(0, 1fr))
  }

  .input-tools {
    width: 50%;
    margin-left: 0;
    justify-content: flex-end;
    transform: translateY(6px);
  }

  .power-sequence {
    min-width: 0;
    max-width: 100%
  }
}
