:root {
  --vs-purple: #68217A; /* VS brand purple */
  --vs-blue: #0078D4; /* VS blue */
  --vs-light-blue: #00BCF2;
  --vs-dark: #1F1F1F;
  --vs-light: #FFFFFF;
  --primary: var(--vs-blue);
  --secondary: var(--vs-purple);
  --accent: var(--vs-light-blue);
  --success: #2E8540; /* Green for success */
  --bg: var(--vs-light); /* Default light background */
  --bg-gradient: linear-gradient(135deg, #F6F6F6 0%, #FFFFFF 100%);
  --surface: #FFFFFF;
  --surface-elevated: #F9F9F9;
  --surface-glass: rgba(255, 255, 255, 0.95);
  --text: #000000;
  --text-muted: #5C5C5C;
  --text-secondary: #323232;
  --border: #E0E0E0;
  --border-accent: rgba(0, 120, 212, 0.2);
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
  --radius: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1F1F;
    --bg-gradient: linear-gradient(135deg, #1F1F1F 0%, #2D2D2D 100%);
    --surface: #2D2D2D;
    --surface-elevated: #3C3C3C;
    --surface-glass: rgba(45, 45, 45, 0.95);
    --text: #FFFFFF;
    --text-muted: #A6A6A6;
    --text-secondary: #D4D4D4;
    --border: #3C3C3C;
    --border-accent: rgba(0, 120, 212, 0.3);
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
}

body {
  height: auto;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: all 0.3s ease;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 1200px; /* Narrower for clean look */
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 0;
  position: relative;
}

.vs-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  display: block;
}

.header h1 {
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: var(--text);
  line-height: 1.2;
}

.header p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  flex: 1;
  margin-bottom: 3rem;
}

.grid.single {
  grid-template-columns: 1fr;
  max-width: 800px;
  margin: 0 auto 3rem auto;
}

.card,
.qr-box,
.result,
.copy-preview,
.copy-format-selector,
.generated {
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h3 {
  margin: 0 0 1rem 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card p {
  margin: 0 0 1.5rem 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  flex: 1;
}

.card .btn {
  margin-top: auto;
  align-self: flex-start;
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.3s ease;
  outline: none;
}

.input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

textarea {
  min-height: 150px;
  font-family: monospace;
  line-height: 1.5;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
  min-height: 40px;
  white-space: nowrap;
}

.btn:hover {
  background: darken(var(--primary), 10%);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-glass);
  color: var(--text);
}

.result {
  margin-top: 2rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  position: relative;
  overflow: hidden;
}

.generated {
  background: var(--surface-glass);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-all;
  overflow-x: auto;
  color: var(--text);
  position: relative;
}

.qr-wrap {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.qr-box {
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.info-section {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  position: relative;
}

.info-section h3 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--text);
  text-align: center;
  font-weight: 600;
}

.info-section .small {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.small {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  border-top: 1px solid var(--border);
  position: relative;
}

.footer p {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: darken(var(--primary), 10%);
}

/* Back link - plain link appearance */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  margin-top: 2rem;
  transition: color 0.2s ease, text-decoration 0.2s ease;
  padding: 0; /* plain link, no button padding */
  border-radius: 0;
  border: none;
}

/* Position the back-link at the very top-left of the card to sit closer to the edge */
.card > .back-link:first-child {
  position: absolute;
  top: 8px;
  left: 16px;
  margin: 0;
  padding: 0; /* keep it link-like */
  z-index: 2;
  background: transparent; /* ensure no button background */
}

/* Make sure the header doesn't overlap the absolutely-positioned back-link; add a bit more space below the back-link */
.card > .back-link:first-child + h3 {
  padding-top: 0.6rem;
  margin-top: 1rem; /* a little more breathing room */
}

/* Hover: only change color and underline slightly, no background */
.back-link:hover {
  color: var(--primary);
  text-decoration: underline;
  background: transparent;
  border-color: transparent;
}

.btn:focus-visible,
.input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.copy-format-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--surface-elevated);
  border-radius: var(--radius);
}

.copy-format-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.copy-format-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

.copy-format-btn:hover:not(.active) {
  background: var(--surface-glass);
  color: var(--text);
}

.copy-preview {
  background: var(--surface-elevated);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  position: relative;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 50px;
  display: flex;
  align-items: center;
}

.copy-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.copy-format-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
}

.button-group .btn {
  min-width: 120px;
  height: auto;
}

.info-section-minimal {
  margin-top: 2rem;
  padding: 1.5rem 0;
  text-align: center;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.info-section-minimal h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
  font-weight: 600;
}

.info-section-minimal p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
  opacity: 0.9;
}