/* ── Variables ─────────────────────────────────────────── */
:root {
    --teal-dark:   #264653;
    --teal:        #2a9d8f;
    --gold:        #e9c46a;
    --orange:      #f4a261;
    --coral:       #e76f51;

    /* Light theme (default) */
    --bg:          #f8f6f2;
    --surface:     #ffffff;
    --surface-2:   #f1ede6;
    --border:      rgba(38,70,83,.10);
    --text:        #1a2e35;
    --text-2:      #4a6370;
    --text-3:      #8fa8b0;

    --radius-sm:   8px;
    --radius:      14px;
    --radius-lg:   20px;
    --shadow-sm:   0 2px 8px rgba(38,70,83,.07);
    --shadow:      0 8px 30px rgba(38,70,83,.08);
    --shadow-lg:   0 20px 60px rgba(38,70,83,.10);

    --mono:        'DM Mono', monospace;
    --sans:        'Epilogue', sans-serif;
    --serif:       'DM Serif Display', serif;
}

/* Dark theme */
body.dark-mode {
    --bg:          #0f1419;
    --surface:     #16202b;
    --surface-2:   #1e2a38;
    --border:      rgba(42,157,143,.15);
    --text:        #e8eef5;
    --text-2:      #b0bfd4;
    --text-3:      #7a8fa3;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background .5s ease, color .5s ease;
}

/* ── Background canvas ─────────────────────────────────── */
#bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}
.blob-1 { width: 520px; height: 520px; background: rgba(42,157,143,.13); top: -100px; left: -100px; }
.blob-2 { width: 400px; height: 400px; background: rgba(233,196,106,.15); top: 40%; right: -80px; }
.blob-3 { width: 300px; height: 300px; background: rgba(231,111,81,.10); bottom: -60px; left: 30%; }

/* ── App wrapper ───────────────────────────────────────── */
#app {
    position: relative;
    z-index: 1;
    max-width: 1260px;
    margin: 0 auto;
    padding: 0 28px 80px;
}

/* ── Header ────────────────────────────────────────────── */
header {
    padding: 54px 0 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    opacity: 0;
    position: relative;
}

.theme-toggle {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform .2s, box-shadow .2s, background .5s;
    box-shadow: var(--shadow-sm);
    outline: none;
}
.theme-toggle:hover { transform: scale(1.08); box-shadow: var(--shadow); }
.theme-toggle:active { transform: scale(.96); }

.logo-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 100px;
    padding: 6px 16px 6px 10px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
    transition: background .5s, border-color .5s;
}
.logo-badge .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0 3px rgba(42,157,143,.20);
    animation: pulse 2.4s ease infinite;
    transition: box-shadow .5s;
}
@keyframes pulse {
    0%,100% { box-shadow: 0 0 0 3px rgba(42,157,143,.20); }
    50%      { box-shadow: 0 0 0 6px rgba(42,157,143,.08); }
}
.logo-badge span { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--teal-dark); text-transform: uppercase; transition: color .5s; }

header h1 {
    font-family: var(--serif);
    font-size: clamp(38px, 6vw, 68px);
    line-height: 1.05;
    color: var(--teal);
    letter-spacing: -.5px;
    transition: color .5s;
}
header h1 em {
    font-style: italic;
    color: var(--coral);
    transition: color .5s;
}
header p {
    margin-top: 16px;
    font-size: 16px;
    color: var(--text-2);
    line-height: 1.65;
    font-weight: 300;
    transition: color .5s;
}

/* ── Stats strip ───────────────────────────────────────── */
.stats-strip {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
}
.stat-chip {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 100px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-2);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .5s, border-color .5s, color .5s;
}
.stat-chip .icon { font-size: 14px; }

/* ── Toolbar ───────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
    opacity: 0;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 100px;
    padding: 6px 14px;
    box-shadow: var(--shadow-sm);
    transition: background .5s, border-color .5s;
}
.toggle-group label { font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: color .5s; }
.toggle { appearance: none; width: 36px; height: 20px; border-radius: 100px; background: var(--surface-2); border: 1.5px solid var(--border); cursor: pointer; position: relative; transition: background .3s, border-color .5s; }
.toggle::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--text-3); top: 1px; left: 1px; transition: transform .3s, background .5s; }
.toggle:checked { background: var(--teal); border-color: var(--teal); }
.toggle:checked::after { transform: translateX(16px); background: #fff; }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: transform .18s, box-shadow .18s, background .18s, color .18s, border-color .18s;
    outline: none;
    position: relative;
    overflow: hidden;
}
.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.15);
    opacity: 0;
    transition: opacity .18s;
    border-radius: inherit;
}
.btn:hover::before { opacity: 1; }

.btn-primary {
    background: var(--teal-dark);
    color: #fff;
    box-shadow: 0 4px 16px rgba(38,70,83,.30);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(38,70,83,.35); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
    background: var(--surface);
    color: var(--teal-dark);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--teal); color: var(--teal); }

.btn-accent {
    background: linear-gradient(135deg, var(--orange), var(--coral));
    color: #fff;
    box-shadow: 0 4px 16px rgba(244,162,97,.35);
}
.btn-accent:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(244,162,97,.45); }

.btn:disabled { opacity: .38; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Two-panel layout ──────────────────────────────────── */
.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    opacity: 0;
}

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

.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .3s, background .5s, border-color .5s;
}
.panel:focus-within { box-shadow: 0 12px 40px rgba(42,157,143,.12), 0 0 0 2px rgba(42,157,143,.20); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1.5px solid var(--border);
    background: var(--surface-2);
    transition: background .5s, border-color .5s;
}
.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-2);
}
.panel-title .dot-label {
    width: 7px; height: 7px;
    border-radius: 50%;
}
.panel-title .dot-label.input  { background: var(--gold); }
.panel-title .dot-label.output { background: var(--teal); }

.byte-count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 9px;
    transition: background .5s, border-color .5s, color .5s;
}

textarea {
    flex: 1;
    width: 100%;
    min-height: 340px;
    padding: 20px 20px;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    tab-size: 2;
    transition: color .5s;
}
textarea::placeholder { color: var(--text-3); }
textarea[readonly] {
    cursor: default;
    color: var(--teal-dark);
}

/* ── Action bar ────────────────────────────────────────── */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 28px 0 0;
    flex-wrap: wrap;
    opacity: 0;
}

/* ── Savings badge ─────────────────────────────────────── */
.savings-badge {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid rgba(42,157,143,.25);
    border-radius: 100px;
    padding: 8px 18px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--teal-dark);
    transition: background .5s, color .5s;
}
.savings-badge.visible { display: flex; }
.savings-badge strong { color: var(--teal); font-weight: 700; transition: color .5s; }

/* ── Toast ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--teal-dark);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 8px 28px rgba(38,70,83,.30);
    display: flex;
    align-items: center;
    gap: 9px;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: auto;
}

/* ── Bottom panel meta ─────────────────────────────────── */
.panel-footer {
    padding: 10px 18px;
    border-top: 1.5px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    transition: background .5s, border-color .5s;
}
.panel-footer .hint { font-size: 11.5px; color: var(--text-3); transition: color .5s; }

/* ── Clear btn (inside panel footer) ──────────────────── */
.btn-ghost {
    background: none;
    border: none;
    font-family: var(--sans);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 5px;
    transition: color .2s, background .2s, color .5s;
}
.btn-ghost:hover { color: var(--coral); background: rgba(231,111,81,.08); }

/* ── Divider arrow ─────────────────────────────────────── */
.arrow-center {
    display: none;
    justify-content: center;
    margin: -8px 0;
    z-index: 2;
    position: relative;
}
.arrow-center svg {
    background: var(--gold);
    border-radius: 50%;
    padding: 6px;
    box-shadow: 0 4px 14px rgba(233,196,106,.40);
    width: 32px; height: 32px;
}
@media (max-width: 760px) {
    .arrow-center { display: flex; }
}

/* ── Footer ────────────────────────────────────────────── */
footer {
    text-align: center;
    padding-top: 48px;
    font-size: 12px;
    color: var(--text-3);
    opacity: 0;
    transition: color .5s;
}
footer a { color: var(--teal); text-decoration: none; transition: color .5s; }
footer a:hover { text-decoration: underline; }

/* ── Scrollbar ─────────────────────────────────────────── */
textarea::-webkit-scrollbar { width: 5px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
