/* DentaPlan 2.2 – "Details anpassen" (VORAAA-80): side panel next to the therapy cards on wide screens,
 * a sheet from the bottom on tablets/phones. Tokens only; no inline styles (CSP). */

/* card: "von Hand angepasst" and the panel link */
.why-def.adj { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); color: var(--ink-2); }
.adj-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: var(--fw-semi); padding: 2px 8px; border-radius: var(--r-pill); background: var(--amber-50); color: var(--warn-ink); }
.why-def .linkish, .txcard-f .linkish { min-height: 32px; font-size: var(--fs-sm); }
.txcard-f { display: flex; justify-content: flex-end; margin-top: var(--sp-2); }
.txcard.det-on { border-color: var(--accent); box-shadow: var(--ring); }
.codes-link { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; min-height: var(--touch); }
.codes-link b { color: var(--accent-text); }
.adj-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn-ink); vertical-align: middle; }

/* the panel */
.det21 { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-4); display: grid; gap: var(--sp-3); align-content: start; min-width: 0; }
.det-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); }
.det-head h2 { margin: 0; font-size: var(--fs-xl); }
.det-head h2:focus { outline: 0; }
.det-head .tiny { display: block; }
.det-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.det-sum { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3); border-radius: var(--r-lg); background: var(--accent-50); }
.det-sum b { display: block; }
.det-sum .tiny { display: block; }
.det-sec { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.det-sec-h { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.det-sec-h h3 { margin: 0; font-size: var(--fs-lg); }
.det-teeth, .det-poss { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
/* one tooth: number, finding, kind of restoration, code, undo – the Verblendung on its own line below */
.det-tooth { display: grid; grid-template-columns: 36px 44px minmax(0, 1fr) auto 36px; gap: 6px; align-items: center; padding: 4px; border-radius: var(--r-md); }
.det-tooth [data-d21-ven], .det-tooth .det-noven { grid-column: 3 / 5; grid-row: 2; }
.det-tooth .det-noven { display: none; }
.det-tooth.hand, .det-pos.hand { background: var(--sunk); }
.det-tooth .tno { font-size: var(--fs-sm); font-weight: var(--fw-bold); text-align: center; font-variant-numeric: tabular-nums; }
.det-f .code { font-family: var(--font-mono); }
.det-noven { text-align: center; }
.det-code { min-height: 36px; min-width: 52px; padding: 0 8px; border: 1px solid var(--field-border); border-radius: var(--r-md); background: var(--field-bg); color: var(--ink); font-family: var(--font-mono); font-size: var(--fs-sm); cursor: pointer; }
.det-code:disabled { cursor: default; color: var(--ink-3); }
.det-add { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.det-pos { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 36px; gap: var(--sp-2); align-items: center; padding: 4px; border-radius: var(--r-md); }
.det-pos.gone { grid-template-columns: auto minmax(0, 1fr) auto; color: var(--ink-3); }
.det-pl { min-width: 0; font-size: var(--fs-sm); overflow-wrap: break-word; } /* long fee texts ("…wiederherstellen/erweitern") wrap instead of running under the stepper (VORAAA-85 C1) */
.det-pl .tiny { display: block; }
.det-addpos { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-3); }
.det-addpos dp-combo { flex: 1 1 200px; min-width: 0; }
.det-codes summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; gap: var(--sp-2); }
.det-codes .chart-wrap { overflow-x: auto; }
.det21 .checks { margin: 0; }
.det-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.det-scrim { display: none; }

/* wide: the panel replaces the Befund column while it is open; the cards stay visible and update live */
@media (min-width: 1081px) {
  .p21.det-open .plan { grid-template-columns: minmax(0, 1fr) minmax(380px, 460px); }
  .p21.det-open .plan > .entry { display: none; }
  .det21 { position: sticky; top: var(--sp-3); max-height: calc(100vh - 120px); overflow-y: auto; }
}
/* tablet/phone: a sheet from the bottom over the screen */
@media (max-width: 1080px) {
  .det21 { position: fixed; left: 0; right: 0; bottom: 0; top: 6vh; z-index: var(--z-sheet); border-radius: var(--radius) var(--radius) 0 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
  .det-scrim { display: block; position: fixed; inset: 0; z-index: var(--z-backdrop); background: var(--backdrop); }
  .det-foot { position: sticky; bottom: calc(-1 * var(--sp-4)); background: var(--card); padding-bottom: var(--sp-2); }
}
@media (max-width: 600px) {
  .det21 { top: 4vh; padding: var(--sp-3); }
  .det-tooth { grid-template-columns: 32px 40px minmax(0, 1fr) auto 36px; }
  .det-foot { flex-direction: column-reverse; }
  .det-foot .btn { width: 100%; }
}

/* ---------- 2.3 (VORAAA-93): tooth chart, Schnelleingabe + Diktat and full screen in the panel ---------- */
.det-head-b { display: flex; gap: 4px; flex: none; }
.det-body, .det-l, .det-r { display: contents; } /* the sections stay items of the panel's grid; full screen makes them columns */
.det21 { grid-template-columns: minmax(0, 1fr); } /* the chart scrolls instead of widening the sheet (VORAAA-93) */
.det-chartsec { min-width: 0; }
.det-chartsec .qe-wrap { margin: 0 0 var(--sp-2); }
.d21-box { position: relative; }
.d21-chart { margin: 0; }
/* a part of the jaws: only the region and its neighbours, centred */
.chart.chart-part { min-width: 0; }
.chart-part .jaw-row { display: flex; justify-content: flex-start; align-items: flex-end; }
.chart-part .jaw.lower .jaw-row { align-items: flex-start; }
.chart-part .midline { margin: 0 4px; }
.chart-part .quad { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(44px, 58px); }
.chart-part[data-rows]:not(:has(.jaw.upper))::before, .chart-part[data-rows]:not(:has(.jaw.lower))::after { content: none; } /* row labels only for the jaw shown */
/* the planned element in place (toothchart.js draw "tp"): drawn in the tooth palette of both themes */
.tooth.tpd { color: var(--tc-intact); }
.tooth.tpd .body { fill: var(--tc-intact-50); stroke: var(--tooth-intact-stroke); }
.tooth.tpd.fam-implant, .tooth.tpd.fam-denture { color: var(--tc-ink); }
.tooth .ven { fill: currentColor; opacity: .38; }
.d21-chart .tooth.inreg { background: var(--sunk); }
.d21-chart .tooth.inreg.pre, .d21-chart .tooth.pre { background: var(--accent-50); box-shadow: inset 0 0 0 2px var(--accent); }
.d21-chart button.tooth:disabled { cursor: default; opacity: .5; background: transparent; }
.d21-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: var(--sp-2) 0 0; color: var(--ink-3); }
.d21-legend .lg { display: inline-block; width: 14px; height: 10px; border-radius: 3px; border: 1.5px solid var(--tc-intact); }
.d21-legend .lg-v { background: linear-gradient(to top, color-mix(in srgb, var(--tc-intact) 38%, transparent) 50%, transparent 50%); }
.d21-legend .lg-m { background: color-mix(in srgb, var(--tc-intact) 38%, transparent); }
.d21-pop { top: calc(100% + 4px); } /* below the chart, next to the tooth (left set via CSSOM) */
.d21-pop .tpop-codes .pchip span { max-width: none; }
.d21-ven { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.qe-preview .pv.add { background: var(--accent-50); }
/* phone/tablet sheet: "Vollbild" only enlarges the chart */
.det21.big .d21-chart .quad { grid-auto-columns: minmax(56px, 76px); }
.det21.big .d21-chart .tooth svg { max-width: 64px; height: 84px; }
/* full screen (wide, 2.3): the panel covers the viewport – chart and line on the left, elements and Prüfung on the right */
@media (min-width: 1024px) {
  /* stronger than the 2.3 column rules (ws23.css: html.l23 .p21 .ws-c > .det21 / html.l23 .plan .det21) */
  html.l23 .p21 .ws-c:has(> .det21.full) { z-index: var(--z-sheet); } /* the sticky column is a stacking context: lift it over the rail and the Befund column */
  html.l23 .p21 .plan .det21.full { position: fixed; inset: 0; z-index: var(--z-sheet); max-height: none; max-width: none; margin: 0; border-radius: 0; border: 0; box-shadow: none; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5) var(--sp-6); }
  .det21.full .det-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(380px, 2fr); gap: var(--sp-5); align-items: start; }
  .det21.full .det-l, .det21.full .det-r { display: grid; gap: var(--sp-3); align-content: start; min-width: 0; }
  .det21.full .det-l { position: sticky; top: 0; }
  .det21.full .d21-chart .quad { grid-auto-columns: minmax(64px, 104px); }
  .det21.full .d21-chart .tooth svg { max-width: 88px; height: 112px; }
  .det21.full .det-foot { position: sticky; bottom: calc(-1 * var(--sp-5)); background: var(--card); padding-bottom: var(--sp-3); }
  .d21-pop { width: min(460px, calc(100% - 16px)); }
}
html:has(.det21.full) { overflow: hidden; }
