.subarchive {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 0.75rem;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.subarchive h2,
.subarchive h3,
.subarchive p {
  margin: 0;
}

.subarchive > div:first-child p,
.subarchive-status,
.subarchive-drop-zone span {
  color: var(--app-muted, #52657e);
  font-size: 0.88rem;
}

.subarchive-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subarchive-toolbar > label.btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.subarchive-name-label {
  display: grid;
  gap: 0.2rem;
  min-width: 10rem;
  color: var(--app-text, #1d2d43);
  font-size: 0.8rem;
  font-weight: 650;
}

.subarchive-name-label input {
  min-height: 2.35rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--app-border, #b9c9dc);
  border-radius: 0.45rem;
  background: var(--app-control-surface, #fff);
  color: var(--app-text, #1d2d43);
  font: inherit;
}

.subarchive-status {
  min-height: 1.3em;
}

.subarchive-drop-zone {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  padding: 0.75rem;
  border: 1px dashed var(--app-border, #b9c9dc);
  border-radius: 0.7rem;
  background: var(--app-panel-surface, #f7f9fc);
  text-align: center;
}

.subarchive-drop-zone.is-dragging {
  border-color: var(--app-accent, #285d9f);
  background: var(--app-control-surface, #edf4fb);
  box-shadow: inset 0 0 0 1px var(--app-accent, #285d9f);
}

.subarchive-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 0.75rem;
  min-height: 0;
}

.subarchive-file-section,
.subarchive-preview-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  min-width: 0;
  min-height: 0;
  padding: 0.7rem;
  border: 1px solid var(--app-border, #b9c9dc);
  border-radius: 0.65rem;
  background: var(--app-panel-surface, #fff);
}

.subarchive-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--app-text, #1d2d43);
}

.subarchive-section-heading span,
.subarchive-entry-size {
  color: var(--app-muted, #52657e);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.subarchive-entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
  overflow: auto;
}

.subarchive-entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem;
  border: 1px solid var(--app-border, #d8e0eb);
  border-radius: 0.45rem;
  background: var(--app-control-surface, #f7f9fc);
}

.subarchive-entry > input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--app-accent, #285d9f);
}

.subarchive-entry-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--app-text, #1d2d43);
}

.subarchive-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.subarchive-entry-actions .btn,
.subarchive-entry .btn {
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}

.subarchive-empty {
  padding: 1rem;
  color: var(--app-muted, #52657e);
  text-align: center;
}

.subarchive-preview-section {
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.subarchive-preview-section h3 {
  color: var(--app-text, #1d2d43);
}

.subarchive-preview {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  color: var(--app-text, #1d2d43);
}

.subarchive-preview pre {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.subarchive-preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0.5rem auto 0;
  object-fit: contain;
}

.file-explorer-archive-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.file-explorer-archive-controls [hidden] {
  display: none !important;
}

.file-explorer-archive-controls .file-explorer-action {
  width: auto;
  min-height: 2.35rem;
}

.file-explorer.is-archive-selecting .file-list-name {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.file-explorer.is-archive-selecting .file-list-name input {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  accent-color: var(--app-accent, #285d9f);
}

.file-explorer.is-archive-selecting .file-list-name span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-explorer .file-list-download {
  width: 100%;
}

.desktop.dark-theme .subarchive-name-label,
.desktop.dark-theme .subarchive-section-heading,
.desktop.dark-theme .subarchive-entry-name,
.desktop.dark-theme .subarchive-preview,
.desktop.dark-theme .subarchive-preview-section h3 {
  color: var(--app-text, #e8f1fb);
}

.desktop.dark-theme .subarchive-drop-zone,
.desktop.dark-theme .subarchive-entry,
.desktop.dark-theme .subarchive-file-section,
.desktop.dark-theme .subarchive-preview-section {
  background: var(--app-panel-surface, #142842);
}

@media (max-width: 767px) {
  .subarchive {
    overflow: auto;
  }

  .subarchive-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .subarchive-file-section {
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  .subarchive-preview-section {
    min-height: 220px;
  }

  .subarchive-entry {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .subarchive-entry-size {
    grid-column: 2;
  }

  .subarchive-entry .btn {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .file-explorer-archive-controls {
    width: 100%;
  }

  .file-explorer-archive-controls .file-explorer-action {
    flex: 1 1 100%;
  }
}
