:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #1e1b4b;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --accent: #22d3ee;
  --ok: #16a34a;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(30, 27, 75, 0.08);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(16px, 4vw, 40px);
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 4px 18px rgba(79, 70, 229, 0.25);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.brand-text h1 { font-size: 18px; margin: 0; line-height: 1.2; }
.brand-text p { font-size: 12px; margin: 2px 0 0; opacity: 0.85; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-off { background: rgba(255,255,255,0.18); color: #fde68a; }
.badge-on  { background: rgba(255,255,255,0.22); color: #bbf7d0; }

/* Layout */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 24px) 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 28px 18px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--brand); background: #fafaff; }
.dropzone.dragover { border-color: var(--accent); background: #f0fbff; }
.dz-icon { font-size: 42px; }
.dz-title { font-size: 15px; font-weight: 600; margin: 8px 0 4px; }
.dz-sub { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 14px; }
.dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Preview */
.preview-wrap { position: relative; }
.preview-wrap img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;
  background: #0f172a;
  display: block;
}
.preview-remove {
  position: absolute;
  top: 10px; right: 10px;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(15,23,42,0.7); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.preview-remove:hover { background: rgba(220,38,38,0.85); }

/* Controls */
.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field-actions { margin-left: auto; }

.seg { display: inline-flex; background: #eef0f7; border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 18px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); transition: all .15s;
}
.seg-btn.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }

/* Buttons */
.btn {
  border: none; cursor: pointer; border-radius: 11px;
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  transition: transform .08s, box-shadow .2s, background .2s, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,0.35); }
.btn-primary:not(:disabled):hover { box-shadow: 0 6px 20px rgba(79,70,229,0.45); }
.btn-ghost { background: #eef0f7; color: var(--ink); }
.btn-ghost:hover { background: #e3e6f3; }

/* Progress */
.progress-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; font-weight: 600; }
.progress-track { height: 10px; background: #eef0f7; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 999px; transition: width .25s ease; }

/* Result */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.result-head h2 { font-size: 16px; margin: 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-text {
  width: 100%; min-height: 220px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-size: 15px; line-height: 1.7;
  font-family: "SF Mono", ui-monospace, "PingFang SC", Menlo, Consolas, monospace;
  color: var(--ink); background: #fcfcff;
}
.result-text:focus { outline: 2px solid var(--brand); border-color: transparent; }
.result-meta { font-size: 12px; color: var(--ink-soft); margin: 8px 2px 0; }

.privacy-note {
  font-size: 12.5px; color: var(--ink-soft); text-align: center;
  background: #eef6ff; border: 1px solid #d6e8ff; border-radius: 12px;
  padding: 12px 14px; margin: 0;
}
.privacy-note strong { color: var(--brand); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1e1b4b; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.25); z-index: 50;
  opacity: 1; transition: opacity .3s, transform .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(10px); }

.hidden { display: none !important; }

@media (max-width: 560px) {
  .controls { flex-direction: column; align-items: stretch; }
  .field-actions { margin-left: 0; }
  .btn-primary { width: 100%; }
}
