:root {
    color-scheme: light;
    --bg: #f1f5f9;
    --panel: #ffffff;
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #0ea5e9;
    --accent: #f97316;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --radius: 18px;
}

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

body {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #e0f2fe 0, #f8fafc 45%, #ecfeff 100%);
    color: var(--text);
    min-height: 100vh;
}

.hidden {
    display: none;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.hero {
    text-align: center;
    margin-bottom: 32px;
}

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

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
}

.brand img {
    width: 46px;
    height: 46px;
}

.back-link {
    font-size: 14px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 999px;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: var(--text);
    border-color: var(--secondary);
}

.hero h1 {
    font-size: clamp(28px, 3.3vw, 44px);
    margin: 10px 0 8px;
}

.hero p {
    color: var(--muted);
    max-width: 720px;
    margin: 0 auto;
}

.converter {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 8px);
    padding: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

.converter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.converter-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
    flex-wrap: wrap;
}

.icon-button {
    border: 1px solid var(--line);
    background: #f8fafc;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.icon-button:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.6fr);
    gap: 20px;
}

textarea {
    width: 100%;
    min-height: 266px;
    padding: 16px;
    border-radius: var(--radius);
    border: 2px solid #38bdf8;
    font-size: 15px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    color: var(--text);
    resize: vertical;
    outline: none;
}

textarea:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

.action-button {
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.action-button.primary {
    background: var(--primary);
    color: white;
}

.action-button.primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 12px 24px rgba(16, 185, 129, 0.25);
    transform: translateY(-1px);
}

.action-button.secondary {
    background: #e0f2fe;
    color: #0f172a;
}

.action-button.secondary:hover {
    background: #bae6fd;
}

.action-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.control-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

select,
input[type="text"] {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    font-size: 14px;
    font-family: inherit;
    width: 100%;
}

.preview {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.preview h3 {
    font-size: 20px;
    color: #2563eb;
    margin-bottom: 14px;
}

.preview-card {
    min-height: 266px;
    border-radius: var(--radius);
    border: 2px dashed #cbd5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #f8fafc;
}

.preview-card img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 14px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
}

.preview-hint {
    color: var(--muted);
    font-size: 14px;
}

.notice {
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
}

.status {
    margin-top: 10px;
    font-size: 14px;
    color: var(--muted);
}

.status[data-state="success"] {
    color: #16a34a;
}

.status[data-state="error"] {
    color: #dc2626;
}

.footer {
    text-align: center;
    margin-top: 36px;
    padding-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 900px) {
    .hero-top {
        flex-direction: column;
        align-items: flex-start;
    }

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

@media (max-width: 640px) {
    .page {
        padding: 36px 16px 56px;
    }

    .converter {
        padding: 18px;
    }

    .converter-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .converter-title {
        font-size: 18px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .icon-button {
        padding: 5px 6px;
        border-radius: 8px;
    }

    textarea {
        min-height: 200px;
    }

    .controls {
        gap: 14px;
    }

    .control-row {
        flex-direction: column;
    }

    .action-button,
    select,
    input[type="text"] {
        width: 100%;
    }
}
