:root {
  color-scheme: light;
  --ink: #18201c;
  --muted: #66736d;
  --line: #d8dfd8;
  --paper: #f5f7f2;
  --panel: rgba(255, 255, 255, 0.92);
  --green: #176b52;
  --green-dark: #0f513e;
  --amber: #a86916;
  --blue: #255f9f;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(28, 39, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(245, 247, 242, 0.92)),
    repeating-linear-gradient(135deg, #eef3ed 0 2px, #f8faf6 2px 12px);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans CJK SC", "PingFang SC", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 22px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 5px;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.queue-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  white-space: nowrap;
}

.queue-pill span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.status-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #5f6c65;
  font-size: 13px;
  font-weight: 750;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

#dpi {
  text-align: center;
}

input:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 0 0 3px rgba(23, 107, 82, 0.14);
}

.toggle-row {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 2px;
  color: var(--ink);
}

.checkline span {
  margin: 0;
  color: var(--ink);
}

.checkline input {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid #99a49d;
  border-radius: 5px;
  appearance: none;
  accent-color: var(--green);
  background: #fff;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.checkline input:checked {
  border-color: var(--green);
  background: var(--green);
}

.checkline input:checked::after {
  content: "";
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.checkline input:focus-visible {
  box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.14);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 188px;
  border: 1px dashed #acb7af;
  border-radius: 8px;
  background: #f8faf6;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--green);
  background: #edf6f1;
  transform: translateY(-1px);
}

.drop-zone input {
  display: none;
}

.drop-zone span {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.drop-zone small {
  max-width: 90%;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
  margin-top: 16px;
}

button,
.download {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

button:hover,
.download:hover {
  background: var(--green-dark);
}

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

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  border-color: #b7c1b8;
  background: #f7f8f4;
}

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

.status-panel {
  padding: 20px;
}

.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

#statusKicker {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 900;
}

.download[hidden] {
  display: none;
}

.meter-block {
  margin-top: 20px;
}

.meter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.meter-label strong {
  color: var(--ink);
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9e2;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 220ms ease;
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 22px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.facts div {
  min-width: 0;
  padding: 13px 10px;
}

.facts div + div {
  border-left: 1px solid var(--line);
}

.facts dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.facts dd {
  margin: 0;
  min-height: 20px;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

#logBox {
  min-height: 104px;
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  color: #37443e;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.status-panel.is-error {
  border-color: rgba(180, 35, 24, 0.45);
}

.status-panel.is-error #statusKicker {
  color: var(--red);
}

@media (max-width: 840px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .queue-pill {
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 22px, 1160px);
    padding: 18px 0;
  }

  h1 {
    font-size: 27px;
  }

  h2 {
    font-size: 23px;
  }

  .field-grid,
  .action-row,
  .facts {
    grid-template-columns: 1fr;
  }

  .facts div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .status-head {
    align-items: stretch;
    flex-direction: column;
  }
}
