:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #111120;
    --bg-tertiary: #1a1a2e;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(108, 99, 255, 0.3);
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --accent: #6c63ff;
    --accent-glow: rgba(108, 99, 255, 0.2);
    --accent-2: #ff6b9d;
    --accent-3: #00d4aa;
    --gradient-1: linear-gradient(135deg, #6c63ff, #a855f7);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.05) 0%, transparent 50%), radial-gradient(ellipse at 80% 50%, rgba(255, 107, 157, 0.03) 0%, transparent 50%)
}

.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
    position: relative
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.badge {
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-weight: 500
}

.header-right {
    display: flex;
    gap: 6px
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border)
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover)
}

.btn-primary {
    background: var(--gradient-1);
    color: #fff;
    border: none
}

.btn-primary:hover {
    opacity: 0.9
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem
}

.btn-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition)
}

.btn-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary)
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px
}

.card-header h2 {
    font-size: 0.85rem;
    font-weight: 600
}

.url-input-row {
    display: flex;
    gap: 4px
}

.scheme-select {
    padding: 8px 10px;
    background: var(--bg-tertiary);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0
}

.scheme-select:focus {
    outline: none;
    border-color: var(--accent)
}

.url-field {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    transition: border-color var(--transition)
}

.url-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow)
}

.url-field::placeholder {
    color: var(--text-muted)
}

.params-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.param-row {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition)
}

.param-row:hover {
    border-color: var(--border-hover)
}

.param-row .param-enabled {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0
}

.param-row .param-key {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-primary);
    color: var(--accent-3);
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500
}

.param-row .param-key:focus {
    outline: none;
    border-color: var(--accent)
}

.param-row .param-key::placeholder {
    color: var(--text-muted)
}

.param-row .param-eq {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    flex-shrink: 0
}

.param-row .param-value {
    flex: 2;
    padding: 6px 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem
}

.param-row .param-value:focus {
    outline: none;
    border-color: var(--accent)
}

.param-row .param-value::placeholder {
    color: var(--text-muted)
}

.param-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 0, 0, 0.08);
    border-radius: 4px;
    color: #ff4757;
    cursor: pointer;
    font-size: 0.6rem;
    flex-shrink: 0;
    transition: background var(--transition)
}

.param-remove:hover {
    background: rgba(255, 0, 0, 0.18)
}

.preview-card .card-header {
    flex-wrap: wrap;
    gap: 8px
}

.preview-actions {
    display: flex;
    gap: 4px
}

.url-preview {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    word-break: break-all;
    color: var(--text-primary);
    min-height: 44px
}

.url-preview .scheme {
    color: var(--accent)
}

.url-preview .host {
    color: var(--text-primary);
    font-weight: 500
}

.url-preview .path {
    color: var(--accent-2)
}

.url-preview .qmark {
    color: var(--text-muted)
}

.url-preview .pkey {
    color: var(--accent-3)
}

.url-preview .peq {
    color: var(--text-muted)
}

.url-preview .pval {
    color: var(--accent)
}

.url-preview .pamp {
    color: var(--text-muted)
}

.url-stats {
    margin-top: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono)
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-style: italic;
    font-family: var(--font)
}

.parse-row {
    display: flex;
    gap: 6px
}

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4)
}

.sidebar.hidden {
    display: none
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border)
}

.sidebar-header h2 {
    font-size: 0.9rem;
    font-weight: 600
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px
}

.template-item {
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition)
}

.template-item:hover {
    background: var(--bg-glass);
    border: 1px solid var(--border-hover)
}

.template-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary)
}

.template-url {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--accent);
    margin-top: 3px;
    word-break: break-all
}

.template-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px
}

@media(max-width:768px) {
    .app {
        padding: 16px 12px
    }

    .url-input-row {
        flex-direction: column
    }

    .param-row {
        flex-wrap: wrap
    }

    .sidebar {
        width: 100%
    }
}