:root {
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --primary: #0b3d91;
  --primary-press: #082c6b;
  --secondary: #1a73e8;
  --danger: #b91c1c;
  --border: #cbd5e1;
  --ok: #166534;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  --tap: 56px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  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;
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  background: var(--primary);
  color: #fff;
  padding: 1.1rem 1.25rem 1.25rem;
  text-align: center;
}
.app-header h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
}
.subtitle {
  margin: 0.35rem 0 0;
  opacity: 0.9;
  font-size: 0.95rem;
}

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0.85rem 1.15rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):active { background: var(--primary-press); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-block { width: 100%; margin-top: 0.85rem; }

.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-wrap {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
}
.preview-wrap img {
  display: block;
  width: 100%;
  max-height: 42vh;
  object-fit: contain;
  background: #0f172a;
}
.hidden { display: none !important; }

.progress-wrap { margin-top: 0.9rem; }
.progress-bar {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1a73e8, #0b3d91);
  transition: width 0.2s ease;
}
.progress-text {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.45rem;
}
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 1.05rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 180px;
  font-family: inherit;
}
textarea:focus {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}

.status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  color: var(--ok);
  font-size: 0.95rem;
}
.status.error { color: var(--danger); }

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.5rem 1rem 1.5rem;
}

.update-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #f59e0b;
  color: #1c1917;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  -webkit-tap-highlight-color: transparent;
}
.update-banner:focus {
  outline: 3px solid #fff;
  outline-offset: -3px;
}
.update-banner:active {
  filter: brightness(0.95);
}

.version-line {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  opacity: 0.85;
}
