/* Komponenten: Kopfzeile, Karten, schwebende Tab-Leiste */

/* Kopfzeile eines Screens */
.screen-header {
  margin-bottom: var(--space-5);
}

.screen-eyebrow {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.screen-title {
  font-size: var(--text-xxl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Karte */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
}

.card + .card {
  margin-top: var(--space-3);
}

.card-title {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.card-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Platzhalter-Karte für noch leere Tabs */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
}

.placeholder-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent-soft);
}

.placeholder-icon svg {
  width: 26px;
  height: 26px;
}

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Schwebende Tab-Leiste */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-gap));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--tabbar-height);
  max-width: calc(100vw - var(--space-4) * 2);
  padding: var(--space-2) var(--space-1);
  background: var(--tabbar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-float);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--tap-min);
  height: 100%;
  min-height: var(--tap-min);
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: background-color var(--transition), color var(--transition);
}

.tab svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.tab-label {
  display: none;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tab.is-active {
  background: var(--accent);
  color: var(--on-accent);
  padding: 0 var(--space-4) 0 var(--space-3);
}

.tab.is-active .tab-label {
  display: inline;
}

.tab:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* Abstände zwischen Karten und Elementen */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.row > .field {
  flex: 1;
  min-width: 0;
}

/* Kartenkopf mit Icon und Wert rechts */
.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-header .card-title {
  margin: 0;
  flex: 1;
}

.card-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.icon-chip {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent-soft);
}

.icon-chip svg {
  width: 18px;
  height: 18px;
}

.value-lg {
  font-size: var(--text-lg);
  font-weight: 700;
}

.value-lg small {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
}

.meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.status {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  padding-left: var(--space-4);
  position: relative;
}

.status::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: var(--radius-pill);
}

.status-ok::before { background: var(--success); }
.status-warning::before { background: var(--warning); }

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  font-size: var(--text-md);
  font-weight: 600;
  transition: background-color var(--transition), opacity var(--transition), transform var(--transition);
}

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

.btn:disabled {
  opacity: 0.6;
}

.btn svg {
  width: 20px;
  height: 20px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--danger);
}

.btn-ghost {
  color: var(--text-muted);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-right: calc(var(--space-3) * -1);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:active {
  background: var(--surface-2);
}

/* Eingabefelder */
.field {
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font: inherit;
  color-scheme: dark;
}

.field:focus,
.stepper-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* −/+ Eingabe für Zahlen */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stepper-btn {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.stepper-btn:active {
  background: var(--accent-dim);
}

.stepper-btn svg {
  width: 22px;
  height: 22px;
}

.stepper-value {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-1);
  height: 56px;
  padding-top: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
}

.stepper-input {
  width: 4.5ch;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: right;
}

.stepper-unit {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Listen in Karten */
.list {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
}

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  border-top: 1px solid var(--border);
}

.list-row-sub .list-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.list-label {
  flex: 1;
  font-size: var(--text-sm);
}

.list-value {
  font-size: var(--text-sm);
  font-weight: 600;
}

.list-value.meta {
  font-weight: 400;
}

/* Bottom-Sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  transition: background-color var(--transition);
}

.sheet-overlay.is-open {
  background: var(--scrim);
}

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: var(--space-3) var(--space-5) calc(env(safe-area-inset-bottom) + var(--space-4));
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  transform: translateY(100%);
  transition: transform 250ms ease;
}

.sheet-overlay.is-open .sheet {
  transform: none;
}

.sheet-handle {
  width: 36px;
  height: 5px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--border);
}

.sheet-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.sheet-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

/* Kurze Meldung oben am Bildschirm */
.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + var(--space-3));
  z-index: 40;
  max-width: calc(100vw - var(--space-8));
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity var(--transition), transform var(--transition);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-success { border-color: var(--success); }
.toast-danger { border-color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .toast {
    transition: none;
  }
}

/* Umschalter (Segmente) */
.segmented {
  display: flex;
  padding: var(--space-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.segment {
  flex: 1;
  min-height: 38px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  transition: background-color var(--transition), color var(--transition);
}

.segment.is-active {
  background: var(--accent);
  color: var(--on-accent);
}

/* Pillen-Filter */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pills-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 calc(var(--space-4) * -1);
  padding: 0 var(--space-4);
  scrollbar-width: none;
}

.pills-scroll::-webkit-scrollbar {
  display: none;
}

.pill {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.pill.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

/* Suche */
.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

.search svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  outline: none;
}

.filters {
  margin-bottom: var(--space-4);
}

/* Übungskarten mit Foto */
.exercise-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.exercise-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 148px;
  padding: var(--space-4);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--photo-empty);
  background-size: cover;
  background-position: center;
  text-align: left;
  transition: transform var(--transition);
}

.exercise-card:active {
  transform: scale(0.985);
}

.exercise-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--photo-overlay);
}

.exercise-card.is-archived {
  opacity: 0.55;
}

.exercise-card-initial {
  position: absolute;
  right: var(--space-5);
  top: 50%;
  transform: translateY(-50%);
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  opacity: 0.35;
}

.exercise-card-text {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.exercise-card-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
}

.exercise-card-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.exercise-card.has-photo .exercise-card-meta {
  color: var(--text);
  opacity: 0.8;
}

.chip {
  position: absolute;
  left: var(--space-3);
  top: var(--space-3);
  padding: 3px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text);
}

.chip-new {
  background: var(--accent);
  color: var(--on-accent);
}

.chip-archived {
  left: auto;
  right: var(--space-3);
}

/* Schwebender Hinzufügen-Button über der Tab-Leiste */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-height) + var(--tabbar-gap) * 2);
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5) 0 var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--shadow-float);
}

.fab svg {
  width: 20px;
  height: 20px;
}

#screen-exercises {
  padding-bottom: calc(48px + var(--space-4));
}

/* Vollbild-Ansicht */
body.has-view {
  overflow: hidden;
}

body.has-view .tabbar,
body.has-view .fab {
  display: none;
}

.view {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 250ms ease;
}

.view.is-open {
  transform: none;
}

.view-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: calc(env(safe-area-inset-top) + var(--space-2)) var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--border);
}

.view-back {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  margin-left: calc(var(--space-2) * -1);
  padding-right: var(--space-2);
  color: var(--accent-soft);
  font-weight: 500;
}

.view-back svg {
  width: 24px;
  height: 24px;
}

.view-title {
  flex: 1;
  font-size: var(--text-md);
  font-weight: 700;
  text-align: center;
  margin-right: 72px;
}

.view-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4);
}

.view-footer {
  padding: var(--space-3) var(--space-4) calc(env(safe-area-inset-bottom) + var(--space-3));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* Formular */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 480px;
  margin: 0 auto;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.form-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field-num {
  width: 100%;
  text-align: center;
}

.field-area {
  min-height: 72px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-inner);
  resize: none;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

/* Foto-Auswahl */
.photo-picker {
  position: relative;
  display: grid;
  place-items: center;
  height: 180px;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  cursor: pointer;
}

.photo-picker-preview {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.photo-picker-preview.has-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--photo-overlay);
}

.photo-picker-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--tabbar-bg);
  font-size: var(--text-sm);
  font-weight: 600;
}

.photo-picker-label svg {
  width: 20px;
  height: 20px;
}

.photo-remove {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--radius-pill);
  background: var(--tabbar-bg);
}

.photo-remove svg {
  width: 18px;
  height: 18px;
}

/* Schalter */
.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  cursor: pointer;
}

.toggle-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.toggle-text small {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color var(--transition);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: var(--radius-pill);
  background: var(--text);
  transition: transform var(--transition);
}

.switch-input:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-input:checked + .switch::after {
  transform: translateX(20px);
}

.switch-input:focus-visible + .switch {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* Spürgefühl */
.feel-list {
  display: flex;
  flex-direction: column;
}

.feel-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  border-top: 1px solid var(--border);
}

.feel-label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
}

.rating {
  display: flex;
}

.rating-dot {
  position: relative;
  width: 34px;
  height: var(--tap-min);
}

.rating-dot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color var(--transition), border-color var(--transition);
}

.rating-dot.is-on::after {
  background: var(--accent);
  border-color: var(--accent-soft);
}

.feel-more summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  color: var(--accent-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.feel-more summary::-webkit-details-marker {
  display: none;
}

.feel-more summary::after {
  content: '+';
  margin-left: auto;
  font-size: var(--text-lg);
}

.feel-more[open] summary::after {
  content: '−';
}

.feel-group-title {
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

@media (prefers-reduced-motion: reduce) {
  .view {
    transition: none;
  }
}
