:root {
  --mat: #e8dfd0;
  --mat_shadow: #d4c7b3;
  --walnut: #2f2118;
  --walnut_soft: #463429;
  --walnut_ink: #f3eadf;
  --brass: #c4a24a;
  --brass_bright: #ddbf67;
  --brass_dark: #8f7331;
  --label: #6f5f4d;
  --focus: #5c7ea3;
  --overlay: rgba(20, 14, 10, 0.58);
}

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

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

body {
  background:
    linear-gradient(180deg, #f0e7da 0%, var(--mat) 38%, #ded2c1 100%);
  color: var(--walnut);
  font-family: "Trebuchet MS", "Gill Sans", "Helvetica Neue", sans-serif;
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

.shop_floor {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.1rem 3.5rem;
}

.shop_header {
  margin-bottom: 1.6rem;
  padding: 1.2rem 1.25rem 1.35rem;
  background: var(--walnut);
  color: var(--walnut_ink);
  border: 1px solid var(--brass_dark);
  box-shadow:
    inset 0 0 0 1px rgba(196, 162, 74, 0.35),
    0 10px 24px rgba(47, 33, 24, 0.18);
}

.gallery_label {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--label);
}

.shop_header .gallery_label {
  color: #b9a78f;
}

h1 {
  margin: 0.45rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}

.shop_lede {
  max-width: 34rem;
  margin: 0.75rem 0 0;
  color: #d8cbb8;
}

.status_message {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--brass_dark);
  background: #f6ead8;
}

.file_input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.drop_stage {
  position: relative;
  min-height: 20rem;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--mat);
  border: 2px solid var(--walnut_soft);
  box-shadow:
    inset 0 0 0 12px var(--mat_shadow),
    inset 0 0 0 13px var(--brass_dark),
    0 8px 18px rgba(47, 33, 24, 0.12);
  cursor: pointer;
}

.drop_stage::before,
.drop_stage::after,
.frame_shell::before,
.frame_shell::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--brass);
  pointer-events: none;
}

.drop_stage::before {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
}

.drop_stage::after {
  top: 10px;
  right: 10px;
  border-left: 0;
  border-bottom: 0;
}

.drop_stage.is_dragging {
  background: #efe4d3;
}

.drop_stage_inner {
  text-align: center;
  max-width: 28rem;
}

.drop_stage_title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
}

.drop_stage_hint {
  margin: 0.5rem 0 1.1rem;
  color: var(--label);
}

.mat_button,
.brass_button,
.ghost_button,
.ratio_group button,
.crop_handle {
  font: inherit;
}

.mat_button {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--walnut);
  background: #f7f0e5;
  color: var(--walnut);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 1.2rem;
  align-items: start;
}

.frame_bench {
  display: grid;
  gap: 1rem;
}

.frame_assembly {
  position: relative;
}

.frame_shell {
  position: relative;
  display: inline-block;
  padding: 18px;
  background: var(--mat_shadow);
  border: 1px solid var(--walnut_soft);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 10px 22px rgba(47, 33, 24, 0.14);
}

.frame_shell::before {
  bottom: 8px;
  left: 8px;
  border-top: 0;
  border-right: 0;
}

.frame_shell::after {
  bottom: 8px;
  right: 8px;
  border-top: 0;
  border-left: 0;
}

.crop_stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  background: #1b1410;
  touch-action: none;
  overflow: hidden;
}

.crop_stage img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.crop_overlay {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.crop_box {
  position: absolute;
  top: 0;
  left: 0;
  cursor: move;
  box-shadow: 0 0 0 9999px var(--overlay);
  outline: 2px solid var(--brass_bright);
  touch-action: none;
  z-index: 1;
}

.crop_box.is_dragging {
  outline-color: #fff1bf;
}

.crop_box_rule {
  position: absolute;
  background: rgba(255, 241, 191, 0.45);
  pointer-events: none;
}

.crop_box_rule_top,
.crop_box_rule_bottom {
  left: 33.33%;
  width: 33.34%;
  height: 1px;
}

.crop_box_rule_left,
.crop_box_rule_right {
  top: 33.33%;
  height: 33.34%;
  width: 1px;
}

.crop_box_rule_top {
  top: 33.33%;
}

.crop_box_rule_bottom {
  bottom: 33.33%;
}

.crop_box_rule_left {
  left: 33.33%;
}

.crop_box_rule_right {
  right: 33.33%;
}

.crop_handle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--walnut);
  background: var(--brass_bright);
  cursor: pointer;
  touch-action: none;
  z-index: 2;
}

.crop_handle::before {
  content: "";
  position: absolute;
  inset: -8px;
}

.crop_handle[data-handle="nw"] {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.crop_handle[data-handle="n"] {
  top: 0;
  left: calc(50% - 7px);
  cursor: ns-resize;
}

.crop_handle[data-handle="ne"] {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.crop_handle[data-handle="e"] {
  top: calc(50% - 7px);
  right: 0;
  cursor: ew-resize;
}

.crop_handle[data-handle="se"] {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}

.crop_handle[data-handle="s"] {
  left: calc(50% - 7px);
  bottom: 0;
  cursor: ns-resize;
}

.crop_handle[data-handle="sw"] {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

.crop_handle[data-handle="w"] {
  top: calc(50% - 7px);
  left: 0;
  cursor: ew-resize;
}

.preview_plaque {
  margin: 0;
}

.preview_plaque .gallery_label {
  margin-bottom: 0.45rem;
}

.preview_window {
  min-height: 10rem;
  padding: 0.85rem;
  background: var(--mat);
  border: 1px solid var(--walnut_soft);
  box-shadow: inset 0 0 0 8px var(--mat_shadow);
}

.preview_window img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  margin: 0 auto;
}

.walnut_console {
  padding: 1.1rem 1rem 1.25rem;
  background: var(--walnut);
  color: var(--walnut_ink);
  border: 1px solid var(--brass_dark);
  box-shadow: inset 0 0 0 1px rgba(196, 162, 74, 0.28);
}

.walnut_console .gallery_label {
  color: #b9a78f;
}

.spec_plate {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(196, 162, 74, 0.25);
}

.spec_plate div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.spec_plate dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.ratio_fieldset {
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

.ratio_group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.ratio_group button {
  padding: 0.5rem 0.35rem;
  border: 1px solid #6d5a45;
  background: transparent;
  color: var(--walnut_ink);
  cursor: pointer;
  font-size: 0.82rem;
}

.ratio_group button.is_active {
  background: var(--brass);
  border-color: var(--brass_bright);
  color: var(--walnut);
}

.output_note {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: #c9b79f;
}

.action_row {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.brass_button,
.ghost_button {
  padding: 0.72rem 0.85rem;
  cursor: pointer;
}

.brass_button {
  border: 0;
  background: linear-gradient(180deg, var(--brass_bright), var(--brass));
  color: var(--walnut);
  font-weight: 700;
}

.brass_button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.ghost_button {
  border: 1px solid #8d7658;
  background: transparent;
  color: var(--walnut_ink);
}

body.crop_is_dragging {
  cursor: grabbing;
  user-select: none;
}

.mat_button:focus-visible,
.brass_button:focus-visible,
.ghost_button:focus-visible,
.ratio_group button:focus-visible,
.crop_handle:focus-visible,
.file_input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .frame_shell {
    width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .ratio_group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
