:root {
  color-scheme: light;
  --bg: #ece7dc;
  --paper: #f6f2e9;
  --ink: #1b1814;
  --muted: #6f675c;
  --line: #c4bbae;
  --accent: #8a3b12;
  --fill: #c46a3a;
  --radius: 1.1rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 44rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.masthead h1,
.panel h2,
.answer h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

.masthead h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lede,
.status,
.empty,
.answer-meta,
.usage {
  color: var(--muted);
  max-width: 65ch;
}

.lede {
  margin: 0.4rem 0 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

label,
.question {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label span {
  font-weight: 600;
  font-size: 0.95rem;
}

select,
textarea,
button,
progress {
  font: inherit;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #fffdf8;
  color: var(--ink);
  padding: 0.5rem 0.65rem;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  min-height: 2.75rem;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf8;
}

button.link {
  align-self: flex-start;
  background: transparent;
  border: 0;
  padding: 0.6rem 0;
  min-height: 2.75rem;
  text-decoration: underline;
}

button:disabled {
  opacity: 0.5;
}

progress {
  width: 100%;
}

.question {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.status,
.empty {
  margin: 0;
}

.answer {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.answer h3 {
  font-size: 1.15rem;
}

.bar {
  display: grid;
  grid-template-columns: minmax(5rem, 8rem) 1fr 3.5rem;
  gap: 0.4rem;
  align-items: center;
}

.meter {
  display: block;
  height: 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fill) 18%, var(--paper));
  position: relative;
  overflow: hidden;
}

.meter::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--p) * 100%);
  background: var(--fill);
}

.answer-meta,
.usage {
  margin: 0;
  font-size: 0.95rem;
}

.log {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  max-width: 75ch;
}

a {
  color: var(--accent);
}

@media (max-width: 40rem) {
  .bar {
    grid-template-columns: 1fr auto;
  }

  .meter {
    grid-column: 1 / -1;
  }
}
