:root {
    --bg-color: #f2f2f7;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --text-primary: #ffffff;
        --text-secondary: #98989d;
        --card-shadow: 0 10px 40px rgba(0,0,0,0.5);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ─── App Container (phone frame) ─── */
.app-container {
    width: 100%;
    max-width: 430px;
    height: 100dvh;
    max-height: 932px;
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    overflow: hidden;
}

/* ─── Header ─── */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    z-index: 100;
    flex-shrink: 0;
}

.status-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Content ─── */
.content-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction-text {
    margin-top: 8vh;
    text-align: center;
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 10;
}

.app-container.cards-expanded .instruction-text,
.app-container.card-active .instruction-text {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
}

.reader-icon {
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%   { transform: translateY(0px); }
    50%  { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

.instruction-text h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.instruction-text p {
    font-size: 15px;
    color: var(--text-secondary);
}

/* ─── Card Stack ─── */
.card-stack {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none; /* let clicks pass through empty areas */
}

.card {
    position: absolute;
    width: 88%;
    max-width: 380px;
    height: 230px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.55s cubic-bezier(0.32, 0.94, 0.60, 1);
    transform-origin: center bottom;
    will-change: transform;
    bottom: 30px;
    color: white;
    pointer-events: auto;
}

/* ─── Card Internals ─── */
.card-content {
    position: relative;
    z-index: 2;
    padding: 24px 20px;
    height: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.card-left-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    flex: 1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    flex-shrink: 0;
}

.logo-container svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.platform-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.user-name {
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 1px 6px rgba(0,0,0,0.3);
    margin-bottom: 2px;
}

/* ─── QR Code Wrapper ─── */
.qr-code-wrapper {
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
    flex-shrink: 0;
    align-self: flex-start; /* align with the top logo/header row */
    overflow: hidden; /* clip the scaled-up image to maintain nice rounded corners if needed */
}

.qr-code-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    /* Scale the image up slightly to hide the unpredictable native margin generated by qrcode.js */
    transform: scale(1.08);
}

.qr-label {
    display: none; /* Hide label in the new compact layout */
}

/* ─── Overlay ─── */
.bg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 40;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-container.card-active .bg-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* ─── Settings Button ─── */
.settings-btn {
    position: absolute;
    top: 14px;
    right: 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 100;
    padding: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.settings-btn:hover {
    opacity: 1;
}

/* ─── Onboarding / Settings Overlay ─── */
.onboarding-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-color);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 60px 24px 40px;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.onboarding-content {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.onboarding-content h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.onboarding-content .subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
}

.platform-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.platform-row {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 16px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
    .platform-row {
        background: rgba(40, 40, 40, 0.5);
        border: 1px solid rgba(255,255,255,0.05);
    }
}

.platform-row.active {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border-color: rgba(0, 122, 255, 0.3);
}

@media (prefers-color-scheme: dark) {
    .platform-row.active {
        background: rgba(50, 50, 50, 0.9);
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    }
}

.platform-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.platform-row-header .platform-name {
    font-size: 17px;
    font-weight: 600;
    text-shadow: none;
}

.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.drag-handle:active {
    cursor: grabbing;
}

.platform-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.05);
    animation: fadeIn 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    .platform-details {
        border-top: 1px solid rgba(255,255,255,0.05);
    }
}

.setup-hint {
    background: rgba(0, 122, 255, 0.1);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.setup-hint p {
    font-size: 13px;
    color: #007AFF;
    margin: 0;
    line-height: 1.4;
}

.input-group {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
    padding: 0 12px;
    overflow: hidden;
}

@media (prefers-color-scheme: dark) {
    .input-group { background: rgba(0,0,0,0.3); }
}

.input-group .prefix {
    color: var(--text-secondary);
    font-size: 15px;
    user-select: none;
    white-space: nowrap;
}

.input-group input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 8px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.primary-btn {
    background: #007AFF;
    color: white;
    border: none;
    padding: 16px;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin-top: auto;
}

.primary-btn:active {
    transform: scale(0.98);
}

/* ─── LinkedIn Redesign ─── */
.linkedin-auth-btn {
    background: #0077B5;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 24px;
    transition: background 0.2s, transform 0.1s;
}

.linkedin-auth-btn:active {
    background: #005a8a;
    transform: scale(0.98);
}

.linkedin-auth-btn svg {
    width: 20px;
    height: 20px;
}

.visual-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.visual-divider::before,
.visual-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
    .visual-divider::before,
    .visual-divider::after {
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
}

.visual-divider:not(:empty)::before {
    margin-right: .5em;
}

.visual-divider:not(:empty)::after {
    margin-left: .5em;
}

.manual-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manual-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: -4px;
    margin-left: 4px;
}

.manual-form .input-group input::placeholder {
    color: #b0b0b0;
    opacity: 0.8;
}

.manual-done-btn {
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.manual-done-btn:active {
    background: rgba(0, 122, 255, 0.2);
}

/* ─── Toggle Switch ─── */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

@media (prefers-color-scheme: dark) {
    .slider { background-color: #555; }
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: #34C759;
}

input:checked + .slider:before {
  -webkit-transform: translateX(20px);
  -ms-transform: translateX(20px);
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ─── Card Gradients with decorative patterns ─── */

.gradient-bg {
    background: linear-gradient(135deg, #333 0%, #111 100%);
}

/* LinkedIn - deep professional blues */
.card.linkedin {
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255,255,255,0.05) 0%, transparent 50%),
        linear-gradient(135deg, #0a66c2 0%, #004182 50%, #002d5c 100%);
}

/* Strava - energetic warm tones */
.card.strava {
    background:
        radial-gradient(ellipse at 30% 70%, rgba(255,255,255,0.10) 0%, transparent 45%),
        radial-gradient(ellipse at 70% 30%, rgba(255,200,100,0.08) 0%, transparent 50%),
        linear-gradient(135deg, #fc5200 0%, #e34402 40%, #b83500 100%);
}

/* Instagram - vibrant gradient mesh */
.card.instagram {
    background:
        radial-gradient(ellipse at 10% 90%, rgba(255,220,100,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 10%, rgba(100,100,255,0.1) 0%, transparent 50%),
        linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* Snapchat - bright yellow */
.card.snapchat {
    background: linear-gradient(135deg, #FFFC00 0%, #FFD700 100%);
    color: #000;
}
.card.snapchat .platform-name, .card.snapchat .user-name {
    text-shadow: none;
}

/* WhatsApp - energetic green */
.card.whatsapp {
    background:
        radial-gradient(ellipse at 80% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
        linear-gradient(135deg, #25D366 0%, #128C7E 100%);
}

/* X / Twitter - pure black with sheen */
.card.twitter {
    background:
        linear-gradient(135deg, #1f1f1f 0%, #000 100%);
    border: 1px solid rgba(255,255,255,0.1);
}

/* ─── Card active state (elevated z) ─── */
.card.is-active {
    z-index: 60 !important;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.url-preview {
    font-size: 13px;
    opacity: 0.7;
    margin-top: 4px;
}

.job-meta {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
    margin-top: 2px;
    letter-spacing: 0.1px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.job-title, .employer {
    display: inline-block;
}

.at-separator {
    opacity: 0.5;
    font-size: 10px;
}
.card.snapchat .url-preview {
    color: #333;
}

/* ─── Shaking Animation (Drag to Reorder) ─── */
@keyframes innerShake {
    0% { transform: rotate(0deg) translate(0px, 0px); }
    25% { transform: rotate(1deg) translate(1px, 1px); }
    50% { transform: rotate(0deg) translate(0px, 0px); }
    75% { transform: rotate(-1deg) translate(-1px, -1px); }
    100% { transform: rotate(0deg) translate(0px, 0px); }
}

.cards-shaking .card > * {
    animation: innerShake 0.3s infinite;
}
