/* ============================================================
   Knitopia — NVIDIA-Inspired Futuristic Design System
   A premium, techy aesthetic: deep blacks, electric greens,
   frosted glass, geometric precision, and subtle glow effects.
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
    --bg:            #000000;
    --bg-card:       #0A0A0A;
    --bg-card-hover: #0F0F0F;
    --bg-elevated:   #111111;
    --border:        #1A1A1A;
    --border-hover:  #76B900;
    --text:          #FFFFFF;
    --text-sec:      #8A8A8A;
    --text-muted:    #555555;
    --green:         #76B900;
    --green-hover:   #8ED100;
    --green-dim:     rgba(118,185,0,0.08);
    --green-glow:    rgba(118,185,0,0.25);
    --amber:         #F59E0B;
    --red:           #EF4444;
    --chart-bg:      #F8F8F4;
    --code-bg:       #060610;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 2px 16px rgba(0,0,0,0.6);
    --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans:     'Inter', system-ui, -apple-system, sans-serif;
    --font-serif:    'Georgia', 'Times New Roman', serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Animated tech-grid dot pattern */
    background-image:
        radial-gradient(circle, rgba(118,185,0,0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { background-image: radial-gradient(circle, rgba(118,185,0,0.03) 1px, transparent 1px); }
    50%      { background-image: radial-gradient(circle, rgba(118,185,0,0.06) 1px, transparent 1px); }
}

a {
    color: var(--green);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--green-hover); }

img { max-width: 100%; height: auto; }

/* ── Animation Keyframes ───────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px var(--green-glow), 0 0 24px rgba(118,185,0,0.10); }
    50%      { box-shadow: 0 0 16px var(--green-glow), 0 0 40px rgba(118,185,0,0.18); }
}

@keyframes borderGlow {
    0%, 100% { border-color: var(--green); box-shadow: 0 0 12px rgba(118,185,0,0.15); }
    50%      { border-color: var(--green-hover); box-shadow: 0 0 24px rgba(118,185,0,0.30); }
}

@keyframes uploadPulse {
    0%, 100% { box-shadow: inset 0 0 20px rgba(118,185,0,0.05); }
    50%      { box-shadow: inset 0 0 40px rgba(118,185,0,0.12); }
}

@keyframes ctaBeacon {
    0%, 100% { box-shadow: 0 0 12px rgba(118,185,0,0.25), 0 4px 20px rgba(118,185,0,0.15); }
    50%      { box-shadow: 0 0 20px rgba(118,185,0,0.40), 0 4px 30px rgba(118,185,0,0.25); }
}

@keyframes loadingGlow {
    0%, 100% { opacity: 0.6; text-shadow: 0 0 8px rgba(118,185,0,0.3); }
    50%      { opacity: 1; text-shadow: 0 0 20px rgba(118,185,0,0.6); }
}

@keyframes heroSpotlight {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.7; }
}

.spin { animation: spin 2s linear infinite; }

/* ── Utility: Text Gradient ────────────────────────────── */
.text-gradient {
    background: linear-gradient(135deg, #FFFFFF 0%, var(--green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Custom Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #0A0A0A;
}
::-webkit-scrollbar-thumb {
    background: var(--green);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--green-hover);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--green) #0A0A0A;
}

/* ── Navigation ────────────────────────────────────────── */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(118,185,0,0.10);
    background: rgba(0,0,0,0.70);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(118,185,0,0.06);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--green);
    transition: color var(--transition), text-shadow var(--transition);
}
.nav-brand:hover {
    color: var(--green-hover);
    text-shadow: 0 0 16px rgba(118,185,0,0.5), 0 0 32px rgba(118,185,0,0.2);
}
.nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.nav-brand-name {
    font-size: 1.25rem;
    font-weight: 700;
}
.nav-brand-sub {
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-sec);
    opacity: 0.7;
}
.nav-link-home {
    color: var(--green) !important;
    font-weight: 600 !important;
}

.nav-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a {
    color: var(--text-sec);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
    position: relative;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--green);
    transition: width var(--transition);
    box-shadow: 0 0 6px rgba(118,185,0,0.4);
}
.nav-links a:hover {
    color: var(--green);
}
.nav-links a:hover::after {
    width: 100%;
}

/* ── Main ──────────────────────────────────────────────── */
.main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    animation: fadeIn 0.5s ease;
    overflow: visible;
}

/* ── Footer ────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

/* ── Hero (Landing) ────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 8rem 2rem 4rem;
    position: relative;
    overflow: hidden;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.hero-video-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}
.hero-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.45;
}
.hero-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 40%, rgba(0,0,0,0.7) 100%),
        radial-gradient(ellipse at center, rgba(118,185,0,0.06) 0%, transparent 70%);
}
.hero-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Radial spotlight behind hero (fallback when no video) */
.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 700px;
    height: 500px;
    background: radial-gradient(ellipse, rgba(118,185,0,0.08) 0%, transparent 70%);
    pointer-events: none;
    animation: heroSpotlight 6s ease-in-out infinite;
    z-index: 0;
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
    background: linear-gradient(135deg, #FFFFFF 30%, var(--green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-tagline {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    color: var(--text-sec);
    margin-top: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero-subtitle {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: var(--text-muted);
    margin-top: 1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
}

/* ── Feature Cards ─────────────────────────────────────── */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 2rem 0;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease both;
}

/* Staggered entrance */
.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }
.feature-card:nth-child(5) { animation-delay: 0.5s; }
.feature-card:nth-child(6) { animation-delay: 0.6s; }

/* Subtle top-edge green light effect */
.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

/* Subtle gradient overlay at top of card */
.feature-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(180deg, rgba(118,185,0,0.03) 0%, transparent 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--green);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 40px rgba(118,185,0,0.12), 0 0 0 1px rgba(118,185,0,0.08);
}
.feature-card:hover::before { opacity: 1; }
.feature-card:hover::after { opacity: 1; }

.feature-icon {
    opacity: 0.7;
    transition: opacity var(--transition), filter var(--transition);
}
.feature-card:hover .feature-icon {
    opacity: 1;
    filter: brightness(1.2);
}

.feature-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.feature-desc {
    font-size: 0.9rem;
    color: var(--text-sec);
    line-height: 1.5;
}

/* ── Stats Bar ─────────────────────────────────────────── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin: 3rem 0 1rem;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg-card);
    transition: background var(--transition);
}
.stat:hover {
    background: var(--bg-card-hover);
}

.stat-number {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 800;
    color: var(--green);
    line-height: 1;
    letter-spacing: -0.02em;
    text-shadow: 0 0 20px rgba(118,185,0,0.25);
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── Page Header ───────────────────────────────────────── */
.page-header {
    text-align: center;
    padding: 3rem 1rem 2rem;
}
.page-header h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--text);
}
.page-subtitle {
    color: var(--text-sec);
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    min-height: 44px;
    position: relative;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--green);
    color: #000000;
    border-color: var(--green);
    box-shadow: 0 0 12px rgba(118,185,0,0.20), 0 4px 12px rgba(118,185,0,0.10);
}
.btn-primary:hover {
    background: var(--green-hover);
    border-color: var(--green-hover);
    color: #000000;
    box-shadow: 0 0 20px rgba(118,185,0,0.35), 0 4px 20px rgba(118,185,0,0.20);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 0 8px rgba(118,185,0,0.20);
}
.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    color: var(--green);
    border-color: var(--green);
}
.btn-outline:hover {
    background: var(--green-dim);
    color: var(--green-hover);
    border-color: var(--green-hover);
    box-shadow: 0 0 12px rgba(118,185,0,0.10);
}

.btn-large {
    font-size: 1.1rem;
    padding: 0.9rem 2.5rem;
    min-height: 52px;
}

.btn-small {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    min-height: 32px;
}

/* ── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-sec);
    margin-bottom: 0.4rem;
    letter-spacing: 0.02em;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    background: var(--code-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(118,185,0,0.15), 0 0 12px rgba(118,185,0,0.08);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%238A8A8A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

/* ── Upload Zone ───────────────────────────────────────── */
.upload-section {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    min-height: 220px;
    position: relative;
    background: rgba(6,6,16,0.4);
}
.upload-zone:hover {
    border-color: var(--green);
    background: var(--green-dim);
    box-shadow: inset 0 0 30px rgba(118,185,0,0.05);
}
.upload-zone.drag-over {
    border-color: var(--green-hover);
    background: rgba(118,185,0,0.06);
    animation: uploadPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(118,185,0,0.15);
}

.upload-icon {
    margin-bottom: 1rem;
    transition: transform var(--transition);
}
.upload-zone:hover .upload-icon {
    transform: translateY(-2px);
}

.upload-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text);
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.upload-preview {
    margin: 1.5rem 0;
    position: relative;
}
.upload-preview img {
    max-height: 300px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.upload-preview .btn {
    margin-top: 0.75rem;
}

.camera-option {
    margin: 1.5rem 0;
}
.camera-option .btn { cursor: pointer; }

.tips-section {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
}
.tips-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 0.5rem;
}
.tips-list {
    list-style: none;
    padding: 0;
}
.tips-list li {
    position: relative;
    padding-left: 1.2rem;
    color: var(--text-sec);
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}
.tips-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 4px rgba(118,185,0,0.4);
}

/* ── Describe Section ──────────────────────────────────── */
.describe-section {
    max-width: 700px;
    margin: 0 auto;
}
.describe-section .btn-large {
    display: block;
    width: 100%;
    margin-top: 1rem;
}

/* ── Loading Overlay ───────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(118,185,0,0.4));
}

.loading-text {
    font-size: 1.1rem;
    color: var(--green);
    animation: loadingGlow 2s ease-in-out infinite;
    letter-spacing: 0.04em;
}

/* ── Results Page ──────────────────────────────────────── */
.result-hero {
    margin-bottom: 2rem;
}
.result-hero-inner {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    transition: border-color var(--transition);
}

.result-image {
    flex-shrink: 0;
    width: 240px;
}
.result-image img {
    border-radius: var(--radius);
    width: 100%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.result-placeholder {
    width: 240px;
    height: 180px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.result-info { flex: 1; }

.pattern-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* ── Confidence Badges ─────────────────────────────────── */
.confidence-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: 0.02em;
}
.badge-green {
    background: rgba(118,185,0,0.12);
    color: var(--green);
    border: 1px solid rgba(118,185,0,0.20);
}
.badge-yellow {
    background: rgba(245,158,11,0.12);
    color: var(--amber);
    border: 1px solid rgba(245,158,11,0.20);
}
.badge-red {
    background: rgba(239,68,68,0.12);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.20);
}

.pattern-desc {
    color: var(--text-sec);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

/* ── Tags ──────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(118,185,0,0.15);
    transition: all var(--transition);
}
.tag:hover {
    background: rgba(118,185,0,0.15);
    border-color: rgba(118,185,0,0.30);
}

/* ── Result Sections ───────────────────────────────────── */
.result-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.5s ease both;
    transition: border-color var(--transition);
}
.result-section:hover {
    border-color: rgba(118,185,0,0.12);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.section-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--green);
}
.section-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    width: 100%;
    margin-top: -0.5rem;
}

.info-tooltip {
    cursor: help;
    font-size: 0.9rem;
    opacity: 0.5;
    transition: opacity var(--transition);
}
.info-tooltip:hover { opacity: 0.8; }

/* ── Stitch Chart ──────────────────────────────────────── */
.chart-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.chart-controls span {
    font-size: 0.85rem;
    color: var(--text-sec);
    min-width: 40px;
    text-align: center;
}

.chart-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.chart-container {
    display: inline-block;
    background: var(--chart-bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: transform 0.2s ease;
    border: 2px solid rgba(118,185,0,0.15);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
}

.chart-grid {
    display: grid;
    gap: 0;
    border: 1.5px solid #999;
}

.chart-cell {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-family: var(--font-mono);
    font-weight: 500;
    border: 1px solid #BBB;
    color: #333;
    transition: background-color 0.15s ease, outline 0.15s ease;
    cursor: default;
    position: relative;
}
.chart-cell:hover {
    outline: 2px solid var(--green);
    outline-offset: -1px;
    z-index: 1;
}
.chart-cell[data-stitch="k"]    { background: #F5E6D3; }
.chart-cell[data-stitch="p"]    { background: #D4D4D4; }
.chart-cell[data-stitch="lc4"],
.chart-cell[data-stitch="rc4"]  { background: #B8E06E; color: #1A1A1A; }
.chart-cell[data-stitch="yo"]   { background: #DCF0FF; }
.chart-cell[data-stitch="k2tog"],
.chart-cell[data-stitch="ssk"]  { background: #FFE0E0; }

.chart-row-num {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #999;
    padding-left: 6px;
    min-width: 24px;
}
.chart-col-num {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-size: 11px;
    color: #999;
    padding-top: 4px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-sec);
}
.legend-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: var(--font-mono);
}

/* ── Color Swatches ────────────────────────────────────── */
.color-swatches {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.swatch:hover { transform: scale(1.15); }
.swatch.active {
    border-color: var(--green);
    box-shadow: 0 0 0 2px var(--green), 0 0 10px rgba(118,185,0,0.3);
}

/* ── Written Instructions ──────────────────────────────── */
.instructions-card {
    background: #FAFAF5;
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    overflow-x: auto;
    border-left: 4px solid var(--green);
}
.instructions-text {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ── Machine Chart ─────────────────────────────────────── */
.machine-chart-container {
    display: inline-block;
    background: #FFF;
    border-radius: var(--radius-sm);
    padding: 1rem;
    border: 1px solid var(--border);
}

.machine-cell {
    width: 16px;
    height: 16px;
    border: 0.5px solid #DDD;
}
.machine-cell.active { background: #1A1A1A; }
.machine-cell.inactive { background: #F0F0F0; }

.machine-settings {
    margin-top: 1.5rem;
}
.machine-settings h3 {
    font-size: 1rem;
    color: var(--text-sec);
    margin-bottom: 0.5rem;
}

/* ── Knitout Code ──────────────────────────────────────── */
.code-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.code-block {
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    overflow-x: auto;
    position: relative;
    border: 1px solid rgba(118,185,0,0.06);
    /* Subtle scanline effect */
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(118,185,0,0.015) 2px,
            rgba(118,185,0,0.015) 4px
        );
    background-color: var(--code-bg);
}
.knitout-code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    color: #E0E0E0;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.kn-comment { color: #76B900; }
.kn-op      { color: #FFFFFF; }
.kn-needle  { color: #8ED100; }
.kn-carrier { color: #5DADE2; }

/* ── Pattern Details ───────────────────────────────────── */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.details-col h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 0.75rem;
}

.specs-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
}
.specs-list dt {
    color: var(--text-muted);
    font-weight: 500;
}
.specs-list dd {
    color: var(--text);
    font-weight: 400;
}

/* ── Action Buttons Row ────────────────────────────────── */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    padding: 2rem 0;
}

/* Primary download CTA beacon pulse */
.result-actions .btn-primary {
    animation: ctaBeacon 3s ease-in-out infinite;
}
.result-actions .btn-primary:hover {
    animation: none;
}

/* ── Waitlist CTA ──────────────────────────────────────── */
.waitlist-cta {
    padding: 2rem 0 1rem;
}
.waitlist-cta-card {
    background: var(--bg-card);
    border: 2px solid var(--green);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 0 30px rgba(118,185,0,0.08);
    position: relative;
    overflow: hidden;
}
/* Subtle top glow line */
.waitlist-cta-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
}
.waitlist-cta-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
}
.waitlist-cta-card p {
    color: var(--text-sec);
    margin-bottom: 1rem;
}

.waitlist-form {
    display: flex;
    gap: 0.75rem;
    max-width: 400px;
    margin: 0 auto;
}
.waitlist-form .form-input { flex: 1; }

.waitlist-success {
    color: var(--green);
    font-weight: 500;
}

/* ── Waitlist Page ─────────────────────────────────────── */
.waitlist-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}
.waitlist-card {
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    max-width: 500px;
    box-shadow: 0 0 40px rgba(118,185,0,0.05);
}
.waitlist-icon { margin-bottom: 1.5rem; }
.waitlist-card h1 {
    font-size: 2rem;
    color: var(--green);
    margin-bottom: 0.75rem;
}
.waitlist-message {
    color: var(--text-sec);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* ── No Data State ─────────────────────────────────────── */
.no-data {
    text-align: center;
    padding: 4rem 2rem;
}
.no-data h2 {
    font-size: 1.5rem;
    color: var(--text-sec);
    margin-bottom: 0.5rem;
}
.no-data p {
    color: var(--text-muted);
}
.action-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ── Selection / Focus Ring ────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* ── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .nav { padding: 0.75rem 1rem; }
    .main { padding: 1.5rem 1rem; }

    .features { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .options-grid { grid-template-columns: 1fr; }
    .details-grid { grid-template-columns: 1fr; }

    .result-hero-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .result-image { width: 100%; max-width: 320px; }
    .tag-list { justify-content: center; }

    .result-actions { flex-direction: column; align-items: stretch; }
    .waitlist-form { flex-direction: column; }

    .hero { padding: 3rem 1rem 2rem; }

    .result-section { padding: 1.25rem; }

    /* Touch-friendly button height */
    .btn { min-height: 48px; }

    /* Full-width inputs */
    .form-input, .form-select, .form-textarea {
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Horizontal scroll for charts */
    .chart-scroll-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .hero-title { font-size: 2.5rem; }
    .pattern-name { font-size: 1.4rem; }
    .chart-cell { width: 22px; height: 22px; font-size: 11px; }
    .nav-links { gap: 1rem; }
    .nav-links a { font-size: 0.8rem; }
}
