:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888888;
  --green: #39fe04;
  --green-hot: #5dff2e;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

button,
input {
  font-family: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
.cropbox:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.tools-bar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.mark {
  display: block;
  height: 32px;
  width: auto;
}

.tools-bar-name {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tools-bar-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}

.tools-bar-back:hover {
  color: var(--text);
}

.xeno-address {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.xeno-address input {
  width: min(280px, 42vw);
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.bench {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: start center;
  padding: 16px 20px 24px;
}

.stage {
  width: min(1480px, 100%);
}

.drop,
.work {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.drop {
  width: min(720px, 100%);
  min-height: min(460px, calc(100vh - 160px));
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: #111111;
  text-align: center;
}

.stage.is-hot .drop {
  border-color: var(--green);
}

.stage-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stage-title {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.96;
}

.stage-choose {
  margin-top: 8px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.stage-choose:hover {
  border-color: var(--green);
}

.drop-note {
  min-height: 1.2em;
  margin: 8px 20px 0;
  color: var(--text);
  font-size: 0.88rem;
}

.stage-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.work-main {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.plate {
  position: relative;
  display: block;
  flex: none;
  max-width: none;
  line-height: 0;
  user-select: none;
  touch-action: none;
  background-color: #141414;
  box-shadow: 0 0 0 1px var(--border);
}

.plate.has-alpha {
  background-image:
    linear-gradient(45deg, #1c1c1c 25%, transparent 25%),
    linear-gradient(-45deg, #1c1c1c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1c1c1c 75%),
    linear-gradient(-45deg, transparent 75%, #1c1c1c 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.frame-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.before,
.after {
  display: block;
  max-width: none;
}

.before {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.clip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  overflow: hidden;
}

.after {
  position: absolute;
  top: 0;
  left: 0;
}

.plate.is-frame .before,
.plate.is-frame .clip,
.plate.is-frame .split,
.plate.is-frame .side {
  display: none;
}

.plate.is-compare .frame,
.plate.is-compare .cropbox,
.plate.is-whole .cropbox {
  display: none;
}

.split {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 28px;
  margin-left: -14px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  z-index: 3;
}

.split::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 13px;
  width: 1px;
  background: #ffffff;
}

.split::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 22px;
  margin: -11px 0 0 -17px;
  border: 1px solid #ffffff;
  border-radius: 11px;
  background: rgba(13, 13, 13, 0.9);
  box-shadow: inset 7px 0 0 -6px #ffffff, inset -7px 0 0 -6px #ffffff;
}

.cropbox {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  border: 1px solid #ffffff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
}

.cropbox.is-live {
  background-image:
    linear-gradient(to right, transparent 33.33%, rgba(255, 255, 255, 0.4) 33.33%, rgba(255, 255, 255, 0.4) calc(33.33% + 1px), transparent calc(33.33% + 1px), transparent 66.66%, rgba(255, 255, 255, 0.4) 66.66%, rgba(255, 255, 255, 0.4) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
    linear-gradient(to bottom, transparent 33.33%, rgba(255, 255, 255, 0.4) 33.33%, rgba(255, 255, 255, 0.4) calc(33.33% + 1px), transparent calc(33.33% + 1px), transparent 66.66%, rgba(255, 255, 255, 0.4) 66.66%, rgba(255, 255, 255, 0.4) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.handle {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
}

.handle::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  box-shadow: 0 0 0 1px #111111;
}

.handle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.handle[data-h="ne"] { right: 0; top: 0; cursor: nesw-resize; }
.handle[data-h="sw"] { left: 0; bottom: 0; cursor: nesw-resize; }
.handle[data-h="se"] { right: 0; bottom: 0; cursor: nwse-resize; }
.handle[data-h="n"] { left: 50%; top: 0; margin-left: -11px; cursor: ns-resize; }
.handle[data-h="s"] { left: 50%; bottom: 0; margin-left: -11px; cursor: ns-resize; }
.handle[data-h="e"] { right: 0; top: 50%; margin-top: -11px; cursor: ew-resize; }
.handle[data-h="w"] { left: 0; top: 50%; margin-top: -11px; cursor: ew-resize; }

.side {
  position: absolute;
  z-index: 4;
  margin: 0;
  background: rgba(13, 13, 13, 0.82);
}

.clear {
  position: static;
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.clear:hover {
  border-color: var(--green);
}

.side {
  bottom: 12px;
  padding: 3px 8px;
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
}

.side-before { left: 12px; }
.side-after { right: 12px; }

.under-photo {
  width: 100%;
}

.spec-row {
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spec {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  margin: 0;
  text-align: center;
  color: var(--text);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.spec p {
  margin: 0;
}

.spec-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spec-pixels,
.spec-size {
  flex: none;
  white-space: nowrap;
}

.spec-name {
  font-weight: 600;
}

.spec-size.is-down {
  color: var(--green);
}

  .controls {
    width: min(720px, 100%);
    margin-top: 22px;
    display: grid;
    gap: 16px;
  }

  .controls-scroll {
    display: grid;
    gap: 16px;
  }

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field-label b,
.field-label button {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.85rem;
}

.field-label button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.field-label button:hover {
  color: var(--green);
}

.save-label {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.fmt,
.seg,
.actions,
.ratios,
.pair {
  display: grid;
  gap: 8px;
}

.fmt {
  grid-template-columns: repeat(3, 1fr);
}

.seg {
  grid-template-columns: repeat(5, 1fr);
}

.actions,
.pair {
  grid-template-columns: 1fr 1fr;
}

.ratios {
  grid-template-columns: repeat(4, 1fr);
}

.social-opts {
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.mini-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-tabs button {
  width: 100%;
  height: 36px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-tabs button:hover:not(.is-on) {
  border-color: #3a3a3a;
}

.mini-tabs button.is-on {
  border-color: transparent;
  background: var(--green);
  color: var(--bg);
}

.fmt button,
.seg button,
.actions button,
.ratios button,
.pair button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.fmt button {
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 8px;
}

.fmt-name {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.fmt-size {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.seg button,
.actions button,
.pair button {
  height: 36px;
  font-size: 0.8rem;
  font-weight: 500;
}

.ratios button {
  min-height: 48px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.15;
}

.ratios button small {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0;
}

.actions button:disabled {
  opacity: 0.35;
  cursor: default;
}

.fmt button:hover:not(.is-on):not(:disabled),
.seg button:hover:not(.is-on):not(:disabled),
.actions button:hover:not(:disabled),
.ratios button:hover:not(.is-on),
.pair button:hover:not(.is-on) {
  border-color: #3a3a3a;
}

.fmt button.is-on,
.seg button.is-on,
.ratios button.is-on,
.pair button.is-on {
  border-color: transparent;
  background: var(--green);
  color: var(--bg);
  font-weight: 700;
}

.range {
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border);
}

.range::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

.range::-webkit-slider-thumb:hover,
.range:focus-visible::-webkit-slider-thumb {
  background: var(--green);
}

.range::-moz-range-track {
  height: 2px;
  background: var(--border);
  border: 0;
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

.hint {
  min-height: 1.3em;
  margin: 8px 0 0;
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
}

.hint:empty {
  display: none;
  min-height: 0;
  margin: 0;
}

.frame-hint {
  width: 100%;
  margin-top: 4px;
  white-space: nowrap;
}

.download {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: var(--bg);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.download:hover:not(:disabled) {
  background: var(--green-hot);
}

.download:disabled,
.send:disabled {
  opacity: 0.35;
  cursor: default;
}

.send {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.send:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green);
}

.fine {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.export {
  padding-bottom: 8px;
}

@media (min-width: 1040px) {
  .bench {
    min-height: calc(100vh - 64px);
    height: auto;
    overflow: visible;
    padding: 12px 20px 8px;
  }

  .stage.has-image {
    height: auto;
    min-height: 0;
  }

  .work {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 28px;
    align-items: start;
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .work-main {
    width: 100%;
    height: auto;
    min-height: 0;
    align-self: start;
    justify-content: flex-start;
    gap: 8px;
  }

  .social-block {
    width: 100%;
    flex: none;
  }

  .social-block .mini-tabs {
    grid-template-columns: repeat(6, 1fr);
  }

  .social-block .social-opts {
    grid-template-columns: repeat(4, 1fr);
  }

  .spec-row,
  .frame-hint {
    margin-top: 0;
  }

  .controls {
    width: 100%;
    height: auto;
    max-height: none;
    min-height: 0;
    margin-top: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-right: 0;
  }

  .controls-scroll {
    min-height: 0;
    overflow: visible;
    gap: 8px;
    padding-bottom: 4px;
  }

  .controls .field-label {
    margin-bottom: 4px;
  }

  .controls .actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .controls .actions button,
  .controls .pair button,
  .controls .seg button {
    height: 32px;
  }

  .controls .ratios button {
    min-height: 34px;
    padding: 4px 2px;
  }

  .controls .fmt button {
    height: 48px;
  }

  .controls .save-label {
    margin-top: 0;
    padding-top: 8px;
  }

  .export {
    position: static;
    flex: none;
    background: var(--bg);
    padding-top: 10px;
  }
}

@media (max-width: 640px) {
  .seg {
    grid-template-columns: repeat(3, 1fr);
  }

  .seg button:first-child {
    grid-column: 1 / -1;
  }

  .ratios {
    grid-template-columns: repeat(3, 1fr);
  }

  .social-opts {
    grid-template-columns: 1fr 1fr;
  }
}
