:root {
  color-scheme: light;
  --bg: #e7e0d8;
  --bg-soft: #d7d0c7;
  --surface: #f4efe8;
  --surface-raised: #ebe4dc;
  --text: #403b36;
  --muted: #746b63;
  --line: rgba(64, 59, 54, 0.14);
  --line-strong: rgba(64, 59, 54, 0.24);
  --accent: #9b6f6b;
  --accent-strong: #865f5b;
  --accent-soft: rgba(155, 111, 107, 0.18);
  --cyan: #7d9991;
  --gold: #b69b72;
  --danger: #9d5d5c;
  --shadow: 0 18px 44px rgba(77, 66, 56, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(154, 137, 121, 0.26) 0, rgba(231, 224, 216, 0) 380px),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fffaf5;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.danger {
  background: rgba(157, 93, 92, 0.07);
  color: var(--danger);
  border: 1px solid rgba(157, 93, 92, 0.28);
}

button.danger:hover {
  background: rgba(157, 93, 92, 0.13);
}

input[type="text"],
input[type="search"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 245, 0.62);
  color: var(--text);
  outline: none;
  padding: 0 13px;
}

input[type="text"]::placeholder,
input[type="search"]::placeholder {
  color: #93877d;
}

input[type="text"]:focus,
input[type="search"]:focus {
  border-color: rgba(125, 153, 145, 0.74);
  box-shadow: 0 0 0 3px rgba(125, 153, 145, 0.14);
}

.app-shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  margin: 0 -16px 18px;
  padding: 10px 16px;
  background: rgba(231, 224, 216, 0.88);
  box-shadow: 0 8px 24px rgba(77, 66, 56, 0.08);
  backdrop-filter: blur(18px);
}

.brand-lockup,
.top-actions,
.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar h1,
.topbar p,
.section-header h2,
.section-header p,
.now-playing h2,
.now-playing p {
  margin: 0;
}

.topbar h1 {
  color: #745f58;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.topnav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.topnav a:hover {
  color: var(--text);
}

.top-actions {
  flex: 1;
  justify-content: flex-end;
  min-width: 280px;
}

.top-actions input {
  max-width: 340px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(125, 153, 145, 0.38);
  border-radius: 999px;
  background: rgba(125, 153, 145, 0.14);
  color: #5e7770;
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
}

.player-panel {
  display: grid;
  grid-template-columns: minmax(520px, 1.55fr) minmax(320px, 0.85fr);
  gap: 0;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.player-frame {
  min-width: 0;
  aspect-ratio: 16 / 9;
  background: #cac1b7;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  background: #cac1b7;
}

.now-playing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  padding: 34px;
  background:
    linear-gradient(90deg, rgba(215, 208, 199, 0.46), var(--surface) 36%),
    var(--surface);
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.now-playing-header {
  display: grid;
  gap: 16px;
}

.now-playing-header h2 {
  max-width: 100%;
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 900;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.now-playing-header button {
  justify-self: start;
  min-height: 42px;
}

.now-playing-header button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.now-playing p {
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.share-status {
  min-height: 22px;
  color: #8c6d66;
}

.tools-panel,
.library-panel {
  margin-top: 22px;
}

.tools-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 239, 232, 0.74);
  padding: 18px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}

.section-header p,
.message {
  color: var(--muted);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.dropzone {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  cursor: pointer;
  padding: 18px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.dropzone::before {
  content: "";
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.dropzone:hover {
  border-color: rgba(155, 111, 107, 0.5);
  background: #f2ece4;
  transform: translateY(-2px);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-weight: 900;
}

.dropzone-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.scan-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  margin-top: 12px;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(64, 59, 54, 0.1);
}

#progressFill {
  width: 0%;
  height: 100%;
  background: var(--cyan);
  transition: width 150ms ease;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  line-height: 1.4;
}

.library-header {
  align-items: baseline;
  padding: 0 2px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bulk-actions button {
  min-height: 34px;
  padding: 0 12px;
}

.folder-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 2px 14px;
  color: var(--muted);
}

.folder-breadcrumb button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 232, 0.72);
  color: var(--muted);
  font-size: 13px;
  padding: 0 12px;
}

.folder-breadcrumb button:hover,
.folder-breadcrumb button.active {
  border-color: rgba(155, 111, 107, 0.56);
  background: var(--accent-soft);
  color: var(--text);
}

.breadcrumb-separator {
  color: rgba(64, 59, 54, 0.34);
  font-weight: 900;
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.video-empty {
  grid-column: 1 / -1;
  min-height: 150px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 24px;
}

.folder-item {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 214px;
  overflow: hidden;
  border: 1px solid rgba(64, 59, 54, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 12%, rgba(182, 155, 114, 0.22), transparent 36%),
    linear-gradient(135deg, rgba(155, 111, 107, 0.26), rgba(125, 153, 145, 0.18)),
    var(--surface-raised);
  box-shadow: 0 14px 34px rgba(77, 66, 56, 0.13);
  cursor: pointer;
  padding: 14px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.folder-item:hover,
.folder-item:focus-visible {
  border-color: rgba(182, 155, 114, 0.7);
  outline: none;
  transform: translateY(-4px);
}

.folder-icon {
  position: absolute;
  left: 14px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 58px;
  height: 42px;
  border-radius: 6px;
  background: rgba(255, 250, 245, 0.42);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.folder-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.folder-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-top: 7px;
}

.video-item {
  position: relative;
  display: grid;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(64, 59, 54, 0.11);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 14px 34px rgba(77, 66, 56, 0.13);
  cursor: grab;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.video-item:hover,
.video-item.active,
.video-item.selected {
  border-color: rgba(155, 111, 107, 0.58);
  background: #f2ece4;
  transform: translateY(-4px);
}

.video-item.selected {
  border-color: rgba(125, 153, 145, 0.72);
  box-shadow: 0 0 0 3px rgba(125, 153, 145, 0.16), 0 14px 34px rgba(77, 66, 56, 0.13);
}

.video-item.dragging {
  opacity: 0.46;
  cursor: grabbing;
  transform: scale(0.98);
}

.video-item.drag-over {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(182, 155, 114, 0.18), 0 12px 30px rgba(77, 66, 56, 0.18);
}

.video-item.drag-over::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--gold);
  z-index: 2;
}

.video-item.drag-over.drag-after::before {
  inset: 0 0 0 auto;
}

.video-main {
  display: grid;
  min-width: 0;
}

.video-selector {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid rgba(64, 59, 54, 0.16);
  border-radius: 999px;
  background: rgba(244, 239, 232, 0.88);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 0 10px;
  box-shadow: 0 8px 18px rgba(77, 66, 56, 0.12);
}

.video-selector input {
  accent-color: var(--cyan);
}

.video-thumbnail {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(155, 111, 107, 0.38), rgba(182, 155, 114, 0.2) 48%, rgba(125, 153, 145, 0.3)),
    #d5cbc0;
}

.video-thumbnail::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(64, 59, 54, 0) 42%, rgba(64, 59, 54, 0.2));
  pointer-events: none;
}

.video-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-missing .video-thumbnail::before {
  content: "MP4";
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.video-title,
.video-meta {
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-title {
  min-height: 52px;
  padding: 12px 12px 0;
  color: var(--text);
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.video-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  padding: 6px 12px 0;
  white-space: nowrap;
}

.video-actions {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 8px;
  padding: 8px 12px 12px;
}

.video-actions button {
  width: 84px;
  min-width: 84px;
  min-height: 32px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 14px;
}

.video-item.active .video-actions button:first-child {
  background: var(--cyan);
  color: #f8f3ec;
}

.video-item.active .video-actions button:first-child:hover {
  background: #8aa9a0;
}

@media (max-width: 1120px) {
  .player-panel {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .now-playing {
    padding: 24px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding: 12px 0 28px;
  }

  .topbar,
  .brand-lockup,
  .top-actions,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    min-width: 0;
  }

  .top-actions input {
    max-width: none;
  }

  .topnav {
    width: 100%;
  }

  .player-frame,
  .video-thumbnail {
    aspect-ratio: 16 / 9;
  }

  .upload-grid,
  .scan-row {
    grid-template-columns: 1fr;
  }

  .now-playing-header h2 {
    font-size: 30px;
  }

  .video-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}
