:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-tertiary: #868e96;
    --accent: #4c6ef5;
    --accent-hover: #3b5bdb;
    --accent-light: #edf2ff;
    --success: #51cf66;
    --border: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

[data-theme="dark"] {
    --bg-primary: #1a1b1e;
    --bg-secondary: #25262b;
    --bg-tertiary: #2c2e33;
    --text-primary: #e9ecef;
    --text-secondary: #c1c2c5;
    --text-tertiary: #909296;
    --accent: #5c7cfa;
    --accent-hover: #748ffc;
    --accent-light: #364fc7;
    --success: #69db7c;
    --border: #373a40;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    z-index: 100;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.theme-toggle svg {
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.header {
    text-align: center;
    margin-bottom: 48px;
}

 .hero {
     margin: 16px auto 0;
     max-width: 760px;
     background: linear-gradient(180deg, var(--bg-secondary), var(--bg-tertiary));
     border: 1px solid var(--border);
     border-radius: var(--radius-lg);
     padding: 22px 22px;
     box-shadow: var(--shadow-sm);
 }

 .hero-badge {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     padding: 8px 12px;
     border-radius: 999px;
     border: 1px solid var(--border);
     background: var(--bg-secondary);
     color: var(--text-secondary);
     font-size: 13px;
     font-weight: 600;
 }

 .hero h2 {
     margin-top: 12px;
     font-size: 28px;
     line-height: 1.2;
     letter-spacing: -0.01em;
 }

 .hero p {
     margin-top: 10px;
     font-size: 16px;
     color: var(--text-secondary);
 }

 .hero-trust {
     margin-top: 12px;
     display: flex;
     justify-content: center;
     flex-wrap: wrap;
     gap: 10px;
     color: var(--text-secondary);
     font-weight: 600;
 }

 .hero-actions {
     margin-top: 14px;
     display: flex;
     justify-content: center;
     gap: 12px;
     flex-wrap: wrap;
 }

 .hero-cta {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 10px;
     padding: 12px 18px;
     border-radius: var(--radius-md);
     border: 1px solid var(--accent);
     background: var(--accent);
     color: #fff;
     text-decoration: none;
     font-weight: 700;
     box-shadow: var(--shadow-md);
     transition: all 0.3s ease;
 }

 .hero-cta:hover {
     background: var(--accent-hover);
     transform: translateY(-2px);
     box-shadow: var(--shadow-lg);
 }

 .hero-secondary {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 10px;
     padding: 12px 18px;
     border-radius: var(--radius-md);
     border: 1px solid var(--border);
     background: var(--bg-secondary);
     color: var(--text-secondary);
     text-decoration: none;
     font-weight: 700;
     box-shadow: var(--shadow-sm);
     transition: all 0.3s ease;
 }

 .hero-secondary:hover {
     transform: translateY(-2px);
     border-color: var(--accent);
     color: var(--text-primary);
     box-shadow: var(--shadow-md);
 }

 .tool-nav {
     display: flex;
     justify-content: center;
     gap: 10px;
     margin-bottom: 18px;
     flex-wrap: wrap;
 }

 .tool-link {
     display: inline-block;
     padding: 10px 14px;
     border-radius: var(--radius-sm);
     border: 1px solid var(--border);
     background: var(--bg-secondary);
     color: var(--text-secondary);
     text-decoration: none;
     font-weight: 600;
     box-shadow: var(--shadow-sm);
     transition: all 0.3s ease;
 }

 .tool-link-content {
     display: flex;
     align-items: center;
     gap: 10px;
 }

 .tool-link-emoji {
     width: 22px;
     height: 22px;
     display: grid;
     place-items: center;
     font-size: 18px;
 }

 .tool-link-text {
     display: grid;
     gap: 2px;
     text-align: left;
 }

 .tool-link-title {
     line-height: 1.1;
 }

 .tool-link-sub {
     font-size: 12px;
     font-weight: 600;
     color: var(--text-tertiary);
     line-height: 1.1;
 }

 .tool-link:hover {
     transform: translateY(-1px);
     box-shadow: var(--shadow-md);
     border-color: var(--accent);
     color: var(--text-primary);
 }

 .tool-link.active {
     background: var(--accent);
     border-color: var(--accent);
     color: #fff;
     box-shadow: var(--shadow-md);
 }

 .tool-link.active .tool-link-sub {
     color: rgba(255, 255, 255, 0.85);
 }

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo svg {
    color: var(--accent);
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.tagline {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
}

.main-content {
    position: relative;
}

 .io-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 18px;
     align-items: start;
 }

 .io-grid .input-section,
 .io-grid .output-section {
     margin-bottom: 0;
 }

 .io-grid .output-section {
     display: block;
 }

 .io-grid .output-section:not(.visible) {
     opacity: 0.8;
 }

 .meta-row {
     margin-top: 10px;
     display: flex;
     justify-content: space-between;
     gap: 10px;
     flex-wrap: wrap;
     align-items: center;
 }

 .meta-left {
     display: flex;
     gap: 12px;
     flex-wrap: wrap;
     align-items: center;
 }

 .meta-pill {
     display: inline-flex;
     align-items: center;
     gap: 6px;
     padding: 6px 10px;
     border-radius: 999px;
     border: 1px solid var(--border);
     background: var(--bg-secondary);
     color: var(--text-secondary);
     font-size: 13px;
     font-weight: 600;
 }

 .clear-btn {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     padding: 10px 14px;
     border-radius: var(--radius-md);
     border: 1px solid var(--border);
     background: var(--bg-secondary);
     color: var(--text-secondary);
     cursor: pointer;
     font-weight: 700;
     box-shadow: var(--shadow-sm);
     transition: all 0.3s ease;
 }

 .clear-btn:hover {
     transform: translateY(-1px);
     border-color: var(--accent);
     color: var(--text-primary);
     box-shadow: var(--shadow-md);
 }

.input-section,
.output-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.input-section:focus-within,
.output-section:focus-within {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.section-label svg {
    color: var(--accent);
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    resize: vertical;
    font-family: inherit;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-secondary);
}

textarea::placeholder {
    color: var(--text-tertiary);
}

.char-count {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: right;
}

 .mode-row {
     display: flex;
     align-items: center;
     justify-content: space-between;
     gap: 12px;
     margin-top: 16px;
 }

 .mode-label {
     margin-bottom: 0;
 }

 .mode-select {
     width: min(360px, 100%);
     padding: 12px 14px;
     font-size: 15px;
     color: var(--text-primary);
     background: var(--bg-tertiary);
     border: 1px solid var(--border);
     border-radius: var(--radius-md);
     transition: all 0.3s ease;
 }

 .mode-select:focus {
     outline: none;
     border-color: var(--accent);
     background: var(--bg-secondary);
 }

.button-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.simplify-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.simplify-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.simplify-btn:active:not(:disabled) {
    transform: translateY(0);
}

.simplify-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.simplify-btn svg {
    animation: none;
}

.simplify-btn:disabled svg {
    animation: spin 1s linear infinite;
}

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

.output-section {
    display: none;
    position: relative;
    animation: slideUp 0.4s ease;
}

.output-section.visible {
    display: block;
}

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

.output-text {
    min-height: 150px;
    padding: 16px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-text.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-style: italic;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-lg);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

.loading-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.footer {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
}

 .footer-links {
     margin-top: 10px;
     display: flex;
     justify-content: center;
     gap: 14px;
     flex-wrap: wrap;
 }

 .footer a {
     color: var(--text-secondary);
     text-decoration: none;
     font-weight: 700;
 }

 .footer a:hover {
     color: var(--text-primary);
     text-decoration: underline;
 }

 .footer-bottom {
     margin-top: 12px;
     font-size: 13px;
     color: var(--text-tertiary);
 }

.footer p {
    font-size: 14px;
    margin-bottom: 8px;
}

.footer-note {
    font-size: 13px;
    color: var(--text-tertiary);
}

@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    .header {
        margin-bottom: 32px;
    }

    .logo h1 {
        font-size: 26px;
    }

    .tagline {
        font-size: 16px;
    }

     .hero {
         padding: 18px;
     }

     .hero h2 {
         font-size: 24px;
     }

     .io-grid {
         grid-template-columns: 1fr;
     }

    textarea {
        min-height: 180px;
        font-size: 15px;
    }

    .simplify-btn {
        width: 100%;
        justify-content: center;
    }

     .mode-row {
         flex-direction: column;
         align-items: stretch;
     }

     .mode-select {
         width: 100%;
     }

    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 8px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .input-section,
    .output-section {
        padding: 20px;
    }
}