/* Erweiterungen: Dichte, Bewegung, Datenvisualisierung, Laborbuch-Details.
   Bewegung bleibt kurz (150 bis 450 ms) und respektiert prefers-reduced-motion. */

:root { --row-pad: 9px; --ease-out: cubic-bezier(.16, 1, .3, 1); }
:root[data-density="compact"] { --row-pad: 5px; }
:root[data-density="compact"] .main { padding-top: 20px; }
:root[data-density="compact"] .card-body { padding: 12px; }
:root[data-density="compact"] body { font-size: 13px; }
.row { padding-top: var(--row-pad); padding-bottom: var(--row-pad); }

/* ---------- Eintritt der Seiten ---------- */
.reveal { opacity: 0; transform: translateY(8px); animation: reveal .5s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }
.view-enter { animation: view-in .28s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress > i { transform-origin: left; animation: grow .8s var(--ease-out) both; }
.title-input { font-size: 20px; font-weight: 600; letter-spacing: -.015em; border: 0 !important; padding: 0 !important; background: none !important; box-shadow: none !important; min-height: 0 !important; }
.title-input:focus { outline: none; }
.title-input:disabled { color: var(--text); }
.btn.ghost.danger:hover { background: var(--bad-soft); }

/* ---------- Instrument-Labels ---------- */
.mono-label { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.big-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; letter-spacing: -.03em; }
.stat .v { font-family: var(--mono); font-size: 28px; font-weight: 500; letter-spacing: -.04em; }
.stat { position: relative; overflow: hidden; transition: border-color .2s var(--ease-out), transform .2s var(--ease-out); }
.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; margin-bottom: 24px; }
.hero h1 { font-size: 26px; letter-spacing: -.03em; }
.hero .kw { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Ring ---------- */
.ring { position: relative; width: var(--size, 96px); height: var(--size, 96px); flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease-out); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-weight: 500; font-size: calc(var(--size, 96px) * .24); letter-spacing: -.04em; }

/* ---------- Roadmap ---------- */
.roadmap { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.rm-step { flex: 1 0 96px; min-width: 96px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.rm-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 8px; }
.rm-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; animation: grow .8s var(--ease-out) both; }
.rm-step.done .rm-bar i { background: var(--ok); }
@keyframes grow { from { transform: scaleX(0); } }
.rm-step .t { font-size: 12px; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rm-step:hover .t { color: var(--text); }
.rm-step .n { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---------- Heatmap ---------- */
.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: minmax(11px, 1fr); gap: 3px; min-width: 300px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); transition: transform .12s var(--ease-out); }
.heat i:hover { transform: scale(1.35); }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--surface-2)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--surface-2)); }
.heat i[data-l="4"] { background: var(--accent); }
.heat i.today { outline: 1.5px solid var(--text); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--faint); margin-top: 8px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-2); }

/* ---------- Ergebnis-Farben ---------- */
.oc { --c: var(--muted); --cs: var(--info-soft); }
.oc[data-o="success"] { --c: var(--ok); --cs: var(--ok-soft); }
.oc[data-o="partial"] { --c: var(--warn); --cs: var(--warn-soft); }
.oc[data-o="failed"] { --c: var(--bad); --cs: var(--bad-soft); }
.oc[data-o="running"] { --c: var(--accent); --cs: var(--accent-soft); }
.oc[data-o="planned"] { --c: var(--muted); --cs: var(--info-soft); }
.oc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--cs); color: var(--c); white-space: nowrap; }
.oc-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.oc[data-o="planned"] .oc-chip::before, .oc-chip[data-o="planned"]::before { background: none; box-shadow: inset 0 0 0 1.5px var(--c); }
.oc-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.oc-dot { display: inline-block; vertical-align: middle; width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 0; padding: 0; cursor: pointer; transition: transform .12s var(--ease-out); }
.oc-dot[data-o="planned"] { background: none; box-shadow: inset 0 0 0 2px var(--c); }
.oc-dot:hover { transform: scale(1.3); }
.outcome-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.outcome-seg button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 3px 11px; cursor: pointer; color: var(--muted); font-weight: 500; transition: all .15s var(--ease-out); }
.outcome-seg button:hover { border-color: var(--c); color: var(--c); }
.outcome-seg button[aria-pressed="true"] { background: var(--cs); border-color: var(--c); color: var(--c); }
.outcome-seg button:disabled { cursor: default; opacity: .6; }

/* ---------- Check-Animation ---------- */
.check svg { width: 12px; height: 12px; stroke-width: 3; stroke-dasharray: 20; stroke-dashoffset: 20; }
.check[data-s="erledigt"] svg { animation: draw .28s var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.check { transition: transform .12s var(--ease-out), background .15s, border-color .15s; }
.check:active { transform: scale(.86); }

/* ---------- Laborbuch-Editor ---------- */
.meta-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.meta-grid .span2 { grid-column: span 2; }
.editor-block { display: flex; flex-direction: column; gap: 6px; }
.editor-block + .editor-block { margin-top: 18px; }
.block-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hint { font-size: 12px; color: var(--faint); }
.dur { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px; align-items: center; }
.dur span { color: var(--muted); font-size: 12px; }

.cond-table { width: 100%; border-collapse: collapse; }
.cond-table th { text-align: left; }
.cond { display: grid; grid-template-columns: 132px minmax(0, 1.2fr) minmax(0, 1fr) 70px minmax(0, 1.2fr) 28px; gap: 6px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.cond:first-of-type { border-top: 0; }
.cond input[type=text], .cond select { min-height: 30px; padding: 3px 8px; font-size: 13px; }
.cond .tick { display: grid; place-items: center; }
.cond-head { display: grid; grid-template-columns: 132px minmax(0, 1.2fr) minmax(0, 1fr) 70px minmax(0, 1.2fr) 28px; gap: 6px; padding-bottom: 4px; }
.cond[data-kind="pos"] select { color: var(--ok); }
.cond[data-kind="neg"] select { color: var(--bad); }
.cond-meter { display: flex; align-items: center; gap: 10px; }
.cond-meter .progress { flex: 1; max-width: 180px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shot button.thumb { aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; padding: 0; background: var(--surface-2); cursor: zoom-in; position: relative; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s var(--ease-out); }
.shot button.thumb:hover img { transform: scale(1.04); }
.shot .fig { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.shot input { min-height: 28px; font-size: 12.5px; padding: 3px 7px; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s var(--ease-out); background: none; width: 100%; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.lightbox img { max-width: 100%; max-height: 62vh; display: block; margin: 0 auto; border-radius: 6px; }
.hash { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; color: var(--muted); }

/* ---------- Kalender ---------- */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: 6px 8px; font-size: 11px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cal-cell { background: var(--surface); min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; border: 0; cursor: pointer; color: inherit; transition: background .12s var(--ease-out); min-width: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { background: color-mix(in srgb, var(--surface) 55%, var(--bg)); color: var(--faint); }
.cal-cell .dn { font-family: var(--mono); font-size: 12px; }
.cal-cell.today .dn { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 6px; align-self: flex-start; }
.cal-item { font-size: 11.5px; line-height: 1.3; padding: 1px 5px; border-radius: 3px; background: var(--info-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.entry { background: var(--cs); color: var(--c); }
.cal-item.done { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--faint); }
.pill.entry { background: var(--cs); color: var(--c); }
.pill .t { font-family: var(--mono); font-size: 11px; opacity: .8; display: block; }

/* ---------- Review ---------- */
.rv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rv-list li { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.rv-list li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--faint)); transform: translateY(-1px); }
.rv-ok { --c: var(--ok); } .rv-bad { --c: var(--bad); } .rv-warn { --c: var(--warn); } .rv-info { --c: var(--accent); }
.sugg { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.sugg + .sugg { border-top: 1px solid var(--line); }
.sugg h3 { font-size: 14px; }
.sugg dl { margin: 0; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 2px 10px; font-size: 13px; }
.sugg dt { color: var(--faint); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.sugg dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Timer ---------- */
.timer { margin: 0 4px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; gap: 10px; background: var(--surface-2); }
.timer .time { font-family: var(--mono); font-size: 18px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; flex: 1; }
.timer.run { border-color: var(--accent); background: var(--accent-soft); }
.timer.run .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.timer .lab { font-size: 11px; color: var(--muted); }
.timer-fab { display: none; }

/* ---------- Palette ---------- */
.palette { width: min(620px, 100%); align-self: start; margin-top: 12vh; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 64px rgba(0, 0, 0, .3); overflow: hidden; animation: rise .16s var(--ease-out); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 48px; padding: 0 16px; font-size: 15px; background: none; }
.palette input:focus { box-shadow: none; }
.pal-list { max-height: 52vh; overflow: auto; padding: 6px; }
.pal-group { padding: 8px 10px 4px; }
.pal-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.pal-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.pal-item .m { color: var(--faint); font-size: 12px; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--surface); }
.overlay.top { align-items: start; }

/* ---------- Sonstiges ---------- */
.kbd-hint { margin-left: auto; }
.search-trigger { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); cursor: pointer; width: 100%; text-align: left; }
.search-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.list-link { color: inherit; text-decoration: none; }
.list-link:hover { text-decoration: none; }
.tabbar { grid-template-columns: repeat(5, 1fr) !important; }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-grid .span2 { grid-column: 1 / -1; }
  .cond, .cond-head { grid-template-columns: 96px minmax(0, 1fr) 40px 28px; }
  .cond .c-value, .cond .c-note, .cond-head .c-value, .cond-head .c-note { grid-column: 1 / -1; }
  .cond-head { display: none; }
  .cond { padding: 8px 0; row-gap: 4px; }
  .rv-grid { grid-template-columns: minmax(0, 1fr); }
  .cal-cell { min-height: 56px; padding: 3px; }
  .cal-item { display: none; }
  .cal-cell .dots { display: flex; gap: 2px; flex-wrap: wrap; }
  .timer-fab { display: flex; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 35; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 6px 20px rgba(0, 0, 0, .15); font-family: var(--mono); cursor: pointer; color: var(--text); }
  .timer-fab.run { border-color: var(--accent); }
}
@media (min-width: 861px) { .cal-cell .dots { display: none; } }


@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .check svg { stroke-dashoffset: 0; }
}


/* ---------- Methods ---------- */
.dg-wrap { overflow-x: auto; padding: 14px 16px 10px; }
.dg { display: block; min-width: 1100px; width: 100%; height: auto; }
.dg-node { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.2; }
.dg-node.run { stroke: var(--accent); fill: var(--accent-soft); }
.dg-node.done { stroke: var(--ok); fill: var(--ok-soft); }
.dg-num { font: 500 10px var(--mono); fill: var(--faint); letter-spacing: .08em; }
.dg-txt { font: 500 11.5px var(--font); fill: var(--text); }
.dg-b { font-weight: 650; }
.dg-cap { font: 400 10.5px var(--font); fill: var(--muted); }
.dg-bar { fill: var(--surface-2); }
.dg-fill { fill: var(--accent); }
.dg-gate { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.4; }
.dg-gate.done { fill: var(--warn); }
.dg-arrow line { stroke: var(--line-strong); stroke-width: 1.4; }
.dg-arrow path { fill: none; stroke: var(--line-strong); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.mlist { display: flex; flex-direction: column; }
.mcard { border-top: 1px solid var(--line); }
.mcard summary { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 16px; cursor: pointer; list-style: none; }
.mcard summary::-webkit-details-marker { display: none; }
.mcard summary:hover { background: var(--surface-2); }
.mcard .chev { color: var(--faint); transition: transform .15s var(--ease-out); }
.mcard[open] .chev { transform: rotate(90deg); }
.mtitle { font-weight: 550; overflow-wrap: anywhere; }
.mbody { padding: 4px 16px 16px 44px; display: flex; flex-direction: column; gap: 14px; }
.mfield .mtext { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; max-width: 78ch; }
@media (max-width: 860px) { .mbody { padding-left: 16px; } }

/* ---------- Methods workspace ---------- */
.mx { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.mx-list { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.mx-tools { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.mx-items { overflow: auto; padding: 4px 0 8px; }
.mx-group { padding: 12px 14px 4px; }
.mx-item { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 6px 14px; border: 0; background: none; cursor: pointer; color: inherit; }
.mx-item:hover { background: var(--surface-2); }
.mx-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.mx-t { overflow-wrap: anywhere; line-height: 1.35; }
.mx-meta { display: inline-flex; gap: 6px; align-items: center; color: var(--faint); font-size: 12px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); justify-self: center; }
.sdot[data-s="running"] { background: var(--accent); }
.sdot[data-s="done"] { background: var(--ok); }
.sdot[data-s="blocked"] { background: var(--bad); }
.note { padding: 8px 12px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.wf-list { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; max-width: 80ch; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.linkbtn:hover { text-decoration: underline; }
.dg-click { cursor: pointer; }
.dg-click:hover .dg-node, .dg-click:focus-visible .dg-node { stroke: var(--accent); }
.dg-click:focus-visible { outline: none; }
.steps-ed { display: flex; flex-direction: column; gap: 6px; }
.steps-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.step { display: grid; grid-template-columns: 20px 26px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.step textarea { min-height: 30px; padding: 4px 8px; resize: none; overflow: hidden; line-height: 1.45; }
.step.done textarea { color: var(--faint); text-decoration: line-through; }
.step .mono { padding-top: 6px; }
.step input[type=checkbox] { margin-top: 7px; }
.step-ctl { display: flex; }
@media (max-width: 860px) {
  .mx { grid-template-columns: minmax(0, 1fr); }
  .mx-list { position: static; max-height: none; }
  .mx[data-mode="detail"] .mx-list { display: none; }
  .mx[data-mode="list"] .mx-detail { display: none; }
}
