:root {
  color-scheme: light;
  --bg: #f5efe3;
  --bg-accent: #efe2be;
  --panel: rgba(255, 251, 242, 0.85);
  --panel-border: rgba(73, 48, 24, 0.12);
  --text: #24160f;
  --muted: #6f5a4b;
  --primary: #0d7a64;
  --primary-dark: #085746;
  --warn: #9c5a17;
  --shadow: 0 18px 60px rgba(68, 44, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 32%),
    radial-gradient(circle at bottom right, rgba(13, 122, 100, 0.15), transparent 25%),
    linear-gradient(145deg, var(--bg), var(--bg-accent));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(36, 22, 15, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 22, 15, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero {
  max-width: 760px;
  margin-bottom: 1.75rem;
  animation: rise 500ms ease-out both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.8rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(36, 22, 15, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.05em;
}

.subtitle {
  max-width: 640px;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) minmax(320px, 420px);
  gap: 1rem;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.35), transparent 35%);
}

.controls,
.output {
  padding: 1.25rem;
}

.control-group + .control-group {
  margin-top: 1rem;
}

label,
.status-label,
.output-header h2 {
  display: block;
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="file"] {
  width: 100%;
  padding: 0.9rem;
  border: 1px dashed rgba(36, 22, 15, 0.25);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font: inherit;
}

.hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.camera-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.camera-actions .capture-full {
  grid-column: 1 / -1;
  padding-top: 1.1rem;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease;
  box-shadow: 0 14px 30px rgba(13, 122, 100, 0.22);
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.status-card {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(36, 22, 15, 0.05);
}

.status-text {
  margin: 0 0 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 22, 15, 0.08);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e39a34, var(--primary));
  transition: width 180ms ease;
}

.meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.viewer {
  min-height: 540px;
  padding: 1rem;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 508px;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(178, 116, 40, 0.08), rgba(156, 90, 23, 0.1)),
    rgba(255, 255, 255, 0.58);

}

#cameraPreview,
#imagePreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 18px;
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.output {
  display: flex;
  flex-direction: column;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.output-header h2 {
  margin: 0;
}

.output-header button {
  min-width: 120px;
  padding: 0.8rem 0.95rem;
}

textarea {
  min-height: 410px;
  resize: vertical;
  border: 1px solid rgba(36, 22, 15, 0.12);
  border-radius: 22px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.96rem;
  line-height: 1.55;
}

.output .status-card {
  margin-top: 1rem;
}

.engine-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.engine-btn {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.75rem;
  border: 2px solid rgba(36, 22, 15, 0.15);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 180ms ease;
}

.engine-btn:hover {
  border-color: var(--primary);
  background: rgba(13, 122, 100, 0.08);
}

.engine-btn.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(13, 122, 100, 0.15), rgba(13, 122, 100, 0.05));
  box-shadow: 0 4px 12px rgba(13, 122, 100, 0.2);
}

.engine-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(36, 22, 15, 0.08);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.engine-btn.active .engine-badge {
  background: var(--primary);
  color: white;
}

.engine-info {
  margin-top: 1rem;
}

.engine-card {
  padding: 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(36, 22, 15, 0.1);
  min-height: 150px;
  margin-bottom: 15px;
}

.engine-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.engine-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

textarea:focus,
input:focus,
button:focus {
  outline: 2px solid rgba(13, 122, 100, 0.22);
  outline-offset: 3px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .viewer {
    min-height: 420px;
  }

  .preview-frame {
    min-height: 380px;
  }

  textarea {
    min-height: 320px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  .hero h1 {
    line-height: 1;
  }

  .panel,
  .preview-frame,
  textarea,
  input[type="file"] {
    border-radius: 20px;
  }
}
