:root {
  font-size: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
  background: #f7f8fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #f7f8fb;
}

body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.browser-shell {
  width: min(118rem, calc(100% - 4rem));
  margin: 0 auto;
  padding: 5rem 0 8rem;
}

.browser-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 3rem;
  margin-bottom: 3.2rem;
}

.eyebrow {
  margin: 0 0 .7rem;
  color: #7c3aed;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(3.4rem, 5vw, 5.4rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.header-copy {
  margin: 1.3rem 0 0;
  color: #6b7280;
  font-size: 1.6rem;
  line-height: 1.55;
}

.icon-button,
.secondary-button,
.primary-button,
.secondary-link {
  min-height: 4.4rem;
  border-radius: 1.2rem;
  padding: 1rem 1.6rem;
  font-weight: 750;
  font-size: 1.4rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.icon-button,
.secondary-button,
.secondary-link {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
}

.primary-button {
  border: 1px solid #6d28d9;
  background: #6d28d9;
  color: white;
  box-shadow: 0 .5rem 1.4rem rgba(109, 40, 217, .18);
}

.icon-button:hover,
.secondary-button:hover,
.secondary-link:hover,
.primary-button:hover { transform: translateY(-1px); }
.primary-button:disabled { opacity: .45; cursor: default; transform: none; }

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  min-height: 3.6rem;
  margin-bottom: 1.6rem;
  font-size: 1.4rem;
}

.breadcrumb-button {
  padding: .6rem .9rem;
  border: 0;
  border-radius: .9rem;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
}

.breadcrumb-button:hover { background: #eceef3; color: #111827; }
.breadcrumb-current { color: #111827; font-weight: 800; }
.breadcrumb-separator { color: #b5bac4; font-size: 2rem; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
}

.search-wrap { flex: 1; max-width: 42rem; }
.search-wrap input {
  width: 100%;
  min-height: 4.6rem;
  border: 1px solid #e0e3e8;
  border-radius: 1.3rem;
  background: white;
  padding: 1.15rem 1.5rem;
  color: #111827;
  font-size: 1.5rem;
  outline: none;
  box-shadow: 0 .2rem .7rem rgba(31, 41, 55, .03);
}
.search-wrap input:focus { border-color: #8b5cf6; box-shadow: 0 0 0 .35rem rgba(139, 92, 246, .12); }

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .8rem;
  flex-wrap: wrap;
}

.folder-summary {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  color: #7a8190;
  font-size: 1.3rem;
}
.selection-count { color: #6d28d9; font-weight: 800; }

.file-panel { min-height: 18rem; }
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1.6rem;
}

.file-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e7e9ee;
  border-radius: 1.8rem;
  background: white;
  box-shadow: 0 .8rem 2.2rem rgba(17, 24, 39, .055);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.file-card:hover { transform: translateY(-2px); box-shadow: 0 1.2rem 3rem rgba(17, 24, 39, .09); }
.file-card.selected { border-color: #7c3aed; box-shadow: 0 0 0 .3rem rgba(124, 58, 237, .12), 0 1.2rem 3rem rgba(17,24,39,.08); }

.preview-card-button {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #eef0f4;
  cursor: pointer;
}
.thumbnail { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.file-card:hover .thumbnail { transform: scale(1.025); }

.file-visual {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  color: #6b7280;
}
.file-visual strong {
  display: grid;
  place-items: center;
  width: 7rem;
  height: 8.2rem;
  border-radius: 1.2rem;
  background: white;
  color: #6d28d9;
  font-size: 1.7rem;
  box-shadow: 0 .6rem 1.8rem rgba(31, 41, 55, .08);
}
.file-visual span { font-size: 1.3rem; }

.card-info {
  min-width: 0;
  padding: 1.4rem 1.5rem .8rem;
}
.card-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2937;
  font-size: 1.45rem;
}
.card-info span {
  display: block;
  margin-top: .45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #8a909c;
  font-size: 1.2rem;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #f0f1f4;
}
.text-button {
  min-height: 4.4rem;
  padding: .9rem 1rem;
  border: 0;
  background: white;
  color: #5b21b6;
  font-weight: 750;
  cursor: pointer;
}
.text-button + .text-button { border-left: 1px solid #f0f1f4; }
.text-button:hover { background: #faf8ff; }

.folder-card {
  min-height: 11rem;
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1.6rem;
  text-align: left;
  cursor: pointer;
}
.folder-card .card-info { padding: 0; }
.folder-visual {
  position: relative;
  width: 5.7rem;
  height: 4.4rem;
  margin-top: .8rem;
  border-radius: .8rem 1rem 1rem 1rem;
  background: #ede9fe;
}
.folder-visual::before {
  content: '';
  position: absolute;
  top: -.9rem;
  left: .4rem;
  width: 2.6rem;
  height: 1.4rem;
  border-radius: .7rem .7rem 0 0;
  background: #ddd6fe;
}
.folder-arrow { color: #9ca3af; font-size: 2.8rem; }

.select-control {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 4;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  box-shadow: 0 .3rem 1rem rgba(0,0,0,.15);
  cursor: pointer;
}
.select-control input { position: absolute; opacity: 0; pointer-events: none; }
.select-control span {
  position: absolute;
  inset: .7rem;
  border: .2rem solid #a7acb5;
  border-radius: 50%;
  background: white;
}
.select-control input:checked + span { border-color: #6d28d9; background: #6d28d9; }
.select-control input:checked + span::after {
  content: '';
  position: absolute;
  left: .45rem;
  top: .15rem;
  width: .5rem;
  height: .95rem;
  border: solid white;
  border-width: 0 .22rem .22rem 0;
  transform: rotate(45deg);
}

.empty-state {
  min-height: 24rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 4rem 2rem;
  text-align: center;
  color: #8a909c;
  font-size: 1.45rem;
}
.empty-state strong { color: #4b5563; font-size: 1.7rem; }
.error-state strong { color: #991b1b; }

.modal[hidden], .toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 2rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .72); backdrop-filter: blur(.4rem); }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(96rem, 100%);
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2rem;
  background: white;
  box-shadow: 0 3rem 8rem rgba(0,0,0,.28);
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.7rem 2rem;
  border-bottom: 1px solid #eceef2;
}
.modal-header h2 { margin: 0; font-size: 1.8rem; overflow-wrap: anywhere; }
.modal-header p { margin: .45rem 0 0; color: #8a909c; font-size: 1.2rem; }
.close-button {
  min-height: 3.8rem;
  padding: .7rem 1.1rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: white;
  color: #4b5563;
  cursor: pointer;
}
.preview-body {
  min-height: 25rem;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #111827;
}
.preview-image { display: block; max-width: 100%; max-height: calc(100vh - 18rem); object-fit: contain; }
.preview-video { width: 100%; max-height: calc(100vh - 18rem); background: black; }
.preview-frame { width: 100%; height: min(70vh, 78rem); border: 0; background: white; }
.no-preview { display: flex; flex-direction: column; gap: .7rem; padding: 4rem; text-align: center; color: #d1d5db; }
.no-preview strong { color: white; font-size: 1.7rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .8rem; padding: 1.3rem 1.6rem; border-top: 1px solid #eceef2; }
.secondary-link { display: inline-flex; align-items: center; justify-content: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 2.4rem;
  z-index: 80;
  transform: translateX(-50%);
  max-width: calc(100% - 3rem);
  padding: 1.2rem 1.7rem;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: 0 1rem 3rem rgba(0,0,0,.22);
}

@media (max-width: 760px) {
  .browser-shell { width: min(100% - 2rem, 118rem); padding-top: 2.8rem; }
  .browser-header { gap: 1.4rem; margin-bottom: 2.4rem; }
  .header-copy { font-size: 1.4rem; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-wrap { max-width: none; }
  .toolbar-actions { justify-content: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-actions > * { width: 100%; }
  #downloadAllButton { grid-column: 1 / -1; }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .file-card { border-radius: 1.4rem; }
  .card-info { padding: 1.1rem 1.1rem .7rem; }
  .card-info strong { font-size: 1.3rem; }
  .card-info span { font-size: 1.1rem; }
  .card-actions { grid-template-columns: 1fr; }
  .text-button { min-height: 4rem; font-size: 1.2rem; }
  .text-button + .text-button { border-left: 0; border-top: 1px solid #f0f1f4; }
  .folder-card { grid-column: 1 / -1; min-height: 9rem; }
  .modal { padding: 0; }
  .modal-card { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .preview-image, .preview-video { max-height: calc(100vh - 17rem); }
}

@media (max-width: 420px) {
  .browser-header { align-items: flex-start; flex-direction: column; }
  .browser-header .icon-button { align-self: flex-end; margin-top: -4.7rem; }
  .toolbar-actions { grid-template-columns: 1fr; }
  #downloadAllButton { grid-column: auto; }
  .file-grid { grid-template-columns: 1fr 1fr; }
}
