:root {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --bg-gradient-1: #0f172a;
    --bg-gradient-2: #1e1b4b;
    --bg-gradient-3: #312e81;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-gradient-1);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 50%);
    background-size: 50% 50%, 60% 60%;
    background-position: 0 0, 100% 100%;
    animation: bgMove 20s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes bgMove {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.container {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    padding: 1.5rem 1rem;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid var(--glass-border);
}

header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    background: linear-gradient(135deg, #a5b4fc 0%, #c084fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(165, 180, 252, 0.3);
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.2);
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

nav a:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

nav a.active {
    color: var(--primary-color);
    background: rgba(129, 140, 248, 0.1);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.converter-box {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2rem;
    box-shadow:
        0 20px 40px -5px rgba(0, 0, 0, 0.4),
        0 0 0 1px var(--glass-border) inset;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: 0.01em;
    display: block;
    margin-bottom: 0.75rem;
}

.label-row label {
    margin-bottom: 0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-text:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.btn-text.active {
    color: #fbbf24;
}

.btn-text.active span {
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.tool-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tool-select-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.tool-select-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.tool-select-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.sub-tool {
    display: none;
}

.sub-tool.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

.tool-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.tool-btn {
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    font-family: var(--font-family);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) inset;
}

.tool-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(129, 140, 248, 0.3);
}

.tool-btn:active {
    transform: translateY(0);
}

.full-width {
    grid-column: 1 / -1;
}

textarea,
select,
input[type="text"],
input[type="number"],
input[type="file"] {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 1.2rem;
    color: var(--text-main);
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) inset;
}

textarea {
    resize: vertical;
}

textarea:focus,
select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow:
        0 0 0 4px rgba(129, 140, 248, 0.15),
        0 2px 5px rgba(0, 0, 0, 0.1) inset;
    background-color: rgba(15, 23, 42, 0.8);
}

.icon-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.6rem;
    border-radius: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
    align-items: start;
}

.control-group {
    display: flex;
    flex-direction: column;
}


.editor-split-view {
    display: flex;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.output-wrapper {
    position: relative;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) inset;
    flex: 1;
}

textarea {
    min-height: 200px;
    height: 100%;
    line-height: 1.5;
    flex: 1;
    resize: none;
}

pre {
    margin: 0;
    padding: 1.2rem;
    overflow: auto;
    width: 100%;
    height: 100%;
    line-height: 1.5;
    font-family: 'Fira Code', monospace;
}

code {
    font-family: 'Fira Code', monospace;
    color: #a5b4fc;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.95rem;
}

.diff-output-section {
    margin-top: 1rem;
}

.diff-output-section .output-wrapper {
    min-height: 200px;
}

.diff-line-added {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.diff-line-removed {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.regex-flags {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.regex-flags label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    cursor: pointer;
}

.regex-flags input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.file-upload-section {
    margin-bottom: 1.5rem;
}

.file-upload-section input[type="file"] {
    padding: 0.75rem;
    cursor: pointer;
}

#imagePreview {
    margin-top: 1rem;
    max-width: 300px;
}

#imagePreview img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--input-border);
}

.qr-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

#qrCodeDisplay {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    display: inline-block;
}

#qrCodeDisplay canvas {
    display: block;
}

.markdown-preview {
    padding: 1.5rem;
    overflow-y: auto;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    color: var(--text-main);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.markdown-preview p {
    margin-bottom: 1rem;
    color: var(--text-main);
}

.markdown-preview code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.markdown-preview pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat-card {
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    padding-bottom: 2rem;
    opacity: 0.7;
}

@media (max-width: 900px) {
    .editor-split-view {
        flex-direction: column;
    }

    textarea {
        min-height: 200px;
    }

    .output-wrapper {
        min-height: 200px;
    }

    .controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .converter-box {
        padding: 1.5rem;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }
}