/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --font: 'Inter', system-ui, sans-serif;

    /* Pastels */
    --peach:     #fde8d8;
    --peach-d:   #f5c9a9;
    --lavender:  #e8dff7;
    --lavender-d:#c9b8ee;
    --sky:       #d6eeff;
    --sky-d:     #a8d8f5;
    --mint:      #d5f5e8;
    --mint-d:    #a2e4c5;
    --rose:      #fde3e9;
    --rose-d:    #f5b8c8;

    /* Neutral */
    --bg:        #f7f8fc;
    --card:      #ffffff;
    --border:    #e8eaf0;
    --text:      #1a1d26;
    --text-2:    #5a5f77;
    --text-3:    #9097b0;

    /* Accent */
    --blue:      #4f82f7;
    --blue-d:    #3567e8;
    --green:     #22c07a;
    --green-d:   #18a364;
    --purple:    #8b5cf6;
    --orange:    #f97316;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
    --shadow-md: 0 8px 32px rgba(0,0,0,.08);
    --shadow-lg: 0 20px 60px rgba(0,0,0,.1);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================
   HERO HEADER
   ============================================= */
.hero {
    position: relative;
    width: 100%;
    padding: 4rem 2rem 3.5rem;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute; inset: 0;
    background: linear-gradient(135deg, #e6d5ff 0%, #c9e9ff 35%, #c9f5e4 65%, #fde8d8 100%);
    z-index: 0;
}

.hero-bg::after {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.25'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

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

.hero-badge {
    display: inline-block;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.8);
    backdrop-filter: blur(8px);
    padding: 0.3rem 1rem;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.hero h1 .accent { color: var(--purple); }

.hero-sub {
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    color: var(--text-2);
    font-weight: 400;
}

/* =============================================
   PANELS
   ============================================= */
.panel {
    width: 100%;
    padding: 2.5rem 0;
}

.panel-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
}

.panel:nth-child(even) { background: white; }

/* =============================================
   INPUT SECTION
   ============================================= */
.input-panel { background: white; }

.input-panel h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.recreation-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.recreation-grid-1x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .recreation-grid-2x2,
    .recreation-grid-1x2 { grid-template-columns: 1fr; }
}

.input-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .input-cards { grid-template-columns: 1fr; }
}

.input-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-card:hover {
    border-color: var(--lavender-d);
    box-shadow: var(--shadow-md);
}

.card-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.input-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.input-card p {
    font-size: 0.9rem;
    color: var(--text-2);
    flex: 1;
}

code {
    background: var(--lavender);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--purple);
}

/* Buttons */
.btn-main {
    display: inline-block;
    padding: 0.7rem 1.4rem;
    background: var(--blue);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    font-family: var(--font);
}

.btn-main:hover {
    background: var(--blue-d);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79,130,247,.35);
}

.btn-outline {
    background: white;
    color: var(--blue);
    border: 2px solid var(--blue);
}

.btn-outline:hover {
    background: var(--sky);
    box-shadow: 0 6px 20px rgba(79,130,247,.15);
}

/* Preview panel */
.preview-panel {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 2rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .preview-panel { grid-template-columns: 1fr; }
}

.preview-left h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.preview-left img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
}

.info-badge {
    display: inline-block;
    padding: 0.3rem 0.9rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.info-badge.green { background: var(--mint); color: var(--green-d); }
.info-badge.blue  { background: var(--sky); color: var(--blue-d); }

/* Toggle */
.option-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

.toggle-wrap {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-wrap input { display: none; }

.toggle-track {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 100px;
    transition: background 0.2s;
}

.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: transform 0.2s;
}

.toggle-wrap input:checked ~ .toggle-track { background: var(--blue); }
.toggle-wrap input:checked ~ .toggle-track .toggle-thumb { transform: translateX(22px); }

.option-hint {
    font-size: 0.82rem;
    color: var(--text-3);
}

/* Run Button */
.btn-run {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--purple) 0%, var(--blue) 100%);
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
    font-family: var(--font);
    letter-spacing: -0.01em;
}

.btn-run:hover {
    opacity: 0.92;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(139,92,246,.4);
}

.btn-run:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress steps */
.progress-panel {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--lavender) 0%, var(--sky) 100%);
    border-radius: var(--radius-lg);
    margin-top: 1rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.step-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s;
}
.step-dot.pending  { background: var(--border); }
.step-dot.running  { background: var(--orange); animation: pulse 1s ease-in-out infinite; }
.step-dot.done     { background: var(--green); }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

.step-info { display: flex; flex-direction: column; }
.step-label { font-size: 0.85rem; font-weight: 600; }
.step-status { font-size: 0.75rem; color: var(--text-2); }

.progress-connector {
    height: 2px;
    width: 2.5rem;
    background: var(--border);
    flex-shrink: 0;
    margin: 0 0.5rem;
}

/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.section-pill {
    padding: 0.3rem 0.9rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.section-pill.mint     { background: var(--mint); color: var(--green-d); }
.section-pill.lavender { background: var(--lavender); color: var(--purple); }

.rec-time-tag {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-2);
    font-weight: 500;
}

/* =============================================
   STATS ROW
   ============================================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 700px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
}
.stat-card.peach   { background: var(--peach); }
.stat-card.lavender{ background: var(--lavender); }
.stat-card.sky     { background: var(--sky); }
.stat-card.mint    { background: var(--mint); }

.stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

/* =============================================
   VIZ BLOCKS
   ============================================= */
.viz-block {
    margin-bottom: 3rem;
}

.viz-block h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.grid-subtitle {
    font-size: 0.82rem;
    color: var(--text-3);
    margin-bottom: 1rem;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-2);
}

.legend-dot {
    width: 12px; height: 12px;
    border-radius: 3px;
    display: inline-block;
}
.legend-dot.blue-dot  { background: rgba(79,130,247,.85); }
.legend-dot.green-dot { background: rgba(34,192,122,.85); }

.canvas-fit {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: white;
    overflow: hidden;
    line-height: 0;   /* remove bottom gap */
}

canvas {
    display: block;
    width: 100%;      /* scale to container width */
    height: auto;     /* keep aspect ratio */
}

/* OCR Grid */
.ocr-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .ocr-grid { grid-template-columns: repeat(3, 1fr); }
}

.grid-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-reroll {
    padding: 0.5rem 1rem;
    background: var(--lavender);
    color: var(--purple);
    border: 1px solid var(--lavender-d);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.15s;
    font-family: var(--font);
    flex-shrink: 0;
}
.btn-reroll:hover {
    background: var(--lavender-d);
    transform: translateY(-1px);
}

.ocr-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.ocr-item:hover { box-shadow: var(--shadow-md); }

.ocr-item-crop {
    width: 100%;
    height: 70px;
    object-fit: contain;
    background: #f8f9fc;
    display: block;
    border-bottom: 1px solid var(--border);
}

.ocr-item-text {
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ocr-idx {
    font-size: 0.7rem;
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ocr-row {
    font-size: 0.82rem;
    display: flex;
    gap: 0.3rem;
    align-items: baseline;
    line-height: 1.4;
}

.ocr-label {
    font-weight: 700;
    color: var(--text-2);
    flex-shrink: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ocr-val {
    color: var(--text);
    font-weight: 500;
    word-break: break-all;
}

/* =============================================
   SECTION 2 - COMPARE
   ============================================= */
.sec2-panel { background: var(--bg); }

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .compare-grid { grid-template-columns: 1fr; }
}

.compare-box h4 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-2);
    margin-bottom: 0.75rem;
    text-align: center;
}

.img-wrap {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: white;
    min-height: 200px;
}

.box-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.img-wrap img {
    width: 100%;
    display: block;
    object-fit: contain;
}

/* =============================================
   UTILITY
   ============================================= */
.hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.4s;
}

.toast.hidden { opacity: 0; pointer-events: none; display: flex !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
