:root {
  color-scheme: light;
  --bg: #eef4f1;
  --panel: #ffffff;
  --ink: #17324d;
  --muted: #607184;
  --teal: #1a7f76;
  --coral: #e56b5d;
  --line: #d6e3df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(23, 50, 77, 0.08);
}

.controls {
  padding: 20px;
}

.title-row,
.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  margin-top: 8px;
}

code {
  color: var(--teal);
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 250px;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
}

.quota {
  border-radius: 8px;
  padding: 10px;
  background: #eef8f6;
  color: var(--teal);
  font-size: 12px;
  font-weight: 750;
  text-align: left;
  width: 100%;
}

.quota-summary {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
}

.quota-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid rgba(26, 127, 118, 0.18);
}

.quota-row strong,
.quota-row span,
.quota-row small {
  display: block;
}

.quota-row strong {
  color: var(--ink);
  font-size: 13px;
}

.quota-row span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 650;
}

.quota-meta {
  text-align: right;
}

.quota-meta b {
  display: block;
  color: var(--teal);
  font-size: 18px;
  line-height: 1;
}

.quota-meta small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.quota-empty {
  color: var(--muted);
}

.status.ready {
  color: var(--teal);
  border-color: rgba(26, 127, 118, 0.4);
}

.status.error {
  color: var(--coral);
  border-color: rgba(229, 107, 93, 0.4);
}

label {
  display: block;
  margin-top: 18px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

textarea,
select,
input {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 300px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

select,
input {
  height: 42px;
  padding: 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.check-row span {
  font-weight: 650;
}

.help-text {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
}

details {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

summary {
  cursor: pointer;
  padding: 12px;
  font-weight: 750;
}

details pre {
  min-height: 0;
  margin: 0 12px 12px;
}

.usage-doc .help-text {
  margin: 0 12px 12px;
}

.code-block {
  max-height: 360px;
  border: 1px solid rgba(217, 244, 237, 0.14);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
}

.mini-label {
  margin: 10px 12px 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 12px 6px;
}

.mini-label-row .mini-label {
  margin: 0;
}

.copy-button {
  width: auto;
  height: 32px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--teal);
  font-size: 12px;
  white-space: nowrap;
}

.copy-button.copied {
  border-color: rgba(26, 127, 118, 0.45);
  background: #e8f6f2;
}

button {
  width: 100%;
  height: 46px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.secondary-button {
  width: auto;
  height: 34px;
  margin-top: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--teal);
  font-size: 13px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

pre {
  min-height: 90px;
  margin: 18px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: #10263c;
  color: #d9f4ed;
  white-space: pre-wrap;
  font-size: 12px;
}

.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
}

.preview-header {
  align-items: center;
  margin-bottom: 14px;
}

.preview-header a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 700;
}

.image-box {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 420px;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.image-box img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-box.has-image img {
  display: block;
}

.image-box.has-image #empty {
  display: none;
}

.history-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.history-header,
.day-header,
.history-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-dates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.date-button {
  height: auto;
  margin-top: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--ink);
  text-align: left;
}

.date-button strong,
.date-button span,
.day-header strong,
.day-header span,
.history-card-head strong,
.history-card-head span {
  display: block;
}

.date-button span,
.day-header span,
.history-card-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-details {
  margin-top: 14px;
}

.day-header {
  margin-bottom: 12px;
}

.history-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.history-card p {
  font-size: 13px;
  line-height: 1.45;
}

.source-badge {
  display: inline-block;
  margin: 0 0 0 6px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef8f6;
  color: var(--teal);
  font-size: 10px;
  font-weight: 750;
  vertical-align: 2px;
}

.history-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.history-images a {
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.history-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-empty {
  margin-top: 12px;
  font-size: 13px;
}

.history-error {
  min-height: 0;
  margin-top: 10px;
  background: #3c1620;
  color: #ffe6e1;
}

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

  .title-row {
    flex-direction: column;
  }

  .status-stack {
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }
}
