:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.brand-badge {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.privacy-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* Main layout */
.main-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 20px;
  padding-top: 24px;
  padding-bottom: 40px;
  flex: 1;
  align-items: start;
}

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

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

/* Drop Zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background: #f8fafc;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.drop-zone h2 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.drop-zone p {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Toolbar */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.count-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-hint {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.85rem;
  color: #92400e;
}

.empty-hint code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Image List */
.image-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}

.image-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, background-color 0.15s, opacity 0.15s;
}

.image-item.dragging {
  opacity: 0.45;
  border-style: dashed;
}

.image-item.drag-target {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drag-handle {
  color: #94a3b8;
  cursor: grab;
  font-size: 1rem;
  user-select: none;
  padding: 4px 2px;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.thumb-wrap {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}

.thumb-wrap:hover {
  border-color: var(--primary);
}

.thumb-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.item-meta {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: #f1f5f9;
}

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

.icon-btn.danger:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

/* Settings */
.settings-card h2 {
  font-size: 1.05rem;
  margin-bottom: 16px;
}

.setting-group {
  margin-bottom: 16px;
}

.group-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.input-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
}

.input-control:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.checkbox-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.86rem;
  cursor: pointer;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.checkbox-row input {
  margin-top: 3px;
  accent-color: var(--primary);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-ghost {
  background: #f1f5f9;
  color: var(--text);
}

.btn-ghost:hover {
  background: #e2e8f0;
}

.btn-danger-ghost {
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: #fee2e2;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 13px 16px;
  font-size: 0.96rem;
}

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

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

/* Progress */
.progress-wrap {
  margin-bottom: 14px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

/* Info / FAQ section */
.info-section {
  padding-bottom: 24px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

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

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.info-card h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.info-card p {
  font-size: 0.83rem;
  color: var(--muted);
}

.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--muted);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 11px 16px;
  font-size: 0.92rem;
}

.btn-secondary:hover:not(:disabled) {
  background: #dbeafe;
}

.btn-secondary:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: var(--border);
  cursor: not-allowed;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Support / Monetization */
.support-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.support-box p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.support-box.highlight {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px;
}

.btn-coffee {
  display: inline-block;
  text-decoration: none;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 10px 14px;
  font-size: 0.86rem;
}

.btn-coffee:hover {
  background: #fde68a;
}

.ad-slot-wrap {
  padding-bottom: 20px;
}

.ad-slot-inner {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Preview Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
}

.modal-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.preview-stage {
  flex: 1;
  background: #0f172a;
  padding: 20px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 300px;
}

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

.preview-page-card {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.preview-page-label {
  align-self: flex-start;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.preview-page-card img {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  background: #fff;
  border-radius: 4px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.preview-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.hidden {
  display: none !important;
}
