/* ========== Reset & base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0b0d12;
  --bg-elev: #11141c;
  --bg-card: #161a24;
  --border: #232836;
  --border-strong: #2e3445;
  --text: #e6e9f2;
  --text-dim: #98a0b3;
  --text-muted: #6b7180;
  --accent: #6366f1;
  --accent-hover: #7c7ff5;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.18);
  --maxw: 1100px;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ========== Layout ========== */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}

.nav a:hover {
  color: var(--text);
  background: var(--bg-card);
}

.nav a.active {
  color: var(--text);
  background: var(--accent-soft);
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ========== Hero ========== */
.hero {
  padding: 64px 0 32px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero p {
  margin: 0 auto;
  max-width: 600px;
  color: var(--text-dim);
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #a5a7ff;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

/* ========== Cards / Tool grid ========== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.tool-card {
  display: block;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--bg-elev);
}

.tool-card .ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 20px;
}

.tool-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.tool-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ========== Page header ========== */
.page-head {
  padding: 40px 0 20px;
}

.page-head h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.page-head p {
  margin: 0;
  color: var(--text-dim);
}

/* ========== Drop zone ========== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-elev);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
}

.dropzone > * {
  pointer-events: none;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone .hint {
  color: var(--text-dim);
  font-size: 14px;
}

/* Robustly hide file input — defensive against any rule overriding display. */
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ========== Panel ========== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel + .panel {
  margin-top: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

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

/* ========== Forms ========== */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row input[type="range"] {
  flex: 1;
}

.range-row .val {
  min-width: 48px;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #c8c9ff;
}

/* ========== Preview area ========== */
.preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #0e1118 25%, transparent 25%),
    linear-gradient(-45deg, #0e1118 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0e1118 75%),
    linear-gradient(-45deg, transparent 75%, #0e1118 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #131722;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview img,
.preview canvas {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

/* keep cropper area working */
.preview.cropper-host {
  display: block;
  min-height: 480px;
}

.preview.cropper-host img {
  max-width: 100%;
  max-height: 480px;
  display: block;
}

/* Cropper.js theme overrides: make crop selection clearly visible
   on the dark canvas. Default is a thin solid blue outline that
   easily blends with the background. */
.cropper-view-box {
  outline: 2px dashed var(--accent);
  outline-color: rgba(99, 102, 241, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.cropper-modal {
  background-color: #000;
  opacity: 0.6;
}

.cropper-dashed {
  border-color: rgba(255, 255, 255, 0.85);
  opacity: 0.6;
}

.cropper-line {
  background-color: var(--accent);
  opacity: 0.85;
}

.cropper-point {
  background-color: var(--accent);
  opacity: 1;
  width: 8px;
  height: 8px;
}

.cropper-point.point-se {
  width: 14px;
  height: 14px;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.compare .col {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.compare h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.compare h3 .size {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ========== File list / meta ========== */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 12px;
}

.meta strong {
  color: var(--text);
  font-weight: 600;
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

.alert-info {
  background: var(--accent-soft);
  color: #b9bbff;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.alert-warn {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ========== Spinner ========== */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* x-cloak: prevent flash before Alpine inits */
[x-cloak] {
  display: none !important;
}
