:root {
  --bg: #0f172a;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --danger: #fb7185;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.25), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.2), transparent 30rem),
    var(--bg);
}

button, input, select, textarea { font: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .78rem;
}

h1, h2 { margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 4rem); line-height: 1; }
h2 { font-size: 1.25rem; margin-bottom: 18px; }
.subtitle { color: var(--muted); font-size: 1.1rem; margin: 12px 0 0; }

.badge {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 10px 14px;
  border-radius: 999px;
  color: #bae6fd;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-btn, button {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); background: var(--panel-strong); }
button:disabled { opacity: .45; cursor: not-allowed; }
.tab-btn.active { background: rgba(56, 189, 248, 0.2); border-color: rgba(56, 189, 248, .55); }
.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #00111f; font-weight: 800; }
.ghost { background: rgba(255,255,255,.06); }
.danger { background: rgba(251, 113, 133, .15); border-color: rgba(251, 113, 133, .5); color: #fecdd3; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid { display: grid; gap: 18px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

label { display: block; color: #dbeafe; margin: 14px 0 7px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .74);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(56, 189, 248, .7); }
textarea { min-height: 112px; resize: vertical; margin-top: 16px; }

.dynamic-fields { margin-top: 10px; }
.advanced { margin-top: 18px; }
.advanced summary { cursor: pointer; color: #bae6fd; font-weight: 700; }
.advanced-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.actions.center { justify-content: center; }

.preview-card { text-align: center; }
.qr-box {
  width: min(100%, 340px);
  min-height: 320px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.88);
  border-radius: 24px;
  padding: 22px;
}
.qr-box img, .qr-box canvas { max-width: 100%; height: auto; border-radius: 10px; }
.muted { color: var(--muted); }

.reader {
  min-height: 320px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px dashed var(--border);
  background: rgba(15, 23, 42, .55);
}

.file-label {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed rgba(56, 189, 248, .6);
  border-radius: 22px;
  color: #bae6fd;
  background: rgba(56, 189, 248, .08);
  cursor: pointer;
}
#imageInput { display: none; }
.result-title { margin-top: 24px; }
.result-box {
  min-height: 116px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .65);
  word-break: break-word;
  text-align: left;
  white-space: pre-wrap;
}

.history-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.history-list { display: grid; gap: 12px; margin-top: 18px; }
.history-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .55);
}
.history-item small { color: var(--muted); display: block; margin-bottom: 6px; }
.history-item p { margin: 0; word-break: break-word; }

@media (max-width: 850px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .two-cols { grid-template-columns: 1fr; }
  .advanced-grid { grid-template-columns: 1fr; }
  .qr-box { min-height: 260px; }
}
