:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #6b6b6b;
  --line: #ececec;
  --badge: #3a3a3a;
  --danger: #c43c2c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(36px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.app {
  width: min(430px, 100%);
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 12px 0 8px;
}

.brand {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.ver {
  margin: 6px 0 28px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.tagline {
  margin: 0 auto 12px;
  max-width: 20em;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.45;
}

.sub {
  margin: 0 auto 28px;
  max-width: 28em;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.cta,
.cta-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.cta:active,
.cta-mini:active {
  opacity: 0.82;
}

.cta[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.45;
}

.sheet {
  margin-top: 40px;
  text-align: center;
}

.sheet img,
.dialog-body img {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  background: #fff;
}

.progress {
  margin: 18px 0 0;
  text-align: left;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--ink);
  transform-origin: left center;
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

#progressPct {
  flex: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
}

.status {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.result {
  margin-top: 22px;
  text-align: left;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--badge);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

textarea {
  display: block;
  width: 100%;
  margin-top: 16px;
  resize: vertical;
  min-height: 200px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.85;
}

textarea:focus {
  outline: none;
}

.text-btn {
  margin-top: 8px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.text-btn:active {
  color: var(--ink);
}

.recent {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.recent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.recent-head .text-btn {
  margin: 0;
}

.recent-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.recent-list li {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.recent-list .forget {
  margin-top: 0;
  font-size: 0.78rem;
}

.recent-list img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  background: #f5f5f5;
}

.meta {
  min-width: 0;
}

.meta .prompt-snip {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta .time {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.meta .err {
  color: var(--danger);
}

.empty {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

dialog {
  width: min(430px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: #fff;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(255, 255, 255, 0.72);
}

.dialog-body {
  padding: 18px 16px 16px;
}

.dialog-body .badge {
  margin-top: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.dialog-actions .text-btn {
  margin: 0;
}

.cta-mini {
  min-height: 36px;
  padding: 0 16px;
  font-size: 0.85rem;
}
