:root {
  --ink: #191816;
  --muted: #918d83;
  --paper: #f4f0e7;
  --panel: #171713;
  --panel-soft: #20201b;
  --line: #34342d;
  --accent: #d85a3d;
  --accent-light: #f07b5d;
  --text: #f3efe5;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 75% 5%, rgba(216, 90, 61, 0.08), transparent 28rem),
    #0d0d0b;
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-light);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 5vw, 5.2rem);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.top-actions,
.recipe-actions {
  display: flex;
  gap: 10px;
}

.button {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  font-weight: 650;
  transition: 160ms ease;
  text-decoration: none;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-light);
}

.button.secondary {
  border-color: #555248;
  background: #292821;
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: #c6c1b5;
}

.button.module-link {
  border-color: #36352f;
  background: #161612;
  color: #858177;
}

.button.module-link.active {
  border-color: #706b5d;
  color: var(--text);
}

.button.wide {
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 180px);
  overflow: hidden;
  border: 1px solid #2f2f28;
  border-radius: 5px;
  background: #11110e;
  box-shadow: var(--shadow);
}

.control-panel {
  max-height: calc(100vh - 150px);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.panel-intro {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  color: #b9b4a8;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #78a867;
  box-shadow: 0 0 10px rgba(120, 168, 103, 0.5);
}

details {
  border-bottom: 1px solid var(--line);
}

summary {
  padding: 16px 20px;
  color: #ded9ce;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  list-style: none;
  text-transform: uppercase;
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

details[open] summary::after {
  content: "−";
}

.controls,
.control-grid,
.recipe-actions {
  padding: 0 20px 20px;
}

.controls {
  display: grid;
  gap: 18px;
}

.control-grid {
  display: grid;
  gap: 13px;
}

.control-grid.two-column {
  grid-template-columns: 1fr 1fr;
}

label > span,
.range-control > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #bbb6aa;
  font-size: 0.76rem;
}

label b {
  color: #6f6d64;
  font-size: 0.68rem;
  font-weight: 600;
}

output {
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}

input[type="number"] {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid #3b3a33;
  border-radius: 2px;
  outline: none;
  background: #10100d;
  color: var(--text);
}

input[type="number"]:focus {
  border-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  height: 3px;
  appearance: none;
  border-radius: 2px;
  background: #444239;
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  appearance: none;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 0 1px var(--accent-light);
}

.recipe-actions {
  flex-direction: column;
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.stage-wrap {
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.stage-toolbar,
.stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 20px;
  color: #8e8a80;
  font-size: 0.77rem;
}

.stage-toolbar {
  border-bottom: 1px solid var(--line);
}

.stage-footer {
  border-top: 1px solid var(--line);
}

.stage-footer p {
  margin: 0;
}

.artwork-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.divider {
  width: 1px;
  height: 14px;
  background: #46443c;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle input {
  accent-color: var(--accent);
}

.toggle span {
  margin: 0;
}

.stage {
  display: grid;
  min-height: 560px;
  place-items: center;
  overflow: hidden;
  padding: 34px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    #0c0c0a;
  background-size: 24px 24px;
}

#artwork {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 260px);
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.upload-zone {
  display: grid;
  min-height: 128px;
  padding: 18px;
  place-items: center;
  border: 1px dashed #4a483f;
  border-radius: 3px;
  background: #11110e;
  color: #aaa599;
  text-align: center;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragging {
  border-color: var(--accent);
  background: rgba(216, 90, 61, 0.06);
}

.upload-zone input {
  display: none;
}

.upload-zone strong,
.upload-zone small {
  display: block;
}

.upload-zone strong {
  margin-bottom: 5px;
  color: #e5e0d5;
}

.upload-zone small {
  color: #77746b;
}

.source-editor {
  overflow: hidden;
  border: 1px solid #3a3932;
  border-radius: 2px;
  background: #080806;
  cursor: grab;
  touch-action: none;
}

.source-editor.dragging {
  cursor: grabbing;
  border-color: var(--accent);
}

.source-editor canvas {
  display: block;
  width: 100%;
  height: auto;
}

.source-editor p {
  margin: 0;
  padding: 7px;
  border-top: 1px solid #302f29;
  color: #716e65;
  font-size: 0.66rem;
  text-align: center;
}

.crop-controls {
  padding: 4px 0 0;
}

.empty-stage-message {
  position: absolute;
  width: min(420px, 70%);
  color: #757168;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}

.stage {
  position: relative;
}

.relief-stage {
  display: block;
  overflow: auto;
  text-align: center;
}

.relief-stage #artwork {
  max-width: none;
  max-height: none;
  margin: 0 auto;
  transform-origin: top center;
}

.preview-tools,
.preview-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-zoom input {
  width: 105px;
}

.preview-zoom output {
  min-width: 38px;
  font-size: 0.7rem;
}

.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid #3c3a33;
  border-radius: 2px;
  background: #191914;
  color: #d6d1c5;
}

.icon-button:hover {
  border-color: #666257;
}

.icon-button.text-button {
  width: auto;
  padding: 0 9px;
  font-size: 0.7rem;
}

.select-control select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid #3b3a33;
  border-radius: 2px;
  outline: none;
  background: #10100d;
  color: var(--text);
}

.secret-control {
  display: grid;
  gap: 7px;
}

.secret-control span {
  color: #aaa599;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.secret-control input {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid #3b3a33;
  border-radius: 2px;
  outline: none;
  background: #10100d;
  color: var(--text);
}

.secret-control input:focus {
  border-color: var(--accent);
}

.control-note {
  margin: 0;
  color: #77746b;
  font-size: 0.68rem;
  line-height: 1.5;
}

.control-note.success {
  color: #88b58d;
}

.control-note.error {
  color: #df8b7c;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 20px 20px;
}

.mini-stat {
  padding: 10px;
  border: 1px solid #34332d;
  background: #11110e;
}

.mini-stat b,
.mini-stat span {
  display: block;
}

.mini-stat b {
  margin-bottom: 3px;
  color: var(--accent-light);
  font-size: 0.9rem;
}

.mini-stat span {
  color: #77736a;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .control-panel {
    max-height: none;
    border-right: 0;
  }

  .stage {
    min-height: 520px;
  }

  #artwork {
    max-height: 70vh;
  }
}
