/* ── Generator v3 — polished, modern, clean ── */

/* ── Toolbar ── */

.gen-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 14px;
}

.gen-toolbar-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.gen-title {
    color: var(--text);
    letter-spacing: 0.02em;
}

.gen-subtitle {
    color: var(--muted);
}

.gen-toolbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.gen-btn,
.gen-preset,
.gen-lock,
.gen-custom-input,
.gen-opt,
.gen-aspect-opt,
.gen-output-panel,
.gen-history-item {
    border-radius: var(--border-radius);
}

/* ── Shared button base ── */

.gen-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    padding: 5px 11px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: color 100ms ease, background 100ms ease;
}

html[data-theme="light"] .gen-btn {
    background: rgba(0, 0, 0, 0.04);
}

.gen-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .gen-btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.gen-btn svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.gen-btn:hover svg {
    opacity: 1;
}

.gen-btn-ghost {
    background: transparent;
}

.gen-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] .gen-btn-ghost:hover {
    background: rgba(0, 0, 0, 0.04);
}

.gen-btn-xs {
    padding: 2px 7px;
}

.gen-btn-copy {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

html[data-theme="light"] .gen-btn-copy {
    background: rgba(0, 0, 0, 0.05);
}

.gen-btn-copy:hover {
    background: rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .gen-btn-copy:hover {
    background: rgba(0, 0, 0, 0.09);
}

.gen-btn-copy.is-copied {
    color: var(--text);
    background: rgba(255, 255, 255, 0.14);
}

html[data-theme="light"] .gen-btn-copy.is-copied {
    background: rgba(0, 0, 0, 0.1);
}

/* ── Presets row ── */

.gen-presets {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    overflow-x: auto;
}

html[data-theme="light"] .gen-presets {
    border-top-color: rgba(0, 0, 0, 0.04);
}

.gen-presets-label {
    letter-spacing: 0.02em;
    color: var(--muted);
    flex-shrink: 0;
}

.gen-presets-list {
    display: flex;
    gap: 4px;
}

.gen-preset {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    padding: 4px 10px;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: color 100ms ease, background 100ms ease;
}

html[data-theme="light"] .gen-preset {
    background: rgba(0, 0, 0, 0.035);
}

.gen-preset:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .gen-preset:hover {
    background: rgba(0, 0, 0, 0.07);
}

.gen-preset-dot {
    width: 5px;
    height: 5px;
    flex-shrink: 0;
}

/* ── Layout ── */

.gen-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: calc(100vh - 200px);
    align-items: start;
    margin-top: 4px;
}

/* ── Left column: parameters ── */

.gen-col-params {
    padding-right: 24px;
    padding-bottom: 40px;
}

.gen-group {
    padding: 16px 0 14px;
}

.gen-group + .gen-group {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

html[data-theme="light"] .gen-group + .gen-group {
    border-top-color: rgba(0, 0, 0, 0.05);
}

.gen-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.gen-group-label {
    color: var(--text);
    letter-spacing: 0.02em;
    user-select: none;
}

.gen-group-number {
    color: var(--border);
    margin-right: 6px;
}

.gen-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    padding: 0;
    transition: color 100ms ease;
}

html[data-theme="light"] .gen-lock {
    color: rgba(0, 0, 0, 0.12);
}

.gen-lock:hover {
    color: var(--muted);
}

.gen-lock.is-locked {
    color: var(--text);
}

.gen-lock svg {
    width: 11px;
    height: 11px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Custom object input ── */

.gen-custom-input {
    width: 100%;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 6px 9px;
    margin-bottom: 8px;
    outline: none;
    transition: background 100ms ease;
}

html[data-theme="light"] .gen-custom-input {
    background: rgba(0, 0, 0, 0.035);
}

.gen-custom-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.gen-custom-input:focus {
    background: rgba(255, 255, 255, 0.07);
}

html[data-theme="light"] .gen-custom-input:focus {
    background: rgba(0, 0, 0, 0.055);
}

/* ── Option buttons ── */

.gen-options {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.gen-opt {
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1.35;
    white-space: nowrap;
    transition: color 100ms ease, background 100ms ease;
    text-transform: uppercase;
}

html[data-theme="light"] .gen-opt {
    background: rgba(0, 0, 0, 0.035);
}

.gen-opt:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .gen-opt:hover {
    background: rgba(0, 0, 0, 0.07);
}

.gen-opt.is-selected {
    color: var(--text);
    background: rgba(255, 255, 255, 0.13);
}

html[data-theme="light"] .gen-opt.is-selected {
    background: rgba(0, 0, 0, 0.1);
}

/* ── Aspect ratio visual options ── */

.gen-aspect-options {
    display: flex;
    gap: 4px;
}

.gen-aspect-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    padding: 9px 12px 7px;
    transition: color 100ms ease, background 100ms ease;
}

html[data-theme="light"] .gen-aspect-opt {
    background: rgba(0, 0, 0, 0.035);
}

.gen-aspect-opt:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .gen-aspect-opt:hover {
    background: rgba(0, 0, 0, 0.07);
}

.gen-aspect-opt.is-selected {
    color: var(--text);
    background: rgba(255, 255, 255, 0.13);
}

html[data-theme="light"] .gen-aspect-opt.is-selected {
    background: rgba(0, 0, 0, 0.1);
}

.gen-aspect-shape {
    border: 1px solid currentColor;
    opacity: 0.35;
}

.gen-aspect-shape-1x1 { width: 16px; height: 16px; }
.gen-aspect-shape-4x5 { width: 14px; height: 17px; }
.gen-aspect-shape-3x4 { width: 13px; height: 17px; }
.gen-aspect-shape-2x3 { width: 12px; height: 18px; }
.gen-aspect-shape-16x9 { width: 20px; height: 11px; }
.gen-aspect-shape-3x2 { width: 18px; height: 12px; }
.gen-aspect-shape-9x16 { width: 10px; height: 18px; }

.gen-aspect-opt:hover .gen-aspect-shape {
    opacity: 0.55;
}

.gen-aspect-opt.is-selected .gen-aspect-shape {
    opacity: 0.85;
}

.gen-aspect-label {
    letter-spacing: 0.03em;
}

/* ── Right column: output ── */

.gen-col-output {
    padding-left: 24px;
    position: sticky;
    top: 52px;
    max-height: calc(100vh - 52px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gen-output-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] .gen-output-panel {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

.gen-output-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

html[data-theme="light"] .gen-output-bar {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

.gen-output-label {
    letter-spacing: 0.02em;
    color: var(--muted);
}

.gen-output-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gen-output-meta {
    color: var(--muted);
    letter-spacing: 0.02em;
    opacity: 0.7;
}

.gen-output-body {
    position: relative;
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    min-height: 120px;
}

.gen-prompt {
    font-family: inherit;
    font-size: inherit;
    line-height: 1.75;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.gen-prompt-empty {
    color: var(--muted);
    opacity: 0.6;
}

/* ── Scanline ── */

.gen-scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--text), transparent);
    opacity: 0;
    pointer-events: none;
}

.gen-scanline.is-active {
    animation: scanline-sweep 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scanline-sweep {
    0% {
        transform: translateY(0);
        opacity: 0.25;
    }
    40% {
        opacity: 0.1;
    }
    100% {
        transform: translateY(min(500px, 60vh));
        opacity: 0;
    }
}

/* ── History ── */

.gen-history {
    margin-top: 10px;
    flex-shrink: 0;
    max-height: 180px;
    display: flex;
    flex-direction: column;
}

.gen-history-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.gen-history-label {
    letter-spacing: 0.02em;
    color: var(--muted);
}

.gen-history-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.gen-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 9px;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    transition: color 100ms ease, background 100ms ease;
}

html[data-theme="light"] .gen-history-item {
    background: rgba(0, 0, 0, 0.025);
}

.gen-history-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

html[data-theme="light"] .gen-history-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.gen-history-preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gen-history-time {
    flex-shrink: 0;
    opacity: 0.4;
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .gen-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .gen-col-params {
        padding-right: 0;
        padding-bottom: 16px;
    }

    .gen-col-output {
        padding-left: 0;
        position: relative;
        top: auto;
        max-height: none;
        margin-top: 8px;
    }

    .gen-output-body {
        min-height: 200px;
        max-height: 50vh;
    }
}

@media (max-width: 640px) {
    .gen-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .gen-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .gen-presets {
        gap: 6px;
    }

    .gen-aspect-options {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gen-scanline { animation: none !important; }
    .gen-opt, .gen-btn, .gen-preset, .gen-aspect-opt, .gen-lock,
    .gen-custom-input, .gen-history-item, .gen-btn-copy {
        transition: none !important;
    }
}
