:root {
    --bg: #11151c;
    --panel: #191f29;
    --panel-soft: #202835;
    --panel-strong: #0d1117;
    --border: #303b4c;
    --border-soft: #242d3a;
    --text: #edf2ff;
    --muted: #94a3b8;
    --accent: #5eead4;
    --accent-strong: #2dd4bf;
    --danger: #fb7185;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Segoe UI, Roboto, sans-serif;
    background:
        radial-gradient(circle at top, rgba(45, 212, 191, 0.08), transparent 30%),
        linear-gradient(180deg, #0b0f14, #11151c 45%, #0f1319);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--border);
    background: #18202a;
    color: var(--text);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover {
    background: #202a36;
    border-color: #4a586f;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

input,
select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f1520;
    color: var(--text);
}

input[type="range"] {
    padding: 0;
    accent-color: var(--accent);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    margin: 0;
}

.app-shell {
    min-height: 100vh;
    padding: 1rem;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
}

.panel {
    background: linear-gradient(180deg, rgba(30, 38, 50, 0.98), rgba(20, 27, 37, 0.96));
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.topbar {
    padding: 1rem 1.25rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.95rem;
}

.brand-mark {
    width: 3rem;
    height: 3rem;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(94, 234, 212, 0.25), rgba(59, 130, 246, 0.15));
    border: 1px solid rgba(94, 234, 212, 0.35);
    font-size: 1.5rem;
}

.brand h1,
.panel-heading h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.brand p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.topbar-controls,
.inline-fields,
.panel-actions,
.timeline-actions,
.canvas-meta,
.canvas-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.field-group {
    display: grid;
    gap: 0.4rem;
}

.field-group.compact label,
.field-group > span,
.label-muted {
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.inline-fields input[type="number"] {
    width: 4.5rem;
}

.workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 320px;
    gap: 1rem;
}

.left-column,
.right-column,
.editor-column {
    min-height: 0;
    display: grid;
    gap: 1rem;
}

.tools-panel,
.palette-panel,
.layers-panel,
.canvas-panel,
.timeline-panel {
    padding: 1rem;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.tool-btn {
    min-height: 5rem;
    display: grid;
    place-items: center;
    text-align: center;
    gap: 0.15rem;
    background: linear-gradient(180deg, #18202a, #131922);
}

.tool-btn small {
    color: var(--muted);
}

.tool-btn.active,
.ghost-button.active {
    border-color: rgba(94, 234, 212, 0.8);
    box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.35) inset, 0 10px 24px rgba(45, 212, 191, 0.08);
    background: linear-gradient(180deg, rgba(25, 52, 56, 0.9), rgba(16, 30, 33, 0.95));
}

.tool-icon {
    font-size: 1.25rem;
}

.ghost-button {
    background: #141b24;
}

.accent-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #08221e;
    border-color: transparent;
    font-weight: 700;
}

.accent-button.small {
    padding-inline: 1rem;
}

.pill {
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #111720;
    font-size: 0.82rem;
    color: var(--muted);
}

.accent-pill {
    color: var(--text);
    border-color: rgba(94, 234, 212, 0.3);
}

.color-preview-wrap {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1rem;
}

.color-preview {
    width: 3rem;
    height: 3rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: #ff6688;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.value-strong {
    font-weight: 700;
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    padding: 0;
}

.swatch.active {
    border-color: #f8fafc;
    box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.3);
}

.picker-block,
.color-input-grid {
    display: grid;
    gap: 0.75rem;
}

.picker-row {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 0.75rem;
    align-items: center;
}

.picker-row label {
    color: var(--muted);
    font-size: 0.82rem;
}

.color-input-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1rem;
}

.color-input-grid label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.hex-field {
    grid-column: 1 / -1;
}

.canvas-panel {
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 0.85rem;
}

.canvas-stage {
    position: relative;
    min-height: 420px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(8, 11, 16, 0.75), rgba(14, 20, 29, 0.9)),
        radial-gradient(circle at center, rgba(59, 130, 246, 0.06), transparent 45%);
    border: 1px solid var(--border);
    overflow: hidden;
}

#editorCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.canvas-overlay-note {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(10, 14, 19, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--muted);
    font-size: 0.75rem;
}

.status-strip {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: rgba(10, 14, 19, 0.6);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}

.layers-list,
.frames-list {
    display: grid;
    gap: 0.65rem;
    align-content: start;
}

.layer-row,
.frame-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(12, 17, 24, 0.92);
}

.layer-row {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 0.65rem;
    align-items: center;
    padding: 0.75rem;
}

.layer-row.active,
.frame-card.active {
    border-color: rgba(94, 234, 212, 0.65);
    box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.15) inset;
}

.layer-main {
    min-width: 0;
}

.layer-name {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.layer-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.78rem;
}

.opacity-slider {
    accent-color: var(--accent);
}

.drag-handle {
    font-size: 1.1rem;
    color: var(--muted);
}

.eye-btn {
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    display: grid;
    place-items: center;
}

.timeline-actions {
    justify-content: flex-end;
}

.fps-control {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.fps-control input {
    width: 5rem;
}

.frames-list {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
}

.frame-card {
    padding: 0.75rem;
    display: grid;
    gap: 0.55rem;
}

.frame-thumb {
    width: 100%;
    aspect-ratio: 1;
    background:
        linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937),
        linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937);
    background-position: 0 0, 8px 8px;
    background-size: 16px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.frame-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.frame-title {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.86rem;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(3, 7, 12, 0.65);
    backdrop-filter: blur(6px);
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-card {
    width: min(420px, 100%);
    padding: 1rem;
}

.modal-body,
.modal-footer {
    display: grid;
    gap: 0.9rem;
}

.modal-footer {
    margin-top: 1rem;
}

.empty-state {
    padding: 1.2rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--muted);
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 290px minmax(0, 1fr);
    }

    .right-column {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .canvas-stage {
        min-height: 340px;
    }

    .left-column,
    .right-column {
        grid-template-columns: 1fr;
    }

    .tool-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
