/* Noise Texture Generator — Dark Creative Studio */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

:root {
    --accent: #A78BFA;
    --accent-rgb: 167, 139, 250;
    --accent-dim: #7C5CC7;
    --bg: #18181B;
    --bg-card: #27272A;
    --bg-elevated: #3F3F46;
    --bg-surface: #52525B;
    --text: #FAFAFA;
    --text-muted: #A1A1AA;
    --text-dim: #71717A;
    --border: rgba(167, 139, 250, 0.15);
    --border-hover: rgba(167, 139, 250, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border)
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: var(--radius-sm);
    font-size: 1.1rem
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #C4B5FD);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px
}

.layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px
}

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

/* Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 20px
}

.control-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px
}

.group-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px
}

.type-btn {
    padding: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition)
}

.type-btn:hover {
    color: var(--text);
    border-color: var(--border-hover)
}

.type-btn.active {
    background: var(--accent);
    border-color: transparent;
    color: var(--bg);
    font-weight: 600
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px
}

.control-row label {
    flex: 0 0 80px;
    font-size: 0.75rem;
    color: var(--text-muted)
}

.control-row input[type="range"] {
    flex: 1;
    height: 4px;
    appearance: none;
    background: var(--bg-surface);
    border-radius: 2px;
    outline: none;
    cursor: pointer
}

.control-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer
}

.ctrl-val {
    min-width: 36px;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    text-align: right
}

.seed-input {
    width: 70px;
    padding: 4px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    text-align: center
}

.seed-input:focus {
    border-color: var(--accent)
}

.btn-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition)
}

.btn-icon:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface)
}

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px
}

.color-row label {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted)
}

.color-input {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px
}

.size-row {
    display: flex;
    align-items: center;
    gap: 8px
}

.size-input {
    width: 80px;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    text-align: center
}

.size-x {
    color: var(--text-dim);
    font-size: 0.8rem
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 10px
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4);
    transform: translateY(-1px)
}

.download-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px
}

.btn-secondary {
    padding: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition)
}

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

.preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px
}

.preset-thumb {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    position: relative
}

.preset-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.05)
}

.preset-thumb canvas {
    width: 100%;
    height: 100%;
    display: block
}

.preset-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px;
    background: rgba(0, 0, 0, 0.6);
    font-size: 0.5rem;
    color: var(--text-muted);
    text-align: center
}

/* Preview */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 20px
}

.canvas-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 400px
}

.canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    image-rendering: pixelated
}

.tile-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px
}

.tile-section .group-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer
}

.tile-section input[type="checkbox"] {
    accent-color: var(--accent)
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    margin-top: 12px
}

.tile-grid canvas {
    width: 100%;
    height: auto;
    display: block
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: 0.35s ease;
    z-index: 200
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

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

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

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