/* ============================================================
   Kleiderschrank – Liquid-Glass-Style, mobile-first
   ============================================================ */

:root {
  --bg: #eef0f4;
  --bg-elevated: rgba(255, 255, 255, 0.46);
  --bg-elevated-strong: rgba(255, 255, 255, 0.7);
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --accent: #0a84ff;
  --accent-2: #5e9bff;
  --danger: #ff3b30;
  --border: rgba(60, 60, 67, 0.15);
  --glass-rim: rgba(255, 255, 255, 0.85);
  --glass-rim-soft: rgba(255, 255, 255, 0.5);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.10);
  --chip-bg: rgba(255, 255, 255, 0.35);
  --chip-bg-active: var(--accent);
  --chip-text-active: #fff;
  --tile-bg: rgba(255, 255, 255, 0.5);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: rgba(36, 36, 38, 0.5);
    --bg-elevated-strong: rgba(58, 58, 60, 0.75);
    --text: #f2f2f7;
    --text-secondary: #98989d;
    --accent: #0a84ff;
    --accent-2: #64a1ff;
    --danger: #ff453a;
    --border: rgba(255, 255, 255, 0.12);
    --glass-rim: rgba(255, 255, 255, 0.22);
    --glass-rim-soft: rgba(255, 255, 255, 0.08);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --chip-bg: rgba(120, 120, 128, 0.24);
    --tile-bg: rgba(44, 44, 46, 0.55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(ellipse 90% 50% at 15% 0%, rgba(10, 132, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 30%, rgba(94, 92, 230, 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

body {
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

h1, h2, h3, p { margin: 0; }

button, input {
  font-family: inherit;
}

/* ---------- Glass surface ----------
   iOS-26-artiges "Liquid Glass": starker Blur/Saturate, dazu ein heller
   Lichtsaum an der Oberkante (inset box-shadow) simuliert die Lichtbrechung
   am Rand einer echten Glasscheibe. */
.glass {
  background: var(--bg-elevated);
  backdrop-filter: blur(38px) saturate(190%);
  -webkit-backdrop-filter: blur(38px) saturate(190%);
  border: 1px solid var(--glass-rim-soft);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 var(--glass-rim),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* ---------- Screens ---------- */
.screen { min-height: 100vh; min-height: 100dvh; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--bg), var(--bg));
}

.login-card {
  width: 100%;
  max-width: 340px;
  border-radius: 32px;
  padding: 36px 28px;
  text-align: center;
}

.login-icon { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--text-secondary); font-size: 15px; margin-bottom: 20px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.error-text { color: var(--danger); font-size: 14px; margin-top: 14px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-secondary {
  background: var(--chip-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text);
  border: 1px solid var(--glass-rim-soft);
}
.btn-danger { background: rgba(255, 59, 48, 0.15); color: var(--danger); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:active { background: var(--chip-bg); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  border-radius: 0 0 24px 24px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.app-title { font-size: 20px; font-weight: 700; }

.home-tabs {
  display: flex;
  gap: 8px;
  background: rgba(120, 120, 128, 0.16);
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--glass-rim-soft);
}

.home-tab {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.25s cubic-bezier(0.32, 0.72, 0, 1), color 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}

.home-tab.active {
  background: var(--bg-elevated-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0,0,0,0.14), inset 0 1px 0 var(--glass-rim);
}

.home-tab.drop-hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.05);
}

/* ---------- Type filter ---------- */
.type-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  scrollbar-width: none;
}
.type-filter::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--chip-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--glass-rim-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.chip.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--chip-text-active);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(10, 132, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.chip:active { transform: scale(0.95); }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

/* ---------- Storage sections ---------- */
.storage-sections {
  padding: 4px 16px calc(120px + var(--safe-bottom));
}

.storage-section {
  margin-top: 20px;
  border-radius: 26px;
  padding: 14px 14px calc(16px);
  transition: background 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.storage-section.drop-hover {
  box-shadow: 0 0 0 2px var(--accent) inset;
}

.storage-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px;
  flex-shrink: 0;
}

.storage-section-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.storage-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.storage-section-count {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--chip-bg);
  padding: 2px 9px;
  border-radius: 999px;
}

.storage-expand-btn {
  width: 30px;
  height: 30px;
  color: var(--text-secondary);
}

.tile-grid {
  display: grid;
  gap: 10px;
  align-content: flex-start;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Normale Ansicht: horizontal scrollbare Kartenreihe pro Kategorie – eine
   große Kachel mit komplettem, unbeschnittenem Foto, die nächste schaut
   rechts leicht rein. Die Kategorie-Karte wächst dadurch nicht in die Höhe,
   egal wie viele Kleidungsstücke sie enthält.
   "Vollbild"-Button öffnet die Kategorie zusätzlich als mehrspaltiges Raster. */
.tile-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 2px;
  padding-bottom: 4px;
  padding-right: 2px;
  min-height: 56px;
}

.tile-list .tile {
  flex: 0 0 auto;
  width: 80%;
  max-width: 320px;
  scroll-snap-align: start;
}

/* Vollbild: mehrspaltiges Raster mit kompakten Vorschau-Kacheln. */
.fullscreen-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.empty-hint {
  grid-column: 1 / -1;
  flex: 1 1 100%;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 14px 0;
}

/* Gruppierung nach Kleidungstyp im Vollbild */
.fullscreen-group-label {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  padding: 2px 2px 0;
}

.fullscreen-group-divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 8px 2px 2px;
}

/* ---------- Tile ----------
   Bild sitzt oben, das Label ist ein eigener Textbereich darunter statt
   eines Overlays. In der normalen (horizontal scrollbaren) Ansicht wird das
   ganze Foto unbeschnitten gezeigt, im Vollbild-Raster bleibt es eine
   quadratische Vorschau-Kachel. */
.tile {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: var(--tile-bg);
  border: 1px solid var(--glass-rim-soft);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  cursor: grab;
  /* erlaubt sowohl horizontales Wischen (Kartenreihe) als auch vertikales
     Wischen (Seiten-Scroll) direkt auf der Kachel; das eigentliche Drag&Drop
     übernimmt erst nach Long-Press per JS die Kontrolle (siehe dragdrop.js). */
  touch-action: pan-x pan-y;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  -webkit-user-select: none;
  user-select: none;
}

.tile-image {
  aspect-ratio: 1 / 1;
  background: var(--chip-bg);
  flex-shrink: 0;
}

.tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Normale Ansicht: kein Beschnitt, komplettes Bild sichtbar (ggf. mit
   Rand statt Zuschnitt), Höhe gedeckelt, damit sehr hohe Fotos die
   Kartenreihe nicht sprengen. */
.tile-list .tile-image {
  aspect-ratio: auto;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-list .tile-image img {
  height: auto;
  max-height: 52vh;
  object-fit: contain;
}

.tile-label {
  padding: 8px 10px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile.dragging {
  position: fixed;
  z-index: 500;
  cursor: grabbing;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  transform: scale(1.08);
  transition: none;
  pointer-events: none;
}

.tile.lift {
  transform: scale(1.06);
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: calc(20px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  z-index: 30;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.15s ease;
}
.fab:active { transform: scale(0.90); }

/* ---------- Vollbild-Kategorieansicht ---------- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fullscreen-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes fullscreen-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.fullscreen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  border-radius: 0 0 26px 26px;
  flex-shrink: 0;
}

.fullscreen-title {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
}

.fullscreen-grid {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  align-content: flex-start;
  padding: 16px calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
  -webkit-overflow-scrolling: touch;
}

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sheet-backdrop.visible { opacity: 1; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 30px 30px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.visible { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  margin: 6px auto 16px;
}

.sheet h2 { font-size: 19px; font-weight: 700; margin-bottom: 16px; }
.sheet-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); margin: 18px 0 8px; }

.photo-picker {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: var(--chip-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-picker img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.photo-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.photo-actions .btn { flex: 1; text-align: center; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.sheet-actions .btn { flex: 1; }

.detail-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 18px;
  margin-bottom: 10px;
}
.detail-type {
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 85vw;
  text-align: center;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Drop-zone home-tab pulse while dragging ---------- */
.home-tab.drop-target-active {
  animation: pulse-border 1.2s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(10,132,255,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(10,132,255,0); }
}
