*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #5865f2;
  --primary-hover: #4752c4;
  --border: #e5e7eb;
  --notice-bg: #fef3c7;
  --notice-text: #92400e;
  --status-bg: #f9fafb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
  --max-width: 860px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* Header */
.header {
  margin-bottom: 24px;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.notice {
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 0.8125rem;
  padding: 12px 16px;
  border-radius: 8px;
  line-height: 1.6;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover:not(.active) {
  background: #f9fafb;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.panel[hidden] {
  display: none;
}

/* Form */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.field-row .field {
  margin-bottom: 0;
}

/* Button */
.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  margin-bottom: 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-text {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.8125rem;
  cursor: pointer;
}

.btn-text:hover {
  text-decoration: underline;
}

.upload-area {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 8px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: #f5f7ff;
}

.upload-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.upload-placeholder span {
  display: block;
  font-size: 0.9375rem;
  margin-bottom: 6px;
}

.upload-placeholder small {
  font-size: 0.75rem;
}

.upload-preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.upload-preview:not([hidden]) {
  display: block;
}

.upload-placeholder[hidden],
.upload-replace-hint[hidden],
.upload-add-hint[hidden] {
  display: none;
}

.upload-add-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 8px 12px;
}

.upload-area.has-image,
.upload-area.has-images {
  cursor: pointer;
  background: #fff;
}

.upload-area-multi.has-images {
  min-height: 0;
  padding: 12px;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.upload-grid-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 1;
}

.upload-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-grid-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.upload-grid-remove:hover {
  background: rgba(185, 28, 28, 0.88);
}

.upload-replace-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px;
  font-size: 0.8125rem;
  color: #fff;
  text-align: center;
  background: rgba(17, 24, 39, 0.72);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.upload-area.has-image:hover .upload-replace-hint,
.upload-area.has-image.dragover .upload-replace-hint {
  opacity: 1;
}

/* Status & Progress */
.status {
  background: var(--status-bg);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.status.error {
  color: #b91c1c;
  background: #fef2f2;
}

.status.success {
  color: #166534;
  background: #f0fdf4;
}

.progress-panel {
  margin-top: 12px;
}

.progress-panel[hidden] {
  display: none;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-bar.indeterminate {
  width: 40%;
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Result */
.result {
  margin-top: 20px;
}

.result img,
.result video {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.result a {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
}

.result a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
  .page {
    padding: 20px 14px 36px;
  }

  .title {
    font-size: 1.375rem;
  }

  .card {
    padding: 20px 16px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .field-row .field {
    margin-bottom: 16px;
  }

  .tabs {
    flex-wrap: wrap;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .page {
    padding: 28px 24px 40px;
  }
}
