:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-border: #e0e0e0;
  --text: #2c3e50;
  --muted: #7f8c8d;
  --accent: #3498db;
  --accent-strong: #2980b9;
  --danger: #e74c3c;
  --font-display: "Space Grotesk", "Chivo Mono", sans-serif;
  --font-body: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background: #ffffff;
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  font-size: 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  width: min(1200px, 90vw);
  margin: 0 auto;
  padding: 3rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.hero {
  width: 100%;
  margin: 0;
  padding: 3rem 0 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  position: relative;
  z-index: 2;
  border-top: 1px solid #e0e0e0;
  padding-top: 3.5rem;
}

.hero__content h2 {
  font-size: clamp(3.2rem, 5vw, 4.4rem);
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero__eyebrow {
  font-family: "Chivo Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

.hero__preview {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 1.5rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.hero__preview img {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 1rem;
}

.hero__tag {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid #d0d7de;
  background: #ffffff;
  font-size: 0.95rem;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  font-weight: 600;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  border: none;
}

.cta--ghost {
  background: transparent;
  border: 1px solid #d0d7de;
  color: var(--text);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin: 0;
}

.features article {
  background: #f8f9fa;
  border-radius: 1.2rem;
  border: 1px solid #e0e0e0;
  padding: 1.5rem;
}

.features h3 {
  margin-top: 0;
  font-size: 1.25rem;
  line-height: 1.4;
}

.studio header {
  margin-bottom: 2rem;
}

.studio h1,
.studio h2 {
  margin-top: 0.2rem;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.2;
}

.overline {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.85rem;
  color: var(--muted);
}

.studio--spotlight {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 1.5rem;
  padding: 2.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.studio__intro {
  max-width: 720px;
}

.studio__intro h1 {
  font-size: 125px;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.2rem;
}

.studio__url {
  color: var(--accent);
  font-size: 0.95rem;
  font-family: "Chivo Mono", monospace;
  margin: 0 0 1rem 0;
  opacity: 0.8;
}

.studio__subtext {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 540px;
  line-height: 1.7;
}

.studio__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.8rem;
  align-items: stretch;
  margin-top: 2rem;
}

.panel {
  background: #ffffff;
  border-radius: 1.3rem;
  border: 1px solid #e0e0e0;
  padding: 1.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

.panel--input {
  grid-column: span 2;
}

.panel--output canvas,
.panel--input canvas {
  margin-top: 1.2rem;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel__head h4 {
  margin: 0;
}

.panel__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.panel__hint {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.upload {
  border: 2px dashed #3498db;
  border-radius: 1.15rem;
  padding: 1.8rem;
  margin: 1.2rem 0;
  text-align: center;
  background: #f0f8ff;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
}

.upload:hover {
  border-color: #2980b9;
  background: #e3f2fd;
}

.upload__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 1.15rem;
}

.upload__label small {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 0.8rem;
  border: 1px solid #e0e0e0;
  background: #f5f5f5;
  position: relative;
}

canvas.empty {
  background: #f5f5f5;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.canvas-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #aaa;
  font-size: 0.95rem;
  pointer-events: none;
  text-align: center;
  display: none;
}

canvas.empty + .canvas-placeholder {
  display: block;
}

.code-field {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin: 1rem 0;
  padding: 0.75rem;
  border-radius: 0.9rem;
  border: 1px solid #e0e0e0;
  background: #f8f9fa;
  flex-wrap: wrap;
  max-width: 100%;
  box-sizing: border-box;
}

.progress {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.progress__bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #e0e0e0;
  position: relative;
}
.progress__bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  transition: width 0.15s ease;
}
.progress span {
  font-size: 0.95rem;
  color: var(--muted);
}

.code-field input {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: 1.4rem;
  border-radius: 0.6rem;
  border: 1px solid #d0d7de;
  background: #ffffff;
  color: var(--text);
  font-family: "Chivo Mono", monospace;
  text-align: center;
  box-sizing: border-box;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button.small {
  font-size: 0.95rem;
  border-radius: 999px;
  border: 1px solid #d0d7de;
  padding: 0.4rem 1.1rem;
  background: #ffffff;
  color: var(--text);
}

button.ghost {
  border: 1px solid #d0d7de;
  background: #ffffff;
  color: var(--text);
  padding: 0.5rem 1.2rem;
  border-radius: 0.6rem;
}

.actions .secondary {
  background: #f8f9fa;
  border: 1px solid #d0d7de;
  color: var(--text);
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.actions button {
  padding: 1rem 1.1rem;
  border-radius: 0.8rem;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-size: 1rem;
}

#distort-btn {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  border: none;
}

#recover-btn {
  border: none;
}

#reset-btn {
  border: 1px solid #d0d7de;
  background: #ffffff;
  color: var(--text);
}

.status {
  min-height: 2.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: 0.8rem;
  background: #f0f8ff;
  font-size: 1rem;
  color: var(--muted);
  border: 1px solid #d0e8ff;
}

.status.success {
  color: #27ae60;
  background: #e8f8f5;
  border-color: #a3e4d7;
}

.status.error {
  color: var(--danger);
  background: #ffebee;
  border-color: #ffcdd2;
}

.status.busy {
  color: var(--accent-strong);
  background: #e3f2fd;
  border-color: #bbdefb;
}

.download {
  width: 100%;
  padding: 1rem 1.1rem;
  border-radius: 0.8rem;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  margin-top: 0.8rem;
  font-weight: 600;
  font-size: 1rem;
}

.download:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 4rem;
  padding: 3rem;
  border-radius: 1.5rem;
  border: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.guide ol {
  padding-left: 1.2rem;
}

.guide li {
  margin-bottom: 0.8rem;
}

.checklist {
  background: #ffffff;
  border-radius: 1.2rem;
  border: 1px solid #e0e0e0;
  padding: 1.5rem;
}

.checklist ul {
  padding-left: 1.2rem;
}

footer {
  width: min(1200px, 92vw);
  margin: 0 auto 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--muted);
}

.orb {
  display: none;
}

/* Desktop Layout - 1024px and above */
@media (min-width: 1024px) {
  body {
    font-size: 17px;
  }

  main {
    width: min(1300px, 88vw);
    padding: 2rem 0 5rem;
  }

  .studio--spotlight {
    padding: 3.5rem;
  }

  .studio__intro {
    text-align: center;
    max-width: 100%;
    margin-bottom: 2rem;
  }

  .studio__intro h1 {
    font-size: 125px;
  }

  .studio__subtext {
    max-width: 100%;
    font-size: 1.3rem;
    margin: 0 auto;
  }

  .studio__grid {
    display: grid;
    grid-template-columns: 1fr 400px 1fr;
    grid-template-rows: auto;
    gap: 2rem;
    margin-top: 3rem;
  }

  .panel--input {
    grid-column: 1;
    grid-row: 1;
  }

  .panel--controls {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
  }

  .panel--output {
    grid-column: 3;
    grid-row: 1;
  }

  .panel {
    padding: 2rem;
    min-height: 500px;
  }

  .panel--controls {
    justify-content: space-between;
  }

  .panel--controls .actions {
    margin-top: auto;
  }

  .hero {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    padding: 4rem 0 3rem;
    margin-top: 2rem;
  }

  .hero__content h2 {
    font-size: clamp(3.8rem, 6vw, 5.2rem);
  }

  .hero__preview {
    padding: 2.5rem;
  }

  .features {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }

  .code-field {
    flex-wrap: nowrap;
  }

  canvas {
    min-height: 300px;
  }
}

/* Tablet Layout - 721px to 1023px */
@media (min-width: 721px) and (max-width: 1023px) {
  .studio__grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  .panel--input {
    grid-column: span 2;
  }

  .panel--controls {
    grid-column: 1;
  }

  .panel--output {
    grid-column: 2;
  }
}

/* Mobile Layout - 720px and below */
@media (max-width: 720px) {
  .hero {
    padding-top: 2rem;
  }

  .hero__actions {
    flex-direction: column;
  }

  .panel {
    padding: 1.25rem;
  }

  .guide {
    padding: 2rem 1.2rem;
  }

  .panel--input {
    grid-column: span 1;
  }

  .studio__grid {
    grid-template-columns: 1fr;
  }

  .studio__intro h1 {
    font-size: 40px;
  }
}

/* ================= Sharing Modal Styles ================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal--visible {
  display: flex;
  opacity: 1;
}

.modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 10000;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 2px solid #e8eef4;
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: #ffffff;
  border-radius: 12px 12px 0 0;
}

.modal__header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
}

.modal__close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal__body {
  padding: 28px;
  color: #2c3e50;
}

.modal__intro {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.6;
  color: #34495e;
}

.modal__option {
  margin: 20px 0;
  padding: 16px;
  background: #f8f9fa;
  border-left: 4px solid #3498db;
  border-radius: 6px;
}

.modal__option h4 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  color: #2c3e50;
}

.modal__option ul {
  margin: 8px 0 0;
  padding-left: 20px;
  list-style: disc;
}

.modal__option li {
  margin: 6px 0;
  line-height: 1.6;
  color: #555;
  font-size: 14px;
}

.modal__option strong {
  color: #2c3e50;
  font-weight: 600;
}

.modal__warning {
  margin: 20px 0 0;
  padding: 14px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  color: #856404;
  font-size: 15px;
  line-height: 1.5;
}

.modal__footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 28px;
  border-top: 2px solid #e8eef4;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

.modal__btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Space Grotesk', sans-serif;
}

.modal__btn--secondary {
  background: #e8eef4;
  color: #2c3e50;
}

.modal__btn--secondary:hover {
  background: #d4dce6;
}

.modal__btn--primary {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.modal__btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}

@media (max-width: 720px) {
  .modal__content {
    width: 95%;
    max-height: 95vh;
  }

  .modal__header {
    padding: 20px;
  }

  .modal__header h3 {
    font-size: 18px;
  }

  .modal__body {
    padding: 20px;
  }

  .modal__option {
    padding: 12px;
  }

  .modal__option h4 {
    font-size: 15px;
  }

  .modal__option li {
    font-size: 13px;
  }

  .modal__footer {
    flex-direction: column;
    padding: 16px 20px;
  }

  .modal__btn {
    width: 100%;
    padding: 14px;
  }
}
