:root {
  color-scheme: light dark;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  --header-footer-bg: rgba(255, 255, 255, 0.82);
  --surface-bg: rgba(255, 255, 255, 0.82);
  --surface-strong-bg: rgba(255, 255, 255, 0.9);
  --surface-muted-bg: rgba(241, 245, 249, 0.92);
  --border-color: rgba(148, 163, 184, 0.35);
  --card-border: rgba(148, 163, 184, 0.28);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-tertiary: #475569;
  --accent-start: #2563eb;
  --accent-end: #38bdf8;
  --accent-hover: #60a5fa;
  --accent-shadow: rgba(56, 189, 248, 0.35);
  --card-hover: rgba(59, 130, 246, 0.12);
  --tag-bg: rgba(59, 130, 246, 0.18);
  --tag-muted-bg: rgba(148, 163, 184, 0.3);
  --muted-text: rgba(100, 116, 139, 0.85);
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 22px;
  --radius-xl: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: linear-gradient(180deg, #101928 0%, #05070c 100%);
    --header-footer-bg: rgba(15, 23, 42, 0.8);
    --surface-bg: rgba(15, 23, 42, 0.6);
    --surface-strong-bg: rgba(15, 23, 42, 0.72);
    --surface-muted-bg: rgba(30, 41, 59, 0.75);
    --border-color: rgba(148, 163, 184, 0.2);
    --card-border: rgba(148, 163, 184, 0.2);
    --text-primary: #f5f7fa;
    --text-secondary: rgba(226, 232, 240, 0.9);
    --text-tertiary: rgba(148, 163, 184, 0.8);
    --accent-hover: #7dd3fc;
    --card-hover: rgba(59, 130, 246, 0.18);
    --tag-bg: rgba(56, 189, 248, 0.2);
    --tag-muted-bg: rgba(71, 85, 105, 0.7);
    --muted-text: rgba(148, 163, 184, 0.85);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--background);
  color: var(--text-primary);
  transition: background 0.4s ease, color 0.4s ease;
}

a {
  color: inherit;
}

header,
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--header-footer-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  border-bottom: none;
  font-size: 0.9rem;
  color: var(--text-tertiary);
}

main {
  flex: 1;
  padding: 2rem 1rem 3rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
}

.app-selection header {
  padding-bottom: 1rem;
}

.app-selection main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 960px;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 2.75rem);
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: var(--text-primary);
}

p {
  margin: 0;
  line-height: 1.6;
  color: var(--text-secondary);
}

.app-selection .intro p {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.app-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  background: var(--surface-strong-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 35px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease,
    border-radius 0.3s ease;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.12);
  border-color: var(--card-hover);
}

.app-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.app-card ul {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted-text);
  line-height: 1.6;
}

.app-card li + li {
  margin-top: 0.35rem;
}

.app-card-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--accent-start);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-card-tag--muted {
  background: var(--tag-muted-bg);
  color: var(--text-tertiary);
}

.app-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}

.app-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.app-card-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 25px var(--accent-shadow);
}

.app-card--disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.app-card--disabled .app-card-action {
  background: var(--surface-muted-bg);
  color: var(--text-tertiary);
  box-shadow: none;
  cursor: default;
}

.app-card--disabled:hover {
  transform: none;
  box-shadow: 0 20px 35px rgba(15, 23, 42, 0.08);
  border-color: var(--card-border);
}

.top-nav {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-start);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
  background: rgba(59, 130, 246, 0.22);
  transform: translateX(-2px);
}


.uploader {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: border-color 0.3s ease, background 0.3s ease, border-radius 0.3s ease;
  background: var(--surface-bg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.uploader-main {
  position: relative;
  width: 100%;
  max-width: 640px;
  min-height: 180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.uploader.dragover {
  border-color: var(--accent-end);
  background: var(--surface-muted-bg);
}

#file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#file-label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  color: var(--text-secondary);
}

.uploader-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.secondary-button {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-start);
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: none;
}

.secondary-button:not(:disabled):hover {
  background: rgba(59, 130, 246, 0.22);
  transform: translateY(-1px);
  box-shadow: none;
}

.uploader-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.label-main {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.label-sub {
  font-size: 0.95rem;
  color: var(--text-tertiary);
}

.mode-tabs {
  display: inline-flex;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--surface-bg);
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.mode-tab {
  padding: 0.75rem 2.4rem;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 1rem;
  border: 1px solid transparent;
  box-shadow: none;
  transform: none;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease,
    border-color 0.2s ease, border-radius 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-tab:focus {
  outline: none;
}

.mode-tab:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.mode-tab:not(:disabled):not(.is-active):hover {
  background: var(--surface-muted-bg);
  box-shadow: none;
  transform: none;
}

.mode-tab.is-active {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 14px 30px var(--accent-shadow);
}

.mode-tab.is-active:not(:disabled):hover {
  box-shadow: 0 16px 36px var(--accent-shadow);
  transform: none;
}

.mode-tab.is-active:focus-visible {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45), 0 16px 36px var(--accent-shadow);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  background: var(--surface-bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.file-info {
  flex: 1;
  min-width: 200px;
  color: var(--text-secondary);
}

.ghost-button {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  box-shadow: none;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
}

.ghost-button:not(:disabled):hover {
  background: var(--surface-muted-bg);
  transform: none;
  box-shadow: none;
}

button,
.app-card-action {
  appearance: none;
  border: none;
  cursor: pointer;
}

button:not(.mode-tab):not(.sort-button) {
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

button:not(.mode-tab):not(.sort-button):not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px var(--accent-shadow);
}

[hidden] {
  display: none !important;
}

.is-hidden {
  display: none !important;
}

.progress {
  background: var(--surface-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  width: 0%;
  transition: width 0.2s ease;
}

.status {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.result,
.log {
  background: var(--surface-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.result p {
  margin: 0;
  color: var(--text-secondary);
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.download-list a {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted-bg);
  color: var(--accent-end);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, border-radius 0.3s ease;
}

.download-list a:hover {
  background: var(--card-hover);
  color: var(--accent-hover);
}

.download-size {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.download-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.download-actions button {
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  font-size: 0.9rem;
}

.analysis,
.config {
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: grid;
  gap: 1.25rem;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.analysis-summary {
  color: var(--text-secondary);
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.analysis[data-mode="audio"] .column-video-only {
  display: none;
}

.analysis-size {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}


.analysis-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

th.analysis-actions {
  text-align: center;
  white-space: nowrap;
}

td.analysis-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.analysis-codec {
  min-width: 7ch;
}

button.sort-button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  box-shadow: none;
  font: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: inherit;
  text-align: left;
  white-space: normal;
  position: relative;
  outline: none;
  transition: color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

button.sort-button:focus {
  outline: none;
  box-shadow: none;
}

button.sort-button:focus-visible {
  outline: none;
  box-shadow: none;
  color: var(--text-primary);
  transform: translateY(-2px);
}

button.sort-button:hover {
  color: var(--text-primary);
  transform: translateY(-2px);
}

button.sort-button:focus-visible .sort-button-label {
  text-decoration: underline;
  color: var(--text-primary);
}

.sort-button-label {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: calc(1.25em * 2);
  text-decoration: none;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent-start);
  text-underline-offset: 0.2em;
}

button.sort-button::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0.2rem;
  border-left: 0.28em solid transparent;
  border-right: 0.28em solid transparent;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

button.sort-button[data-sort-state="asc"]::after {
  border-bottom: 0.34em solid currentColor;
  border-top: 0;
  transform: translateY(-0.1em);
  opacity: 0.85;
}

button.sort-button[data-sort-state="desc"]::after {
  border-top: 0.34em solid currentColor;
  border-bottom: 0;
  transform: translateY(0.1em);
  opacity: 0.85;
}

.analysis-action-button {
  border: 1px solid var(--border-color);
  background: transparent;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.analysis-action-button:hover,
.analysis-action-button:focus-visible {
  border-color: var(--accent-end);
  color: var(--accent-end);
  background: rgba(59, 130, 246, 0.08);
  outline: none;
}

.delete-button {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.4);
}

.delete-button:hover,
.delete-button:focus-visible {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.65);
  background: rgba(220, 38, 38, 0.1);
}

thead {
  background: var(--surface-muted-bg);
}

th,
td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
  background: rgba(148, 163, 184, 0.12);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.is-visible {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-dialog {
  position: relative;
  background: var(--surface-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: min(560px, calc(100% - 2.5rem));
  max-height: calc(100% - 4rem);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: border-radius 0.3s ease, background 0.2s ease, color 0.2s ease;
}

.modal-close:hover,
.modal-close:focus-visible {
  color: var(--accent-end);
  background: rgba(59, 130, 246, 0.1);
  outline: none;
}

.modal-content {
  overflow-y: auto;
  padding-right: 0.25rem;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.25rem;
  row-gap: 0.5rem;
  margin: 0;
}

.detail-list dt {
  margin: 0;
  font-weight: 600;
  color: var(--text-secondary);
}

.detail-list dd {
  margin: 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.config form {
  display: grid;
  gap: 1.5rem;
}

.config-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.5rem;
}

.config-block {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem 1.25rem;
  background: var(--surface-strong-bg);
  display: grid;
  gap: 1rem;
  transition: border-radius 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.config-block legend {
  font-weight: 700;
  padding: 0 0.2rem;
  color: var(--text-primary);
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
  color: var(--text-secondary);
}

select,
input[type="number"] {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, background 0.3s ease, border-radius 0.3s ease,
    box-shadow 0.2s ease;
}

input[type="number"]:focus,
select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
}

.inline-inputs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-inputs input {
  flex: 1 1 120px;
}

.helper-text {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin: 0;
}

@media (max-width: 720px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  button {
    width: 100%;
  }

  .inline-inputs {
    flex-direction: column;
  }
}

.log pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--muted-text);
  background: var(--surface-muted-bg);
  padding: 1rem;
  border-radius: var(--radius-sm);
  transition: border-radius 0.3s ease;
}

@media (max-width: 600px) {
  main {
    padding: 1.5rem 1rem 2rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  button {
    width: 100%;
  }

  .app-card {
    padding: 1.5rem;
  }
}
