:root {
  --color-bg: #0b1120;
  --color-surface: #111827;
  --color-surface-alt: #1f2937;
  --color-border: #2d3748;
  --color-text: #f3f4f6;
  --color-text-muted: #9ca3af;
  --color-accent: #e11d48;
  --tab-bar-height: 64px;
  --header-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-view {
  padding: 1rem;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 1rem);
  min-height: calc(100vh - var(--header-height) - var(--safe-top));
}

.tab-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.placeholder-hint {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.kamera-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kamera-action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.kamera-action-button:active {
  background: var(--color-surface-alt);
}

.kamera-preview {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kamera-preview[hidden] {
  display: none;
}

.kamera-preview-image {
  width: 100%;
  max-height: 45vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}

.kamera-confirm-button {
  padding: 0.85rem 1rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.kamera-confirm-button:active {
  opacity: 0.85;
}

.brand-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.brand-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.brand-list-item:active {
  background: var(--color-surface-alt);
}

.brand-name {
  font-weight: 600;
}

.brand-count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.progress-total {
  font-size: 1.1rem;
  font-weight: 600;
}

.brand-detail-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
  z-index: 15;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.brand-detail-view[hidden] {
  display: none;
}

.brand-detail-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(var(--safe-top) + 0.75rem) 1rem 0.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.back-button {
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-left: -0.5rem;
}

.brand-detail-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  min-width: 0;
}

.brand-detail-heading h2 {
  margin: 0;
  font-size: 1.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-detail-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
}

#brand-detail-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.zuordnung-search-wrap {
  padding: 0.75rem 1rem 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.zuordnung-search-wrap[hidden] {
  display: none;
}

.zuordnung-search-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  font: inherit;
}

.zuordnung-search-input::placeholder {
  color: var(--color-text-muted);
}

#zuordnung-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.zuordnung-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1rem;
  text-align: center;
}

.zuordnung-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
}

.photo-detail-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.photo-detail-view[hidden] {
  display: none;
}

.photo-detail-year {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.photo-detail-image-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
}

.photo-detail-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-detail-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.photo-detail-nav-button[hidden] {
  display: none;
}

.photo-detail-nav-prev {
  left: 0.75rem;
}

.photo-detail-nav-next {
  right: 0.75rem;
}

.photo-detail-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 1rem 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.photo-detail-photo-date {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.photo-detail-date-input {
  color-scheme: dark;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.8rem;
}

.photo-detail-panel {
  padding: 1rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.photo-detail-panel[hidden] {
  display: none;
}

.photo-detail-panel.kamera-preview {
  margin-top: 0;
}

.photo-detail-remove-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.photo-detail-text-button {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
}

.photo-detail-danger-button {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.photo-detail-danger-button:active {
  opacity: 0.85;
}

.photo-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem calc(var(--safe-bottom) + 0.75rem);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.photo-detail-production {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-detail-seen {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.photo-detail-seen-button {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.photo-detail-seen-button:active {
  background: var(--color-border);
}

.photo-detail-seen-count {
  min-width: 5.5rem;
  text-align: center;
  font-size: 0.85rem;
  white-space: nowrap;
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-rows: min-content;
  gap: 0.75rem;
}

.dex-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.dex-card-media {
  aspect-ratio: 4 / 3;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-alt);
}

.dex-card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dex-card-silhouette {
  font-size: 2rem;
  opacity: 0.35;
}

.dex-card.is-owned {
  cursor: pointer;
}

.dex-card.is-locked {
  opacity: 0.55;
  filter: grayscale(1);
}

.dex-card-info {
  padding: 0.4rem 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.dex-card-year {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.dex-card-name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dex-card-production {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.tab-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.tab-button.is-active {
  color: var(--color-accent);
}

.tab-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.7rem;
  font-weight: 600;
}

@media (min-width: 640px) {
  .app-view {
    max-width: 640px;
    margin: 0 auto;
  }

  .brand-detail-header,
  #brand-detail-grid,
  #zuordnung-list,
  .zuordnung-search-wrap {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
  }
}
