:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687589;
  --line: #dce3ec;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --accent: #c2410c;
  --shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  min-width: 320px;
}

a {
  color: inherit;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.download-link {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover,
.download-link:hover {
  border-color: var(--brand);
  color: var(--brand);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.crumbs a,
.crumbs span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--brand);
}

.crumbs .current {
  color: var(--text);
  font-weight: 700;
}

.tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  width: min(360px, 36vw);
  min-width: 220px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.search svg {
  color: var(--muted);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  font: inherit;
  background: transparent;
  color: var(--text);
}

.select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.summary div {
  display: flex;
  gap: 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.file-panel,
.preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-head,
.file-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 178px 70px;
  align-items: center;
  gap: 14px;
}

.table-head {
  height: 44px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.file-list {
  min-height: 320px;
}

.file-row {
  min-height: 62px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: #f9fbfd;
}

.file-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.file-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f4f2;
  color: var(--brand);
  font-size: 18px;
  font-weight: 800;
}

.file-icon.folder {
  background: #fff7ed;
  color: var(--accent);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.file-size,
.file-date {
  color: var(--muted);
  font-size: 14px;
}

.file-actions {
  display: flex;
  justify-content: flex-end;
}

.file-row.is-folder .download-link {
  display: none;
}

.empty,
.error {
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: #b42318;
}

.preview {
  position: sticky;
  top: 92px;
  min-height: 420px;
  overflow: hidden;
}

.preview-empty {
  min-height: 420px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.preview-empty svg {
  width: 42px;
  height: 42px;
  color: var(--brand);
}

.preview-empty strong {
  color: var(--text);
}

.preview-content {
  padding: 16px;
}

.preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.preview-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.preview-box img,
.preview-box video {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #0f172a;
}

.preview-box audio {
  width: 100%;
  display: block;
  margin: 18px 0;
}

.preview-box iframe {
  width: 100%;
  height: 62vh;
  border: 0;
  background: white;
}

.text-preview {
  max-height: 62vh;
  overflow: auto;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.65 Consolas, "SFMono-Regular", monospace;
  color: #243044;
}

.unsupported {
  padding: 24px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .shell {
    width: min(100vw - 20px, 1320px);
    margin-top: 16px;
  }

  .toolbar,
  .tools,
  .summary {
    align-items: stretch;
    flex-direction: column;
  }

  .search,
  .select {
    width: 100%;
    min-width: 0;
  }

  .table-head {
    display: none;
  }

  .file-row {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
  }

  .file-size,
  .file-date {
    grid-column: 1;
    padding-left: 50px;
  }

  .file-actions {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}
