/* ===================================================================
   QR Code Generator — Tomato + LCD device aesthetic.
   The form is on cream; the QR preview is on a tomato-red plastic bezel
   wrapping a near-black LCD frame with a cream screen inside.
   =================================================================== */

:root {
  --bg:           #faf6f1;
  --bg-2:         #f3eee5;
  --surface:      #ffffff;
  --surface-2:    #faf6ed;
  --surface-3:    #eee7d8;
  --border:       #e8dfcc;
  --border-soft:  #f0e9da;
  --text:         #1f1a14;
  --text-2:       #5c5547;
  --text-3:       #6e6557;
  --text-faint:   #b5ac9b;

  --accent:       #e85f4d;
  --accent-2:     #d44a39;
  --accent-3:     #b8392b;
  --accent-soft:  rgba(232, 95, 77, 0.10);
  --accent-glow:  rgba(232, 95, 77, 0.30);

  --tomato-from:  #ff6b4a;
  --tomato-to:    #e85f4d;
  --sage:         #5eb985;
  --sage-soft:    rgba(94, 185, 133, 0.14);

  /* LCD device */
  --lcd-bezel:    #e85f4d;       /* tomato plastic outer */
  --lcd-bezel-2:  #c0382a;       /* shadow side */
  --lcd-frame:    #1f1a14;       /* warm near-black inner frame */
  --lcd-screen:   #faf6f1;       /* cream screen */
  --lcd-screen-glow: rgba(255, 240, 200, 0.18);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { color: var(--accent); background: var(--surface-2); }

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { border-color: var(--accent); }
.lang-switcher:focus:not(:focus-visible) { outline: none; }

.page-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ============ Tabs ============ */
.tabs-wrap {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin: 0 auto 32px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  text-align: center;
  padding-bottom: 4px;
}
.tabs-wrap::-webkit-scrollbar { height: 6px; }
.tabs-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
.tab {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.tab:hover { color: var(--accent); }
.tab-active {
  background: linear-gradient(180deg, var(--tomato-from) 0%, var(--tomato-to) 100%);
  color: #fff;
  box-shadow:
    0 2px 6px rgba(232, 95, 77, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.tab-active:hover { color: #fff; }

/* ============ Workspace ============ */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
  margin-bottom: 56px;
}
@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; gap: 28px; }
}

/* ============ Form area ============ */
.form-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-sm);
}

.panel { display: block; }
.panel[hidden] { display: none; }

.field {
  display: block;
  margin-bottom: 16px;
}
.field-group {
  border: none;
  padding: 0;
}
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:focus:not(:focus-visible) { outline: none; }
.textarea { resize: vertical; min-height: 110px; font-family: var(--font-mono); font-size: 14px; line-height: 1.5; }

/* Password field with toggle */
.password-wrap {
  position: relative;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: var(--r-sm);
  transition: color var(--transition), background var(--transition);
}
.password-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.password-toggle.is-on { color: var(--accent); }

/* Radio + Checkbox */
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.radio {
  flex: 1 1 auto;
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}
.radio input { position: absolute; opacity: 0; pointer-events: none; }
.radio:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
}
.radio:hover { border-color: var(--text-3); }

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  margin-top: 4px;
}
.checkbox-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ============ LCD device ============ */
.device {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Outer tomato plastic bezel */
.device-bezel {
  position: relative;
  padding: 22px;
  background: linear-gradient(160deg, var(--tomato-from) 0%, var(--tomato-to) 60%, var(--lcd-bezel-2) 100%);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(0, 0, 0, 0.10),
    0 12px 28px rgba(232, 95, 77, 0.30),
    0 32px 56px rgba(232, 95, 77, 0.16);
}
/* Subtle highlight strip on top of bezel */
.device-bezel::before {
  content: "";
  position: absolute;
  top: 6px; left: 8%; right: 8%;
  height: 14%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent);
  border-radius: 999px;
  pointer-events: none;
}

/* Inner near-black frame around the LCD screen */
.device-screen-frame {
  position: relative;
  background: var(--lcd-frame);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.25);
}

/* LCD-style status bar above the cream screen */
.device-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #f3eee5;
  text-transform: uppercase;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 6px rgba(94, 185, 133, 0.7);
  transition: background var(--transition), box-shadow var(--transition);
}
.status-dot.is-encoding {
  background: #f7c948;
  box-shadow: 0 0 6px rgba(247, 201, 72, 0.7);
  animation: pulse 700ms infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* The cream screen itself */
.device-screen {
  position: relative;
  width: 320px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--lcd-screen);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.10),
    inset 0 2px 12px rgba(0, 0, 0, 0.08);
}
.device-screen::before {
  /* faint scanline / glow overlay */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 60% at 50% 35%, var(--lcd-screen-glow), transparent 70%);
  pointer-events: none;
}
@media (max-width: 360px) {
  .device-screen { width: 260px; }
}

#qr-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#qr-canvas.is-empty { visibility: hidden; }

.device-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  padding: 24px;
  pointer-events: none;
  font-style: italic;
}
.device-empty[hidden] { display: none; }

/* Privacy banner (WiFi tab) */
.privacy-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--sage-soft);
  border: 1px solid rgba(94, 185, 133, 0.32);
  border-radius: var(--r-pill);
  color: #2f7a55;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  max-width: 360px;
  line-height: 1.4;
}
.privacy-banner svg { flex-shrink: 0; color: #3a9d6f; }

/* Download button — tomato red, looks like a physical button */
.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--tomato-from) 0%, var(--tomato-to) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--r-pill);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 4px 10px rgba(232, 95, 77, 0.30);
  transition: transform 80ms ease-out, box-shadow var(--transition), filter var(--transition);
}
.btn-download:hover:not([disabled]) {
  filter: brightness(1.04);
}
.btn-download:active:not([disabled]) {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.20),
    inset 0 -1px 0 rgba(255, 255, 255, 0.10),
    0 1px 2px rgba(232, 95, 77, 0.30);
}
.btn-download[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* ============ Info section ============ */
.info {
  max-width: 760px;
  margin: 0 auto;
}
.info h2 {
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 24px 0 8px;
  color: var(--text);
}
.info h2:first-child { margin-top: 0; }
.info p {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 10px;
}
.info ul.bullet {
  margin: 8px 0 12px 18px;
}
.info ul.bullet li {
  list-style: disc;
  padding-left: 4px;
  margin-bottom: 6px;
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.65;
}
.info strong { color: var(--text); font-weight: 600; }

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
}
.related-grid li { margin: 0; }
.related-grid a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.related-grid a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232, 95, 77, 0.10);
  color: var(--text);
}
.related-grid small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 2px;
}

/* ============ Footer ============ */
.site-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }
