:root {
  --accent: #0A84FF;
  --accent-2: #BF5AF2;
  --bg-deep: #05070d;
  --text-primary: #F5F5F7;
  --text-secondary: rgba(235, 235, 245, 0.62);
  --glass-fill: rgba(255, 255, 255, 0.09);
  --glass-fill-strong: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.55);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

/* Ambient, langsam wandernder Farbverlauf hinter dem Glas – das eigentliche
   Signature-Element: die Oberflächen selbst tragen keine Farbe, sie brechen
   nur das Licht dieses Hintergrunds. */
.bg-mesh {
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 22%, rgba(10, 132, 255, 0.55), transparent 45%),
    radial-gradient(circle at 82% 15%, rgba(191, 90, 242, 0.45), transparent 50%),
    radial-gradient(circle at 30% 85%, rgba(48, 209, 88, 0.28), transparent 45%),
    radial-gradient(circle at 78% 78%, rgba(255, 159, 10, 0.22), transparent 50%),
    var(--bg-deep);
  filter: blur(60px) saturate(140%);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(-4%, 3%, 0) rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-mesh { animation: none; }
}

/* --- Glass primitives ------------------------------------------------- */

.glass-surface {
  background: var(--glass-fill);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 8px 32px rgba(0, 0, 0, 0.35);
}

.glass-card {
  background: var(--glass-fill-strong);
  backdrop-filter: blur(34px) saturate(170%);
  -webkit-backdrop-filter: blur(34px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 20px 60px rgba(0, 0, 0, 0.45);
}

/* --- Layout ------------------------------------------------------------ */

.screen {
  height: 100vh;
  width: 100%;
}

/* Die nativen [hidden]-Attribute werden sonst von .login-screen/.app-screen
   (display: flex) überschrieben, weil beide Regeln dieselbe Spezifität haben
   und .login-screen/.app-screen im Stylesheet später stehen. Ohne dieses
   !important blieben beide Screens gleichzeitig sichtbar übereinander. */
[hidden] {
  display: none !important;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 28px 28px;
  text-align: center;
}

.app-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(10, 132, 255, 0.35);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 26px;
}

.field {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 4px;
}

.field input {
  font-size: 16px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--accent), #3fa3ff);
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.4);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.error-text {
  color: #FF6961;
  font-size: 13px;
  margin: 12px 0 0;
}

.fine-print {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 20px 0 0;
  line-height: 1.5;
}

/* --- App shell ---------------------------------------------------------- */

.app-screen {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 14px;
  border-left: none;
  border-right: none;
  border-top: none;
  border-radius: 0;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-fill);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 100px);
  -webkit-overflow-scrolling: touch;
}

/* Karten je Modul-Eintrag */
.item-card {
  background: var(--glass-fill);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.item-card .row-1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  font-size: 15px;
}

.item-card .row-2 {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.item-card .row-3 {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  line-height: 1.45;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 132, 255, 0.22);
  color: #7cbaff;
}

.badge-open {
  background: rgba(255, 159, 10, 0.22);
  color: #ffb84d;
}

.badge-done {
  background: rgba(48, 209, 88, 0.2);
  color: #6fe08a;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 14px;
}

/* --- Stundenplan-Wochentabelle ------------------------------------------ */

.stundenplan-grid {
  display: inline-flex;
  flex-direction: column;
  min-width: 100%;
  background: var(--glass-fill);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  /* Bewusst KEIN overflow: hidden hier (anders als bei anderen Cards) -
     das würde diese Box selbst zum "nearest scrolling ancestor" für die
     sticky-positionierte Zeitspalte (.sp-time) machen. Da .stundenplan-grid
     selbst nie scrollt (nur der äußere .content-Container tut das, siehe
     unten), wäre die Sticky-Positionierung dann relativ zu einem
     Bezugsrahmen berechnet, der sich beim Wischen gar nicht bewegt -
     .sp-time würde also nie "kleben" bleiben. Die Eckenrundung wird
     stattdessen direkt auf die vier Eckzellen gelegt (siehe unten).*/
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Horizontal scrollbar container, damit 5 Spalten auf schmalen Handy-
   Breiten nicht gequetscht werden, sondern seitlich wischbar sind. */
.content:has(.stundenplan-grid) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sp-row {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
}

.sp-row:last-child {
  border-bottom: none;
}

.sp-cell {
  flex: 1 0 108px;
  min-width: 108px;
  padding: 10px 8px;
  font-size: 12.5px;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sp-cell:last-child {
  border-right: none;
}

.sp-time {
  flex: 0 0 64px;
  min-width: 64px;
  position: sticky;
  left: 0;
  /* Muss nahezu deckend sein (statt der vorherigen rgba(10,12,20,0.55)) -
     sonst schimmern die Zellen der Wochentage durch, während sie beim
     Wischen unter dieser fixierten Spalte hindurchlaufen. */
  background: rgba(5, 7, 13, 0.96);
  font-size: 13px;
  color: var(--text-secondary);
  /* Ohne z-index würden später im DOM stehende (nicht positionierte)
     Zellen derselben Zeile beim Wischen über der sticky-Spalte landen,
     da position:sticky ohne z-index in der normalen DOM-Reihenfolge
     gestapelt wird. */
  z-index: 2;
  /* Feine Trennlinie/Schatten am rechten Rand, damit optisch klar bleibt,
     dass hier scrollbarer Inhalt beginnt. */
  box-shadow: 2px 0 6px -2px rgba(0, 0, 0, 0.45);
}

.sp-row:first-child .sp-time {
  border-top-left-radius: var(--radius-md);
}

.sp-row:last-child .sp-time {
  border-bottom-left-radius: var(--radius-md);
}

.sp-row:first-child .sp-cell:last-child {
  border-top-right-radius: var(--radius-md);
}

.sp-row:last-child .sp-cell:last-child {
  border-bottom-right-radius: var(--radius-md);
}

.sp-time small {
  color: var(--text-secondary);
  font-size: 10.5px;
}

.sp-head {
  font-weight: 600;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.06);
}

.sp-head .sp-cell {
  color: var(--text-primary);
}

.stunde-eintrag {
  line-height: 1.35;
}

.stunde-eintrag + .stunde-eintrag {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.stunde-eintrag b {
  font-size: 13px;
}

.stunde-raum {
  color: var(--text-secondary);
  font-size: 11px;
}

.stunde-eintrag small {
  color: var(--text-secondary);
  font-size: 10.5px;
}

/* Hervorhebung der aktuellen Schulstunde (heutiger Wochentag + Uhrzeit
   liegt innerhalb der Stunden-Zeitspanne) - siehe istZeitraumJetzt() in
   frontend/modules/stundenplan.js. Als Inset-Box-Shadow statt echtem
   border umgesetzt, damit sich die Zellengröße nicht verschiebt (border
   würde die Breite/Höhe der Zelle um die Randstärke vergrößern und damit
   das Grid-Layout der Nachbarzellen verschieben). */
.sp-cell-jetzt {
  position: relative;
  background: rgba(10, 132, 255, 0.16);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}


.stunde-leer {
  color: var(--text-secondary);
  opacity: 0.4;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 60px auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tab bar ------------------------------------------------------------ */

.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-radius: 26px;
  display: flex;
  justify-content: space-around;
  padding: 8px 4px;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10.5px;
  padding: 6px 8px;
  border-radius: 16px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab-btn.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
}

.tab-btn svg { display: block; }

@media (min-width: 720px) {
  .content { max-width: 640px; margin: 0 auto; width: 100%; }
  .tabbar { max-width: 640px; margin: 0 auto; }
}

/* --- Klickbare Karten (z.B. Nachrichten) --------------------------------- */

.item-card--clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.12s ease;
}

.item-card--clickable:active {
  transform: scale(0.98);
  background: var(--glass-fill-strong);
}

/* --- Detail-Modal (Nachrichtentext etc.) --------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

@media (min-width: 720px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: min(78vh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 44px 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  text-align: left;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.modal-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  padding-right: 32px;
}

.modal-meta {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
}

.modal-content-text {
  font-size: 14.5px;
  line-height: 1.6;
  white-space: normal;
}

/* --- Klickbare Aktions-Badges (z.B. "als 'erledigt' markieren") --------- */

.badge-action {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.12s ease, opacity 0.12s ease;
}

.badge-action:active {
  transform: scale(0.95);
  opacity: 0.75;
}

/* --- Kalender: zwei getrennte Blöcke (Klausurtermine / echte Termine) --- */

.kalender-section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 4px 4px 10px;
}

.kalender-divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 18px 4px 16px;
}

/* --- Dateispeicher: Breadcrumb + Ordner-Kacheln -------------------------- */

.dateispeicher-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 2px 4px 14px;
}

.dateispeicher-breadcrumb-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--accent);
}

.dateispeicher-breadcrumb-link:active {
  opacity: 0.7;
}

.dateispeicher-breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.dateispeicher-breadcrumb-sep {
  color: var(--text-secondary);
  opacity: 0.6;
}

.dateispeicher-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.dateispeicher-folder-card {
  background: var(--glass-fill);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--folder-color, var(--accent));
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.12s ease;
}

.dateispeicher-folder-card:active {
  transform: scale(0.97);
  background: var(--glass-fill-strong);
}

.dateispeicher-folder-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dateispeicher-folder-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dateispeicher-folder-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  opacity: 0.8;
}

/* --- Nachrichten: Ausblenden-Icon je Kachel ------------------------------ */

.nachrichten-hide-btn {
  font-size: 14px;
  padding: 2px 6px;
  margin-left: 8px;
  border-radius: 999px;
  opacity: 0.55;
}

.nachrichten-hide-btn:active {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.1);
}
