:root {
  --bg-top: #f6f0e7;
  --bg-bottom: #e7ddd0;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: rgba(255, 255, 255, 0.94);
  --surface-stroke: rgba(255, 255, 255, 0.58);
  --text: #262523;
  --muted: #686562;
  --primary: #2b3733;
  --accent: #ca7546;
  --shadow: rgba(31, 25, 22, 0.12);
  --panel-shadow: rgba(34, 28, 25, 0.09);
  --screen-max: 460px;
  --projection-padding: 22px;
  --safe-bottom: max(22px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
}

button,
input,
label {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.screen-editor {
  min-height: 100vh;
  padding: 24px 18px 28px;
}

.hero {
  max-width: var(--screen-max);
  margin: 0 auto 22px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2.1rem, 8vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  line-height: 1.5;
  font-size: 1rem;
}

.preview-card {
  max-width: var(--screen-max);
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--surface-stroke);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px var(--shadow);
}

.preview-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  overflow: hidden;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.8);
}

.preview-image {
  max-width: 78%;
  max-height: 292px;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 180ms ease;
  will-change: transform;
}

.empty-state {
  display: grid;
  gap: 12px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0;
  font-size: 1.18rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  line-height: 1.5;
}

.empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-size: 1.9rem;
  color: var(--accent);
  background: rgba(202, 117, 70, 0.11);
}

.scale-badge {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(22, 17, 15, 0.08);
}

.controls {
  margin-top: 18px;
}

.upload-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background 140ms ease;
}

.upload-button:active,
.action-button:active,
.floating-close:active {
  transform: scale(0.98);
}

.upload-button {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.editor-controls {
  margin-top: 18px;
  display: grid;
  gap: 18px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.control-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.control-value {
  font-size: 0.94rem;
  color: var(--muted);
}

.size-slider {
  width: 100%;
  accent-color: var(--accent);
}

.action-row {
  display: flex;
  gap: 12px;
}

.action-button {
  font-weight: 700;
}

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

.action-button-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
}

.screen-projection {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #fff;
}

.projection-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
}

.projection-image {
  display: block;
  width: min(90vw, 780px);
  max-height: 72vh;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
}

.floating-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 18px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(25, 24, 22, 0.06);
  color: var(--primary);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}

.projection-panel {
  position: absolute;
  left: 50%;
  bottom: var(--safe-bottom);
  width: min(358px, calc(100vw - 28px));
  padding: 10px 12px 11px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 252, 248, 0.8);
  backdrop-filter: blur(20px) saturate(135%);
  box-shadow:
    0 18px 40px rgba(34, 28, 25, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transform: translateX(-50%);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.projection-panel-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.control-row-compact {
  gap: 10px;
  flex: 0 0 auto;
}

.control-label-compact {
  font-size: 0.92rem;
}

.control-value-compact {
  font-size: 0.86rem;
}

.projection-slider-wrap {
  margin-top: 8px;
}

.projection-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.mini-action-button {
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(43, 55, 51, 0.07);
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background 140ms ease;
}

.mini-action-button:active {
  transform: scale(0.98);
}

.mini-action-button-accent {
  background: rgba(202, 117, 70, 0.14);
  color: #8f4f2d;
}

.projection-panel.hidden-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.floating-close.hidden-panel {
  opacity: 0;
  pointer-events: none;
}

.projection-hint {
  margin: 0;
  flex: 0 1 auto;
  text-align: right;
  font-size: 0.68rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--muted);
}

@media (min-width: 768px) {
  .screen-editor {
    display: grid;
    place-items: center;
    padding: 42px 24px;
  }

  .preview-card {
    width: min(100%, 460px);
  }
}
