@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: fallback;
    src: local("Inter"), local("Inter Regular"), url("../assets/fonts/inter-latin.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: fallback;
    src: local("JetBrains Mono"), local("JetBrainsMono-Regular"), url("../assets/fonts/jetbrains-mono-latin.woff2") format("woff2");
}

@font-face {
    font-family: "Inter Fallback";
    src: local("Segoe UI");
    ascent-override: 90%;
    descent-override: 22%;
    line-gap-override: 0%;
    size-adjust: 102%;
}

@font-face {
    font-family: "JetBrains Mono Fallback";
    src: local("Consolas");
    ascent-override: 92%;
    descent-override: 24%;
    line-gap-override: 0%;
    size-adjust: 98%;
}

:root {
    --bg: #09090b;
    --surface: #131316;
    --surface-hover: #1c1c20;
    --border: #303035;
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent: #ffc700;
    --accent-hover: #e6b300;
    --accent-dim: rgba(255, 199, 0, 0.15);
    --text-on-accent: #000;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;

    --font-ui: "Inter", "Inter Fallback", "Segoe UI", system-ui, sans-serif;
    --font-code: "JetBrains Mono", "JetBrains Mono Fallback", "Cascadia Mono", Consolas, monospace;

    --shadow: none;
    --duration-instant: 0s;
    --duration-ui-fast: 0.12s;
    --duration-ui: 0.3s;
    --duration-base: 0.22s;
    --duration-entrance: 0.26s;
    --duration-feedback: 0.34s;

    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-smooth: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-enter: cubic-bezier(0, 0.55, 0.45, 1);

    --transition-fast: var(--duration-ui) var(--ease-standard);
    --transition-base: var(--duration-base) var(--ease-standard);

    --scale-hover: 1.08;
    --scale-active: 0.95;
    --scale-badge-hover: 1.11;
    --scale-badge-active: 0.93;
    --scale-drop-active: 0.99;
    --lift-hover: 0px;
    --lift-thumb-active: -2px;

    --app-header-height: 43px;
    --workspace-gap: 1rem;
    --screen-edge-gap: 0.7rem;
    --layout-inline-pad: var(--screen-edge-gap);

    --header-float-bg: linear-gradient(180deg, rgba(24, 24, 28, 0.94), rgba(16, 16, 19, 0.94));
    --header-float-border: rgba(255, 255, 255, 0.16);
    --header-float-radius: var(--radius-xl);
    --header-float-shadow: none;
    --header-divider: rgba(255, 255, 255, 0.2);

    --preview-checker: #1c1c20;
    --overlay-bg-strong: rgba(0, 0, 0, 0.8);
    --overlay-bg-soft: rgba(0, 0, 0, 0.7);

    --shadow-strong: none;
    --shadow-soft: none;
    --shadow-thumb-active: none;
    --shadow-slider-thumb: none;
    --shadow-inset-strong: none;
    --shadow-inset-code: none;

    --code-toolbar-divider: #000;
    --code-title-color: #fff;
    --code-title-shadow: none;
    --code-fg: #fff;
    --code-bg: #0a0a0c;

    --checkmark-color: #000;
    --scrollbar-hover: #666;

    --native-select-chevron: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");

    --ring-size: 2px;
    --ring-offset: 2px;
    --ring-color: var(--accent);
    --ring-shadow: 0 0 0 3px var(--accent-dim);

    --state-hover-border: rgba(255, 199, 0, 0.66);
    --state-hover-bg: rgba(255, 199, 0, 0.14);
    --state-active-bg: rgba(255, 199, 0, 0.22);
    --state-press-scale: var(--scale-active);
    --state-disabled-opacity: 0.48;
}

:root[data-app-theme="light"] {
    --bg: #f2f2f2;
    --surface: #ffffff;
    --surface-hover: #ebebeb;
    --border: #b8b8b8;
    --text: #171717;
    --text-muted: #4f4f4f;
    --accent: #ffc700;
    --accent-hover: #e1ac00;
    --accent-dim: rgba(255, 199, 0, 0.2);
    --text-on-accent: #171717;

    --shadow: none;
    --shadow-strong: none;
    --shadow-soft: none;
    --shadow-thumb-active: none;
    --shadow-slider-thumb: none;
    --shadow-inset-strong: none;
    --shadow-inset-code: none;

    --header-float-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 248, 248, 0.98));
    --header-float-border: rgba(28, 28, 28, 0.22);
    --header-float-shadow: none;
    --header-divider: rgba(28, 28, 28, 0.22);

    --preview-checker: #d6d6d6;
    --overlay-bg-strong: rgba(255, 255, 255, 0.95);
    --overlay-bg-soft: rgba(255, 255, 255, 0.92);

    --code-toolbar-divider: #b5b5b5;
    --code-title-color: #171717;
    --code-title-shadow: none;
    --code-fg: #171717;
    --code-bg: #f6f6f6;

    --checkmark-color: #171717;
    --scrollbar-hover: #727272;

    --state-hover-border: rgba(225, 172, 0, 0.72);
    --state-hover-bg: rgba(255, 199, 0, 0.2);
    --state-active-bg: rgba(255, 199, 0, 0.3);
    --ring-shadow: 0 0 0 3px rgba(255, 199, 0, 0.45);

    --native-select-chevron: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23171717' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

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

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    background: transparent;
    border-bottom: none;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--screen-edge-gap) var(--layout-inline-pad) 0;
    min-height: var(--app-header-height);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 110;
}

.header-inner {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--header-float-border);
    border-radius: var(--header-float-radius);
    background: var(--header-float-bg);
    box-shadow: var(--header-float-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.brand h1 {
    margin-top: 0;
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 650;
    letter-spacing: -0.3px;
}

.tagline {
    margin-top: 0;
    margin-left: 0.1rem;
    padding-left: 0.8rem;
    border-left: 1px solid var(--header-divider);
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.2;
}

.header-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-left: 0.3rem;
}

.visit-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    padding: 0.28rem 0.62rem;
    min-height: 28px;
    font-family: var(--font-code);
}

.visit-count[data-state="loading"],
.visit-count[data-state="ready"] {
    color: var(--text-muted);
}

.visit-count[data-state="unavailable"] {
    color: var(--text-muted);
    opacity: 0.9;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1;
    padding: 0.28rem 0.62rem;
    min-height: 28px;
    min-width: 114px;
    transition: background-color var(--duration-ui-fast) var(--ease-standard), border-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-bounce);
    transform-origin: center center;
}

.theme-toggle-btn:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent-hover);
    transform: scale(var(--scale-hover));
}

.theme-toggle-btn:active {
    transform: scale(var(--state-press-scale));
}

.theme-toggle-btn:focus-visible {
    outline-color: var(--accent);
}

.workspace {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: var(--screen-edge-gap) var(--layout-inline-pad) var(--screen-edge-gap);
    flex-grow: 1;
    display: grid;
    grid-template-columns: 280px 300px 1fr;
    gap: var(--workspace-gap);
    overflow: hidden;
}

.panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.panel-result {
    overflow-y: auto;
    overflow-x: visible;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
    animation: cardIn var(--duration-entrance) var(--ease-enter) both;
}

.card:has(.custom-select-wrapper.open) {
    z-index: 30;
}

.panel > .card:nth-child(2) {
    animation-delay: 0.06s;
}

.card.flex-col {
    height: 100%;
}

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

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
}

:root[data-app-theme="light"] .card-header h2 {
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
}

.icon-heading svg {
    margin-bottom: 2px;
    opacity: 0.85;
    stroke-width: 2.2px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mt-2 {
    margin-top: 0.75rem;
}

.mt-3 {
    margin-top: 1.25rem;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.badge {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-code);
    font-size: 11px;
    font-weight: 600;
}

.badge.interactive {
    user-select: none;
    cursor: pointer;
    transition: transform var(--duration-ui) var(--ease-bounce), background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard);
}

.badge.interactive:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    transform: scale(var(--scale-badge-hover)) rotate(-1deg);
    box-shadow: var(--shadow-strong);
}

.badge.interactive:active {
    transform: scale(var(--scale-badge-active));
}

input[type="number"],
input[type="text"],
.custom-select,
.custom-select-trigger {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-ui);
    transition: border-color var(--duration-ui-fast) var(--ease-standard), box-shadow var(--duration-ui) var(--ease-smooth), transform var(--duration-ui) var(--ease-smooth), background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard);
}

input[type="number"],
input[type="text"],
.custom-select {
    padding: 0.45rem 0.6rem;
    outline: none;
}

/* Remove native number input spinners to keep sizing fields visually clean. */
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"]:focus,
input[type="text"]:focus,
#code-output:focus {
    border-color: var(--accent);
    box-shadow: var(--ring-shadow);
}

input[type="number"]:hover,
input[type="text"]:hover,
#code-output:hover {
    border-color: var(--state-hover-border);
}

.custom-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--native-select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    padding-right: 2.2rem;
}

.custom-select.sm {
    width: auto;
    font-size: 12px;
    padding: 0.3rem 1.8rem 0.3rem 0.5rem;
    background-position: right 0.4rem center;
}

.custom-select.native-select-hidden {
    display: none;
}

.size-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard), background-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-bounce);
    transform-origin: center center;
}

.icon-btn:hover {
    border-color: var(--accent-hover);
    color: var(--text-on-accent);
    background: var(--accent);
    transform: scale(var(--scale-hover));
}

input[type="range"] {
    width: 100%;
    padding: 0.5rem 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    margin-top: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: var(--shadow-slider-thumb);
    cursor: grab;
    -webkit-appearance: none;
    transition: transform var(--duration-ui) var(--ease-bounce), background-color var(--duration-ui-fast) var(--ease-standard), box-shadow var(--duration-ui-fast) var(--ease-standard);
    transform-origin: center center;
}

input[type="range"]:hover::-webkit-slider-thumb {
    background: var(--accent);
    transform: scale(1.22);
}

input[type="range"]:hover::-webkit-slider-runnable-track {
    background: var(--border);
}

input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
    background: var(--accent);
    transform: scale(0.9);
}

input[type="range"]:active::-webkit-slider-runnable-track {
    background: var(--border);
}

.checkbox-row {
    display: flex;
    gap: 1rem;
}

.cb-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    font-size: 13px;
    user-select: none;
    cursor: pointer;
}

.cb-wrap input {
    display: none;
}

.cb {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    transition: border-color var(--duration-ui-fast) var(--ease-standard), background-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-bounce);
}

.cb-wrap:hover .cb {
    border-color: var(--accent);
}

.cb-wrap input:checked ~ .cb {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.06);
}

.cb-wrap input:checked ~ .cb::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 3.5px;
    height: 8px;
    border: solid var(--checkmark-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.preset-chips {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
}

.preset-btn {
    width: 100%;
    padding: 0.4rem 0.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 11.5px;
    font-family: var(--font-code);
    text-align: center;
    cursor: pointer;
    transition: background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard), border-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-bounce);
    transform-origin: center center;
}

.preset-btn:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent-hover);
    transform: scale(var(--scale-hover));
    box-shadow: var(--shadow-soft);
}

.preset-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

:root[data-app-theme="light"] .preset-btn.active {
    background: var(--state-active-bg);
    color: var(--text);
    border-color: var(--state-hover-border);
}

:root[data-app-theme="light"] .preset-btn.active:hover {
    background: var(--state-active-bg);
    color: var(--text);
    border-color: var(--state-hover-border);
}

.action-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard), border-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-bounce);
    transform-origin: center center;
}

.action-btn:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent-hover);
    transform: scale(var(--scale-hover));
}

.action-btn.outline:hover {
    border-color: var(--accent-hover);
    color: var(--text-on-accent);
}

.action-btn.highlight {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-on-accent);
    font-weight: 600;
}

.action-btn.highlight:hover {
    background: var(--accent);
    border-color: var(--accent-hover);
}

.action-btn:active,
.icon-btn:active,
.preset-btn:active {
    transform: scale(var(--state-press-scale));
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: pointer;
    transition: border-color var(--duration-ui-fast) var(--ease-standard), background-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-smooth), box-shadow var(--duration-ui-fast) var(--ease-standard);
}

.drop-zone:hover,
.drop-zone.is-dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: inset 0 0 0 1px var(--accent-dim);
}

.drop-zone.is-dragover {
    animation: gentlePop var(--duration-feedback) var(--ease-smooth) infinite alternate;
}

.drop-zone:active {
    transform: scale(var(--scale-drop-active));
}

.drop-icon {
    margin: 0 auto;
    color: var(--text-muted);
}

.drop-text {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.drop-hint {
    color: var(--text-muted);
    font-size: 11px;
}

.preview-area {
    position: relative;
    height: clamp(240px, 38vh, 360px);
    margin-bottom: 1rem;
    padding: 1rem;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    background-image: linear-gradient(45deg, var(--preview-checker) 25%, transparent 25%, transparent 75%, var(--preview-checker) 75%, var(--preview-checker)), linear-gradient(45deg, var(--preview-checker) 25%, transparent 25%, transparent 75%, var(--preview-checker) 75%, var(--preview-checker));
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

.preview-area canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

#preview-canvas {
    cursor: default;
}

#preview-canvas.is-gif {
    cursor: pointer;
}

.preview-info {
    position: absolute;
    right: 0.4rem;
    bottom: 0.4rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--overlay-bg-strong);
    color: var(--text);
    font-family: var(--font-code);
    font-size: 11px;
    pointer-events: none;
}

.gif-frames-timeline {
    min-height: 80px;
    margin-bottom: 0.75rem;
    padding: 0.25rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-inset-strong);
}

.gif-thumb-wrap {
    position: relative;
    height: 56px;
    width: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--surface);
    border-radius: var(--radius-xs);
    background: var(--surface);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity var(--duration-ui-fast) var(--ease-standard), border-color var(--duration-ui-fast) var(--ease-standard), background-color var(--duration-ui-fast) var(--ease-standard), transform var(--duration-ui) var(--ease-smooth);
    animation: thumbIn var(--duration-entrance) var(--ease-enter) both;
}

.gif-thumb-wrap:hover {
    opacity: 1;
    border-color: var(--text-muted);
    transform: translateY(var(--lift-hover));
}

.gif-thumb-wrap.active,
.gif-thumb-wrap:hover {
    opacity: 1;
    border-color: var(--accent);
    background: var(--state-hover-bg);
    box-shadow: var(--shadow-thumb-active);
}

.gif-thumb-wrap:active {
    transform: scale(0.97);
}

.gif-thumb-wrap:has(.animation-thumb).active {
    border-style: dashed;
}

.gif-frame-thumb {
    width: auto;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: calc(var(--radius-xs) - 2px);
}

.thumb-label {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    padding: 0;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: var(--font-code);
    font-size: 10px;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--overlay-bg-soft);
    pointer-events: none;
}

.thumb-label.play-icon {
    width: 14px;
    height: 14px;
}

.thumb-label svg {
    width: 10px;
    height: 10px;
}

.code-area {
    min-height: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.code-toolbar {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--code-toolbar-divider);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface-hover);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-title {
    color: var(--code-title-color);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: var(--code-title-shadow);
}

.code-actions {
    display: flex;
    gap: 0.4rem;
}

#code-output {
    width: 100%;
    flex-grow: 1;
    resize: none;
    outline: none;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 1rem;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.6;
    font-family: var(--font-code);
    font-size: 12.5px;
    color: var(--code-fg);
    background: var(--code-bg);
    box-shadow: var(--shadow-inset-code);
}

.tune-icon {
    margin-right: 6px;
    vertical-align: -2px;
    color: var(--text-muted);
}

.custom-select-wrapper {
    width: 100%;
    position: relative;
    user-select: none;
    font-family: var(--font-ui);
    font-size: 13px;
}

.custom-select-wrapper.sm {
    width: auto;
    font-size: 12px;
}

.custom-select-trigger {
    padding: 0.45rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color var(--duration-ui-fast) var(--ease-standard), background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard);
}

.custom-select-wrapper.sm .custom-select-trigger {
    padding: 0.3rem 0.5rem;
}

.custom-select-trigger:hover {
    border-color: var(--accent-hover);
    background: var(--accent);
    color: var(--text-on-accent);
}

.custom-select-trigger:hover .custom-select-icon {
    color: var(--text-on-accent);
}

.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--accent-hover);
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-wrapper.open .custom-select-icon {
    color: var(--text-on-accent);
}

.custom-select-trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    transition: transform var(--duration-ui) var(--ease-smooth);
}

.custom-select-wrapper.sm .custom-select-icon svg {
    width: 14px;
    height: 14px;
}

.custom-select-wrapper.open .custom-select-icon {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 1px);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-strong);
    transform-origin: center top;
}

.custom-select-wrapper.open .custom-select-dropdown {
    display: block;
    animation: slideDown var(--duration-entrance) var(--ease-enter);
}

.custom-select-option {
    padding: 0.45rem 0.6rem;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--duration-ui-fast) var(--ease-standard), color var(--duration-ui-fast) var(--ease-standard);
}

.custom-select-wrapper.sm .custom-select-option {
    padding: 0.3rem 0.5rem;
}

.custom-select-option:hover {
    background: var(--surface-hover);
    box-shadow: none;
}

.custom-select-option:active {
    background: var(--surface-hover);
    color: var(--text);
    box-shadow: none;
}

.custom-select-option.selected,
.custom-select-option[aria-selected="true"] {
    background: var(--state-active-bg);
    color: var(--text);
    box-shadow: none;
    font-weight: 700;
}

:root[data-app-theme="light"] .custom-select-option.selected,
:root[data-app-theme="light"] .custom-select-option[aria-selected="true"] {
    background: var(--state-active-bg);
    color: var(--text);
}

@keyframes slideDown {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes thumbIn {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes gentlePop {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.01);
    }
}

button,
select,
input[type="file"],
input[type="checkbox"],
input[type="radio"],
.preset-btn,
.cb-wrap {
    cursor: pointer;
}

:where(button, input, select, textarea, .preset-btn, .icon-btn, .action-btn, .badge.interactive):focus-visible {
    outline: var(--ring-size) solid var(--ring-color);
    outline-offset: var(--ring-offset);
}

.custom-select-trigger:focus-visible {
    outline: none;
    border-color: var(--state-hover-border);
    box-shadow: none;
}

:where(button, input, select, textarea, .custom-select-trigger):focus:not(:focus-visible) {
    outline: none;
}

:where(button, input, select, textarea):disabled {
    opacity: var(--state-disabled-opacity);
    filter: grayscale(0.25);
    cursor: not-allowed;
}

:where(button, input, select, textarea):disabled:hover,
:where(button, input, select, textarea):disabled:active {
    transform: none;
    box-shadow: none;
}

::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

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

::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border: 4px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
    transition: background-color var(--duration-ui-fast) var(--ease-standard);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-hover);
    cursor: grab;
}

::-webkit-scrollbar-thumb:active {
    background-color: var(--accent);
    cursor: grabbing;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

.is-hidden {
    display: none !important;
}

.cb-wrap.is-hidden {
    display: none !important;
}

.gif-frames-timeline.is-hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    body {
        height: auto;
        overflow: auto;
    }

    .workspace {
        height: auto;
        overflow: visible;
        align-items: start;
        grid-template-columns: 300px 1fr;
    }

    .panel {
        height: auto;
        overflow: visible;
    }

    .panel-tuning {
        grid-column: 1;
    }

    .panel-result {
        grid-column: 2;
        grid-row: 1 / span 2;
        position: sticky;
        top: calc(var(--app-header-height) + var(--screen-edge-gap));
        overflow-y: auto;
        overflow-x: visible;
        height: calc(100vh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
        max-height: calc(100vh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
        height: calc(100dvh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
        max-height: calc(100dvh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: var(--screen-edge-gap) var(--layout-inline-pad) 0;
    }

    .header-inner {
        gap: 0.58rem;
        padding: 0.46rem 0.62rem;
        border-radius: var(--radius-xl);
    }

    .tagline {
        display: none;
    }

    .theme-toggle-btn {
        font-size: 11.25px;
        padding: 0.22rem 0.52rem;
        min-height: 27px;
        min-width: 104px;
    }

    .visit-count {
        font-size: 11px;
        padding: 0.22rem 0.52rem;
        min-height: 27px;
    }

    .workspace {
        display: flex;
        flex-direction: column-reverse;
    }

    .panel-result {
        position: sticky;
        top: calc(var(--app-header-height) + var(--screen-edge-gap));
        z-index: 10;
        overflow-y: auto;
        overflow-x: visible;
        height: min(60vh, calc(100vh - var(--app-header-height) - (var(--screen-edge-gap) * 2)));
        height: min(60dvh, calc(100dvh - var(--app-header-height) - (var(--screen-edge-gap) * 2)));
        min-height: 320px;
        max-height: calc(100vh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
        max-height: calc(100dvh - var(--app-header-height) - (var(--screen-edge-gap) * 2));
    }

    .code-area {
        min-height: unset;
    }
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --duration-instant: 0s;
        --duration-ui-fast: 0s;
        --duration-ui: 0s;
        --duration-base: 0s;
        --duration-entrance: 0s;
        --duration-feedback: 0s;
        --scale-hover: 1;
        --scale-active: 1;
        --scale-badge-hover: 1;
        --scale-badge-active: 1;
        --scale-drop-active: 1;
        --lift-hover: 0px;
        --lift-thumb-active: 0px;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0s !important;
        scroll-behavior: auto !important;
    }

    .drop-zone.is-dragover,
    .gif-thumb-wrap,
    .panel > .card {
        animation: none !important;
    }
}
