:root {
  --bg: #07111f;
  --surface: rgba(16, 28, 48, 0.86);
  --surface-strong: #101c30;
  --border: rgba(148, 163, 184, 0.22);
  --border-strong: rgba(56, 189, 248, 0.4);
  --text: #e5f0ff;
  --muted: #9fb1c9;
  --accent: #38bdf8;
  --accent-2: #14b8a6;
  --danger: #fb7185;
  --warning: #facc15;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(20, 184, 166, 0.16), transparent 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: 40px;
  border: 2px solid var(--border-strong);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(8, 47, 73, 0.3), rgba(12, 74, 110, 0.25));
  box-shadow: inset 0 1px 0 rgba(56, 189, 248, 0.15), 0 12px 40px rgba(0, 0, 0, 0.4);
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.app-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.subtitle,
.panel-note,
.empty-state p,
.danger-panel p {
  color: var(--muted);
}

.hero-card {
  min-width: 240px;
  padding: 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(20, 184, 166, 0.05));
  border: 2px solid var(--accent);
  display: grid;
  align-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2), inset 0 1px 0 rgba(56, 189, 248, 0.15);
}

.hero-card span {
  color: var(--muted);
}

.hero-card strong {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  gap: 12px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.tab,
button {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tab {
  padding: 13px 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.76);
}

.tab:hover,
button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111f;
  font-weight: 800;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.toolbar,
.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 2px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.06), rgba(20, 184, 166, 0.03));
  backdrop-filter: blur(18px);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(56, 189, 248, 0.1), 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: max-height 300ms ease, opacity 300ms ease;
  max-height: 200px;
  opacity: 1;
}

.toolbar[hidden] {
  display: none;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  margin-bottom: 0;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.toolbar label input,
.toolbar label select {
  width: auto;
  min-width: 140px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.toolbar-wrapper {
  margin-bottom: 20px;
}

.reminder-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 2px solid rgba(20, 184, 166, 0.34);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.11), rgba(15, 23, 42, 0.7));
  box-shadow: inset 0 1px 0 rgba(56, 189, 248, 0.12), 0 8px 24px rgba(0, 0, 0, 0.24);
}

.reminder-panel h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.reminder-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.push-note {
  margin-top: 8px !important;
  font-size: 0.86rem;
}

.reminder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.reminder-actions button {
  white-space: normal;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border-strong);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(20, 184, 166, 0.08));
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.toolbar label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.label-icon {
  font-size: 1.2em;
  margin-right: 0;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.68);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}

.therapy-grid {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: 24px;
  padding: 16px 0;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 50%;
  background: linear-gradient(180deg, rgba(8, 47, 73, 0.15), transparent);
  border-radius: var(--radius);
  padding-left: 24px;
  padding-right: 24px;
}

.therapy-grid::-webkit-scrollbar {
  height: 0;
  display: none;
}

.therapy-grid {
  scrollbar-width: none;
}

.therapy-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  padding: 32px 28px 28px 28px;
  min-height: 220px;
  width: 500px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 2px solid var(--border-strong);
  background: linear-gradient(135deg, rgba(8, 47, 73, 0.5), rgba(15, 23, 42, 0.9));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(56, 189, 248, 0.1);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.therapy-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -50% auto;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
}

.card-time {
  display: grid;
  place-items: center;
  min-width: 100px;
  height: 100px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111f;
  font-weight: 900;
  font-size: 2.2rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.3);
}

.card-body h2 {
  margin-bottom: 16px;
  font-size: 1.35rem;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.meta-row span {
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.empty-state {
  display: none;
  padding: 42px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.5);
}

.backend-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.actions,
.stacked-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.stacked-actions {
  flex-direction: column;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn {
  padding: 12px 16px;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111f;
}

.ghost-btn,
.small-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
}

.danger-btn {
  background: rgba(251, 113, 133, 0.14);
  color: #fecdd3;
  border: 1px solid rgba(251, 113, 133, 0.38);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-btn {
  padding: 8px 10px;
  font-size: 0.84rem;
}

.fixed-label {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(20, 184, 166, 0.16);
  color: #99f6e4;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.fixed-note {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

@media (max-width: 820px) {
  .hero,
  .backend-layout,
  .toolbar,
  .form-grid,
  .reminder-panel {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
  }

  .therapy-card {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .card-time {
    width: 100%;
  }

  .therapy-grid {
    padding-left: 0;
    padding-right: 0;
    gap: 16px;
  }

  .reminder-panel {
    display: grid;
    align-items: stretch;
  }

  .reminder-actions,
  .reminder-actions button {
    width: 100%;
  }
}

/* Verbesserte Lesbarkeit, Animationen und Live-Markierung */
.view.active-view {
  animation: viewFadeIn 260ms ease both;
}

#frontend {
  background: linear-gradient(180deg, rgba(8, 47, 73, 0.08) 0%, transparent 50%);
  padding: 28px;
  border-radius: 20px;
  margin: -28px -28px 0 -28px;
  padding-bottom: 56px;
}

.therapy-card {
  isolation: isolate;
  overflow: visible;
  min-height: 178px;
  animation: cardEnter 520ms cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--delay, 0ms);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.therapy-card:hover {
  transform: translateY(-8px);
  border-color: var(--accent);
  box-shadow: 0 12px 40px rgba(56, 189, 248, 0.3), inset 0 1px 0 rgba(56, 189, 248, 0.15);
}

.therapy-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(20, 184, 166, 0.18));
  transition: opacity 180ms ease;
}

.therapy-card::after {
  pointer-events: none;
  z-index: -1;
}

.card-body {
  min-width: 0;
  flex: 1;
}

.card-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  position: relative;
  min-height: 28px;
}

.card-headline h2 {
  flex: 1;
}

.card-body h2 {
  margin: 0;
  min-width: 0;
  line-height: 1.35;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  border-bottom: 2px solid rgba(56, 189, 248, 0.2);
  padding-bottom: 14px;
  margin-bottom: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.status-badge {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-transform: uppercase;
  margin-left: 12px;
  box-shadow: inset 0 1px 0 rgba(56, 189, 248, 0.2);
}

.meta-row span {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.therapy-card.is-current {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(20, 184, 166, 0.08));
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3), 0 12px 48px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(56, 189, 248, 0.2);
  animation: currentPulse 2.4s ease-in-out infinite, cardEnter 520ms cubic-bezier(.2,.8,.2,1) both;
  animation-delay: 0ms, var(--delay, 0ms);
}

.therapy-card.is-current::before {
  opacity: 1;
}

.therapy-card.is-current .status-badge {
  color: #fff;
  background: linear-gradient(135deg, #facc15, #38bdf8);
  box-shadow: 0 4px 16px rgba(250, 204, 21, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-weight: 900;
}

.therapy-card.is-current .card-time {
  animation: timeGlow 1.8s ease-in-out infinite;
}

.therapy-card.is-current .card-body::after {
  content: "";
  display: block;
  height: 8px;
  width: 100%;
  margin-top: 16px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent), var(--accent-2)) 0 / var(--progress, 0%) 100% no-repeat,
    rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.therapy-card.is-soon {
  border-color: rgba(250, 204, 21, 0.6);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.08), rgba(15, 23, 42, 0.8));
}

.therapy-card.is-soon .status-badge {
  color: #fff;
  background: linear-gradient(135deg, #facc15, #fbbf24);
  box-shadow: 0 4px 16px rgba(250, 204, 21, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-weight: 900;
}

.therapy-card.is-upcoming .status-badge {
  color: var(--text);
  background: rgba(56, 189, 248, 0.2);
  box-shadow: inset 0 1px 0 rgba(56, 189, 248, 0.3);
}

.therapy-card.is-done .status-badge {
  color: #94a3b8;
  background: rgba(51, 65, 85, 0.5);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.2);
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3), 0 12px 48px rgba(56, 189, 248, 0.2), inset 0 1px 0 rgba(56, 189, 248, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.15), 0 16px 56px rgba(56, 189, 248, 0.32), inset 0 1px 0 rgba(56, 189, 248, 0.2); }
}

@keyframes timeGlow {
  0%, 100% { transform: scale(1); filter: brightness(1) drop-shadow(0 0 0px rgba(56, 189, 248, 0)); }
  50% { transform: scale(1.06); filter: brightness(1.2) drop-shadow(0 0 12px rgba(56, 189, 248, 0.6)); }
}

@media (max-width: 620px) {
  .therapy-card {
    gap: 14px;
    padding: 18px;
  }

  .card-headline {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-badge {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 20ms !important;
    scroll-behavior: auto !important;
  }
}

.date-header {
  grid-column: 1 / -1;
  padding: 16px 20px;
  margin: 24px 0 12px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  border-left: 4px solid var(--accent);
  background: rgba(56, 189, 248, 0.08);
  border-radius: 8px;
}

@media (max-width: 480px) {
  :root {
    --radius: 18px;
    --shadow: 0 14px 42px rgba(0, 0, 0, 0.32);
  }

  body {
    background:
      linear-gradient(180deg, rgba(56, 189, 248, 0.13), transparent 18rem),
      var(--bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .app-shell {
    width: 100%;
    padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 88px);
  }

  .hero {
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    border-width: 1px;
  }

  .hero-title {
    gap: 12px;
  }

  .app-icon {
    width: 52px;
    height: 52px;
    border-radius: 15px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
  }

  h1 {
    margin-bottom: 0;
    font-size: 2rem;
    line-height: 1;
  }

  .subtitle {
    display: none;
  }

  .hero-card {
    min-width: 0;
    padding: 12px 14px;
    border-radius: 14px;
  }

  .hero-card span {
    font-size: 0.78rem;
  }

  .hero-card strong {
    font-size: 1.35rem;
  }

  .tabs {
    position: fixed;
    z-index: 20;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(7, 17, 31, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  }

  .tab {
    padding: 11px 8px;
    border-radius: 12px;
    font-size: 0.88rem;
  }

  main {
    margin-top: 14px;
  }

  #frontend {
    margin: 0;
    padding: 0 0 18px;
    border-radius: 0;
    background: transparent;
  }

  .toolbar-wrapper {
    margin-bottom: 12px;
  }

  .filter-toggle {
    width: 100%;
    justify-content: center;
    border-radius: 14px;
  }

  .toolbar {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    border-radius: 14px;
  }

  .toolbar label,
  .toolbar label input,
  .toolbar label select {
    width: 100%;
    min-width: 0;
  }

  .reminder-panel {
    gap: 14px;
    margin-bottom: 12px;
    padding: 14px;
    border-radius: 16px;
  }

  .reminder-panel h2 {
    font-size: 1rem;
  }

  .reminder-panel p {
    font-size: 0.86rem;
  }

  .reminder-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .therapy-grid {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
    gap: 12px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    scroll-snap-type: none;
  }

  .date-header {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    background: rgba(56, 189, 248, 0.09);
  }

  .therapy-card {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    width: 100%;
    min-height: 0;
    gap: 12px;
    padding: 14px;
    border-width: 1px;
    border-radius: 16px;
    overflow: hidden;
    scroll-snap-align: none;
  }

  .therapy-card::after {
    display: none;
  }

  .therapy-card:hover {
    transform: none;
  }

  .card-time {
    width: 76px;
    min-width: 76px;
    height: 76px;
    border-radius: 14px;
    font-size: 1.45rem;
  }

  .card-headline {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 0;
  }

  .card-body h2 {
    padding-bottom: 8px;
    margin-bottom: 8px;
    font-size: 1.05rem;
    line-height: 1.25;
    -webkit-line-clamp: 3;
  }

  .status-badge {
    margin-left: 0;
    padding: 5px 8px;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  .meta-row {
    gap: 6px;
    margin-top: 0;
  }

  .meta-row span {
    padding: 7px 9px;
    font-size: 0.82rem;
  }

  .backend-layout,
  .form-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .actions,
  .stacked-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 0.84rem;
  }
}
