:root {
  color-scheme: light;

  --bg-a: #f4fbff;
  --bg-b: #fff4ec;
  --ink-1: #151b35;
  --ink-2: #596087;
  --card: rgba(255, 255, 255, 0.86);
  --card-strong: #ffffff;
  --line: #d9e1fb;
  --line-strong: #c4d0f2;
  --accent-1: #03a9f4;
  --accent-2: #ff5f6d;
  --accent-3: #7c4dff;
  --focus-ring: 0 0 0 3px rgba(3, 169, 244, 0.24);
  --shadow-card: 0 20px 50px rgba(34, 73, 181, 0.16);
  --shadow-soft: 0 12px 26px rgba(52, 86, 176, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Manrope, ui-sans-serif, system-ui;
  color: var(--ink-1);
  background:
    radial-gradient(circle at 6% 4%, rgba(3, 169, 244, 0.24), transparent 30%),
    radial-gradient(circle at 94% 8%, rgba(255, 95, 109, 0.18), transparent 28%),
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  overflow-x: clip;
}

.app-shell-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% 1%, rgba(124, 77, 255, 0.12), transparent 32%),
    radial-gradient(circle at 0% 80%, rgba(3, 169, 244, 0.1), transparent 34%);
}

.app-main {
  position: relative;
  width: min(100%, 930px);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 0.9rem max(1rem, env(safe-area-inset-bottom));
}

.app-header {
  margin-bottom: 1rem;
  padding: 0.3rem 0.2rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #d4dbff;
  background: linear-gradient(135deg, #eefbff, #fff2f4);
  color: #2f3f9e;
  padding: 0.22rem 0.72rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-layout {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.app-preview,
.app-export,
.app-controls {
  width: 100%;
}

.control-card {
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
  padding: 0.95rem;
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink-1);
}

.field-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-2);
}

.field-value {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.72rem;
  color: #727ba6;
}

.hint-text {
  margin-top: 0.35rem;
  font-size: 0.68rem;
  color: #7d83aa;
}

.preview-stage-wrap {
  display: grid;
  place-items: center;
  min-height: 390px;
  border-radius: 1rem;
  border: 1px solid #d5dff8;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(241, 248, 255, 0.92)),
    linear-gradient(35deg, rgba(3, 169, 244, 0.06), rgba(255, 95, 109, 0.05));
  padding: 1rem;
}

.qr-stage {
  inline-size: 100%;
  min-block-size: 300px;
  display: grid;
  place-items: center;
}

.qr-stage > * {
  margin: 0 auto !important;
  display: grid !important;
  place-items: center;
}

.qr-stage canvas,
.qr-stage svg {
  width: min(100%, 390px) !important;
  max-width: 100% !important;
  height: auto;
  display: block;
  margin: 0 auto !important;
}

.text-input,
.select-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0.84rem;
  background: var(--card-strong);
  color: var(--ink-1);
  font-size: 0.875rem;
  line-height: 1.3rem;
  padding: 0.58rem 0.72rem;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea.text-input {
  min-height: 88px;
  resize: vertical;
}

.text-input:focus,
.select-input:focus {
  border-color: var(--accent-1);
  box-shadow: var(--focus-ring);
}

.select-shell {
  position: relative;
}

.select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.3rem;
  cursor: pointer;
}

.select-input:disabled {
  cursor: not-allowed;
  background: #f5f8ff;
}

.select-chevron {
  position: absolute;
  right: 0.86rem;
  top: 50%;
  transform: translateY(-50%);
  color: #5c67a8;
  pointer-events: none;
  font-weight: 800;
  font-size: 0.95rem;
}

.range-input {
  width: 100%;
  accent-color: var(--accent-3);
}

.file-input {
  display: block;
  width: 100%;
  cursor: pointer;
  border-radius: 0.84rem;
  border: 1px solid var(--line-strong);
  background: var(--card-strong);
  color: #2f3f66;
  padding: 0.5rem 0.58rem;
  font-size: 0.85rem;
}

.file-input::file-selector-button {
  margin-right: 0.55rem;
  border: none;
  border-radius: 0.6rem;
  background: linear-gradient(120deg, #e8f8ff, #f0e9ff);
  color: #3255b7;
  padding: 0.35rem 0.56rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.color-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.color-row .text-input {
  min-width: 0;
}

.color-input {
  width: 54px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 0.84rem;
  background: #ffffff;
  cursor: pointer;
  padding: 0.22rem;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    var(--shadow-soft);
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 0.66rem;
}

.color-input::-moz-color-swatch {
  border: none;
  border-radius: 0.66rem;
}

.btn-primary,
.btn-secondary {
  border-radius: 0.82rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.15;
  padding: 0.68rem 0.92rem;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent-1), var(--accent-3));
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(124, 77, 255, 0.25);
}

.btn-primary:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  border-color: var(--line-strong);
  background: var(--card-strong);
  color: var(--ink-2);
}

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

.btn-primary:disabled,
.btn-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  filter: none;
  transform: none;
  box-shadow: none;
}

.status-banner {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.status-info {
  border-color: #d5dcf5;
  background: #f5f8ff;
  color: #3f4a83;
}

.status-success {
  border-color: #9ce4f9;
  background: #ebfaff;
  color: #0f5f7d;
}

.status-error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

@media (min-width: 768px) {
  .app-main {
    padding-left: 1.15rem;
    padding-right: 1.15rem;
  }

  .app-layout {
    gap: 1.02rem;
  }
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }

  .app-main {
    padding-top: max(0.95rem, env(safe-area-inset-top));
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .app-main {
    padding-left: 0.62rem;
    padding-right: 0.62rem;
    padding-top: max(0.72rem, env(safe-area-inset-top));
    padding-bottom: max(0.78rem, env(safe-area-inset-bottom));
  }

  .app-header {
    margin-bottom: 0.72rem;
    padding: 0.15rem 0.05rem;
  }

  .app-header h1 {
    margin-top: 0.46rem;
    font-size: 1.35rem;
    line-height: 1.18;
  }

  .app-header p {
    margin-top: 0.45rem;
    font-size: 0.79rem;
    line-height: 1.3;
  }

  .badge-pill {
    font-size: 0.63rem;
    padding: 0.18rem 0.56rem;
  }

  .app-layout {
    gap: 0.72rem;
  }

  .control-card {
    border-radius: 0.92rem;
    padding: 0.74rem;
  }

  .section-title {
    margin-bottom: 0.58rem;
    font-size: 0.79rem;
  }

  .field-label {
    margin-bottom: 0.22rem;
    font-size: 0.69rem;
  }

  .field-value {
    font-size: 0.65rem;
  }

  .hint-text {
    margin-top: 0.28rem;
    font-size: 0.62rem;
    line-height: 1.2;
  }

  .text-input,
  .select-input {
    border-radius: 0.72rem;
    font-size: 0.82rem;
    line-height: 1.2rem;
    padding: 0.5rem 0.6rem;
  }

  .select-input {
    padding-right: 2.05rem;
  }

  .select-chevron {
    right: 0.76rem;
    font-size: 0.86rem;
  }

  textarea.text-input {
    min-height: 74px;
  }

  .file-input {
    border-radius: 0.72rem;
    padding: 0.44rem 0.5rem;
    font-size: 0.79rem;
  }

  .file-input::file-selector-button {
    border-radius: 0.5rem;
    margin-right: 0.43rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.67rem;
  }

  .preview-stage-wrap {
    min-height: 285px;
    border-radius: 0.9rem;
    padding: 0.62rem;
  }

  .qr-stage {
    min-block-size: 230px;
  }

  .qr-stage canvas,
  .qr-stage svg {
    width: min(100%, 265px) !important;
  }

  .color-row {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 0.42rem;
  }

  .color-input {
    width: 46px;
    height: 38px;
    border-radius: 0.72rem;
  }

  .color-input::-webkit-color-swatch,
  .color-input::-moz-color-swatch {
    border-radius: 0.56rem;
  }

  .btn-primary,
  .btn-secondary {
    border-radius: 0.72rem;
    font-size: 0.8rem;
    padding: 0.56rem 0.72rem;
  }

  .status-banner {
    border-radius: 0.72rem;
    padding: 0.58rem 0.68rem;
    font-size: 0.79rem;
  }
}
