:root {
  --bg: #eee8e1;
  --panel: #f7f2eb;
  --ink: #383838;
  --muted: #7c7c7c;
  --line: #383838;
  --soft: #d7d0c8;
  --button: #91cff4;
  --error: #a8483d;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background:
    linear-gradient(rgba(56, 56, 56, 0.08) 3px, transparent 3px),
    linear-gradient(90deg, rgba(56, 56, 56, 0.08) 3px, transparent 3px),
    var(--bg);
  background-size: 116px 116px;
}

button {
  font: inherit;
}

.page {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  padding: 72px 0 28px;
}

.frame {
  width: min(640px, calc(100vw - 24px));
  position: relative;
  left: 50vw;
  transform: translateX(-50%);
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  gap: 14px;
  border: 4px solid var(--line);
  border-radius: 4px;
  background: rgba(247, 242, 235, 0.92);
  padding: 22px;
}

.tool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 3px solid var(--line);
  padding-bottom: 14px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.head-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 142px;
}

.head-meta span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
  background: rgba(247, 242, 235, 0.7);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

#targetBadge {
  width: 142px;
}

.dropzone {
  position: relative;
  min-height: 146px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 4px dashed #cfc8c0;
  background: rgba(247, 242, 235, 0.52);
  text-align: center;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.dropzone.is-dragging {
  border-color: var(--line);
  background: #f1ece5;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

#visualCanvas {
  display: none;
}

.drop-title {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.drop-meta {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

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

.fields .field {
  grid-column: auto;
  width: 100%;
  justify-self: stretch;
}

.field {
  display: grid;
  gap: 8px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.results-title {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.field output,
.target-input-wrap {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 3px solid var(--line);
  border-radius: 4px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(247, 242, 235, 0.74);
  font-size: 18px;
  font-weight: 800;
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #55bd82;
}

.target-input-wrap {
  gap: 8px;
}

.target-input-wrap input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
}

.target-input-wrap span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.target-input-wrap:focus-within {
  background: #fffaf2;
}

.progress {
  height: 12px;
  overflow: hidden;
  border: 2px solid #c7c1bb;
  border-radius: 3px;
  background: #eee8e1;
}

.progress.hidden {
  display: none;
}

.progress div {
  width: 0%;
  height: 100%;
  background: var(--button);
  transition: width 160ms ease;
}

.results-wrap {
  display: grid;
  gap: 10px;
}

.results-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results {
  min-height: 72px;
  border: 3px solid var(--soft);
  background: rgba(247, 242, 235, 0.58);
}

.results.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.results.empty p {
  margin: 0;
}

.result-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 82px;
  gap: 12px;
  align-items: center;
  padding: 12px 24px 24px 12px;
}

.result-card + .result-card {
  border-top: 3px solid var(--soft);
}

.thumb {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--soft);
  color: var(--muted);
}

.thumb:empty::before {
  content: "IMG";
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-name {
  overflow: hidden;
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.badge {
  color: var(--ink);
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.badge.error {
  color: var(--error);
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.primary-button,
.outline-button,
.plain-button,
.download,
.delete-button {
  border: 3px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: var(--button);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.primary-button,
.outline-button,
.download {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button {
  min-width: 112px;
}

.outline-button,
.plain-button,
.delete-button {
  background: transparent;
}

.outline-button {
  min-height: 40px;
  margin-top: 4px;
}

.plain-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
}

.icon-button {
  justify-self: end;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  color: var(--ink);
  background: rgba(247, 242, 235, 0.92);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.download.icon-button {
  min-height: 0;
  padding: 0;
  font-size: 22px;
}

.primary-button:not(:disabled):hover,
.outline-button:not(:disabled):hover,
.plain-button:not(:disabled):hover {
  transform: translate(8px, -8px);
  box-shadow: -8px 8px 0 var(--line);
}

.icon-button:hover,
.delete-button:not(:disabled):hover {
  transform: translate(8px, -8px);
  box-shadow: -8px 8px 0 var(--line);
}

.primary-button:not(:disabled):active,
.outline-button:not(:disabled):active,
.plain-button:not(:disabled):active {
  transform: translate(5px, -5px);
  box-shadow: -5px 5px 0 var(--line);
}

.icon-button:active,
.delete-button:not(:disabled):active {
  transform: translate(5px, -5px);
  box-shadow: -5px 5px 0 var(--line);
}

.primary-button:disabled,
.outline-button:disabled,
.plain-button:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

@media (max-width: 860px) {
  .page {
    padding: 18px 0;
  }

  .frame {
    gap: 18px;
    padding: 20px;
  }

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

  .fields .field {
    grid-column: auto;
    width: 100%;
    justify-self: stretch;
  }

  .field.wide {
    grid-column: auto;
  }

  .tool-head {
    display: grid;
    gap: 14px;
    padding-bottom: 16px;
  }

  .head-meta {
    justify-content: flex-start;
    min-width: 0;
  }

  .head-meta span {
    font-size: 12px;
    padding: 8px 10px;
  }

  .dropzone {
    min-height: 150px;
    padding: 18px 12px;
  }

  .drop-title {
    font-size: 15px;
  }

  .drop-meta {
    font-size: 12px;
  }

  .field output,
  .target-input-wrap {
    min-height: 44px;
    font-size: 18px;
    padding: 0 14px;
  }

  .result-card {
    grid-template-columns: 56px minmax(0, 1fr);
    padding: 14px;
  }

  .thumb {
    width: 56px;
    height: 56px;
  }

  .row-actions {
    grid-column: 1 / -1;
  }

  .row-actions {
    justify-content: flex-end;
  }
}
