:root {
  --color-bg: #F5F1E4;
  --color-surface: #FFFFFF;
  --color-text: #111111;
  --color-accent: #FFCC00;
  --color-accent-2: #FF3D8B;
  --color-divider: #111111;

  --color-neutral-100: #FFFFFF;
  --color-neutral-200: #F4F1E8;
  --color-neutral-300: #E8E4D6;
  --color-neutral-400: #111111;
  --color-neutral-500: #111111;
  --color-neutral-600: #55534B;
  --color-neutral-700: #33322C;
  --color-neutral-800: #1A1A16;
  --color-neutral-900: #0D0D0B;

  --color-accent-100: #FFF9DB;
  --color-accent-200: #FFF3B0;
  --color-accent-300: #FFE873;
  --color-accent-400: #FFDC58;
  --color-accent-500: #FFCC00;
  --color-accent-600: #E6B800;
  --color-accent-700: #B38F00;
  --color-accent-800: #806600;
  --color-accent-900: #4D3D00;

  --color-accent-2-100: #FFE3EE;
  --color-accent-2-200: #FFC2D9;
  --color-accent-2-300: #FF9EC4;
  --color-accent-2-400: #FF6FA6;
  --color-accent-2-500: #FF3D8B;
  --color-accent-2-600: #E01E6B;
  --color-accent-2-700: #B01555;
  --color-accent-2-800: #800F3D;
  --color-accent-2-900: #4D0925;

  --font-heading: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading-weight: 700;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 3px 3px 0 #111111;
  --shadow-md: 5px 5px 0 #111111;
  --shadow-lg: 8px 8px 0 #111111;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden; /* Strict single screen viewport - no window scrolling */
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
}

h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 var(--space-2); }

a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 2px solid var(--color-accent-2-500);
  transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
  color: var(--color-accent-2-600);
  border-color: var(--color-accent-600);
}

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--color-accent-2-500);
  outline-offset: 2px;
}
::selection {
  background: var(--color-accent-400);
  color: var(--color-text);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: #111111;
  border-radius: 5px;
  border: 2px solid var(--color-bg);
}
::-webkit-scrollbar-track { background: transparent; }

/* Main App Container - Fits viewport height exactly */
.app-container {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 40px 14px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

/* Header */
.main-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 4px solid var(--color-text);
  flex: 0 0 auto;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.wr-badge {
  display: inline-flex;
  align-self: flex-start;
  font-family: var(--font-heading);
  font-size: 13.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  font-weight: 800;
  background: var(--color-accent-400);
  border: 2.5px solid var(--color-text);
  border-radius: 5px;
  padding: 5px 12px;
  box-shadow: 3px 3px 0 #111111;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.wr-badge::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 45%; height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.9) 45%, transparent 80%);
  transform: skewX(-18deg);
  animation: wr-shimmer 3.6s cubic-bezier(.4,0,.2,1) infinite;
}

@keyframes wr-shimmer {
  0%   { left: -60%; }
  38%  { left: 130%; }
  100% { left: 130%; }
}

#projectTitle {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-pill {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--color-text);
  font-weight: 800;
  flex: 0 0 auto;
  background: var(--color-accent-2-300);
  border: 2px solid var(--color-text);
  border-radius: 20px;
  padding: 4px 14px;
  box-shadow: 2px 2px 0 #111111;
  text-align: center;
  position: relative;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.header-pill:hover {
  background: var(--color-accent-2-400);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #111111;
  color: var(--color-text);
}

/* Pocket Bird Perch Line */
#birbPerchLine {
  width: 100%;
  height: 0;
  position: relative;
  flex: 0 0 auto;
}

/* Main Grid Shell - Scaled up by 50% */
.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  max-width: 1420px;
  width: 100%;
  margin: auto auto; /* Centered nicely between header and footer */
  gap: 38px;
  align-items: stretch;
  min-height: 0;
  box-sizing: border-box;
}


/* Cards & Sections */
.panel-card {
  border: 4px solid var(--color-text);
  border-radius: 12px;
  padding: 30px 34px;
  background: var(--color-surface);
  box-shadow: 7px 7px 0 #111111;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 20px;
  min-height: 0;
  box-sizing: border-box;
}

.panel-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text);
}

/* Inputs */
.input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--color-text);
  caret-color: var(--color-accent-2-500);
  background: var(--color-surface);
  border: 3px solid var(--color-text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .12s ease, transform .12s ease, border-color .12s ease;
}

.input:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #111111;
}

.input:focus-visible {
  outline: none;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--color-accent-2-500);
}

textarea.input {
  min-height: 140px;
  height: 180px;
  resize: none;
  line-height: 1.5;
  font-size: 15px;
  padding: 12px 14px;
}
/* Segmented Options Grid */
.segment-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.segment-btn {
  position: relative;
  background: var(--color-surface);
  color: var(--color-text);
  border: 3px solid var(--color-text);
  border-radius: var(--radius-sm);
  padding: 11px 6px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.recommended-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent-400);
  color: var(--color-text);
  border: 2px solid var(--color-text);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-heading);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 1.5px 1.5px 0 #111111;
  pointer-events: none;
  line-height: 1.25;
  z-index: 2;
}

.segment-btn:hover .recommended-badge {
  background: var(--color-accent-500);
}

.segment-btn.active .recommended-badge {
  background: var(--color-accent-300);
  box-shadow: 1.5px 1.5px 0 var(--color-accent-2-500);
}

.segment-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #111111;
  background: var(--color-neutral-200);
}

.segment-btn.active {
  background: var(--color-text);
  color: #FFFFFF;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--color-accent-2-500);
}

/* Custom Size Box - Only visible when custom resolution is selected */
.custom-box {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--color-accent-100);
  border: 3px solid var(--color-text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  margin-top: 2px;
}

.custom-box.visible {
  display: flex;
  animation: note-slide-in 0.2s ease-out;
}

.custom-box .field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.custom-box input.input {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 600;
  border: 2.5px solid var(--color-text);
  background: #FFFFFF;
}

/* Limit Notice when dimension < 256 px or > 2048 px */
.custom-limit-msg {
  display: none;
  align-items: center;
  gap: 7px;
  background: #FFF1F0;
  color: #B91C1C;
  border: 2px solid #B91C1C;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 2px 2px 0 #111111;
  margin-top: 2px;
}

.custom-limit-msg.visible {
  display: flex;
  animation: note-slide-in 0.18s ease-out;
}

.input.input-limit-exceeded {
  border-color: #B91C1C !important;
  color: #B91C1C;
}

.input.input-limit-exceeded:focus-visible {
  box-shadow: 4px 4px 0 #B91C1C !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 14.5px;
  line-height: 1.2;
  color: var(--color-text);
  background: var(--color-surface);
  border: 3px solid var(--color-text);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.btn svg {
  display: block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  transition: transform .15s ease;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 #111111;
}

.btn:hover svg {
  transform: scale(1.12) rotate(-6deg);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #111111;
}

.btn-primary {
  background: var(--color-accent-400);
  color: var(--color-text);
}

.btn-primary:hover {
  background: var(--color-accent-500);
}

.btn-secondary {
  background: var(--color-surface);
}

.btn-secondary:hover {
  background: var(--color-neutral-200);
}

.btn-ghost {
  background: var(--color-accent-2-300);
  border-width: 3px;
  padding: 13px 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  flex: 0 0 auto;
  font-size: 14.5px;
}

.btn-ghost:hover {
  background: var(--color-accent-2-400);
}

.buttons-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 0 0 auto;
}

/* QR Code Preview Box - Scaled up by 50% */
.preview-wrap {
  width: 100%;
  background: var(--color-neutral-100);
  border: 3.5px solid var(--color-text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
}

.preview-stage {
  padding: 22px;
  background: #FFFFFF;
  border: 3px solid var(--color-text);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 268px;
  height: 268px;
  max-width: 100%;
  box-sizing: border-box;
}

#qr {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 6px;
}

.meta-pill {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-accent-2-300);
  border: 2px solid var(--color-text);
  border-radius: 14px;
  padding: 3px 10px;
  box-shadow: 2px 2px 0 #111111;
  z-index: 2;
}
/* Status Pop */
#statusMsg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-accent-300);
  border: 2px solid var(--color-text);
  border-radius: 4px;
  padding: 3px 8px;
  box-shadow: 2px 2px 0 #111111;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#statusMsg.status-pop {
  opacity: 1;
  animation: status-pop-in 0.3s ease-out;
}

/* Animations */
@keyframes note-slide-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes status-pop-in {
  0%   { opacity: 0; transform: translateY(5px) scale(0.9); }
  55%  { opacity: 1; transform: translateY(-2px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes bump-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.2) rotate(-3deg); }
  60%  { transform: scale(0.95) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}

.count-bump {
  animation: bump-pop 0.35s cubic-bezier(.22,.68,.31,1.3);
}

/* Footer - Pinned neatly to bottom */
.main-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 12px;
  border-top: 3px solid var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--color-neutral-700);
}

.footer-tagline {
  font-weight: 600;
}

/* Responsive Mobile & Tablet Rules */
@media (max-width: 768px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
  }

  .app-container {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: none;
    padding: 14px 16px 24px;
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
  }

  .main-header {
    padding-bottom: 10px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
  }

  .header-left {
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .wr-badge {
    font-size: 11.5px;
    padding: 3.5px 9px;
    border-radius: 4px;
  }

  #projectTitle {
    font-size: clamp(15px, 4.4vw, 20px);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .header-pill {
    font-size: 11.5px;
    padding: 3.5px 10px;
    white-space: nowrap;
    align-self: flex-end;
    margin-bottom: 2px;
    flex-shrink: 0;
  }

  /* Bird Perch Wire */
  #birbPerchLine {
    width: 100%;
    flex: 0 0 auto;
  }

  /* Stacked single-column card layout */
  .app-shell {
    display: flex;
    flex-direction: column;
    max-width: 560px;
    width: 100%;
    margin: 16px auto 0;
    gap: 20px;
    align-items: stretch;
  }

  .panel-card {
    width: 100%;
    border: 3.5px solid var(--color-text);
    border-radius: 10px;
    padding: 20px 18px;
    box-shadow: 5px 5px 0 #111111;
    gap: 16px;
    box-sizing: border-box;
  }

  .panel-title {
    font-size: 18px;
  }

  .field-label {
    font-size: 13px;
  }

  .input {
    font-size: 16px; /* Prevents iOS auto-zoom on input focus */
    min-height: 40px;
    padding: 8px 12px;
  }

  textarea.input {
    min-height: 110px;
    height: 130px;
    font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 10px 12px;
  }

  /* Segment grid */
  .segment-grid {
    gap: 6px;
  }

  .segment-btn {
    padding: 10px 4px;
    font-size: 13px;
    min-height: 42px;
  }

  /* Custom size box */
  .custom-box {
    padding: 10px 12px;
  }

  .custom-box input.input {
    min-height: 40px;
    font-size: 16px;
  }

  .custom-limit-msg {
    font-size: 11.5px;
  }

  /* Preview Wrap */
  .preview-wrap {
    padding: 16px 12px;
  }

  .preview-stage {
    width: 220px;
    height: 220px;
    max-width: 100%;
    padding: 16px;
    border-radius: 8px;
  }

  /* Action buttons */
  .buttons-row {
    gap: 10px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 13.5px;
    min-height: 46px; /* Optimal touch target */
  }

  .btn-ghost {
    padding: 11px 16px;
    font-size: 13.5px;
    min-height: 46px;
  }

  /* Footer */
  .main-footer {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 6px;
    margin-top: 14px;
    padding-top: 10px;
  }

  .footer-tagline {
    font-size: 11.5px;
  }
}

/* Extra small mobile adjustments (phones <= 420px) */
@media (max-width: 420px) {
  .app-container {
    padding: 12px 12px 20px;
  }

  .panel-card {
    padding: 16px 14px;
    border-width: 3px;
    box-shadow: 4px 4px 0 #111111;
  }

  #projectTitle {
    font-size: clamp(14px, 4.2vw, 17px);
    white-space: nowrap;
  }

  /* 2x2 grid for size options so text is never cramped */
  .segment-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    row-gap: 14px;
  }

  /* Stack download buttons on very narrow screens */
  .buttons-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .preview-stage {
    width: 196px;
    height: 196px;
    padding: 14px;
    border-radius: 8px;
  }
}

/* Compact Height Optimization for smaller laptop displays (e.g. 1366x768) */
@media (min-width: 769px) and (max-height: 820px) {
  .app-container {
    padding: 12px 32px 10px;
  }
  .main-header {
    padding-bottom: 10px;
  }
  #projectTitle {
    font-size: 24px;
  }
  .wr-badge {
    font-size: 12px;
    padding: 3.5px 9px;
  }
  .app-shell {
    max-width: 1160px;
    gap: 24px;
  }
  .panel-card {
    padding: 20px 24px;
    gap: 14px;
  }
  textarea.input {
    min-height: 100px;
    height: 120px;
  }
  .preview-wrap {
    padding: 16px;
  }
  .preview-stage {
    width: 200px;
    height: 200px;
    padding: 14px;
    border-radius: 8px;
  }
  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  .btn-ghost {
    padding: 9px 16px;
    font-size: 13px;
  }
  .main-footer {
    padding-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wr-badge::after { animation: none; }
  .btn, .btn svg, .segment-btn { transition: none; }
  #statusMsg.status-pop { animation: none; }
  .count-bump, .custom-box, .custom-limit-msg { animation: none; }
}
