/* ── Variables ── */
:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --border: rgba(255,255,255,0.08);
  --accent: #00e5c8;
  --accent2: #6c6cff;
  --text: #f0f0f8;
  --text-muted: #6b6b8a;
  --danger: #ff4d6d;
  --radius: 16px;
  --radius-sm: 8px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'Noto Sans TC', sans-serif;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background grid ── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,229,200,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,200,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}
.bg-grid::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(108,108,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Header ── */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 56px 24px 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo-icon {
  font-size: 32px;
  color: var(--accent);
  line-height: 1;
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.logo-text {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Main ── */
main {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ── Steps ── */
.step {
  position: relative;
  margin-bottom: 40px;
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step.hidden { display: none; }

.step-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.step-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(0,229,200,0.06) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--accent);
  outline: none;
}

.drop-zone:hover::before,
.drop-zone:focus::before,
.drop-zone.drag-over::before {
  opacity: 1;
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-inner {
  padding: 64px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.drop-icon {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }

.drop-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.drop-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Options ── */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  position: relative;
}

.option-card input[type="checkbox"] { display: none; }

.option-card:hover {
  border-color: rgba(0,229,200,0.3);
  background: var(--surface2);
}

.option-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(0,229,200,0.05);
}

.option-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition);
}

.option-card:has(input:checked) .option-icon { color: var(--text); }

.option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.option-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font-display);
}

.option-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.option-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  color: transparent;
}

.option-card:has(input:checked) .option-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* ── Circle Size Control ── */
.circle-size-control {
  width: 100%;
  max-width: 480px;
  padding: 16px 20px 12px;
  background: var(--surface2);
  border: 1.5px solid rgba(0,229,200,0.2);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  animation: fadeUp 0.3s ease both;
}

.size-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.size-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.size-value-badge {
  background: rgba(0,229,200,0.12);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  padding: 3px 14px;
  border-radius: 100px;
  border: 1px solid rgba(0,229,200,0.25);
  min-width: 72px;
  text-align: center;
  transition: var(--transition);
}

.slider-track-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-endpoint {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-display);
  min-width: 36px;
}
.slider-endpoint:last-child { text-align: right; }

/* Custom range slider */
.circle-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 100px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) calc((var(--val, 58) - 42) / 30 * 100%),
    rgba(255,255,255,0.1) calc((var(--val, 58) - 42) / 30 * 100%),
    rgba(255,255,255,0.1) 100%
  );
  outline: none;
  cursor: pointer;
  transition: background 0.1s;
}

.circle-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}

.circle-slider::-webkit-slider-thumb:hover,
.circle-slider:active::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px rgba(0,229,200,0.25);
  transform: scale(1.15);
}

.circle-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
  cursor: pointer;
}

.size-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
}

/* ── Preview canvas wrapper must be position:relative ── */
.preview-canvas-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

/* Remove old circle overlay */
.preview-circle-overlay { display: none !important; }
.preview-area {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.preview-canvas-wrapper {
  position: relative;
  display: inline-block;
}

#previewCanvas {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  display: block;
}

.preview-circle-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: opacity var(--transition);
  opacity: 0;
}

.preview-circle-overlay.visible {
  opacity: 1;
  background: radial-gradient(
    circle at center,
    transparent 49.5%,
    rgba(0,0,0,0.75) 50%
  );
}

.preview-info {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Process Button ── */
.action-area {
  display: flex;
  justify-content: center;
}

.btn-process {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 48px;
  background: var(--accent);
  color: #000;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.01em;
}

.btn-process:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,229,200,0.3);
}

.btn-process:active { transform: translateY(0); }

.btn-icon {
  font-size: 18px;
  transition: transform var(--transition);
}

.btn-process:hover .btn-icon {
  transform: translateX(4px);
}

/* ── Result ── */
.result-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.result-preview {
  background: repeating-conic-gradient(#1e1e2e 0% 25%, #161622 0% 50%) 0 0 / 20px 20px;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  width: 100%;
  max-width: 480px;
}

.result-preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 4px;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--accent);
  color: #000;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-download svg { width: 18px; height: 18px; }

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,229,200,0.3);
}

.btn-reset {
  padding: 14px 32px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Status Log ── */
.status-log {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'Courier New', monospace;
}

.status-log .log-line {
  padding: 4px 12px;
  background: var(--surface);
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}

.status-log .log-line.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden { display: none; }

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-muted);
}

/* ── Footer ── */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .drop-inner { padding: 40px 16px; }
  .btn-process { padding: 14px 32px; font-size: 15px; }
  header { padding: 40px 16px 24px; }
}
