:root {
    --primary: #D97706;
    --primary-dim: #D9770640;
    --primary-glow: #D9770618;
    --secondary: #FBBF24;
    --accent: #6366F1;
    --accent-dim: #6366F130;
    --bg: #1A1400;
    --bg-card: #261E08;
    --bg-card-hover: #302610;
    --bg-input: #1E1805;
    --border: #3D3010;
    --border-hover: #D9770660;
    --text: #F5F0E0;
    --text-muted: #8B7B55;
    --text-dim: #6B5E3E;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --success: #10B981;
    --danger: #EF4444;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(26, 20, 0, 0.98), rgba(26, 20, 0, 0.92));
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 20px var(--primary-dim)
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: -2px
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition)
}

.btn-primary {
    background: var(--primary);
    color: #fff
}

.btn-primary:hover {
    background: var(--secondary);
    box-shadow: 0 0 20px var(--primary-dim);
    transform: translateY(-1px)
}

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

.btn-secondary:hover {
    border-color: var(--primary)
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.35rem 0.75rem
}

.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-glow)
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid var(--primary-dim)
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden
}

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

.panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem
}

.panel-title svg {
    color: var(--primary)
}

.panel-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border)
}

.header-btns {
    display: flex;
    gap: 0.25rem
}

.css-editor {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    background: var(--bg-input);
    color: var(--secondary);
    border: none;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    resize: vertical;
    outline: none;
    line-height: 1.6
}

.css-editor::placeholder {
    color: var(--text-dim)
}

.parse-count {
    font-size: 0.8rem;
    color: var(--text-muted)
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
    transition: border-color var(--transition)
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0.75rem 1rem
}

.preset-btn {
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition)
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow)
}

.custom-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.5rem;
    padding: 0.75rem 1rem
}

.ruler-container {
    padding: 1rem;
    overflow-x: auto
}

.ruler {
    position: relative;
    min-height: 120px
}

.ruler-scale {
    display: flex;
    height: 30px;
    border-bottom: 2px solid var(--border);
    position: relative
}

.ruler-tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    background: var(--border)
}

.ruler-tick.major {
    height: 20px;
    background: var(--text-muted)
}

.ruler-tick.minor {
    height: 10px
}

.ruler-tick-label {
    position: absolute;
    bottom: 22px;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    transform: translateX(-50%);
    white-space: nowrap
}

.ruler-width {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono)
}

.ruler-ranges {
    position: relative;
    margin-top: 0.25rem
}

.ruler-range {
    height: 24px;
    position: absolute;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    transition: all var(--transition);
    opacity: 0.8
}

.ruler-range:hover {
    opacity: 1;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3)
}

.ruler-range .range-label {
    overflow: hidden;
    text-overflow: ellipsis
}

.breakpoint-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem
}

.bp-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-xs);
    transition: background var(--transition);
    cursor: pointer
}

.bp-item:hover {
    background: var(--bg)
}

.bp-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0
}

.bp-info {
    flex: 1
}

.bp-name {
    font-size: 0.82rem;
    font-weight: 500
}

.bp-range {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono)
}

.bp-copy {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition)
}

.bp-item:hover .bp-copy {
    opacity: 1
}

.bp-copy:hover {
    border-color: var(--primary);
    color: var(--primary)
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border)
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-dim)
}

.device-btns {
    display: flex;
    gap: 0.25rem
}

.device-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition)
}

.device-btn:hover,
.device-btn.active {
    border-color: var(--primary);
    background: var(--primary-glow)
}

.preview-size {
    font-size: 0.72rem;
    color: var(--secondary);
    font-family: var(--font-mono)
}

.preview-frame {
    padding: 1rem;
    overflow: hidden
}

.preview-content {
    margin: 0 auto;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-xs);
    min-height: 100px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden
}

.preview-placeholder {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-dim)
}

.preview-active-rules {
    padding: 0.75rem;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--secondary);
    white-space: pre-wrap
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem
}

.toast {
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

::-webkit-scrollbar {
    width: 6px
}

::-webkit-scrollbar-track {
    background: transparent
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px
}

@media(max-width:1024px) {
    .content-grid {
        grid-template-columns: 1fr
    }
}

@media(max-width:640px) {
    .main-content {
        padding: 1rem
    }

    .custom-form {
        grid-template-columns: 1fr 1fr
    }
}