:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #f8faf9;
  --text: #17211f;
  --muted: #65716e;
  --line: #d8e0de;
  --line-strong: #b9c7c3;
  --accent: #0f766e;
  --accent-dark: #095f59;
  --accent-soft: #e3f2ef;
  --warning: #9a6700;
  --warning-soft: #fff7e6;
  --danger: #b42318;
  --danger-soft: #fff0ef;
  --shadow: 0 18px 55px rgba(36, 65, 58, 0.09);
  --radius-large: 22px;
  --radius-medium: 15px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(15, 118, 110, 0.08), transparent 28rem),
    linear-gradient(180deg, #f8faf9 0, var(--bg) 25rem);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.page-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 54px;
}

.step-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.privacy-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid #c7e2dc;
  border-radius: var(--radius-medium);
  color: #174f49;
  background: linear-gradient(135deg, #e7f5f2, #f3faf8);
}

.privacy-icon {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  place-items: center;
  color: white;
  background: var(--accent);
  font-weight: 900;
}

.privacy-banner strong {
  display: block;
  margin-bottom: 3px;
}

.privacy-banner p {
  margin-bottom: 0;
  color: #47716c;
  font-size: 13px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.mode-tab {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #4a5552;
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-weight: 800;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.mode-tab:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.mode-tab[aria-selected="true"] {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.2);
}

.tab-index {
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.68;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

.tool-panel,
.result-card,
.help-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 24px;
}

.panel-heading {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: clamp(21px, 3vw, 28px);
  letter-spacing: -0.025em;
}

.panel-heading > p {
  max-width: 310px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.media-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.media-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--panel-soft);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.media-card.drag-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.media-card-head,
.media-footer,
.crop-heading,
.dialog-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.media-card-head h3 {
  margin-bottom: 2px;
  font-size: 16px;
}

.media-card-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.file-state {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #68736f;
  background: #e9eeec;
  font-size: 11px;
  font-weight: 800;
}

.file-state.ready {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.file-state.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.media-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: 520px;
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
  border: 1px dashed #a9b7b3;
  border-radius: 12px;
  place-items: center;
  color: inherit;
  background:
    linear-gradient(45deg, rgba(210, 221, 218, 0.34) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(210, 221, 218, 0.34) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(210, 221, 218, 0.34) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(210, 221, 218, 0.34) 75%),
    #f2f6f5;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-size: 18px 18px;
  cursor: pointer;
}

.media-stage:hover {
  border-color: var(--accent);
}

.media-stage img,
.media-stage video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 24px;
  place-items: center;
  color: var(--muted);
}

.empty-state strong {
  color: #35413e;
  font-size: 14px;
}

.empty-state small {
  font-size: 12px;
}

.upload-mark {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border: 1px solid #b8cac5;
  border-radius: 50%;
  place-items: center;
  color: var(--accent);
  background: white;
  font-size: 24px;
}

.media-footer {
  min-height: 32px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.media-footer > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
}

.text-button,
.icon-button {
  padding: 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.option-card,
.mode-note,
.advanced-settings {
  margin-top: 14px;
  border-radius: 13px;
}

.option-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #fbfcfc;
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.check-row span {
  display: grid;
  gap: 3px;
}

.check-row strong {
  font-size: 14px;
}

.check-row small {
  color: var(--muted);
  font-size: 12px;
}

.mode-note {
  padding: 12px 14px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
}

.advanced-settings {
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fbfcfc;
}

.advanced-settings summary {
  padding: 12px 15px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 15px 15px;
}

.settings-grid label {
  display: grid;
  gap: 6px;
  color: #4b5653;
  font-size: 12px;
  font-weight: 700;
}

.settings-grid input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: white;
}

.primary-button,
.secondary-button,
.download-button {
  display: inline-flex;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--accent);
  color: white;
  background: var(--accent);
}

.primary-button:hover,
.download-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.primary-button.compact {
  width: auto;
  min-width: 92px;
  margin-top: 0;
}

.secondary-button {
  min-width: 92px;
  border: 1px solid var(--line-strong);
  color: #3e4946;
  background: white;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.result-column {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
}

.result-card,
.help-card {
  padding: 20px;
}

.result-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.result-heading p {
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.result-heading h2 {
  margin-bottom: 0;
  font-size: 19px;
}

.status-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border: 3px solid #d5dedb;
  border-radius: 50%;
  background: #89938f;
}

.status-dot.working {
  border-color: #bce1da;
  background: var(--accent);
  animation: status-pulse 1.2s ease-in-out infinite;
}

.status-dot.success {
  border-color: #bce1da;
  background: var(--accent);
}

.status-dot.error {
  border-color: #ffd0cb;
  background: var(--danger);
}

@keyframes status-pulse {
  50% { box-shadow: 0 0 0 7px rgba(15, 118, 110, 0.08); }
}

.status-message {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result-meta {
  display: grid;
  gap: 8px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 12px;
}

.result-meta div {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding-bottom: 7px;
  border-bottom: 1px solid #edf1f0;
}

.result-meta strong {
  color: var(--text);
}

.download-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--accent);
  color: white;
  background: var(--accent);
}

.help-card h2 {
  margin-bottom: 10px;
  font-size: 15px;
}

.help-card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 12px;
}

.help-card li + li {
  margin-top: 7px;
}

.app-dialog {
  width: min(520px, calc(100% - 28px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 20px;
  color: var(--text);
  background: transparent;
  box-shadow: 0 28px 90px rgba(13, 35, 30, 0.28);
}

.app-dialog::backdrop {
  background: rgba(20, 34, 31, 0.56);
  backdrop-filter: blur(4px);
}

.dialog-card {
  padding: 24px;
  border-radius: 20px;
  background: white;
}

.dialog-card h2 {
  margin: 10px 0 8px;
}

.dialog-card > p {
  color: var(--muted);
  font-size: 13px;
}

.dialog-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 11px;
  font-weight: 800;
}

.video-warning-actions,
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.crop-dialog {
  width: min(760px, calc(100% - 28px));
}

.crop-heading h2 {
  margin-bottom: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #56615e;
  background: #eef2f1;
  font-size: 24px;
}

.crop-stage {
  display: grid;
  min-height: 360px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 14px;
  place-items: center;
  background: #18201e;
  touch-action: none;
}

.crop-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  cursor: grab;
  touch-action: none;
}

.crop-stage canvas.dragging {
  cursor: grabbing;
}

.zoom-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  color: #4d5955;
  font-size: 13px;
  font-weight: 800;
}

.zoom-control input {
  width: 100%;
  accent-color: var(--accent);
}

.crop-tip {
  margin: 8px 0 0;
  font-size: 12px !important;
}

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

  .result-column {
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 12px;
  }

  .privacy-banner {
    padding: 14px;
  }

  .privacy-banner p {
    font-size: 12px;
  }

  .mode-tabs {
    gap: 8px;
  }

  .mode-tab {
    min-height: 54px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .tab-index {
    display: none;
  }

  .tool-panel {
    padding: 14px;
    border-radius: 17px;
  }

  .panel-heading {
    display: block;
  }

  .panel-heading > p {
    max-width: none;
    margin: 7px 0 0;
    text-align: left;
  }

  .media-pair,
  .settings-grid,
  .result-column {
    grid-template-columns: 1fr;
  }

  .media-stage {
    height: min(72vw, 330px);
  }

  .result-card,
  .help-card {
    padding: 16px;
    border-radius: 17px;
  }

  .video-warning-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .video-warning-actions .primary-button {
    grid-column: 1 / -1;
    order: -1;
  }

  .video-warning-actions button {
    width: 100%;
  }

  .dialog-card {
    padding: 18px;
  }

  .crop-stage {
    min-height: 280px;
  }
}
