@font-face {
  font-family: "Nunito";
  src: url("/static/fonts/Nunito-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("/static/fonts/Nunito-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
:root {
  --bg: #faf6ef;
  --ink: #2b2a28;
  --ink-shade: #1a1918;
  --mint: #cfe8dd;
  --peach: #f7d9c4;
  --sky: #cfe0f5;
  --butter: #f8ecc2;
  --card: #fffdf9;
  --line: #e4ddd0;
  --skeleton: #efe8da;
  --ok: #3f8f6b;
  --danger: #a03030;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(43, 42, 40, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}
img, svg { display: block; }
.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { opacity: 0.7; font-size: 13px; }
.center { text-align: center; }
a { color: var(--ink); }

/* Header */
header { display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; min-width: 0; }
header .brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; flex: none; min-width: 0; }
header .brand img { width: 36px; height: 36px; }
header .brand b { font-size: 20px; font-weight: 700; }
header nav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
@media (max-width: 460px) {
  header .brand b { display: none; }
}

/* Controls */
button, .button {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  height: 44px;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
button.primary, .button.primary {
  background: var(--ink);
  color: var(--butter);
  border-color: var(--ink);
  box-shadow: 0 5px 0 var(--ink-shade);
}
button.primary:active, .button.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink-shade); }
button.primary.big, .button.primary.big { height: 56px; font-size: 18px; width: 100%; box-shadow: 0 6px 0 var(--ink-shade); }
button.outline, .button.outline { border: 1.5px solid var(--ink); }
button.strong, .button.strong { border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
button.strong:active, .button.strong:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
button.link { background: none; border: 0; padding: 0; height: auto; font-weight: 700; text-decoration: underline; }
button.icon { width: 40px; height: 40px; padding: 0; border-radius: 999px; }
button.chip { height: 40px; background: var(--butter); font-size: 14px; }
button:disabled { opacity: 0.6; cursor: wait; }

/* Language select and menus */
.lang { position: relative; display: flex; align-items: center; height: 40px; margin: 0; }
.lang > svg { position: absolute; left: 11px; pointer-events: none; }
.lang .caret { position: absolute; right: 10px; left: auto; }
.lang select {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  height: 40px;
  padding: 0 28px 0 32px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  max-width: 132px;
}
.lang noscript button { margin-left: 4px; }
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; height: 40px; }
details.menu summary::-webkit-details-marker { display: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.avatar.initial { display: inline-flex; align-items: center; justify-content: center; background: var(--sky); font-weight: 700; }
.menu-panel {
  position: absolute; right: 0; top: 46px; z-index: 5;
  min-width: 220px; max-width: 80vw;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(43, 42, 40, 0.15);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 14px;
}
.menu-who { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.menu-who b, .menu-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel a, .menu-panel button.link { text-align: left; align-self: flex-start; }

/* Home */
.hero { margin: 10px 0 14px; }
.hero h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.15; }
.hero .lead { margin: 0; font-size: 15px; opacity: 0.8; }
.compose { display: flex; flex-direction: column; gap: 10px; }
textarea {
  width: 100%;
  min-height: 150px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
}
.compose-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compose-tools output { margin-left: auto; }
.autolang { margin: 0; display: flex; align-items: flex-start; gap: 6px; }
.autolang svg { flex: none; margin-top: 3px; }
fieldset { border: 0; padding: 0; margin: 6px 0 0; }
legend { font-weight: 700; font-size: 14px; padding: 0 0 8px; }
.style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.styles input { position: absolute; opacity: 0; width: 0; height: 0; }
.style-card {
  height: 52px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--card);
  display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; cursor: pointer;
}
.styles input:checked + .style-card { border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.styles input:focus-visible + .style-card { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatches { display: flex; gap: 4px; }
.swatches i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.sw-peach { background: var(--peach); } .sw-mint { background: var(--mint); } .sw-sky { background: var(--sky); }
.sw-line { border: 2px solid var(--ink); }
.cta { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cta .muted { margin: 0; }
.notice { margin: 12px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--peach); font-size: 15px; }

/* Progress and result */
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.progress {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 14px;
}
.progress img { width: 56px; height: 56px; flex: none; }
.progress .text { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.progress .title { font-size: 17px; font-weight: 700; }
.progress .status { margin: 0; font-size: 14px; opacity: 0.85; font-weight: 400; }
.progress .track { height: 10px; border-radius: 999px; background: #eee6d8; overflow: hidden; }
.progress .fill { height: 10px; border-radius: 999px; background: var(--ink); width: 4%; transition: width 0.6s ease; }
.progress.running img { animation: bob 1.3s ease-in-out infinite; }
.progress.running .status { animation: pulse 1.2s ease-in-out infinite; }
.progress.running .fill {
  background-image: linear-gradient(135deg, rgba(255,255,255,0.25) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.25) 50%, rgba(255,255,255,0.25) 75%, transparent 75%);
  background-size: 28px 28px; animation: stripes 0.6s linear infinite;
}
.progress.done .fill { background: var(--ok); width: 100%; }
.progress.failed .fill { background: var(--danger); }
.done-mark { width: 28px; height: 28px; border-radius: 999px; background: var(--mint); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.titlebar { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.titlebar h1 { margin: 0; flex: 1; min-width: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--mint); white-space: nowrap; }
.sheet-grid {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px;
  display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .sheet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .sheet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.card .frame { position: relative; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: var(--skeleton); }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card.fresh img { animation: pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.card .frame.pending {
  background: linear-gradient(90deg, #efe8da 25%, #f8f3ea 50%, #efe8da 75%);
  background-size: 400px 100%; animation: shimmer 1.2s linear infinite;
}
.card .frame.pending svg, .card .frame.failed svg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: 0.7; }
.card .frame.failed { background: #fdeceb; }
.card .caption { font-size: 13px; line-height: 1.3; }
.card.pending .caption { opacity: 0.45; }
.card .redo {
  position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; padding: 0; border: 0;
  background: rgba(255, 253, 249, 0.95); box-shadow: 0 2px 8px rgba(43, 42, 40, 0.25); border-radius: 999px;
}
.card .redo.htmx-request svg { animation: spin 1s linear infinite; }
.result-actions { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.result-actions .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.result-actions .row .button, .result-actions .row button { height: 56px; font-size: 16px; }
.upsell { background: var(--butter); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.upsell .head { display: flex; gap: 12px; align-items: flex-start; }
.upsell .head svg { flex: none; margin-top: 2px; }
.upsell b { font-size: 16px; }
.upsell ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.upsell .google { height: 50px; }
.again { display: flex; justify-content: center; margin: 8px 0 20px; }

/* Projects */
.projects { list-style: none; padding: 0; margin: 0; }
.projects li {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.projects li > a { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projects .meta { font-size: 13px; opacity: 0.7; white-space: nowrap; }
.projects form { margin: 0; }
.projects form button { height: 40px; padding: 0 14px; font-size: 14px; }

/* Dialogs */
dialog { border: 0; border-radius: 22px; padding: 20px; max-width: 420px; width: calc(100% - 32px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(43, 42, 40, 0.55); }
dialog input { font: inherit; font-size: 16px; height: 48px; padding: 0 14px; width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog form label { font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
dialog h2 { margin: 0; font-size: 20px; }
dialog .close { position: absolute; right: 14px; top: 14px; }
.sheet-grip { width: 44px; height: 5px; border-radius: 999px; background: var(--line); margin: -6px auto 12px; }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; padding-right: 44px; margin-bottom: 16px; }
.sheet-head img { width: 44px; height: 44px; flex: none; }
.sheet-head p { margin: 2px 0 0; font-size: 14px; }
button.google { background: #fff; width: 100%; height: 56px; font-size: 17px; border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
button.google:active { transform: translateY(2px); box-shadow: 0 3px 0 var(--ink); }
.signin-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
details.signin-email { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
details.signin-email summary { cursor: pointer; font-size: 14px; font-weight: 700; opacity: 0.8; display: flex; align-items: center; gap: 8px; min-height: 44px; list-style: none; }
details.signin-email summary::-webkit-details-marker { display: none; }
details.signin-email form { padding-top: 6px; }
details.signin-email button { background: var(--butter); }
@media (max-width: 600px) {
  dialog.sheet {
    position: fixed; margin: 0; left: 0; right: 0; bottom: 0; top: auto; max-width: none; width: 100%;
    border-radius: 24px 24px 0 0; padding: 12px 20px 28px; max-height: 92vh; overflow: auto;
  }
}

/* Intro */
dialog.intro { max-width: 400px; padding: 22px 20px 20px; }
.intro-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding-right: 44px; }
.intro-head img { width: 30px; height: 30px; }
.intro-step { display: flex; flex-direction: column; gap: 12px; animation: fadeup 0.35s ease both; }
.intro-step[hidden] { display: none; }
.intro-step h2 { font-size: 24px; margin: 4px 0 0; }
.intro-step p { margin: 0; font-size: 15px; opacity: 0.8; }
.intro-art {
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; min-height: 150px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.intro-art.typing { font-size: 17px; line-height: 1.7; }
/* Each line reveals from the left; the span's natural width is the text, so
   the caret (its right border) stops exactly where the words end. */
.intro-art .line { height: 1.7em; }
/* The caret is the span's right border: transparent by default, ink only
   while that line types (the caret animation runs exactly as long as typing),
   blinking on the last line once its text is in. */
.intro-art .line span { display: inline-block; vertical-align: top; overflow: hidden; white-space: nowrap; max-width: 0; border-right: 2px solid transparent; animation: typing 1.1s steps(22) forwards, caret 1.1s step-end; }
.intro-art .line:nth-child(2) span { animation-delay: 0.9s, 0.9s; }
.intro-art .line:nth-child(3) span { animation-delay: 1.8s, 1.8s; }
.intro-art .line:nth-child(4) span { animation: typing 1.1s 2.7s steps(22) forwards, blink 0.8s 2.7s step-end infinite; }
.intro-art.waiting { align-items: center; gap: 14px; }
.intro-art.waiting img { width: 64px; height: 64px; animation: bob 1.4s ease-in-out infinite; }
.intro-art .bar { width: 200px; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; position: relative; }
.intro-art .bar i { display: block; width: 55%; height: 10px; border-radius: 999px; background: var(--ink); }
.intro-art .bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; left: -40%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent); animation: sweep 1.6s linear infinite; }
.intro-art.sheet-art { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.intro-art.sheet-art i { display: block; aspect-ratio: 1; border-radius: 10px; background: var(--peach); animation: pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.intro-art.sheet-art i:nth-child(2) { background: var(--mint); animation-delay: 0.25s; }
.intro-art.sheet-art i:nth-child(3) { background: var(--sky); animation-delay: 0.5s; }
.intro-art.sheet-art i:nth-child(4) { background: var(--butter); animation-delay: 0.75s; }
.intro-foot { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.intro-foot .primary { margin-left: auto; height: 50px; padding: 0 22px; }
.dots { display: flex; gap: 6px; align-items: center; }
.dots i { display: block; width: 8px; height: 8px; border-radius: 999px; background: var(--line); transition: width 0.2s; cursor: pointer; padding: 0; }
.dots i::after { content: ""; display: block; width: 100%; height: 100%; }
.dots i.on { width: 22px; background: var(--ink); }

footer { margin: 40px 0 24px; font-size: 13px; opacity: 0.7; display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }
@keyframes shimmer { from { background-position: -200px 0; } to { background-position: 200px 0; } }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 70% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes typing { to { max-width: 100%; } }
@keyframes caret { 0%, 100% { border-color: var(--ink); } }
@keyframes blink { 0%, 100% { border-color: var(--ink); } 50% { border-color: transparent; } }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sweep { to { left: 110%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .intro-art .line span { max-width: 100%; border-right: 0; }
}
