:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f9fbfb;
  --ink: #17202a;
  --muted: #64727f;
  --line: #dce4ea;
  --line-strong: #c4d0d8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e7f4f2;
  --blue-soft: #edf4ff;
  --warn-soft: #fff7e8;
  --danger: #b42318;
  --danger-soft: #fff2f0;
  --shadow: 0 18px 42px rgba(27, 38, 49, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.shell {
  width: 100%;
  min-height: 100vh;
  padding: 18px 12px;
  display: grid;
  align-items: center;
}

.panel {
  width: min(100%, 560px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.heading {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.eyebrow,
h1,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.subtle {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.form {
  display: grid;
  gap: 16px;
  padding: 20px 24px 24px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

select:focus,
input[type="text"]:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.upload-box {
  min-height: 138px;
  border: 1.5px dashed #8da9a3;
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 7px;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  background: var(--accent-soft);
  transition: border-color 160ms ease, background 160ms ease;
}

.upload-box:hover {
  border-color: var(--accent);
  background: #f1faf8;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-title {
  font-weight: 900;
  color: var(--accent-dark);
}

.preview-section,
.progress-panel,
.usage-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview-section {
  padding: 12px;
}

.usage-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.usage-row {
  display: grid;
  gap: 7px;
}

.usage-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.usage-text span {
  color: var(--muted);
}

.usage-text strong {
  font-size: 13px;
}

.usage-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf1;
}

.usage-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease, background 180ms ease;
}

.usage-bar.over-limit {
  background: var(--danger);
}

.preview-head,
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 900;
}

.preview-head {
  margin-bottom: 12px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preview-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.preview-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--muted);
  font-size: 13px;
  cursor: zoom-in;
}

.preview-media img,
.preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-media video {
  pointer-events: none;
}

.preview-meta {
  display: grid;
  gap: 2px;
  padding: 6px;
}

.preview-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.preview-meta span {
  color: var(--muted);
  font-size: 11px;
}

.progress-panel {
  padding: 12px;
}

.progress-head {
  margin-bottom: 10px;
}

.progress-head span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf1;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.ghost-button,
.remove-button {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.remove-button {
  width: calc(100% - 12px);
  margin: 0 6px 6px;
}

button:disabled {
  background: #8aa39e;
  cursor: progress;
}

button:not(:disabled):active {
  background: var(--accent-dark);
}

.result {
  margin: 0 24px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  font-size: 14px;
  line-height: 1.6;
  background: var(--blue-soft);
  overflow-wrap: anywhere;
}

.result.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--danger-soft);
}

.preview-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.preview-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
}

.preview-dialog-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 920px);
  max-height: min(88vh, 820px);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.preview-dialog-head {
  min-height: 54px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-dialog-head h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.preview-dialog-body {
  height: min(78vh, 720px);
  display: grid;
  place-items: center;
  padding: 12px;
  background: #101820;
  color: #fff;
  overflow: auto;
}

.preview-dialog-body img,
.preview-dialog-body video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

@media (max-width: 480px) {
  .shell {
    align-items: start;
    padding: 10px;
  }

  .heading,
  .form {
    padding-left: 18px;
    padding-right: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .preview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result {
    margin-left: 18px;
    margin-right: 18px;
  }

  .preview-dialog {
    padding: 10px;
  }

  .preview-dialog-body {
    height: 72vh;
  }
}
