* {
  box-sizing: border-box;
}

:root {
  --bg: #eef2ff;
  --card: rgba(255, 255, 255, 0.92);
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-2: #2563eb;
  --primary-soft: #eef2ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 22px 56px rgba(15, 23, 42, 0.10);
  --radius: 24px;
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 8%, rgba(79, 70, 229, 0.18), transparent 30%),
    radial-gradient(circle at 94% 10%, rgba(5, 150, 105, 0.12), transparent 32%),
    linear-gradient(180deg, #fff 0%, #f5f7ff 45%, var(--bg) 100%);
  font-size: 16px;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button,
.dropzone,
.direction-switch label {
  cursor: pointer;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.page-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 18px 22px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 66px;
  margin-bottom: 18px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  border-radius: 14px;
  box-shadow: 0 12px 22px rgba(79, 70, 229, 0.24);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.page-title h1 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.page-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(79, 70, 229, 0.14);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: stretch;
}

.converter-card,
.result-card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.converter-card {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  padding: 18px;
}

.card-header,
.upload-label-row,
.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.card-header h2,
.result-card h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.direction-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.direction-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
  padding: 0;
  border: 0;
}

.direction-switch label {
  position: relative;
  display: block;
}

.direction-switch input {
  position: absolute;
  opacity: 0;
}

.direction-switch span {
  display: grid;
  gap: 2px;
  min-height: 62px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.direction-switch strong {
  font-size: 17px;
}

.direction-switch small {
  color: var(--muted);
  font-size: 13px;
}

.direction-switch input:checked + span {
  border-color: rgba(79, 70, 229, 0.62);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.13), inset 0 0 0 1px rgba(79, 70, 229, 0.18);
}

.upload-label-row label {
  font-weight: 900;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  color: #475569;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 800;
}

.dropzone {
  display: grid;
  min-height: 138px;
  margin-top: 8px;
  place-items: center;
  padding: 16px 14px;
  text-align: center;
  background: rgba(248, 250, 252, 0.92);
  border: 2px dashed #c7d2fe;
  border-radius: 16px;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.dropzone:hover,
.dropzone.drag-over {
  background: #f8fbff;
  border-color: var(--primary);
  box-shadow: inset 0 0 0 4px rgba(79, 70, 229, 0.08);
}

.dropzone-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  border-radius: 13px;
  box-shadow: 0 12px 22px rgba(79, 70, 229, 0.22);
}

.dropzone-icon svg {
  width: 21px;
  height: 21px;
}

.dropzone strong {
  margin-top: 8px;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.dropzone span:last-child {
  color: var(--muted);
  font-size: 14px;
}

.selected-files-panel {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin-top: 10px;
}

.selected-files-panel[hidden],
.result-card[hidden],
.result-files-panel[hidden],
.download-button[hidden] {
  display: none;
}

.selected-files-panel > strong {
  font-size: 14px;
}

.selected-files-list {
  display: grid;
  gap: 5px;
  max-height: 66px;
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  list-style: none;
}

.selected-files-list li {
  min-height: 28px;
  padding: 4px 9px;
  color: #334155;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 9px;
  font-size: 12px;
}

.output-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.output-preview div {
  display: grid;
  gap: 2px;
  padding: 12px;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 14px;
}

.output-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.output-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.convert-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  border: 0;
  border-radius: 15px;
  box-shadow: 0 16px 30px rgba(79, 70, 229, 0.23);
  font-size: 16px;
  font-weight: 900;
}

.convert-button {
  width: 100%;
  margin-top: 10px;
}

.convert-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.convert-button svg,
.download-button svg {
  width: 20px;
  height: 20px;
}

.status-message {
  min-height: 18px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
}

.status-message.success,
.status-message.error {
  padding: 10px 12px;
  border-radius: 12px;
}

.status-message.success {
  color: #047857;
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
}

.status-message.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
}

.result-card {
  display: grid;
  gap: 18px;
  min-height: 520px;
  padding: 22px;
  border-color: #bbf7d0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(236, 253, 245, 0.92));
}

.result-card.pending {
  border-color: rgba(199, 210, 254, 0.95);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(238, 242, 255, 0.92));
}

.result-card.pending .result-check {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

.result-card.pending .result-stats strong {
  color: var(--muted);
}

.result-check {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: var(--success);
  border-radius: 14px;
}

.result-top {
  justify-content: flex-start;
}

.result-top p {
  margin: 4px 0 0;
  color: var(--muted);
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.result-stats div {
  display: grid;
  padding: 14px;
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 14px;
}

.result-stats strong {
  color: var(--success);
  font-size: 24px;
  line-height: 1.1;
}

.result-stats span {
  color: var(--muted);
  font-size: 13px;
}

.result-files-panel {
  display: grid;
  gap: 8px;
}

.result-files-panel > strong {
  font-size: 14px;
}

.result-files-list {
  display: grid;
  gap: 6px;
  max-height: 124px;
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  list-style: none;
}

.result-files-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 10px;
  font-size: 12px;
}

.result-files-list li.more-item {
  display: block;
  color: var(--muted);
}

.result-files-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-files-list button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--success);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.result-actions {
  display: grid;
  gap: 10px;
  align-self: end;
}

.download-button {
  width: 100%;
  padding: 0 18px;
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 18px 34px rgba(5, 150, 105, 0.22);
}

.download-button.secondary {
  color: var(--success);
  background: #fff;
  border: 1px solid #a7f3d0;
  box-shadow: none;
}

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

:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.28);
  outline-offset: 3px;
}

@media (max-width: 1120px) {
  .page-shell {
    width: min(100%, 980px);
    margin-inline: auto;
    padding-inline: 16px;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .converter-card,
  .result-card {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding-inline: 12px;
  }

  .site-header,
  .card-header,
  .result-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .local-badge {
    width: 100%;
    justify-content: center;
  }

  .direction-switch,
  .output-preview,
  .selected-files-panel {
    grid-template-columns: 1fr;
  }

  .converter-card,
  .result-card {
    padding: 18px;
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
