:root {
  color-scheme: light;
  --ink: #16201c;
  --muted: #64716b;
  --line: #dde5df;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --accent: #0f8b6d;
  --accent-strong: #0a6b54;
  --rose: #bf4a5a;
  --shadow: 0 18px 48px rgba(33, 48, 40, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  background: linear-gradient(180deg, #f2f8f4 0%, var(--paper) 34%, #f7f3ec 100%);
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.08;
  font-weight: 800;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.quotaGroup {
  display: grid;
  grid-template-columns: repeat(2, 58px);
  gap: 8px;
  flex: 0 0 auto;
}

.uses {
  display: grid;
  place-items: center;
  width: 58px;
  height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.uses span {
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}

.uses small {
  color: var(--muted);
  font-size: 12px;
}

.workspace,
.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.workspace {
  padding: 14px;
}

.field,
.controls label {
  display: grid;
  gap: 8px;
}

.field span,
.controls span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 13px;
  line-height: 1.55;
}

select {
  min-height: 46px;
  padding: 0 12px;
}

textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 109, 0.14);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin-top: 14px;
}

.progressPanel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #d7e6df;
  border-radius: 8px;
  background: #f6fbf8;
}

.progressCopy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.progressCopy strong {
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.progressTrack {
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce9e2;
}

.progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d29b45);
  transition: width 480ms ease;
}

.progressPanel p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  border: 1px solid #b7d8cc;
  background: #eef8f4;
  color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.result,
.historySection {
  margin-top: 16px;
  padding: 12px;
}

.resultHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  font-size: 17px;
}

.result a {
  color: var(--rose);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.result img {
  display: block;
  width: 100%;
  min-height: 240px;
  border-radius: 8px;
  background: #eef1ed;
  object-fit: contain;
}

.historySection {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.historySection span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.historyList {
  display: grid;
  gap: 12px;
}

.historyItem {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.historyItem img {
  width: 92px;
  height: 92px;
  border-radius: 8px;
  background: #eef1ed;
  object-fit: cover;
}

.historyMeta {
  min-width: 0;
}

.historyMeta a {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.historyMeta p {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.historyMeta small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

details {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

details p {
  margin-top: 8px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 488px;
  margin: 0 auto;
  padding: 13px 14px;
  border-radius: 8px;
  background: #16201c;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 380px) {
  .actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 23px;
  }

  .historyItem {
    grid-template-columns: 78px 1fr;
  }

  .historyItem img {
    width: 78px;
    height: 78px;
  }
}
