:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #ccfbf1;
  --bg: #ece7e1;
  --ink: #2b2420;
  --muted: #6b5f57;
  --line: #c9b8ae;
  --pink: #f4c8c4;
  --pink-dark: #e7b0ab;
  --paper: #fffdf8;
  --card: #ffffff;
  --danger: #c24141;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  height: 100vh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--teal);
}

.brand-clinic {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  padding-left: 10px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
}

.header-patient {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.header-no {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 700;
}

.header-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.storage-pill {
  font-size: 0.75rem;
  color: var(--muted);
  background: #f3eee8;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-secondary {
  background: #0f766e;
  color: #fff;
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-danger {
  background: #fff5f4;
  color: #c24141;
  border: 1px solid #c24141;
  font-weight: 800;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-lg { padding: 12px 28px; font-size: 1.05rem; }

.search-main {
  flex: 1;
  display: grid;
  place-items: center;
}

.search-hero {
  width: min(480px, 90vw);
  text-align: center;
}

.search-hero h1 { margin: 0 0 8px; }
.search-hero p { margin: 0 0 20px; color: var(--muted); }

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 1.2rem;
  margin-bottom: 14px;
  font-family: inherit;
}

.hint { font-size: 0.85rem; color: var(--muted); margin-top: 14px; }
.search-error { color: var(--danger); margin-top: 12px; }
.hidden { display: none !important; }
.empty-msg { padding: 40px; text-align: center; color: var(--muted); }

.chart-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, 20%) minmax(640px, 1fr);
  gap: 10px;
  padding: 10px;
}

.plan-pane,
.progress-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #b08986;
  overflow: hidden;
}

.plan-pane {
  background: var(--pink);
}

.progress-pane {
  background: var(--paper);
  min-width: 0;
}

.progress-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.progress-head h1 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.plan-fixed {
  flex: 0 0 auto;
  padding: 4px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* 内容の高さだけ。SRP下に余白を作らない／上段スクロールなし */
  overflow: visible;
}

.plan-section {
  display: block;
  width: 100%;
  margin: 0;
  padding: 5px 7px 6px;
  border: 1px solid rgba(176, 137, 134, 0.55);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.28);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.plan-section:active {
  background: rgba(255, 255, 255, 0.48);
}

.plan-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #7a4f4a;
}

.plan-section-hint {
  font-size: 0.62rem;
  font-weight: 700;
  color: #a67c74;
  letter-spacing: 0.02em;
}

.plan-section-preview {
  min-height: 1.4rem;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: #2b2420;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plan-section-empty {
  color: #a89088;
  font-weight: 600;
}

.plan-section-body.is-preview {
  pointer-events: none;
  user-select: none;
}

/* 治療計画プレビューはスクロール可（タップ拡大は親の data-plan-open が受ける） */
.plan-steps-scroll.is-preview {
  pointer-events: auto;
  user-select: none;
}

.plan-section.is-steps {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 0;
  background: transparent;
}

.plan-section.is-steps .plan-section-head {
  padding: 6px 8px;
  margin: 0;
  border-bottom: 1px solid #d7a8a3;
}

.plan-fixed .field { margin-bottom: 6px; }

.plan-fixed textarea {
  min-height: 2.2rem;
  font-size: 0.76rem;
}

#plan-editor-root:empty { display: none; }

.plan-editor {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #f7d7d4;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.plan-editor-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid #d7a8a3;
  background: rgba(255, 255, 255, 0.55);
}

.plan-editor-head strong {
  font-size: 1.2rem;
  letter-spacing: 0.03em;
}

.plan-section-date {
  font-weight: 500;
  font-size: 0.85em;
  color: #7a5a55;
  margin-left: 0.25em;
}

.formula-epoch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid #d7a8a3;
}

.formula-epoch-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: #5c403c;
}

.formula-epoch-date input {
  min-height: 2rem;
  padding: 4px 8px;
  border: 1px solid #c9a09a;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
}

.formula-epoch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.formula-history-banner {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff4e8;
  border: 1px solid #e0b888;
  color: #6a4a28;
  font-size: 0.85rem;
}

.formula-history-panel {
  margin-top: 16px;
  border-radius: 10px;
  border: 1px solid #d7a8a3;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.formula-history-head {
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #5c403c;
  border-bottom: 1px solid #e4c4bf;
  background: rgba(255, 255, 255, 0.45);
}

.formula-history-empty {
  margin: 0;
  padding: 14px 12px;
  font-size: 0.85rem;
  color: #8a6a65;
}

.formula-history-scroll {
  max-height: min(55vh, 28rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.formula-history-card {
  flex: 0 0 auto;
  border: 1px solid #e0c2bd;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  overflow: visible;
}

.formula-history-card-head {
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #5c403c;
  border-bottom: 1px solid #edd8d4;
  background: rgba(247, 236, 233, 0.9);
}

.formula-history-card-body {
  padding: 10px 8px 12px;
  overflow: visible;
  pointer-events: none;
}

.formula-history-card-body .formula-tools,
.formula-history-card-body .formula-hint {
  display: none !important;
}

.plan-editor-body.is-formula .formula.is-history-preview .formula-chart {
  zoom: 1;
  width: 100%;
  max-width: 100%;
  padding: 8px 6px 10px;
}

.plan-editor-body.is-formula .formula.is-history-preview .br-del {
  display: none;
}

.hist-formula {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hist-formula-axis {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #8a6a65;
}

.hist-formula-arch {
  display: grid;
  grid-template-columns: 1.2rem 1fr;
  gap: 4px;
  align-items: center;
}

.hist-formula-jaw {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5c403c;
}

.hist-formula-teeth {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr)) 4px repeat(8, minmax(0, 1fr));
  gap: 2px;
  align-items: stretch;
}

.hist-formula-tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-height: 2.6rem;
  padding: 3px 1px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid #e4c4bf;
  box-sizing: border-box;
}

.hist-formula-tooth:nth-child(9) {
  grid-column: 10;
}

.hist-formula-mark {
  min-height: 1.15rem;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
  color: #111;
  text-align: center;
}

.hist-formula-num {
  font-size: 0.62rem;
  color: #8a6a65;
  line-height: 1;
}

.hist-formula-tooth.is-missing {
  background: #f3f3f3;
}

.hist-formula-tooth.is-implant .hist-formula-mark {
  color: #1d4ed8;
}

.hist-formula-tooth.is-pex .hist-formula-mark,
.hist-formula-tooth.is-root .hist-formula-mark,
.hist-formula-tooth.is-kp .hist-formula-mark,
.hist-formula-tooth.is-halfburied .hist-formula-mark {
  color: #7a1f1a;
}

.hist-formula-tooth.is-abutment {
  box-shadow: inset 0 0 0 1.5px #2563eb;
}

.hist-formula-tooth.is-pontic {
  box-shadow: inset 0 0 0 1.5px #93c5fd;
}

.hist-formula-tooth.is-denture {
  box-shadow: inset 0 0 0 1.5px #c24141;
}

.plan-editor-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
}

.plan-editor-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid #d7a8a3;
  background: rgba(255, 255, 255, 0.92);
}

.plan-editor-foot.is-steps-actions {
  justify-content: stretch;
}

.plan-editor-foot.is-steps-actions .plan-steps-add-btn,
.plan-editor-foot.is-steps-actions .plan-editor-close {
  flex: 1 1 0;
  min-width: 0;
  min-height: 3.2rem;
  padding: 0.85rem 1rem;
  font-size: 1.08rem;
  font-weight: 900;
  border-radius: 10px;
}

.plan-editor-foot.is-steps-actions .plan-steps-add-btn {
  border: 2px solid #0f766e;
  background: #0f766e;
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.28);
}

.plan-editor-close {
  min-width: min(20rem, 88vw);
  min-height: 3rem;
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 10px;
  border: 2px solid #b91c1c;
  background: #dc2626;
  color: #fff;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.22);
}

.plan-editor-close:hover,
.plan-editor-close:focus-visible {
  background: #b91c1c;
  border-color: #991b1b;
  color: #fff;
}

.plan-editor-text {
  width: 100%;
  min-height: calc(100% - 8px);
  box-sizing: border-box;
  padding: 14px 16px;
  border: 1px solid #c9a8a3;
  border-radius: 10px;
  background: #fffaf6;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1.55;
  resize: none;
}

.plan-editor-body.is-formula .plan-editor-formula {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0;
  border: none;
  background: transparent;
}

.plan-editor-body.is-occlusion .plan-editor-occ,
.plan-editor-body.is-srp .plan-editor-srp {
  max-width: 52rem;
  margin: 0 auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid #d7a8a3;
}

.plan-editor-body.is-formula .formula {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding-bottom: 0;
}

.plan-editor-body.is-formula .formula-chart-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

.plan-editor-body.is-formula .formula-chart {
  box-sizing: border-box;
  width: 100%;
  max-width: 44rem;
  padding: 12px 14px 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid #d7a8a3;
  overflow: visible;
  /* zoom はレイアウト高さも増やす（iPad Safari / Chromium） */
  zoom: 1.22;
}

.plan-editor-body.is-formula .formula-tools {
  position: relative;
  z-index: 2;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 4px 0 0;
}

.plan-editor-body.is-formula .formula-tools .btn {
  font-size: 1rem;
  padding: 10px 16px;
}

.plan-editor-body.is-formula .formula-hint {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 0.95rem;
  margin: 0 auto;
  max-width: 36rem;
}

.plan-editor-body.is-occlusion .occ-group-title {
  flex-basis: 4.5rem;
  font-size: 0.95rem;
}

.plan-editor-body.is-occlusion .occ-chip {
  font-size: 1rem;
  padding: 6px 12px;
}

.plan-editor-body.is-occlusion .occ-talk-items {
  gap: 0.75rem;
}

.plan-editor-body.is-occlusion .occ-talk {
  gap: 5px;
}

.plan-editor-body.is-occlusion .occ-talk-label {
  font-size: 0.95rem;
  letter-spacing: 0;
}

.plan-editor-body.is-occlusion .occ-talk-box {
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.72rem;
}

.plan-editor-body.is-occlusion .occ-pick {
  width: 1.7rem;
  height: 1.7rem;
  flex-basis: 1.7rem;
}

.plan-editor-body.is-srp .srp-tooth {
  font-size: 0.95rem;
  min-height: 2rem;
}

.plan-editor-body.is-steps {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.plan-editor-steps {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.35);
}

.plan-editor-steps .plan-steps-head {
  font-size: 1rem;
  padding: 12px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.plan-editor-steps .plan-steps-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 20px;
}

.plan-editor-steps .plan-steps-list {
  font-size: 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plan-steps-add-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 8px 28px;
}

.plan-steps-add-wrap .plan-steps-add-btn,
.plan-steps-add-wrap .btn.plan-steps-add-btn {
  min-width: min(20rem, 88vw);
  min-height: 3.6rem;
  padding: 0.95rem 1.75rem !important;
  font-size: 1.2rem !important;
  font-weight: 900 !important;
  letter-spacing: 0.04em;
  border-radius: 12px !important;
  border: 2px solid #0f766e !important;
  background: #0f766e !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.28);
}

.plan-editor-steps .plan-step {
  min-height: 3.2rem;
}

.plan-editor-steps .plan-step.is-flow-step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 5.2rem 10px 6px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.55);
  grid-template-columns: none;
  cursor: default;
  border-radius: 10px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.plan-editor-steps .plan-step.is-flow-step:hover,
.plan-editor-steps .plan-step.is-flow-step:focus-visible {
  background: transparent;
  outline: none;
}

.plan-editor-steps .plan-step.is-flow-step:has(.plan-flow-after.is-edit-target:hover),
.plan-editor-steps .plan-step.is-flow-step:has(.plan-flow-after.is-edit-target:focus-visible) {
  background: transparent;
}

.plan-steps-head-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

.plan-editor-steps .plan-step-row {
  display: grid;
  grid-template-columns: 3.4rem 1fr 2rem;
  gap: 4px;
  align-items: center;
  min-height: 3.2rem;
  cursor: default;
}

.plan-editor-steps .plan-step-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.plan-editor-steps .plan-step-body {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px 12px;
  min-width: 0;
  width: 100%;
}

.plan-editor-steps .plan-step-body .plan-step-rows {
  flex: 0 1 auto;
  width: max-content;
  max-width: 100%;
  min-width: 0;
}

.plan-editor-steps .plan-step-tail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 14px;
  align-items: end;
  width: 100%;
  min-width: 0;
}

.plan-editor-steps .plan-step-tail .plan-flow-after {
  min-width: 0;
}

.plan-editor-steps .plan-step-send {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
  flex: 0 0 auto;
  margin: 0;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  align-self: end;
  margin-left: 1.25rem;
  padding-bottom: 0;
}

.plan-editor-steps .plan-step-send .btn {
  font-size: 0.88rem;
  font-weight: 800;
  padding: 0.65rem 0.85rem;
  line-height: 1.25;
  border-radius: 9px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.18);
  min-height: 2.6rem;
}

.plan-editor-steps .plan-step-send .plan-send-today {
  background: #0f766e;
  border: 1px solid #0f766e;
  color: #fff;
}

.plan-editor-steps .plan-step-send .plan-send-next {
  background: #fff;
  border: 2px solid #0f766e;
  color: #0f766e;
}

.plan-editor-steps .plan-step-send .plan-send-reclaim {
  margin-top: 2px;
  background: #fff;
  border: 1.5px solid #c24141;
  color: #c24141;
  box-shadow: 0 1px 3px rgba(194, 65, 65, 0.16);
}

.plan-editor-steps .plan-step-send .plan-send-reclaim:not(:disabled):active {
  background: #fef2f2;
}

.plan-editor-steps .plan-step-send .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.plan-editor-steps .plan-step .step-simul-pick {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.step-simul-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem;
  margin: -0.2rem;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.step-mark-col {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 3.2rem;
  align-self: center;
}

.step-mark-col .step-mark {
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  pointer-events: none;
}

.plan-editor-steps .plan-step-row .step-open {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.plan-editor-steps .plan-step-row .step-open-main {
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
}

.step-tx-warn {
  color: #c62828;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
}

.plan-step.is-preview-step .step-tx-warn {
  display: inline;
  margin-left: 0.25rem;
}

.step-simul-pick input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.step-simul-circle {
  width: 1.85rem;
  height: 1.85rem;
  border: 3px solid #64748b;
  border-radius: 50%;
  background: #fff;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.step-simul-pick input:checked + .step-simul-circle {
  border-color: #0f766e;
  background: #0f766e;
  box-shadow: inset 0 0 0 4px #fff, 0 1px 3px rgba(15, 118, 110, 0.35);
}

.step-simul-pick:active .step-simul-circle {
  transform: scale(0.94);
}

.plan-editor-steps .plan-step-row {
  cursor: default;
}

.plan-editor-steps .plan-flow-after {
  pointer-events: auto;
  cursor: default;
}

.plan-editor-steps .plan-flow-after.is-edit-target {
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.plan-editor-steps .plan-flow-after.is-edit-target:hover,
.plan-editor-steps .plan-flow-after.is-edit-target:focus-visible {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
  outline: none;
}

.plan-editor-steps .plan-flow-after.is-edit-empty {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.04);
}

.plan-editor-steps .plan-flow-after.is-edit-empty .plan-flow-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f766e;
}

.plan-simul-action-slot:empty {
  display: none;
}

.plan-simul-action {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0));
  border-top: 2px solid rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.12), rgba(15, 118, 110, 0.22));
  box-shadow: 0 -4px 16px rgba(15, 118, 110, 0.12);
}

.plan-simul-action-count {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f766e;
}

.plan-simul-apply-btn {
  min-width: 9.5rem;
  padding: 0.85rem 1.4rem !important;
  font-size: 1.15rem !important;
  font-weight: 900 !important;
  line-height: 1.2;
  border-radius: 12px !important;
  border: 2px solid #0f766e !important;
  background: #0f766e !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.35);
  letter-spacing: 0.04em;
}

.plan-simul-apply-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.28);
}

.plan-simul-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  padding: 0 2px;
}

.plan-simul-group-head .step-remove.is-simul-bulk {
  margin-top: 0;
  margin-left: auto;
  width: 2.45rem;
  height: 2.45rem;
  font-size: 1.55rem;
  border-width: 2px;
  box-shadow: 0 2px 4px rgba(194, 65, 65, 0.22);
}

.plan-simul-group-head .step-handle.is-group {
  flex: 0 0 auto;
  min-width: 1.6rem;
  min-height: 2rem;
  padding: 4px 2px;
  font-size: 1rem;
  color: #0f766e;
}

.plan-simul-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.14);
  color: #0f766e;
  font-size: 0.72rem;
  font-weight: 800;
}

.step-mark.is-combined {
  color: #0f766e;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.plan-step.is-simul-group {
  border: 1.5px solid rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.05);
}

.plan-editor-steps .plan-step-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-editor-steps .plan-step.is-simul-group .plan-step-rows {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px 18px;
  margin: 4px 0 2px;
}

.plan-editor-steps .plan-step.is-simul-group .plan-step-row {
  flex: 1 1 9.5rem;
  min-width: 8.5rem;
  max-width: 100%;
  padding: 6px 4px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  box-sizing: border-box;
}

.plan-step.is-preview-step.is-simul-group {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
}

.step-preview-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-mark-mini {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f766e;
  margin-right: 4px;
}

.plan-editor-steps .plan-step-row .step-mark {
  pointer-events: none;
}

.plan-editor-steps .plan-step .step-handle,
.plan-editor-steps .plan-step .step-remove,
.plan-editor-steps .plan-step .br-del,
.plan-editor-steps .plan-step [data-plan-del-bridge],
.plan-editor-steps .plan-step [data-plan-del-denture],
.plan-editor-steps .plan-step [data-plan-strip-undo],
.plan-editor-steps .plan-step [data-plan-strip-redo],
.plan-editor-steps .plan-step [data-simul-remove] {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.plan-editor-steps .plan-step .step-done-stamp {
  pointer-events: auto;
  z-index: 4;
}

.plan-editor-steps .plan-step .step-handle {
  cursor: grab;
}

.plan-editor-steps .plan-step .step-remove,
.plan-editor-steps .plan-step .br-del,
.plan-editor-steps .plan-step [data-plan-del-bridge],
.plan-editor-steps .plan-step [data-plan-del-denture] {
  cursor: pointer;
}

.plan-editor-steps .plan-flow-after {
  cursor: default;
}

.plan-editor-steps .plan-flow-after.is-edit-target {
  cursor: pointer;
}

.plan-editor-steps .plan-flow-after .br-del,
.plan-editor-steps .plan-flow-after [data-plan-del-bridge],
.plan-editor-steps .plan-flow-after [data-plan-del-denture],
.plan-editor-steps .plan-flow-after [data-plan-strip-undo],
.plan-editor-steps .plan-flow-after [data-plan-strip-redo] {
  pointer-events: auto;
}

.plan-flow-current,
.plan-flow-after {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  padding: 8px 10px 14px;
  overflow: visible;
}

.plan-flow-current {
  margin: 0 0 14px;
}

.plan-flow-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.plan-editor-body.is-steps .formula.is-history-preview {
  transform: none;
  width: 100%;
}

.plan-editor-body.is-steps .formula.is-history-preview .formula-chart {
  transform: scale(0.92);
  transform-origin: top center;
  width: 100%;
  overflow: visible;
}

.plan-editor-body.is-steps .formula.is-plan-flow .formula-chart-stage {
  overflow: visible;
  padding-bottom: 8px;
}

.plan-editor-body.is-steps .formula.is-history-preview .br-del {
  display: none;
}

.plan-editor-body.is-steps .formula.is-plan-flow .br-del {
  display: inline-flex;
}

/* 〇後の歯式: 枠内どこでも編集。削除×とストリップ操作だけ例外で押せる */
.plan-editor-steps .plan-flow-after.is-edit-target .formula,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-tooth,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-tooth select,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-face,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-chart,
.plan-editor-steps .plan-flow-after.is-edit-target .br-group,
.plan-editor-steps .plan-flow-after.is-edit-target .br-caption,
.plan-editor-steps .plan-flow-after.is-edit-target .br-beam,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-denture-block {
  pointer-events: none;
}

.plan-editor-steps .plan-flow-after.is-edit-target .br-del,
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-del-bridge],
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-del-denture],
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-strip-undo],
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-strip-redo],
.plan-editor-steps .plan-flow-after.is-edit-target .plan-strip-toolbar {
  pointer-events: auto;
}

.plan-editor-steps .plan-flow-after.is-edit-target .br-del,
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-del-bridge],
.plan-editor-steps .plan-flow-after.is-edit-target [data-plan-del-denture] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  font-size: 1.15rem;
  line-height: 1;
  border-width: 2px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
  touch-action: manipulation;
  padding: 0;
}

.plan-editor-steps .plan-flow-after.is-edit-target .br-group.is-denture .br-del,
.plan-editor-steps .plan-flow-after.is-edit-target .formula-denture-block .br-del {
  box-shadow: 0 2px 6px rgba(194, 65, 65, 0.4);
}

.plan-editor-body.is-steps .formula-tooth.is-plan-site {
  background: rgba(34, 197, 94, 0.28);
  box-shadow: inset 0 0 0 2px #16a34a;
  border-radius: 4px;
}

.plan-editor-body.is-steps .formula-tooth.is-plan-site-latest {
  background: rgba(250, 204, 21, 0.42);
  box-shadow: inset 0 0 0 2px #ca8a04;
  border-radius: 4px;
}

.plan-editor-body.is-steps .formula-tooth.is-plan-site select,
.plan-editor-body.is-steps .formula-tooth.is-plan-site-latest select {
  background: transparent;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 2px 6px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.check-item input {
  flex: 0 0 auto;
  margin: 0;
}

.srp-plan {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.srp-chart {
  display: grid;
  grid-template-rows: auto auto;
  gap: 0;
  border: 1px solid #c9a8a3;
  border-radius: 6px;
  background: rgba(255,255,255,.55);
  overflow: visible;
}

.srp-arch {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr)) 2px repeat(8, minmax(0, 1fr));
  gap: 2px;
  padding: 3px 4px;
  position: relative;
  overflow: visible;
}

.srp-arch.is-upper {
  border-bottom: 1px solid #c9a8a3;
  padding-top: 10px;
  padding-bottom: 6px;
}

.srp-arch.is-lower {
  padding-top: 8px;
  padding-bottom: 4px;
}

.srp-arch::before {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: calc(50% - 1px);
  width: 2px;
  background: #c9a8a3;
  pointer-events: none;
}

.srp-tooth {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  min-height: 1.35rem;
  padding: 2px 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  color: #2b2420;
  text-align: center;
  border-radius: 3px;
  cursor: pointer;
}

.srp-cell {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 1.35rem;
  overflow: visible;
}

.srp-cell.is-gone {
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    rgba(148, 163, 184, 0.18) 3px,
    rgba(148, 163, 184, 0.18) 5px
  );
  border-radius: 3px;
  opacity: 0.55;
}

.srp-formula-hint {
  margin: 2px 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: #8a6a65;
}

.srp-cell.is-set {
  background: var(--srp-bg);
  border-radius: 3px;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.35);
}

.srp-tooth.is-picking {
  outline: 2px solid #0d9488;
  outline-offset: 0;
  background: rgba(13, 148, 136, 0.12);
}

.srp-tooth.is-set {
  color: var(--srp-ink);
  cursor: default;
}

.srp-del {
  position: absolute;
  top: -4px;
  right: -2px;
  z-index: 2;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #5c4a42;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.srp-order {
  position: absolute;
  top: -5px;
  left: -2px;
  z-index: 2;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 2px;
  border-radius: 999px;
  background: #fff;
  color: var(--srp-ink, #5c4a42);
  border: 1.5px solid var(--srp-ink, #5c4a42);
  box-shadow: 0 1px 2px rgba(43, 36, 32, 0.16);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.srp-plan.is-preview-mode .srp-order {
  min-width: 1.3rem;
  height: 1.3rem;
  font-size: 0.9rem;
  border-width: 2px;
  box-shadow: 0 1px 3px rgba(43, 36, 32, 0.2);
}

.srp-plan.is-preview-mode .srp-arch.is-upper {
  padding-top: 12px;
}

.srp-cell:nth-child(8) { grid-column: 8; }
.srp-cell:nth-child(9) { grid-column: 10; }

.srp-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.occ-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.occ-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: nowrap;
}

.occ-group-title {
  flex: 0 0 3.6rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: #8a6a65;
}

.occ-pick {
  position: relative;
  flex: 0 0 1.35rem;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid #cfc3b6;
  border-radius: 4px;
  background: #efe6dc;
}

.occ-pick.is-disabled {
  opacity: 0.4;
}

.occ-pick select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1.55rem;
  font-weight: 700;
}

.occ-pick::after {
  content: '▾';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #5c4a42;
  font-size: 0.78rem;
  font-weight: 800;
}

.occ-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.occ-chip {
  border: 1px solid #c9a8a3;
  border-radius: 999px;
  padding: 2px 9px 2px 10px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  background: #fff7f5;
  color: #5c4a42;
  cursor: pointer;
  white-space: nowrap;
}

.occ-chip::after {
  content: ' ×';
  font-weight: 800;
  color: #a67c74;
}

.occ-block.is-preview .occ-pick {
  display: none;
}

.occ-block.is-preview .occ-chip {
  cursor: default;
  padding-right: 10px;
}

.occ-block.is-preview .occ-chip::after {
  content: none;
}

.occ-talk-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
  flex-wrap: nowrap;
  padding-left: 0;
}

.occ-talk-items {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.28rem;
  min-width: 0;
  flex: 0 1 auto;
  margin: 0;
  padding: 0;
}

.occ-talk {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 0;
}

.occ-talk-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #5c4a42;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.occ-talk-box {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: 1.5px solid #c9a8a3;
  border-radius: 3px;
  background: rgba(255,255,255,.9);
  font: inherit;
  font-size: 0.5rem;
  font-weight: 800;
  line-height: 1;
  color: #111;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.occ-talk-box.is-on {
  border-color: #0f766e;
  background: #ecfdf5;
}

.plan-steps {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #d7a8a3;
  background: rgba(255,255,255,.18);
}

.plan-steps-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.plan-flow-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.plan-flow-label-row .plan-flow-label {
  margin-bottom: 0;
}

.plan-strip-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.plan-strip-toolbar .btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.btn-sm { padding: 4px 8px; font-size: 0.75rem; }

.plan-steps-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 0 8px 10px;
}

.plan-steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-step {
  position: relative;
  display: grid;
  grid-template-columns: 1.4rem 1.4rem 1fr 1.4rem;
  gap: 4px;
  align-items: start;
  background: rgba(255,255,255,.72);
  border: 1px solid #d7a8a3;
  border-radius: 8px;
  padding: 4px;
}

.plan-step.is-preview-step {
  grid-template-columns: 1.6rem 1fr auto;
  cursor: inherit;
  align-items: center;
}

.plan-step.is-preview-step .step-mark {
  align-self: center;
  line-height: 1;
  padding: 0;
}

.plan-step.is-preview-step .step-open {
  cursor: inherit;
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 2px 4px;
}

.plan-step.is-preview-step .step-preview-body {
  align-items: stretch;
}

.plan-step.is-preview-step .step-open-main {
  align-items: center;
}

.plan-step.is-done {
  background: rgba(255, 248, 247, 0.92);
}

.step-done-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  margin: 2px 2px 0 0;
  padding: 0;
  border: 2.5px solid #c24141;
  border-radius: 0.35rem;
  background: rgba(255, 245, 244, 0.94);
  color: #c24141;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Hiragino Sans", serif;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  box-shadow:
    inset 0 0 0 1.5px rgba(194, 65, 65, 0.45),
    0 1px 2px rgba(194, 65, 65, 0.12);
  transform: rotate(-14deg);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.plan-editor-steps .step-done-stamp {
  width: 4.3rem;
  height: 4.3rem;
  border-width: 3.5px;
  border-radius: 0.5rem;
  font-size: 2.1rem;
  box-shadow:
    inset 0 0 0 2px rgba(194, 65, 65, 0.45),
    0 2px 4px rgba(194, 65, 65, 0.14);
}

.step-done-stamp.is-toggle {
  position: absolute;
  top: 8px;
  right: 0.45rem;
  z-index: 5;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.55;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    inset 0 0 0 1.5px rgba(194, 65, 65, 0.45),
    0 1px 4px rgba(194, 65, 65, 0.18);
}

.step-done-stamp.is-done {
  opacity: 1;
  border-style: solid;
  background: rgba(255, 245, 244, 0.96);
}

.step-done-stamp.is-toggle.is-done {
  opacity: 1;
}

.step-done-stamp.is-toggle:active {
  transform: rotate(-14deg) scale(0.94);
}

.plan-step.dragging {
  opacity: 0.72;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.22);
  transform: scale(1.01);
  z-index: 5;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(15, 118, 110, 0.45);
  cursor: grabbing;
}

.plan-step.is-drag-source {
  display: none !important;
}

.plan-step.is-placeholder {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 2px dashed rgba(15, 118, 110, 0.45);
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.08);
  pointer-events: none;
}

.plan-step-ghost {
  position: fixed;
  z-index: 10000;
  margin: 0;
  list-style: none;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  background: rgba(255, 255, 255, 0.97);
  border: 1.5px solid rgba(15, 118, 110, 0.5);
  opacity: 0.96;
  transform: scale(1.02);
  cursor: grabbing;
}

body.is-plan-step-dragging {
  cursor: grabbing !important;
  user-select: none;
  -webkit-user-select: none;
}

body.is-plan-step-dragging .plan-steps-scroll {
  touch-action: none;
}

.step-handle {
  display: none;
}

.step-mark {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 2px;
  text-align: center;
}

.plan-step textarea {
  min-height: 3.2rem;
  font-size: 0.78rem;
  border: 0;
  background: transparent;
  padding: 4px 2px;
}

.step-open {
  min-height: 2.4rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 4px 4px;
  font: inherit;
  text-align: left;
  color: #2b2420;
  cursor: pointer;
}

.step-open.is-empty {
  color: #aa8f86;
  font-weight: 600;
}

.step-placeholder {
  font-size: 0.82rem;
  font-weight: 600;
  color: #aa8f86;
}

.step-nosite {
  font-size: 0.82rem;
  font-weight: 800;
  color: #5c4a42;
}

.step-tx {
  font-size: 0.92rem;
  font-weight: 800;
  color: #2b2420;
  line-height: 1.2;
}

.step-site-chart {
  display: none;
}

/* Zigmondy（Palmer）部位表記 — 十字は共有グリッドで縦線を一致 */
.zp-chart {
  display: inline-grid;
  width: max-content;
  max-width: 100%;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.05;
  color: #2b2420;
  letter-spacing: 0;
  user-select: none;
  align-items: stretch;
  justify-items: stretch;
}

.zp-chart.has-right.has-left {
  grid-template-columns: max-content 1.5px max-content;
}

.zp-chart.has-right:not(.has-left) {
  grid-template-columns: max-content 1.5px;
}

.zp-chart.has-left:not(.has-right) {
  grid-template-columns: 1.5px max-content;
}

.zp-chart.has-upper.has-lower {
  grid-template-rows: auto 1.5px auto;
}

.zp-chart.has-upper:not(.has-lower) {
  grid-template-rows: auto 1.5px;
}

.zp-chart.has-lower:not(.has-upper) {
  grid-template-rows: 1.5px auto;
}

.zp-v,
.zp-h {
  background: #3f3530;
  pointer-events: none;
}

/* --- 両側あり --- */
.zp-chart.has-right.has-left .zp-v {
  grid-column: 2;
  grid-row: 1 / -1;
}

.zp-chart.has-right.has-left.has-upper.has-lower .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-right.has-left.has-upper.has-lower .is-ur { grid-column: 1; grid-row: 1; }
.zp-chart.has-right.has-left.has-upper.has-lower .is-ul { grid-column: 3; grid-row: 1; }
.zp-chart.has-right.has-left.has-upper.has-lower .is-lr { grid-column: 1; grid-row: 3; }
.zp-chart.has-right.has-left.has-upper.has-lower .is-ll { grid-column: 3; grid-row: 3; }

.zp-chart.has-right.has-left.has-upper:not(.has-lower) .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-right.has-left.has-upper:not(.has-lower) .is-ur { grid-column: 1; grid-row: 1; }
.zp-chart.has-right.has-left.has-upper:not(.has-lower) .is-ul { grid-column: 3; grid-row: 1; }
.zp-chart.has-right.has-left.has-upper:not(.has-lower) .is-lr,
.zp-chart.has-right.has-left.has-upper:not(.has-lower) .is-ll { display: none; }

.zp-chart.has-right.has-left.has-lower:not(.has-upper) .zp-h {
  grid-column: 1 / -1;
  grid-row: 1;
}
.zp-chart.has-right.has-left.has-lower:not(.has-upper) .is-lr { grid-column: 1; grid-row: 2; }
.zp-chart.has-right.has-left.has-lower:not(.has-upper) .is-ll { grid-column: 3; grid-row: 2; }
.zp-chart.has-right.has-left.has-lower:not(.has-upper) .is-ur,
.zp-chart.has-right.has-left.has-lower:not(.has-upper) .is-ul { display: none; }

/* --- 右側のみ --- */
.zp-chart.has-right:not(.has-left) .zp-v {
  grid-column: 2;
  grid-row: 1 / -1;
}
.zp-chart.has-right:not(.has-left) .is-ul,
.zp-chart.has-right:not(.has-left) .is-ll { display: none; }

.zp-chart.has-right:not(.has-left).has-upper.has-lower .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-right:not(.has-left).has-upper.has-lower .is-ur { grid-column: 1; grid-row: 1; }
.zp-chart.has-right:not(.has-left).has-upper.has-lower .is-lr { grid-column: 1; grid-row: 3; }

.zp-chart.has-right:not(.has-left).has-upper:not(.has-lower) .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-right:not(.has-left).has-upper:not(.has-lower) .is-ur { grid-column: 1; grid-row: 1; }
.zp-chart.has-right:not(.has-left).has-upper:not(.has-lower) .is-lr { display: none; }

.zp-chart.has-right:not(.has-left).has-lower:not(.has-upper) .zp-h {
  grid-column: 1 / -1;
  grid-row: 1;
}
.zp-chart.has-right:not(.has-left).has-lower:not(.has-upper) .is-lr { grid-column: 1; grid-row: 2; }
.zp-chart.has-right:not(.has-left).has-lower:not(.has-upper) .is-ur { display: none; }

/* --- 左側のみ --- */
.zp-chart.has-left:not(.has-right) .zp-v {
  grid-column: 1;
  grid-row: 1 / -1;
}
.zp-chart.has-left:not(.has-right) .is-ur,
.zp-chart.has-left:not(.has-right) .is-lr { display: none; }

.zp-chart.has-left:not(.has-right).has-upper.has-lower .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-left:not(.has-right).has-upper.has-lower .is-ul { grid-column: 2; grid-row: 1; }
.zp-chart.has-left:not(.has-right).has-upper.has-lower .is-ll { grid-column: 2; grid-row: 3; }

.zp-chart.has-left:not(.has-right).has-upper:not(.has-lower) .zp-h {
  grid-column: 1 / -1;
  grid-row: 2;
}
.zp-chart.has-left:not(.has-right).has-upper:not(.has-lower) .is-ul { grid-column: 2; grid-row: 1; }
.zp-chart.has-left:not(.has-right).has-upper:not(.has-lower) .is-ll { display: none; }

.zp-chart.has-left:not(.has-right).has-lower:not(.has-upper) .zp-h {
  grid-column: 1 / -1;
  grid-row: 1;
}
.zp-chart.has-left:not(.has-right).has-lower:not(.has-upper) .is-ll { grid-column: 2; grid-row: 2; }
.zp-chart.has-left:not(.has-right).has-lower:not(.has-upper) .is-ul { display: none; }

.zp-quad {
  display: inline-flex;
  gap: 0;
  min-height: 1em;
  min-width: 0;
  white-space: nowrap;
  box-sizing: border-box;
}

.zp-quad.is-ur,
.zp-quad.is-lr {
  justify-content: flex-end;
  text-align: right;
  padding: 0 0.12em 0 0.15em;
}

.zp-quad.is-ul,
.zp-quad.is-ll {
  justify-content: flex-start;
  text-align: left;
  padding: 0 0.15em 0 0.12em;
}

.zp-chart.has-upper .zp-quad.is-ur,
.zp-chart.has-upper .zp-quad.is-ul {
  padding-bottom: 0.04em;
}

.zp-chart.has-lower .zp-quad.is-lr,
.zp-chart.has-lower .zp-quad.is-ll {
  padding-top: 0.04em;
}

.zp-n,
.zp-run {
  display: inline-block;
  min-width: 0;
  text-align: inherit;
  letter-spacing: 0.01em;
}

.step-open-main {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.step-open-main .step-tx-warn {
  flex: 1 1 100%;
  margin-left: 0;
}

.step-open-main .zp-chart {
  flex: 0 0 auto;
}

.step-open-main .step-tx {
  flex: 0 1 auto;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.tx-rest-md {
  display: inline-block;
  line-height: 1.2;
  vertical-align: middle;
}

.tx-rest-split {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.tx-rest-arch-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.tx-rest-arch-row .zp-chart {
  flex: 0 0 auto;
}

.tx-rest-seq {
  white-space: nowrap;
}

.tx-clasp-types-text {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.88em;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  max-width: 100%;
  overflow-x: auto;
}

.visit-tx-group.is-rest-clasp .visit-tx-names,
.visit-tx-name .tx-rest-split {
  width: 100%;
}

.plan-editor-steps .plan-step-row {
  min-width: 0;
}

.step-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin-top: 0.2rem;
  padding: 0;
  border: 1.5px solid #c24141;
  border-radius: 999px;
  background: #fff5f4;
  color: #c24141;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(194, 65, 65, 0.18);
}

.step-remove:active {
  background: #fde8e6;
  transform: scale(0.96);
}

.plan-step-empty {
  color: var(--muted);
  text-align: center;
  padding: 16px 8px;
  font-size: 0.8rem;
}

.formula-field { margin-bottom: 4px; }

.formula-axis {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #8a6a65;
  margin-bottom: 2px;
}

.formula-arch.is-upper { margin-bottom: 2px; }
.formula-arch.is-lower { margin-top: 2px; }

.formula-arch-stack {
  position: relative;
  min-width: 0;
  overflow: visible;
}

.formula-beam-layer,
.formula-teeth,
.formula-nums {
  display: grid;
  grid-template-columns: repeat(8, 1fr) 3px repeat(8, 1fr);
  gap: 1px;
}

.formula-teeth-wrap {
  position: relative;
  z-index: 4; /* デンチャー赤枠（outer=3）より上：クラスプ→・種類・レストを常に前面へ */
  min-width: 0;
  overflow: visible;
}

.formula-beam-layer {
  min-height: 0;
  align-items: end;
  overflow: visible;
  grid-auto-rows: max-content;
}

.formula-arch.is-lower .formula-beam-layer {
  align-items: start;
}

.formula-teeth {
  overflow: visible;
}

.formula-prostho-inner {
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 0;
}

.formula-prostho-inner:has(.formula-denture-block.is-inner) {
  min-height: 28px;
}

.formula-denture-block {
  position: relative;
  min-width: 0;
  z-index: 1;
}

.formula-denture-block.is-outer {
  z-index: 3;
  pointer-events: none;
}

.formula-denture-block.is-outer .br-del {
  pointer-events: auto;
}

.formula-arch.is-upper .formula-denture-block {
  display: flex;
  flex-direction: column;
}

.formula-arch.is-lower .formula-denture-block {
  display: flex;
  flex-direction: column-reverse;
}

.formula-denture-block.is-inner {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
}

.formula-denture-block.is-inner .br-del {
  pointer-events: auto;
}

.formula-arch.is-upper .formula-denture-block.is-inner {
  justify-content: flex-end;
}

.formula-arch.is-lower .formula-denture-block.is-inner {
  flex-direction: column-reverse;
  justify-content: flex-start;
}

.formula-beam-layer.is-denture-caps {
  align-items: center;
  pointer-events: none;
}

.formula-beam-layer.is-denture-caps .br-del {
  pointer-events: auto;
}

.den-layer {
  display: grid;
  grid-template-columns: repeat(8, 1fr) 3px repeat(8, 1fr);
  gap: 1px;
  pointer-events: none;
  height: 14px;
}

.formula-denture-block.is-inner .den-layer {
  height: 12px;
}

/* 2段目: 縦線を歯マス外側まで伸ばす（Br段をまたいでマス縁に着地） */
.formula-arch.is-upper .formula-denture-block.is-outer .den-layer {
  height: 43px;
  margin-bottom: -29px;
}

.formula-arch.is-lower .formula-denture-block.is-outer .den-layer {
  height: 43px;
  margin-top: -29px;
}

.den-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.formula-arch.is-lower .den-cell {
  flex-direction: column-reverse;
}

.den-h {
  height: 2px;
  background: #c24141;
  flex-shrink: 0;
  margin-left: -1px;
  margin-right: -1px;
}

.den-cell.is-start .den-h {
  margin-left: 50%;
}

.den-cell.is-end .den-h {
  margin-right: 50%;
}

.den-cell.is-start.is-end .den-h {
  margin-left: 50%;
  margin-right: 50%;
}

.den-v {
  width: 2px;
  align-self: center;
  flex: 1 1 auto;
  min-height: 0;
  background: #c24141;
  margin-top: -2px;
}

.formula-arch.is-lower .den-v {
  margin-top: 0;
  margin-bottom: -2px;
}

.den-cell.is-draft .den-h {
  background: repeating-linear-gradient(to right, #c24141 0 4px, transparent 4px 7px);
}

.den-cell.is-draft .den-v {
  background: repeating-linear-gradient(to bottom, #c24141 0 4px, transparent 4px 7px);
}

.br-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.formula-arch.is-lower .br-group {
  flex-direction: column-reverse;
}

.br-caption {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1;
  margin: 1px 0;
  pointer-events: auto;
  white-space: nowrap;
}

.br-beam {
  width: 100%;
  height: 9px;
  border: 2px solid #2563eb;
  background: transparent;
  padding: 0;
  pointer-events: none;
}

.formula-arch.is-upper .br-beam {
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}

.formula-arch.is-lower .br-beam {
  border-top: 0;
  border-radius: 0 0 6px 6px;
}

.br-group.is-draft .br-beam {
  border-style: dashed;
}

.br-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: center;
}

.br-del::after {
  content: '×';
  display: block;
  line-height: 1;
  font-weight: 800;
  transform: translateY(0.05em);
}

.br-group.is-denture .br-caption { color: #c24141; }
.br-group.is-denture .br-del { background: #c24141; }

.formula-row {
  display: grid;
  grid-template-columns: 1rem 1fr;
  gap: 2px;
  align-items: start;
}

.formula-arch.is-upper .formula-row {
  align-items: end;
}

.formula-jaw {
  font-size: 0.66rem;
  font-weight: 700;
}

.formula-tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  position: relative;
  z-index: 1;
  overflow: visible;
}

/* クラスプ印のある歯は隣歯より前面（正中付近の重なり対策） */
.formula-tooth:has(.clasp-mark),
.formula-tooth:has(.clasp-approach),
.formula-tooth:has(.clasp-rest),
.formula-tooth.is-clasp-done,
.formula-tooth.is-clasp-active,
.formula-tooth.is-clasp-md-host {
  z-index: 5;
}

.formula-face {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-weight: 800;
  line-height: 1.05;
  color: #000;
}

.formula-tooth.is-horizontal .formula-face {
  writing-mode: horizontal-tb;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.formula-tooth.is-vertical .formula-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  writing-mode: horizontal-tb;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.formula-tooth.is-vertical .formula-face .fv {
  display: block;
  line-height: 1.05;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.formula-tooth.is-missing .formula-face {
  color: #111;
}

.formula-tooth.is-implant .formula-face {
  color: #1d4ed8;
  font-weight: 800;
}

.formula-tooth.is-implant select {
  background: #eff6ff;
}

.formula-tooth.formula-mid { margin-left: 0; }

.formula-tooth:nth-child(9) {
  grid-column: 10;
}

.formula-num {
  display: block;
  text-align: center;
  font-size: 0.55rem;
  color: #8a6a65;
  line-height: 1.1;
  padding: 1px 0 0;
}

.formula-arch.is-lower .formula-num {
  padding: 0 0 1px;
}

.formula-num.formula-mid,
.formula-num:nth-child(9) {
  grid-column: 10;
}

.formula-num.is-deciduous {
  color: #1d4ed8;
  font-weight: 800;
}

.formula-tooth.is-deciduous-target {
  outline: 1px dashed rgba(29, 78, 216, 0.45);
  outline-offset: -1px;
}

.formula-tooth select,
.formula-tooth input {
  width: 100%;
  min-width: 0;
  border: 1px solid #c9a8a3;
  border-radius: 4px;
  padding: 6px 0;
  min-height: 2.4rem;
  font-size: 1.56rem;
  line-height: 1.15;
  font-weight: 700;
  text-align: center;
  color: transparent;
  background: rgba(255,255,255,.8);
  appearance: none;
  position: relative;
  z-index: 2;
  caret-color: transparent;
}

.formula-tooth select option {
  font-size: 1.56rem;
  font-weight: 700;
  color: #111;
  background: #fff;
}

.formula-tooth.is-missing select {
  background: #d4d4d4;
  color: transparent;
  border-color: #b0b0b0;
}

.formula-tooth.is-pontic select {
  background: repeating-linear-gradient(-45deg, #93c5fd 0 3px, #dbeafe 3px 7px);
  border-color: #2563eb;
}

.formula-tooth.is-denture select {
  background: repeating-linear-gradient(-45deg, #f4b4ae 0 3px, #fde8e6 3px 7px);
  border-color: #c24141;
}

.formula-tooth.is-missing.is-pontic select {
  background:
    repeating-linear-gradient(-45deg, #60a5fa 0 3px, transparent 3px 7px),
    #d4d4d4;
  border-color: #2563eb;
  box-shadow: inset 0 0 0 2px #2563eb;
}

.formula-tooth.is-missing.is-denture select {
  background:
    repeating-linear-gradient(-45deg, #f4b4ae 0 3px, transparent 3px 7px),
    #d4d4d4;
  border-color: #c24141;
  box-shadow: inset 0 0 0 2px #c24141;
}

.formula-tooth.is-abutment select {
  box-shadow: inset 0 0 0 2px #2563eb;
}

.formula-tooth.is-picking {
  outline: 2px solid #0d9488;
  outline-offset: 0;
  border-radius: 4px;
}

.formula-tooth.is-br-used {
  opacity: 0.45;
  pointer-events: none;
}

.formula.is-editing .formula-tooth select {
  pointer-events: none;
  caret-color: transparent;
}

.formula.is-editing .formula-tooth {
  cursor: pointer;
}

.formula-tools {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.formula-tools .btn {
  flex: 0 0 auto;
  width: auto;
}

.formula-mat-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.formula-mat-btn {
  min-height: 2.6rem;
  padding: 0.55rem 0.9rem !important;
  font-size: 0.95rem !important;
  font-weight: 800 !important;
  border: 2px solid #0f766e !important;
  color: #0f766e !important;
  background: #fff !important;
  border-radius: 10px !important;
}

.formula-mat-btn:active {
  background: #ecfdf5 !important;
}

.formula-tooth.is-mat-pick {
  outline: 2px solid #0f766e;
  outline-offset: 1px;
  background: rgba(15, 118, 110, 0.08);
}

.formula-hint {
  margin: 4px 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: #8a6a65;
}

.formula-hint.is-alert {
  color: #c24141;
}

.plan-scroll {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.field textarea,
.field input,
.plan-date input,
.foot-field input,
.staff-note,
.site-note,
.progress-table input[type="date"],
.progress-table textarea {
  width: 100%;
  border: 1px solid #d7a8a3;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-weight: 500;
  background: rgba(255,255,255,.72);
  resize: none;
}

.progress-table textarea,
.progress-table input[type="date"],
.staff-note {
  border-color: #ddd2c6;
  background: #fff;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.site-cell { display: flex; flex-direction: column; gap: 4px; }

.quad {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 1;
  border: 1.5px solid #5c403c;
  background: rgba(255,255,255,.55);
}

.quad::before,
.quad::after {
  content: "";
  position: absolute;
  background: #5c403c;
  pointer-events: none;
}

.quad::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 1.5px;
  transform: translateX(-50%);
}

.quad::after {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 1.5px;
  transform: translateY(-50%);
}

.quad .q {
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 0.78rem;
  padding: 0 4px;
  z-index: 1;
}

.site-note { font-size: 0.7rem; padding: 3px 5px; }

.arch-sketch {
  margin-top: 8px;
  padding: 6px 4px;
  border-top: 1px dashed #d7a8a3;
}

.arch-row {
  display: flex;
  justify-content: center;
  gap: 2px;
}

.arch-row.lower { margin-top: 4px; transform: scaleY(-1); }

.tooth {
  width: 16px;
  height: 18px;
  border: 1px solid #8a6a65;
  border-radius: 7px 7px 3px 3px;
  font-size: 0.58rem;
  display: grid;
  place-items: center;
  color: #8a6a65;
}

.progress-frame {
  flex: 1;
  min-height: 0;
  min-width: 0;
  margin: 0 10px;
  border: 1px solid #4a3f39;
  background: #fff;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.progress-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.progress-table th,
.progress-table td {
  border: 1px solid #cfc3b6;
  vertical-align: top;
  padding: 4px;
}

.progress-table thead th {
  background: #f3ebe3;
  font-size: 0.88rem;
  line-height: 1.2;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 #4a3f39;
  border-bottom: 1px solid #4a3f39;
}

.progress-table td.col-tx,
.progress-table td.col-next {
  /* 行高に合わせて子の height:100% を効かせる */
  height: 1px;
}

.col-date { width: 8.6rem; min-width: 8.6rem; }
/* 元の Next 見た目の約 2/3。狭くしすぎた 10% から戻す */
.progress-table .col-tx,
.progress-table col.col-tx {
  width: 28%;
}
.progress-table .col-next,
.progress-table col.col-next {
  width: 20%;
}

.visit-tx-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px;
  min-height: 4.5rem;
  justify-content: center;
}

.visit-tx-source-btn {
  width: 100%;
  padding: 0.65rem 0.75rem !important;
  font-size: 0.88rem !important;
  font-weight: 800 !important;
  line-height: 1.25;
  border-radius: 8px !important;
  border: 2px solid #0f766e !important;
  background: #fff !important;
  color: #0f766e !important;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.14);
}

.visit-tx-source-btn.is-menu {
  background: #0f766e !important;
  color: #fff !important;
}

.visit-tx-source-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  border-color: #94a3b8 !important;
  color: #64748b !important;
  background: #f1f5f9 !important;
  box-shadow: none;
}

.visit-tx-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.visit-tx-source-btn-sm {
  width: auto !important;
  padding: 0.4rem 0.65rem !important;
  font-size: 0.78rem !important;
}

.next-source-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(30, 24, 20, 0.18);
}

.next-source-float {
  position: fixed;
  z-index: 81;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: min(20rem, calc(100vw - 24px));
  max-width: min(26rem, calc(100vw - 16px));
  padding: 16px 18px;
  border-radius: 14px;
  background: #fffdf9;
  border: 1px solid rgba(15, 118, 110, 0.28);
  box-shadow: 0 12px 32px rgba(60, 40, 30, 0.22);
}

.next-source-float.is-pick {
  width: min(96vw, 72rem);
  max-width: min(96vw, 72rem);
  min-width: min(96vw, 20rem);
  max-height: min(92vh, 58rem);
  padding: 14px 16px 10px;
  overflow: hidden;
}

.next-source-float-head {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f766e;
}

.next-source-float-btn {
  width: 100%;
  min-height: 3.1rem;
  padding: 1rem 1.1rem !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  border-radius: 10px !important;
  border: 2px solid #0f766e !important;
  background: #fff !important;
  color: #0f766e !important;
  touch-action: manipulation;
}

.next-source-float-btn.is-menu {
  background: #0f766e !important;
  color: #fff !important;
}

.next-source-float-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #94a3b8 !important;
  color: #64748b !important;
  background: #f1f5f9 !important;
}

.next-source-float-close {
  align-self: stretch;
  min-height: 2.6rem;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  padding: 0.65rem 0.85rem !important;
}

.next-source-pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 12px 16px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 4px;
  align-items: start;
}

.next-source-pick-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 8px;
  border-radius: 8px;
  border: 1px solid #e2cfc8;
  background: #fff;
}

.next-source-pick-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}

.next-source-unit-remove {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  padding: 0;
  border: 1.5px solid #c24141;
  border-radius: 999px;
  background: #fff5f4;
  color: #c24141;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.next-source-unit-remove:active {
  background: #fde8e6;
  transform: scale(0.96);
}

.next-source-pick-row.is-on {
  border-color: #0f766e;
  background: rgba(15, 118, 110, 0.08);
}

.next-source-pick-label {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.35;
  color: #2b2420;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.next-source-pick-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.next-source-pick-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.next-source-unit-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.next-source-unit-row .zp-chart {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

.next-source-pick-name {
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.25;
  color: #2b2420;
}

.next-source-plan-mark {
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 900;
  color: #0f766e;
  letter-spacing: 0.02em;
  line-height: 1;
}

.next-source-offplan-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid #c24141;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.next-source-pick-row.is-offplan {
  border-color: #f0a8a8;
  background: #fff7f7;
}

.next-source-pick-row.is-offplan.is-on {
  border-color: #c24141;
  background: #fee2e2;
}

.next-source-simul-badge {
  display: inline-block;
  margin-right: 0.4em;
  padding: 0.1em 0.45em;
  border-radius: 4px;
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: 0.05em;
}

.next-source-pick-row.is-simul {
  border-color: rgba(15, 118, 110, 0.45);
}

.next-source-empty {
  margin: 0;
  padding: 8px;
  font-size: 0.85rem;
  color: #64748b;
}

.next-source-float-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  flex: 0 0 auto;
  margin-top: 4px;
  padding: 12px 8px 6px;
  border-top: 1px solid #e8ddd6;
}

.next-source-action-btn {
  min-width: 8.5rem;
  min-height: 3rem;
  padding: 0.85rem 1.35rem !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  border-radius: 10px !important;
  touch-action: manipulation;
}

.next-source-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.visit-tx-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100%;
  height: 100%;
  box-sizing: border-box;
}

.visit-tx-list.is-split {
  gap: 3px;
}

.visit-tx-list.is-split .visit-tx-lane,
.visit-tx-list.is-single .visit-tx-lane {
  flex: 0 0 auto;
  overflow: visible;
  min-height: 0;
}

.visit-tx-list.is-split .visit-tx-lane {
  border: 1px solid #e4d4ce;
  border-radius: 6px;
  padding: 3px 4px 4px;
  background: #fbf8f6;
}

.visit-tx-lane {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.visit-tx-lane-tag {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 1px 5px;
  border-radius: 3px;
}

.visit-tx-lane.is-dr .visit-tx-lane-tag {
  color: #1e3a8a;
  background: rgba(37, 99, 235, 0.12);
}

.visit-tx-lane.is-dh .visit-tx-lane-tag {
  color: #115e59;
  background: rgba(15, 118, 110, 0.12);
}

.visit-tx-lane-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.visit-tx-group {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid #e2cfc8;
  border-radius: 6px;
  background: #fff;
  min-width: 0;
}

.visit-tx-group.is-simul {
  border-color: #0f766e;
  background: rgba(15, 118, 110, 0.04);
}

.visit-tx-group.is-simul.is-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.visit-tx-simul-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.visit-tx-simul-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.visit-tx-simul-row .zp-chart {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

.visit-tx-nosite {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
}

.visit-tx-simul-badge {
  flex: 0 0 auto;
  font-size: 0.58rem;
  font-weight: 900;
  color: #0f766e;
  border: 1px solid #0f766e;
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.35;
}

.pset-srp-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #e2cfc8;
  border-radius: 6px;
  background: #fff;
  max-height: none;
  overflow: visible;
}

.pset-srp-line {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  color: #2b2420;
}

.pset-srp-label {
  flex: 0 0 auto;
  min-width: 2.8rem;
  font-weight: 900;
  color: #0f766e;
}

.pset-srp-line .zp-chart {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

.pset-srp-line .step-nosite {
  font-size: 0.72rem;
}

.visit-tx-group .zp-chart {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

.visit-tx-names {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.visit-tx-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 3px;
  max-width: 100%;
  min-width: 0;
}

.visit-tx-name {
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
  color: #2b2420;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.visit-tx-name .tx-rest-md,
.step-tx .tx-rest-md,
.next-source-pick-name .tx-rest-md {
  display: inline-block;
  max-width: 100%;
  line-height: 1.2;
}

.visit-tx-name .tx-rest-seq,
.visit-tx-name .tx-clasp-types-text {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: visible;
  max-width: 100%;
}

.step-tx .tx-rest-seq,
.next-source-pick-name .tx-rest-seq {
  white-space: nowrap;
}

.step-tx .tx-clasp-types-text,
.next-source-pick-name .tx-clasp-types-text {
  white-space: nowrap;
}

.visit-tx-remove {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid #d7bfb6;
  border-radius: 999px;
  background: #fff8f6;
  color: #8a4f46;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.visit-tx-add {
  margin-top: auto;
  flex: 0 0 auto;
  width: 100%;
  padding: 5px 6px;
  border: 1px dashed #c9a8a3;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  color: #7a4f4a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.visit-tx-open {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 4.5rem;
  height: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid #ddd2c6;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  color: inherit;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.visit-tx-open.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #a89088;
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
}

.visit-tx-placeholder {
  font-weight: 600;
  white-space: nowrap;
  word-break: keep-all;
  font-size: 0.92rem;
}
.col-flag { width: 8rem; text-align: center; }
.col-staff { width: 6rem; min-width: 6rem; max-width: 6rem; }
.col-remarks { width: auto; }

.progress-table tbody td {
  height: auto;
  min-height: 5.5rem;
  vertical-align: top;
}

.col-date {
  position: relative;
  padding: 4px 6px 6px !important;
}

.date-display {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 2.8rem;
  padding: 1px 1px 0;
  overflow: visible;
}

.date-year {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.date-md {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.date-display.is-empty .date-md {
  font-size: 0.95rem;
  font-weight: 700;
  color: #9a7b74;
}

.date-display.is-same-day .date-year,
.date-display.is-same-day .date-md,
.date-same-day {
  color: #0f766e;
}

.date-same-day {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.row-delete,
.date-edit,
.row-first {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 3px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 4px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  font-family: inherit;
  box-sizing: border-box;
}

.row-delete {
  border: 1px solid #d7bfb6;
  background: #fff8f6;
  color: #8a4f46;
}

.date-edit {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  display: block;
  touch-action: manipulation;
}

.date-edit input[type="date"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1.2rem; /* iOS でネイティブピッカーが開きやすくなる */
}

.date-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin: 0;
  border: 1px solid #cfc3b6;
  border-radius: 6px;
  background: #f7f1ea;
  color: #5c4a42;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  padding: 5px 4px;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: none; /* 見た目のみ。タップは上の date input が受ける */
}

.row-first {
  border: 1px solid #e8b4b0;
  background: #fff5f4;
  color: #b42318;
}

.row-first.is-on {
  background: #c24141;
  border-color: #c24141;
  color: #fff;
}

.date-edit-cal {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.col-staff {
  padding: 0 !important;
  vertical-align: stretch;
}

.staff-stack {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 11.2rem;
}

.staff-slot {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
}

.staff-slot + .staff-slot {
  border-top: 1px solid #cfc3b6;
}

.staff-role {
  position: absolute;
  top: 3px;
  left: 6px;
  z-index: 1;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}

.staff-value {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 1.1rem 6px 4px;
  font-size: 1.55rem;
  font-weight: 800;
  font-family: inherit;
  color: #2b2420;
  text-align: center;
  line-height: 1.15;
  pointer-events: none;
  word-break: keep-all;
}

.staff-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1.6rem;
  z-index: 2;
}

.staff-note { margin-top: 8px; font-size: 0.75rem; }

.progress-table textarea {
  min-height: 11.2rem;
  height: 100%;
  font-size: 1rem;
  line-height: 1.4;
}

.col-flag input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
}

.med-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 100%;
  padding-top: 4px;
}

.med-check {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.med-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
  color: #0f766e;
}

.med-summary-line {
  display: block;
  white-space: nowrap;
}

.med-picker {
  position: fixed;
  z-index: 80;
  width: 15.5rem;
  padding: 8px;
  border: 1px solid #cfc3b6;
  border-radius: 10px;
  background: #fffdf9;
  box-shadow: 0 10px 28px rgba(60, 40, 30, 0.18);
  text-align: left;
}

.med-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 14rem;
  overflow-y: auto;
}

.tx-med-list {
  max-height: min(18rem, 52vh);
  padding: 2px 0;
}

.med-option {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 4px;
  border-radius: 6px;
}

.med-option-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
}

.med-option.is-on {
  background: #e7f6f3;
}

.med-option input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
}

.med-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4a3f39;
}

.med-qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.med-qty button {
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid #cfc3b6;
  border-radius: 4px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

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

.med-qty input[type="number"] {
  width: 2.2rem;
  height: 1.35rem;
  border: 1px solid #cfc3b6;
  border-radius: 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0;
  -moz-appearance: textfield;
}

.med-qty input[type="number"]::-webkit-outer-spin-button,
.med-qty input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.med-unit {
  min-width: 1.1rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #8a6a65;
}

.med-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eadfd6;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.progress-table tbody tr.year-rule td,
.progress-table tbody tr.first-rule td {
  height: 6px;
  min-height: 6px;
  padding: 0;
  border: 0;
}

.progress-table tbody tr.year-rule td {
  background: #0d9488;
}

.progress-table tbody tr.first-rule td {
  background: #c24141;
}

.progress-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4.8rem;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.spt-group,
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.foot-field {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.foot-field input { width: 4.8rem; }

.foot-field.foot-site {
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
}

.foot-site-chart {
  display: flex;
  align-items: center;
  min-height: 2.2rem;
}

.foot-site-chart .zp-chart {
  font-size: 0.82rem;
}

.foot-field.is-alert {
  padding: 3px 8px;
  border-radius: 8px;
  border: 1.5px solid #c24141;
  background: #fef2f2;
}

.foot-field.is-alert .foot-field-label {
  color: #b91c1c;
  font-weight: 800;
}

.foot-alert {
  font-size: 0.72rem;
  font-weight: 900;
  color: #b91c1c;
  line-height: 1.2;
  max-width: 9.5rem;
  white-space: normal;
}

.formula-tooth.is-tx-pick {
  appearance: none;
  border: 1px solid #c9a8a3;
  border-radius: 4px;
  padding: 6px 0;
  min-height: 2.4rem;
  width: 100%;
  background: rgba(255,255,255,.8);
  position: relative;
  cursor: pointer;
}

.formula-tooth.is-tx-pick:disabled,
.formula-tooth.is-tx-pick.is-disabled {
  opacity: 0.28;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

/* 設定中（黄）・鉤歯（緑）・先行処置部位はグレーアウトしない */
.formula-tooth.is-tx-pick.is-disabled.is-clasp-active,
.formula-tooth.is-tx-pick:disabled.is-clasp-active,
.formula-tooth.is-tx-pick.is-disabled.is-clasp-done,
.formula-tooth.is-tx-pick:disabled.is-clasp-done,
.formula-tooth.is-tx-pick.is-disabled.is-picking,
.formula-tooth.is-tx-pick:disabled.is-picking,
.formula-tooth.is-tx-pick.is-disabled.is-prior-tx,
.formula-tooth.is-tx-pick:disabled.is-prior-tx {
  opacity: 1;
  filter: none;
  cursor: default;
}

/* 先に確定した処置の対象歯（例: In → CR のときの In 部位） */
.formula.is-tx-pick .formula-tooth.is-prior-tx {
  background: #fde68a;
  border-color: #d97706;
  box-shadow: inset 0 0 0 1px #f59e0b;
}
.formula.is-tx-pick .formula-tooth.is-prior-tx.is-picking {
  outline: 2px solid #0d9488;
  outline-offset: 0;
  background: #fef3c7;
}

.formula-tooth.is-tx-pick.is-missing {
  background: #d4d4d4;
  border-color: #b0b0b0;
}

.formula-tooth.is-tx-pick.is-pontic {
  background: repeating-linear-gradient(-45deg, #93c5fd 0 3px, #dbeafe 3px 7px);
  border-color: #2563eb;
}

.formula-tooth.is-tx-pick.is-denture {
  background: repeating-linear-gradient(-45deg, #f4b4ae 0 3px, #fde8e6 3px 7px);
  border-color: #c24141;
}

.formula-tooth.is-tx-pick.is-missing.is-pontic {
  background:
    repeating-linear-gradient(-45deg, #60a5fa 0 3px, transparent 3px 7px),
    #d4d4d4;
}

.formula-tooth.is-tx-pick.is-missing.is-denture {
  background:
    repeating-linear-gradient(-45deg, #f4b4ae 0 3px, transparent 3px 7px),
    #d4d4d4;
}

.formula.is-tx-pick .formula-tooth.is-picking {
  outline: 2px solid #0d9488;
  outline-offset: 0;
}

#tx-picker-root:empty { display: none; }

.tx-reflect-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(40, 28, 20, 0.45);
}

.tx-reflect-card {
  width: min(28rem, 100%);
  background: #fffaf6;
  border-radius: 16px;
  border: 1px solid #e2cfc8;
  box-shadow: 0 18px 48px rgba(40, 28, 20, 0.28);
  padding: 20px 20px 16px;
}

.tx-reflect-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #3f2a22;
}

.tx-reflect-lead {
  margin: 0 0 12px;
  color: #5c463c;
  font-size: 0.95rem;
}

.tx-reflect-notes {
  margin: 0 0 18px;
  padding: 12px 12px 12px 1.4rem;
  background: #fff;
  border: 1px solid #ecdcd4;
  border-radius: 10px;
  color: #4a372f;
  font-size: 0.88rem;
  line-height: 1.55;
}

.tx-reflect-notes li + li {
  margin-top: 8px;
}

.tx-reflect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tx-reflect-actions .btn {
  min-width: 7.5rem;
}

.tx-picker {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: #fffaf6;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.tx-picker-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2cfc8;
  background: #fff;
}

.tx-picker-head strong {
  font-size: 1.1rem;
}

.tx-multi-hint {
  color: #c24141;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tx-picker-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid #e2cfc8;
  background: #fff;
}

.tx-picker-close {
  min-width: min(12rem, 42vw);
  min-height: 3rem;
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 10px;
}

.tx-picker-body.is-teeth {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 11.5rem;
  gap: 12px;
  padding: 12px;
  overflow: auto;
}

.tx-picker-body.is-surfaces {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 16px 16px;
  background: linear-gradient(180deg, #f7f3ef 0%, #fffaf6 40%);
}

.tx-picker-body.is-surfaces .tx-formula-wrap {
  flex: 0 0 auto;
}

.tx-picker-body.is-surfaces .tx-surf-grid {
  flex: 1 1 auto;
}

.formula-tooth.is-tx-draft .formula-face,
.formula-tooth.is-tx-pick.is-tx-draft .formula-face {
  gap: 1px;
}

.formula-tooth.is-tx-draft .fv.is-cav {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f766e;
  line-height: 1;
}

.formula-tooth.is-tx-draft .fv.is-tx {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.05;
  color: #134e4a;
}

.formula.is-tx-pick .formula-tooth.is-tx-draft:not(.is-picking) {
  background: #ecfdf5;
  border-color: #5eead4;
}

.formula-tooth.is-tx-pick.is-disabled.is-tx-draft,
.formula-tooth.is-tx-pick:disabled.is-tx-draft {
  opacity: 1;
  filter: none;
}

/* CR: 対角線で4分割 + 周辺面に〇（O/Iは文字と重なるので無し） */
.formula-tooth.is-cr-draft {
  overflow: visible;
}

.formula-tooth.is-cr-draft::before,
.formula-tooth.is-cr-draft::after {
  content: '';
  position: absolute;
  inset: 1px;
  pointer-events: none;
  z-index: 2;
}

.formula-tooth.is-cr-draft::before {
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.6px),
    rgba(15, 118, 110, 0.45) 50%,
    transparent calc(50% + 0.6px)
  );
}

.formula-tooth.is-cr-draft::after {
  background: linear-gradient(
    to top left,
    transparent calc(50% - 0.6px),
    rgba(15, 118, 110, 0.45) 50%,
    transparent calc(50% + 0.6px)
  );
}

.formula-tooth.is-cr-draft .formula-face {
  z-index: 5;
  writing-mode: horizontal-tb;
  font-size: 0.58rem;
  letter-spacing: -0.02em;
  line-height: 1.02;
  padding: 0 1px;
  text-align: center;
  gap: 0;
}

.formula-tooth.is-cr-draft .fv.is-tx {
  font-size: 0.68rem;
  font-weight: 800;
  color: #134e4a;
  line-height: 1.05;
}

.formula-tooth.is-cr-draft .fv.is-cav.is-cr-circles {
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #0f766e;
  line-height: 1;
  white-space: nowrap;
}

.formula-tooth.is-cr-draft .fv.is-cav:not(.is-cr-circles) {
  font-size: 0.48rem;
  font-weight: 800;
  color: #0f766e;
  line-height: 1;
}

.formula-tooth .cr-surf-dot {
  position: absolute;
  z-index: 4;
  width: 0.42rem;
  height: 0.42rem;
  border: 1.6px solid #0f766e;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-sizing: border-box;
  pointer-events: none;
}

.formula-tooth .cr-surf-dot.is-top {
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
}

.formula-tooth .cr-surf-dot.is-bottom {
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
}

.formula-tooth .cr-surf-dot.is-left {
  left: 1px;
  top: 50%;
  transform: translateY(-50%);
}

.formula-tooth .cr-surf-dot.is-right {
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
}

.formula.is-tx-pick .formula-tooth.is-cr-draft:not(.is-picking) {
  background: #f0fdfa;
  border-color: #2dd4bf;
}

.formula.is-plan-flow .formula-tooth.is-cr-draft,
.formula.is-history-preview .formula-tooth.is-cr-draft {
  background: #f0fdfa;
  border-color: #2dd4bf;
}

.formula.is-plan-flow .formula-tooth.is-tx-draft:not(.is-cr-draft),
.formula.is-history-preview .formula-tooth.is-tx-draft:not(.is-cr-draft) {
  background: #ecfdf5;
  border-color: #5eead4;
}

.tx-surf-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
  justify-content: flex-start;
}

.tx-surf-arch {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
}

.tx-surf-arch.is-upper:not(:only-child) {
  padding-bottom: 14px;
  border-bottom: 1px dashed rgba(15, 118, 110, 0.28);
}

.tx-surf-card {
  min-width: 11.5rem;
  padding: 12px 14px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 118, 110, 0.22);
  box-shadow: 0 4px 14px rgba(60, 40, 30, 0.08);
}

.tx-surf-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tx-surf-site {
  flex: 0 0 auto;
}

.tx-surf-site .zp-chart {
  font-size: 1rem;
}

.tx-surf-preview {
  font-size: 0.82rem;
  font-weight: 800;
  color: #2b2420;
  text-align: right;
}

.tx-surf-preview.is-pending {
  color: #0f766e;
}

.tx-surf-split {
  width: 100%;
  margin-top: 10px;
  padding: 0.55rem 0.75rem !important;
  font-size: 0.88rem !important;
  font-weight: 800 !important;
  border-radius: 8px !important;
  border: 2px dashed #0f766e !important;
  background: rgba(15, 118, 110, 0.06) !important;
  color: #0f766e !important;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.tx-surf-split:active {
  transform: scale(0.97);
  background: rgba(15, 118, 110, 0.18) !important;
}

.tx-surf-split.is-armed {
  border-style: solid !important;
  background: #0f766e !important;
  color: #fff !important;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.22);
}

.tx-surf-pad {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.tx-surf-row {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.tx-surf-row.is-single {
  grid-template-columns: 3.2rem;
}

.tx-surf-row.is-mid {
  grid-template-columns: 3.2rem 3.2rem 3.2rem;
}

.tx-surf-row.is-wsd-pair {
  grid-template-columns: 4.2rem 4.2rem;
  gap: 12px;
}

.tx-surf-face.is-wsd {
  width: 4.2rem;
  height: 4.2rem;
  font-size: 1.25rem;
}

.tx-surf-face {
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
  border-radius: 10px;
  border: 2px solid #0f766e;
  background: #fffdf8;
  color: #0f766e;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}

.tx-surf-face.is-on {
  background: #0f766e;
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 253, 248, 0.25);
}

.tx-surf-face:active {
  transform: scale(0.96);
}

.tx-surf-spacer {
  width: 3.2rem;
  height: 3.2rem;
  display: block;
}

.tx-formula-wrap {
  min-width: 0;
  overflow: auto;
  padding: 10px 12px 14px;
  border: 1px solid #d7a8a3;
  border-radius: 10px;
  background: rgba(247, 215, 212, 0.55);
}

.tx-formula-wrap .formula {
  transform: none;
  width: 100%;
}

.tx-site-hint {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #7a4f4a;
}

.tx-site-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tx-nosite {
  width: 100%;
  font-weight: 800;
}

.tx-blocks,
.tx-jaws {
  display: grid;
  gap: 6px;
}

.tx-blocks {
  grid-template-columns: 1fr;
}

.tx-jaws {
  grid-template-columns: 1fr 1fr;
}

.tx-block {
  border: 1px solid #c9a8a3;
  border-radius: 8px;
  padding: 10px 8px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  background: #fff;
  color: #2b2420;
  cursor: pointer;
}

.tx-picker-body.is-tx {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tx-picker-body.is-tx.is-all {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 14px 18px;
}

.tx-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #8a6a65;
  padding-bottom: 2px;
  border-bottom: 1px solid #e2cfc8;
}

.tx-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 8px;
  align-content: start;
}

.tx-item {
  border: 1px solid #c9a8a3;
  border-radius: 12px;
  padding: 14px 10px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  background: #fff;
  cursor: pointer;
  min-height: 3.6rem;
}

.tx-item.is-selected {
  border-color: #c24141;
  background: #fff5f4;
  box-shadow: inset 0 0 0 2px rgba(194, 65, 65, 0.25);
}

.denture-kind-items,
.denture-flow-items,
.denture-type-items {
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

.denture-jaw-row .tx-site-hint {
  margin: 0;
}

.tx-item.is-clear:not(.is-selected) {
  opacity: 0.72;
}

.tx-item-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 3.4rem;
  line-height: 1.2;
  white-space: normal;
  text-align: center;
}

.tx-item-line {
  display: block;
}

.tx-item-line.is-muted {
  font-size: 0.78em;
  font-weight: 600;
  color: #7a6460;
}

.tx-ho-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  margin-right: 0.12em;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: 0.92em;
  font-weight: 800;
  line-height: 1;
  vertical-align: -0.08em;
  box-sizing: border-box;
}

.tx-picker-body.is-denture-clasp {
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 12rem);
}

.tx-picker-body.is-denture-clasp .tx-formula-wrap,
.tx-picker-body.is-denture-clasp .formula,
.tx-picker-body.is-denture-clasp .formula-chart,
.tx-picker-body.is-denture-clasp .formula-arch,
.tx-picker-body.is-denture-clasp .formula-teeth,
.tx-picker-body.is-denture-clasp .formula-teeth-wrap {
  overflow: visible;
}

.denture-clasp-opts .tx-items {
  grid-template-columns: 1fr;
}

.formula-tooth.is-clasp-active {
  position: relative;
  box-shadow: inset 0 0 0 3px #ca8a04;
  background: rgba(250, 204, 21, 0.35);
  z-index: 2;
  overflow: visible;
}

.formula-tooth.is-clasp-done {
  box-shadow: inset 0 0 0 2px #0f766e;
  background: rgba(15, 118, 110, 0.18);
}

/* 待ち／設定済の鉤歯は緑枠を優先（picking outline と併用） */
.formula.is-tx-pick .formula-tooth.is-picking.is-clasp-done,
.formula.is-tx-pick .formula-tooth.is-picking:not(.is-clasp-active) {
  outline: 2px solid #0f766e;
  outline-offset: 0;
  box-shadow: inset 0 0 0 2px #0f766e;
  background: rgba(15, 118, 110, 0.18);
}

.formula-tooth.is-clasp-active.is-clasp-done,
.formula.is-tx-pick .formula-tooth.is-picking.is-clasp-active {
  outline: none;
  box-shadow: inset 0 0 0 3px #ca8a04;
  background: rgba(250, 204, 21, 0.35);
}

.formula-tooth.is-clasp-md-host {
  overflow: visible;
  z-index: 6;
}

.formula-tooth .clasp-md {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #b45309;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.4rem;
  text-align: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

.formula-tooth .clasp-md.is-hit:active {
  transform: translateY(-50%) scale(0.92);
}

.formula-tooth .clasp-md.is-selected {
  background: #065f46;
  border-color: #ecfdf5;
  box-shadow: 0 0 0 2px rgba(6, 95, 70, 0.35), 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* 鉤歯を挟む：外側に大きく出す */
.formula-tooth .clasp-md-left { left: -1.35rem; }
.formula-tooth .clasp-md-right { right: -1.35rem; }

.clasp-mark.is-rest .clasp-mark-type { background: #be123c; }

.denture-approach-hint {
  margin: 0;
  padding: 8px 6px;
  text-align: center;
  line-height: 1.45;
}

.formula-tooth.is-tx-pick {
  position: relative;
}

.clasp-mark {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
  top: -0.42rem;
  left: 50%;
  transform: translateX(-50%);
}

/* 向き→があるときは同じ側の直上へ */
.clasp-mark.is-left {
  left: -0.7rem;
  right: auto;
  transform: none;
}
.clasp-mark.is-right {
  right: -0.7rem;
  left: auto;
  transform: none;
}

.clasp-mark-type {
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.12rem;
  border-radius: 3px;
  background: #1e3a8a;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 900;
  line-height: 0.95rem;
  text-align: center;
}

.clasp-mark.is-akers .clasp-mark-type { background: #1d4ed8; }
.clasp-mark.is-ibar .clasp-mark-type { background: #7c3aed; }
.clasp-mark.is-arm .clasp-mark-type { background: #0f766e; }
.clasp-mark.is-ring .clasp-mark-type { background: #b45309; }
.clasp-mark.is-combi .clasp-mark-type { background: #be185d; }

/* クラスプ向き：種類アイコンの直下に斜め→ */
.clasp-approach {
  position: absolute;
  top: 0.62rem;
  z-index: 5;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  color: #1e3a8a;
  pointer-events: none;
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff,
    1px 1px 0 #fff,
    -1px -1px 0 #fff;
}
.clasp-approach.is-left {
  left: -0.55rem;
  transform: rotate(32deg);
}
.clasp-approach.is-right {
  right: -0.55rem;
  transform: scaleX(-1) rotate(32deg);
}

/* レスト：近心／遠心の〇 */
.clasp-rest {
  position: absolute;
  bottom: 0.02rem;
  z-index: 5;
  min-width: 1.55rem;
  height: 1.05rem;
  padding: 0 0.15rem;
  border-radius: 999px;
  border: 1.5px solid #be123c;
  background: #fff;
  color: #9f1239;
  font-size: 0.48rem;
  font-weight: 800;
  line-height: 1.05rem;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.clasp-rest.is-left { left: -0.55rem; }
.clasp-rest.is-right { right: -0.55rem; }

.clasp-mark-dir {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: #b45309;
  color: #fff;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 0.9rem;
  text-align: center;
  pointer-events: none;
}

.clasp-mark-dir.is-left { left: -0.12rem; }
.clasp-mark-dir.is-right { right: -0.12rem; }

.visit-tx-chip.is-sticky-perio,
.visit-tx-chip.is-sticky-rep {
  outline: 1px dashed #0f766e;
  background: rgba(15, 118, 110, 0.08);
}

.visit-anesth-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  box-sizing: border-box;
}

.visit-anesth-label,
.visit-anesth-unit {
  white-space: nowrap;
}

.visit-anesth-ct {
  appearance: auto;
  min-width: 2.4rem;
  width: 2.6rem;
  height: 1.7rem;
  padding: 0 0.15rem;
  border: 1px solid #64748b;
  border-radius: 4px;
  background: #fff;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.visit-anesth-ct:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.visit-anesth-remove {
  margin-left: auto;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: #64748b;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.visit-anesth-remove:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.visit-tx-lane.is-dr .visit-tx-chip.is-sticky-rep {
  outline-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}

.next-source-lane-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
  min-width: 0;
}

.next-source-lane-head {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 2px 0;
}

.next-source-lane-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 6px 10px;
  align-items: stretch;
}

.next-source-lane-block.is-dr .next-source-lane-head { color: #1e3a8a; }
.next-source-lane-block.is-dh .next-source-lane-head { color: #115e59; }

.denture-rest-done {
  width: 100%;
  margin-top: 6px;
}

@media (max-width: 900px) {
  .chart-split {
    grid-template-columns: 1fr;
  }

  .tx-picker-body.is-denture-clasp {
    grid-template-columns: 1fr;
  }
}
