/* ============ Reset / Basis ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ============ App Shell ============ */
.app-shell {
  display: grid;
  grid-template-rows: 52px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.app-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  background: #1f2937;
  color: #f9fafb;
  border-bottom: 1px solid #111827;
}
.app-title { font-weight: 600; }
.spacer { flex: 1; }
.user-chip {
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: #f9fafb;
  font-size: 20px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover, .icon-btn:focus { background: rgba(255,255,255,0.12); }

/* ============ Content Grid ============ */
.app-body { overflow: hidden; }
.content-grid {
  display: grid;
  grid-template-columns: var(--left-w, 320px) 6px 1fr 320px;
  height: 100%;
  gap: 0;
}

/* ============ Splitter ============ */
.splitter {
  background: #e5e7eb;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.splitter-vertical {
  cursor: col-resize;
}
.splitter::after {
  /* unsichtbarer „greifbarer" Bereich rechts/links, damit Touch leichter trifft */
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -4px; right: -4px;
}
.splitter:hover, .splitter.dragging { background: #2563eb; }
.pane {
  background: #ffffff;
  overflow: auto;
  min-height: 0;
  border-right: 1px solid #e5e7eb;
}
.pane.right-pane { border-right: 0; border-left: 1px solid #e5e7eb; }
.center-pane {
  display: flex;
  flex-direction: column;
  background: #0b0b0d;
  color: #f3f4f6;
}

/* ============ Top Bar ============ */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .5rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 1;
}
.select, .input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
  min-height: 36px;
}
.input.filter { flex: 1; min-width: 140px; }
.input.num { width: 80px; }
.check { display: inline-flex; align-items: center; gap: .25rem; min-height: 36px; }
.btn {
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 36px;
}
.btn:hover { background: #f3f4f6; }
.btn.small { padding: 4px 8px; min-height: 32px; font-size: 12px; }
.btn.danger { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.btn.icon {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.icon-text {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-btn .icon { color: inherit; }

/* ============ File List ============ */
.file-list { display: flex; flex-direction: column; height: calc(100% - 62px); }
.file-list-status { padding: .5rem; font-size: 12px; color: #6b7280; border-bottom: 1px solid #f3f4f6; }
.file-list-scroll { flex: 1; overflow: auto; }
.file-row {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  min-height: 36px;
  display: flex;
  align-items: center;
  word-break: break-all;
}
.file-row:hover  { background: #f9fafb; }
.file-row.selected { background: #dbeafe; color: #1d4ed8; }

/* ============ Player ============ */
.player {
  display: flex;
  flex-direction: column;
  background: #0b0b0d;
  border-bottom: 1px solid #1f2937;
}
.player-stage {
  background: #000;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.video-element {
  width: 100%;
  max-height: 60vh;
  background: #000;
  display: block;
}
.player-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  padding: .5rem .75rem;
  background: #14161a;
  color: #e5e7eb;
}
.player-controls .btn,
.player-controls .check { color: #e5e7eb; background: #1f2937; border-color: #374151; }
.player-controls .time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* ============ Thumbnails ============ */
.thumb-grid-host {
  background: #0b0b0d;
  padding: .5rem;
  flex: 1;
  overflow: auto;
}
.thumb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  color: #d1d5db;
  margin-bottom: .5rem;
}
.thumb-toolbar .status { font-size: 12px; color: #9ca3af; }
.thumb-error {
  background: #7f1d1d;
  color: #fee2e2;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: .5rem;
  word-break: break-word;
}
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .5rem;
}
.thumb-cell {
  background: #14161a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
}
.thumb-cell:hover { border-color: #2563eb; }
.thumb-cell img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
}
.thumb-cell .label { font-size: 11px; margin-top: 2px; text-align: center; }

/* ============ Tags Panel ============ */
.tags-panel { padding: .5rem .75rem; display: flex; flex-direction: column; gap: .5rem; }
.tags-header { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.tag-list {
  display: flex; flex-direction: column; gap: .25rem;
  padding: .25rem 0;
  border-top: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
  max-height: 50vh;
  overflow: auto;
}
.tag-row { display: flex; align-items: center; gap: .5rem; padding: 4px; min-height: 32px; }
.cat-edit { display: flex; flex-wrap: wrap; gap: .25rem; }
.cat-edit .input { flex: 1; min-width: 140px; }

.empty { padding: 2rem; text-align: center; color: #9ca3af; flex: 1; align-self: center; }
.empty.small { padding: 1rem; }

/* ============ Login ============ */
.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 2rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: .5rem;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .subtitle { margin: 0 0 .5rem; color: #6b7280; font-size: 13px; }
.login-card label { font-size: 12px; color: #374151; }
.login-card input {
  border: 1px solid #d1d5db; border-radius: 8px; padding: 10px;
  font: inherit; min-height: 40px;
}
.login-error { color: #b91c1c; font-size: 13px; margin: .25rem 0; }
.btn-primary {
  background: #2563eb; color: white; border: 0; border-radius: 8px;
  padding: 12px; font-weight: 600; cursor: pointer; min-height: 44px; margin-top: .5rem;
}
.btn-primary:hover { background: #1d4ed8; }

/* ============ Right-Pane Collapse (Desktop) ============ */
.app-shell[data-right-collapsed="1"] .pane.right-pane { display: none; }
.app-shell[data-right-collapsed="1"] .content-grid {
  grid-template-columns: var(--left-w, 320px) 6px 1fr;
}
@media (max-width: 1024px) {
  .app-shell[data-right-collapsed="1"] .content-grid {
    grid-template-columns: var(--left-w, 280px) 6px 1fr;
  }
}
.icon-btn.active { background: rgba(255,255,255,0.18); }

/* ============ Mobile / Tablet ============ */
.only-mobile  { display: none; }
.only-desktop { display: inline-flex; }

/* Tablet */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: var(--left-w, 280px) 6px 1fr 280px; }
}

/* Phone */
@media (max-width: 720px) {
  .only-mobile  { display: inline-flex; }
  .only-desktop { display: none; }
  .splitter { display: none; }
  .content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }
  .pane.left-pane, .pane.right-pane {
    position: absolute;
    top: 0; bottom: 0;
    width: 84vw;
    max-width: 360px;
    z-index: 20;
    box-shadow: 0 0 30px rgba(0,0,0,0.4);
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    background: #fff;
  }
  .pane.right-pane { left: auto; right: 0; transform: translateX(100%); }

  .app-shell[data-left-open="1"]  .pane.left-pane  { transform: translateX(0); }
  .app-shell[data-right-open="1"] .pane.right-pane { transform: translateX(0); }

  .center-pane { grid-column: 1; }
  .video-element { max-height: 45vh; }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .thumb-cell img { height: 64px; }
  .player-controls .time { width: 100%; text-align: right; margin-left: 0; }
}

/* Fullscreen für <video> */
:fullscreen video, :-webkit-full-screen video { max-height: 100vh; }
