:root {
  --bg: #f5f5f5;
  --bg-panel: #ffffff;
  --border-subtle: #e5e7eb;
  --accent: rgb(27, 94, 32);
  --accent-soft: rgba(27, 94, 32, 0.06);
  --text: #111827;
  --text-muted: #6b7280;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e0edff 0, #f9fafb 42%, #ffffff 100%);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app__header {
  padding: 24px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.app__logo {
  height: 52px;
  width: auto;
  object-fit: contain;
}

.app__header-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.app__header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.app__header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.app__main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 12px 6vw 32px;
}

.panel--left {
  width: min(100%, 540px);
}

.panel {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 22px 22px 18px;
  position: relative;
}

.panel--right {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.panel--right.panel--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(27, 94, 32, 0.8), rgba(67, 160, 71, 0.8));
}

.panel h2 {
  margin-top: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  font-size: 13px;
}

.field--inline {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.field__label {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.field input[type="text"],
.field input[type="url"] {
  min-height: 38px;
}

.field__input {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

.field__input--textarea,
.field textarea {
  border-radius: 12px;
  min-height: 80px;
  resize: vertical;
}

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5);
}

.field__options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
}

.field__options label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}

.field__options label:hover {
  background: #e5edff;
  transform: translateY(-1px);
}

.field__options label:has(input:checked) {
  background: linear-gradient(135deg, rgb(27, 94, 32) 30%, rgb(67, 160, 71) 90%);
  border-color: transparent;
  color: #ffffff;
}

.field__hint {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.field--hidden {
  display: none;
}

.field--invalid .field__input,
.field--invalid input,
.field--invalid textarea,
.field--invalid select {
  border-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

input[type="range"] {
  width: 100%;
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: rgb(27, 94, 32);
}

input[type="color"] {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  width: 46px;
  height: 32px;
  padding: 0;
  cursor: pointer;
}

.field__select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #9ca3af 50%),
    linear-gradient(135deg, #9ca3af 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.form-error {
  margin-top: 8px;
  min-height: 16px;
  font-size: 12px;
  color: #b91c1c;
}

.upload-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.9);
  background: #f9fafb;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.upload-box__icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgb(27, 94, 32) 30%, rgb(67, 160, 71) 90%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.upload-box__text {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.upload-box__text strong {
  font-weight: 600;
}

.upload-box__text span {
  color: var(--text-muted);
}

.upload-box:hover {
  background: #eef2ff;
  border-color: rgb(27, 94, 32);
  transform: translateY(-1px);
}

.upload-box__input {
  display: none;
}

.upload-box__meta {
  margin-top: 6px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.upload-box__filename {
  color: var(--text-muted);
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.btn--subtle {
  border-color: transparent;
  background: transparent;
  color: rgb(27, 94, 32);
}

.btn.btn--small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn--secondary {
  border-color: rgb(27, 94, 32);
  color: rgb(27, 94, 32);
  background: #ffffff;
}

.btn--secondary:hover {
  background: rgba(27, 94, 32, 0.06);
}

.btn--download {
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.btn--share {
  border-style: dashed;
  opacity: 0.9;
}

.btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #ffffff;
  color: var(--text);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.btn--primary {
  background: linear-gradient(135deg, rgb(27, 94, 32) 30%, rgb(67, 160, 71) 90%);
  border-color: transparent;
  color: #ffffff;
}

.btn:hover {
  transform: translateY(-1px);
  background-color: #f3f4f6;
}

.btn--primary:hover {
  filter: brightness(1.05);
}

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

.actions--preview {
  margin-top: 14px;
  display: none;
}

.actions--preview.actions--preview--visible {
  display: flex;
}

.actions--modal {
  margin-top: 16px;
  justify-content: center;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal--open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px 16px 18px;
  width: min(94vw, 420px);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
}

.modal__title {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal__preview {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.modal__preview img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 600px) {
  .modal {
    align-items: center;
  }

  .modal__dialog {
    width: min(94vw, 420px);
    border-radius: 16px;
    padding: 24px 20px 32px;
    transform: none;
    transition: none;
  }

  .modal--open .modal__dialog {
    transform: none;
  }

  .modal__close {
    top: 14px;
    right: 14px;
    padding: 10px;
    font-size: 22px;
  }
}


.modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

@media (min-width: 601px) {

  /* Allow modal behavior on desktop */
  .modal__dialog {
    width: min(94vw, 500px);
    /* Adjusted for better desktop view */
  }
}

.preview {
  position: relative;
  border-radius: var(--radius-md);
  padding: 14px;
  background: #ffffff;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 260px;
  gap: 16px;
}

#qrCanvas {
  max-width: 100%;
  height: auto;
  z-index: 1;
}

.preview__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.preview--active .preview__placeholder {
  display: none;
}

.preview__iframe-container {
  width: 100%;
  height: 320px;
  background: #f9fafb;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.preview__iframe-header {
  height: 32px;
  background: #f3f4f6;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.preview__iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

@media (max-width: 920px) {
  .app__main {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .app__header {
    flex-direction: column;
    text-align: center;
    padding: 12px 16px 2px;
    gap: 0;
  }

  .app__logo {
    align-self: center;
    margin-bottom: 2px;
    height: 42px;
  }

  .app__header h1 {
    font-size: 22px;
  }

  .app__header p {
    font-size: 12px;
  }

  .app__main {
    padding: 8px 12px 120px;
    /* Increased bottom padding for keyboard clearance */
    gap: 12px;
  }

  .panel {
    padding: 14px 12px 24px;
    border-radius: 14px;
  }

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

  .actions .btn,
  .actions--preview .btn,
  .actions--modal .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Scroll to top button */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgb(27, 94, 32) 30%, rgb(67, 160, 71) 90%);
  color: #ffffff;
  border: none;
  box-shadow: 0 10px 25px rgba(27, 94, 32, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
  z-index: 100;
  transform: translateY(16px);
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(27, 94, 32, 0.4);
  filter: brightness(1.1);
}

.scroll-top-btn:active {
  transform: translateY(-2px);
}

.powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.powered-by:hover {
  opacity: 1;
}

.powered-by img {
  height: 18px;
  width: auto;
  object-fit: contain;
}

.powered-by--inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.powered-by--inline img {
  height: 14px;
}