:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #34d399;
    --accent-hover: #10b981;
    --accent-light: #064e3b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

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

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.tool-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    border: 1px solid var(--border);
}

.mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-tertiary);
    padding: 0.375rem;
    border-radius: var(--radius-sm);
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow);
}

.mode-btn .icon {
    font-size: 1.1rem;
}

.input-section,
.output-section {
    margin-bottom: 1rem;
}

.input-header,
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

label {
    font-weight: 600;
    color: var(--text-primary);
}

.input-actions,
.output-actions {
    display: flex;
    gap: 0.5rem;
}

.small-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.small-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.small-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

textarea {
    width: 100%;
    padding: 1rem;
    font-size: 0.95rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

textarea[readonly] {
    background: var(--bg-tertiary);
    cursor: default;
}

.char-count {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.detected-badge {
    padding: 0.25rem 0.5rem;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 500;
    display: none;
}

.detected-badge.visible {
    display: inline-block;
}

.convert-section {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.convert-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.convert-btn:active {
    transform: translateY(0);
}

.convert-btn .arrow {
    font-size: 1.25rem;
}

.options-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.info-section {
    margin-top: 2rem;
}

.info-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.info-section > p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.info-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.info-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.note {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.2s;
    z-index: 100;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Drag and drop styles */
.input-section.dragover textarea {
    border-color: var(--accent);
    border-style: dashed;
    background: var(--accent-light);
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .tool-card {
        padding: 1.5rem;
    }

    .mode-toggle {
        flex-direction: column;
    }

    .input-header,
    .output-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

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

    .options-section {
        flex-direction: column;
        gap: 0.75rem;
    }
}
