:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --ok: #34d399;
  --warn: #fbbf24;
  --border: #334155;
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

.spec-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.spec-card {
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: inherit;
  cursor: pointer;
}

.spec-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.spec-card strong {
  display: block;
  margin-bottom: 4px;
}

.spec-card span {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

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

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

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

.btn.ghost {
  background: transparent;
}

.btn.large {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
}

.btn-row {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

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

.toolbar-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
}

.camera-stage video,
.camera-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-stage video {
  transform: scaleX(-1);
}

.status-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.status-pill.ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}

.status-pill.warn {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warn);
}

.hints {
  min-height: 2.6em;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 14px;
}

.preview-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
}

.preview-card img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
}

.progress-wrap {
  margin-bottom: 16px;
}

.progress-bar {
  height: 8px;
  background: var(--panel);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.2s ease;
}

#process-progress-text {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 0;
}

.crop-stage {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  margin-bottom: 12px;
}

#crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: grab;
}

.slider-label {
  display: block;
  margin: 10px 0;
  font-size: 0.92rem;
}

.slider-label input {
  width: 100%;
  margin-top: 6px;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.footnote {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.advanced-shadow {
  margin-top: 12px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.advanced-shadow summary {
  cursor: pointer;
  user-select: none;
}

.tip-card {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(37, 99, 235, 0.12));
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.tip-card strong {
  display: block;
  color: var(--ok);
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.tip-card p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.55;
}

.tip-inline {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--ok);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
}

.ad-slot {
  min-height: 0;
  margin-top: 18px;
}

.ad-slot.has-ad {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  overflow: hidden;
}

.ad-slot .ad-placeholder {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 12px;
}

select {
  width: 100%;
  margin: 10px 0 14px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

@media (min-width: 640px) {
  .btn-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

.export-actions {
  grid-template-columns: 1fr;
}

.export-actions .btn.large {
  width: 100%;
}

@media (min-width: 640px) {
  .export-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .export-actions #btn-share-save {
    grid-column: 1 / -1;
  }
}

#save-helper-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  padding: 24px 16px;
  align-items: center;
  justify-content: center;
}

#save-helper-overlay.open {
  display: flex;
}

.save-helper-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.save-helper-title {
  font-weight: 700;
  margin: 0 0 12px;
}

.save-helper-card img {
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 12px;
  -webkit-touch-callout: default;
  user-select: none;
}

.save-helper-note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 14px;
}
