.downpic-toolbar {
  --downpic-ink: #24332d;
  --downpic-green: #25634b;
  --downpic-line: #dce3de;
  position: absolute;
  z-index: 2147483647;
  width: max-content;
  min-width: 0;
  max-width: calc(100vw - 24px);
  padding: 7px;
  transform: translateX(-50%);
  color: var(--downpic-ink);
  background: #fff;
  border: 1px solid var(--downpic-line);
  border-radius: 9px;
  box-shadow: 0 10px 26px rgb(20 36 29 / 20%);
  font: 14px/1.35 "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

.downpic-toolbar * { box-sizing: border-box; }
.downpic-toolbar-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.downpic-toolbar .downpic-mark {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  place-items: center;
  color: #fff;
  background: transparent;
}

.downpic-mark svg { display: block; width: 30px; height: 30px; }

.downpic-toolbar button {
  height: 36px;
  margin: 0;
  padding: 0 8px;
  color: var(--downpic-ink);
  background: #fff;
  border: 1px solid var(--downpic-line);
  border-radius: 7px;
  box-shadow: none;
  font: 600 13px/1 "Microsoft YaHei UI", "PingFang SC", sans-serif;
  letter-spacing: normal;
  text-transform: none;
  appearance: none;
  cursor: pointer;
}

.downpic-toolbar-row > [data-action="save"] { width: 76px; flex: 0 0 76px; }
.downpic-toolbar-row > [data-action="analyze"] { width: 96px; flex: 0 0 96px; }
.downpic-toolbar .downpic-collapse {
  display: grid;
  width: 26px;
  flex: 0 0 26px;
  padding: 0;
  place-items: center;
  color: #64716a;
  background: transparent;
  border-color: transparent;
}
.downpic-toolbar .downpic-collapse:hover { color: var(--downpic-green); background: #f0f5f1; }
.downpic-collapse svg { display: block; width: 18px; height: 18px; }
.downpic-toolbar .downpic-expand {
  display: none;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 4px 0 0;
  color: #64716a;
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 500;
}
.downpic-toolbar[data-collapsed="true"] .downpic-mark { flex-basis: 28px; width: 28px; height: 28px; }
.downpic-toolbar[data-collapsed="true"] .downpic-mark svg { width: 28px; height: 28px; }
.downpic-toolbar[data-collapsed="true"] { padding: 4px; box-shadow: 0 3px 12px rgb(20 36 29 / 15%); }
.downpic-toolbar[data-collapsed="true"] .downpic-toolbar-row > :not(.downpic-expand):not(.downpic-mark),
.downpic-toolbar[data-collapsed="true"] .downpic-custom-row,
.downpic-toolbar[data-collapsed="true"] .downpic-feedback-row { display: none; }
.downpic-toolbar[data-collapsed="true"] .downpic-expand { display: flex; }

.downpic-toolbar [data-action="analyze"],
.downpic-toolbar [data-action="apply-custom"] { color: #fff; background: var(--downpic-green); border-color: var(--downpic-green); }
.downpic-toolbar button:disabled { cursor: default; opacity: .65; }
.downpic-toolbar button:focus-visible { outline: 2px solid var(--downpic-green); outline-offset: 2px; }
.downpic-category-label { display: flex; align-items: center; gap: 6px; color: #64716a; font: 500 14px/1 "Microsoft YaHei UI", "PingFang SC", sans-serif; white-space: nowrap; }
.downpic-category-label select {
  width: 126px;
  height: 36px;
  margin: 0;
  padding: 0 28px 0 10px;
  color: var(--downpic-ink);
  background: #fff;
  border: 1px solid var(--downpic-line);
  border-radius: 7px;
  box-shadow: none;
  font: 500 14px/1 "Microsoft YaHei UI", "PingFang SC", sans-serif;
  letter-spacing: normal;
  appearance: auto;
}
.downpic-category-label select:focus-visible,
.downpic-toolbar input:focus-visible { outline: 2px solid var(--downpic-green); outline-offset: 2px; }
.downpic-custom-row { display: flex; gap: 7px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--downpic-line); }
.downpic-custom-row[hidden] { display: none; }
.downpic-custom-row input {
  min-width: 0;
  height: 36px;
  flex: 1;
  padding: 0 9px;
  color: var(--downpic-ink);
  background: #fff;
  border: 1px solid var(--downpic-line);
  border-radius: 7px;
  box-shadow: none;
  font: 500 14px/1 "Microsoft YaHei UI", "PingFang SC", sans-serif;
  appearance: none;
}
.downpic-feedback-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; padding: 1px 3px 0; }
.downpic-feedback-row[hidden] { display: none; }
.downpic-status { margin: 0; color: #64716a; font-size: 12px; text-align: center; }
.downpic-status[data-tone="error"] { color: #a44638; }
.downpic-status[data-tone="success"] { color: var(--downpic-green); }
.downpic-toolbar .downpic-reveal {
  height: auto;
  padding: 0;
  color: var(--downpic-green);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
}
.downpic-toolbar .downpic-reveal[hidden] { display: none; }

@media (max-width: 420px) {
  .downpic-toolbar { min-width: 0; }
  .downpic-toolbar-row { flex-wrap: wrap; }
  .downpic-toolbar button { padding-inline: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .downpic-toolbar { animation: downpic-in 120ms ease-out; }
  @keyframes downpic-in {
    from { opacity: 0; transform: translate(-50%, -4px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
}
