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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #252936;
    --border: #343848;
    --text: #e8eaef;
    --text-muted: #9aa3b5;
    --accent: #6c8cff;
    --accent-hover: #8aa4ff;
    --radius: 10px;
    --font: "Google Sans", system-ui, sans-serif;
    --mono: "Google Sans", system-ui, sans-serif;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-optical-sizing: auto;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.header {
    text-align: center;
    padding: 2rem 1.5rem 1rem;
}

.logo {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tagline {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.generator {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem 3rem;
}

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

.preview-panel {
    min-height: 320px;
    height: auto;
    max-height: 600px;
}

.preview {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    overflow: hidden;
}

.preview--animated {
    background-size: 400% 400%;
    background-position: 0% 50%;
    -webkit-animation: gradient-shift var(--anim-duration, 8s) ease infinite;
    animation: gradient-shift var(--anim-duration, 8s) ease infinite;
}

@-webkit-keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.animate-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.animate-hint {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.animate-hint a {
    color: var(--accent);
    text-decoration: none;
}

.animate-hint a:hover {
    text-decoration: underline;
}

.animate-duration-wrap.hidden {
    display: none;
}

.animate-duration-label {
    min-width: 2.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.type-tabs {
    display: flex;
    gap: 0;
    background: var(--surface-2);
    border-radius: 8px;
    padding: 3px;
}

.type-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

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

.type-tab.active {
    background: var(--accent);
    color: #fff;
}

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

.option-group select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

.option-group.hidden {
    display: none;
}

.shape-radios {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.shape-radio {
    cursor: pointer;
}

.shape-radio input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.shape-radio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.5rem;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.shape-icon {
    width: 32px;
    height: 32px;
}

.shape-label {
    font-size: 0.8rem;
    font-weight: 600;
}

.shape-radio:hover .shape-radio-card {
    border-color: var(--accent);
    color: var(--text);
}

.shape-radio input:focus-visible+.shape-radio-card {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.shape-radio input:checked+.shape-radio-card {
    border-color: var(--accent);
    background: rgba(108, 140, 255, 0.12);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(108, 140, 255, 0.25);
}

.shape-radio input:checked+.shape-radio-card .shape-icon {
    color: var(--accent);
}

.angle-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.angle-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.angle-num {
    width: 3.5rem;
    padding: 0.35rem 0.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    text-align: center;
}

.unit {
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.stops-header .label {
    margin-bottom: 0;
}

.stop-count-btns {
    display: flex;
    gap: 2px;
}

.stop-count-btns button {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

.stop-count-btns button:hover {
    color: var(--text);
    border-color: var(--accent);
}

.stop-count-btns button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.stops-bar {
    position: relative;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: crosshair;
    overflow: visible;
}

.stop-handle {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: grab;
    z-index: 2;
    transition: transform 0.1s;
}

.stop-handle:hover,
.stop-handle.active {
    transform: scale(1.15);
    z-index: 3;
}

.stop-handle:active {
    cursor: grabbing;
}

.color-mode-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.color-mode {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

.color-mode.active {
    border-color: var(--accent);
    color: var(--accent);
}

.color-inputs {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

#picker {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
}

.input-wrap {
    flex: 1;
}

.input-wrap.hidden {
    display: none;
}

#hex-input {
    width: 100%;
    padding: 0.55rem 0.65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: var(--mono);
    font-size: 0.95rem;
    text-transform: uppercase;
}

.rgba-row {
    display: flex;
    gap: 0.35rem;
}

.rgba-row input {
    width: 100%;
    padding: 0.55rem 0.35rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    text-align: center;
}

.css-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.css-header .label {
    margin-bottom: 0;
}

.compat-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.compat-toggle input {
    accent-color: var(--accent);
}

.css-output {
    margin: 0;
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.55;
    color: #b8c5e8;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 220px;
    overflow-y: auto;
}

.copy-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-btn.copied {
    background: #3d9e6a;
}

.share-section,
.import-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.share-row {
    display: flex;
    gap: 0.5rem;
}

.share-url {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font: var(--mono);
    font-size: 0.72rem;
}

.btn-secondary {
    flex-shrink: 0;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

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

.btn-secondary.copied {
    border-color: #3d9e6a;
    color: #3d9e6a;
}

.import-textarea {
    width: 100%;
    padding: 0.6rem 0.65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: var(--mono);
    font-size: 0.78rem;
    line-height: 1.45;
    resize: vertical;
    min-height: 4rem;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.import-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.import-error {
    font-size: 0.8rem;
    color: #f87171;
}

.import-error[hidden] {
    display: none;
}

.swatches-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.section-title {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.section-desc {
    margin: 0 0 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.swatches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.swatch-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: var(--surface);
    transition: border-color 0.15s, transform 0.15s;
}

.swatch-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

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

.swatch-preview {
    height: 72px;
}

.swatch-name {
    display: block;
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.swatch-card:hover .swatch-name {
    color: var(--text);
}

.seo-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.seo-title {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.seo-lead {
    margin: 0 0 2rem;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text);
}

.seo-content h3 {
    margin: 2rem 0 0.6rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.seo-content p {
    margin: 0 0 1rem;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
}

.seo-content p strong {
    color: var(--text);
    font-weight: 600;
}

.seo-content code {
    font-family: var(--mono);
    font-size: 0.88em;
    padding: 0.12em 0.35em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #b8c5e8;
}

.seo-code {
    margin: 0.75rem 0 1.25rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.5;
    color: #b8c5e8;
    overflow-x: auto;
}

.seo-list {
    margin: 0.5rem 0 1.25rem;
    padding-left: 1.25rem;
    color: var(--text-muted);
    line-height: 1.75;
    font-size: 0.95rem;
}

.seo-list li {
    margin-bottom: 0.35rem;
}

.seo-list strong {
    color: var(--text);
}

.site-footer {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 2.5rem;
    text-align: center;
}

.footer-logo {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.footer-tagline {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-text {
    max-width: 36rem;
    margin: 1.25rem 0 1.5rem;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.footer-copy {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.footer-copy-sep {
    opacity: 0.5;
}

@media (min-width: 640px) {
    .footer-inner {
        text-align: left;
    }

    .footer-copy {
        justify-content: flex-start;
    }
}