:root {
  color: #1d2521;
  background: #f4f6f3;
  font-family: Arial, "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.64; }

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, calc((100vw - 880px) / 2));
  background: #ffffff;
  border-bottom: 1px solid #dfe5df;
}

.brand { color: #c14a00; font-size: 19px; font-weight: 700; }
.service-state, .form-message, .section-heading span, .input-status { color: #5e6e65; font-size: 13px; line-height: 1.5; }
main { max-width: 880px; margin: 20px auto 52px; padding: 0 16px; }

.access-panel, .query-form { padding: 20px 0; border-bottom: 1px solid #dfe5df; }
.access-form { max-width: 400px; }
label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.access-row, .query-actions { display: flex; align-items: center; gap: 10px; }
input[type="password"], textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #b7c4ba;
  border-radius: 4px;
  color: #1d2521;
  background: #ffffff;
  padding: 11px 12px;
}

textarea { display: block; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: #c14a00; outline: 2px solid #ffe1c9; }
button {
  flex: none;
  border: 1px solid #c14a00;
  border-radius: 4px;
  color: #ffffff;
  background: #c14a00;
  padding: 10px 15px;
  font-weight: 700;
  white-space: nowrap;
}

.field-heading { display: flex; align-items: baseline; justify-content: space-between; }
.text-button { border: 0; padding: 0; color: #075c8c; background: transparent; font-size: 13px; font-weight: 400; }
.input-status { min-height: 20px; margin: 7px 0 0; }
.query-actions { margin-top: 7px; }
.file-button {
  flex: none;
  margin: 0;
  border: 1px solid #b7c4ba;
  border-radius: 4px;
  padding: 9px 12px;
  color: #31433a;
  background: #ffffff;
  cursor: pointer;
  white-space: nowrap;
}
#extra-images { position: absolute; width: 1px; height: 1px; opacity: 0; }
#file-summary { overflow: hidden; flex: 1; color: #5e6e65; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.image-preview { display: flex; gap: 8px; margin-top: 10px; }
.image-preview img { width: 52px; height: 52px; border: 1px solid #d5ddd7; border-radius: 4px; object-fit: cover; }
.form-message { min-height: 20px; margin: 10px 0 0; }

#results { padding-top: 18px; }
.source { display: flex; gap: 14px; align-items: flex-start; padding: 0 0 16px; }
.source img { width: 88px; height: 88px; flex: none; border-radius: 4px; object-fit: cover; background: #e9eeea; }
.source-copy { min-width: 0; }
h1, h2, p { margin: 0; }
.source-label, .section-label { color: #68766e; font-size: 12px; line-height: 1.4; }
h1 { margin-top: 3px; font-size: 17px; line-height: 1.45; }
.source-details { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-top: 7px; }
#source-meta { color: #5e6e65; font-size: 13px; }
#source-price { color: #b63d00; font-size: 18px; }

.task-state { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 10px 0; border-top: 1px solid #dfe5df; border-bottom: 1px solid #dfe5df; color: #405149; font-size: 14px; }
.state-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #c14a00; }
.state-dot.is-complete { background: #168353; }
.state-dot.is-error { background: #b63d00; }

.result-section { padding: 22px 0; border-bottom: 1px solid #dfe5df; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
h2 { margin-top: 2px; font-size: 17px; }
.section-heading span { max-width: 50%; text-align: right; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.result-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  min-height: 104px;
  padding: 10px;
  border: 1px solid #d5ddd7;
  border-radius: 6px;
  background: #ffffff;
}
.result-item img, .image-placeholder { width: 76px; height: 76px; border-radius: 4px; object-fit: cover; background: #edf1ee; }
.image-placeholder { display: block; }
.result-copy { display: flex; min-width: 0; flex-direction: column; }
.result-title { display: -webkit-box; overflow: hidden; color: #1d2521; font-size: 14px; font-weight: 700; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.result-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; color: #506159; font-size: 12px; line-height: 1.35; }
.result-meta span { border: 1px solid #dbe3dd; border-radius: 3px; padding: 2px 4px; }
.result-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.result-price { color: #b63d00; font-size: 16px; font-weight: 700; white-space: nowrap; }
.result-link { color: #075c8c; font-size: 13px; text-decoration: none; white-space: nowrap; }
.empty-result { grid-column: 1 / -1; padding: 18px 0; color: #5e6e65; font-size: 13px; text-align: center; }

@media (max-width: 640px) {
  main { margin-top: 12px; padding: 0 12px; }
  .topbar { padding: 0 12px; }
  .access-row { align-items: stretch; flex-wrap: wrap; }
  .access-row button { margin-left: auto; }
  .query-actions { align-items: stretch; flex-wrap: wrap; }
  #file-summary { flex-basis: 100%; order: 3; }
  .result-grid { grid-template-columns: minmax(0, 1fr); }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .section-heading span { max-width: 100%; text-align: left; }
}
