:root {
  --ink: #f7f4ec;
  --muted: #b7b2a8;
  --panel: rgba(20, 20, 18, 0.86);
  --panel-strong: rgba(30, 30, 27, 0.92);
  --line: rgba(247, 244, 236, 0.16);
  --line-strong: rgba(247, 244, 236, 0.28);
  --accent: #2fb680;
  --accent-ink: #06140f;
  --warning: #e1b33b;
  --shadow: rgba(0, 0, 0, 0.34);
  --white: #f4f1e8;
  --yellow: #f0c431;
  --red: #db3b32;
  --orange: #e8752b;
  --blue: #2f73d9;
  --green: #2ab06f;
  --mobile-panel-height: min(48vh, 430px);
  --mobile-status-space: 58px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #11110f;
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
}

button {
  appearance: none;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(247, 244, 236, 0.08);
  color: var(--ink);
  cursor: pointer;
  font: 650 12px/1.1 system-ui, sans-serif;
  letter-spacing: 0;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

button:hover:not(:disabled) {
  background: rgba(247, 244, 236, 0.14);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

.workspace,
.stage,
.stage canvas {
  width: 100%;
  height: 100%;
}

.workspace {
  position: relative;
  min-width: 320px;
}

.stage {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
}

.stage canvas {
  display: block;
  touch-action: none;
  cursor: grab;
}

.stage canvas.dragging {
  cursor: grabbing;
}

.control-panel {
  position: fixed;
  z-index: 5;
  top: 14px;
  right: 14px;
  width: min(372px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 58px var(--shadow);
  backdrop-filter: blur(16px) saturate(118%);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.18;
  font-weight: 780;
}

h2 {
  font-size: 12px;
  line-height: 1;
  font-weight: 760;
}

.stats-pill,
.block-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.stats-pill {
  min-width: 62px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
  background: rgba(247, 244, 236, 0.07);
}

.control-block {
  padding: 13px 0 0;
}

.block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented button {
  min-width: 0;
  height: 34px;
}

.segmented button.is-active,
.face-tabs button.is-active,
.swatches button.is-active {
  border-color: rgba(47, 182, 128, 0.72);
  background: rgba(47, 182, 128, 0.22);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.button-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.step-card {
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.step-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.22;
}

.step-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.48;
}

.guide-block .button-grid,
.matcher-block .button-grid {
  margin-top: 8px;
}

.face-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.face-tabs button {
  height: 31px;
  min-height: 31px;
  padding: 0;
}

.face-grid {
  --grid-size: 3;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 252px;
}

.face-grid button {
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border-color: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.20), inset 0 -10px 16px rgba(0, 0, 0, 0.18);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.swatches button {
  position: relative;
  height: 32px;
  min-height: 32px;
  padding: 0;
  overflow: hidden;
  color: transparent;
}

.swatches button::after {
  content: attr(data-label);
  position: absolute;
  inset: auto 0 0;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.82);
  font-size: 9px;
  font-weight: 850;
  background: rgba(255, 255, 255, 0.48);
}

.status {
  position: fixed;
  z-index: 6;
  left: 16px;
  bottom: 16px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 14, 12, 0.72);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(12px);
}

.status.busy {
  border-color: rgba(47, 182, 128, 0.62);
  color: #dff8ed;
}

@media (min-width: 761px) {
  .stage {
    right: 410px;
  }

  .status {
    max-width: min(520px, calc(100vw - 438px));
  }
}

@media (max-width: 760px) {
  .stage {
    inset: 0 0 calc(var(--mobile-panel-height) + var(--mobile-status-space)) 0;
  }

  .control-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: var(--mobile-panel-height);
    padding: 12px;
  }

  .brand {
    align-items: center;
    padding-bottom: 10px;
  }

  h1 {
    font-size: 15px;
  }

  .control-block {
    padding-top: 11px;
  }

  .button-grid,
  .button-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .face-grid {
    max-height: 210px;
  }

  .status {
    left: 8px;
    right: 8px;
    bottom: calc(var(--mobile-panel-height) + 14px);
    max-width: none;
    text-align: center;
  }
}

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

  .face-tabs,
  .swatches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-pill {
    min-width: 54px;
  }
}
