:root {
    --bg: #ffffff;
    --panel: rgba(255, 255, 255, 0.98);
    --ink: #2a2a2a;
    --muted: #6d6d78;
    --surface: #ffffff;
    --surface-soft: #fff3f7;
    --surface-tint: rgba(239, 20, 78, 0.04);
    --surface-tint-strong: rgba(239, 20, 78, 0.06);
    --line: rgba(239, 20, 78, 0.18);
    --accent: #ef144e;
    --accent-dark: #c20d3d;
    --accent-soft: rgba(239, 20, 78, 0.1);
    --overlay: rgba(42, 42, 42, 0.44);
    --shadow: 0 18px 50px rgba(239, 20, 78, 0.12);
    --radius: 24px;
}

[data-theme="dark"] {
    --bg: #09090c;
    --panel: rgba(20, 20, 26, 0.94);
    --ink: #f6f2f4;
    --muted: #b6aab0;
    --surface: #14141a;
    --surface-soft: #1d161a;
    --surface-tint: rgba(239, 20, 78, 0.1);
    --surface-tint-strong: rgba(239, 20, 78, 0.13);
    --line: rgba(239, 20, 78, 0.26);
    --accent-soft: rgba(239, 20, 78, 0.18);
    --overlay: rgba(0, 0, 0, 0.66);
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Montserrat", sans-serif;
    color: var(--ink);
    background: var(--bg);
    transition: background 220ms ease, color 220ms ease;
}

[data-theme="dark"] body {
    background: var(--bg);
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 15, 22, 0.88);
    backdrop-filter: blur(8px);
}

.page-loader-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid rgba(239, 20, 78, 0.16);
    box-shadow: 0 18px 40px rgba(239, 20, 78, 0.14);
    color: var(--accent-dark);
    font-weight: 700;
}

.page-loader-spinner {
    width: 24px;
    height: 24px;
}

/* ── App shell ─────────────────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle, rgba(239, 20, 78, 0.055) 1px, transparent 1px),
        #0f0f16;
    background-size: 22px 22px, auto;
    border-right: 1px solid rgba(239, 20, 78, 0.14);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 18px 18px;
    border-bottom: 1px solid rgba(239, 20, 78, 0.1);
}

.sidebar-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.04em;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.28);
    padding: 0 8px;
    margin-bottom: 8px;
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.48);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
    font-family: inherit;
}

.nav-item:hover {
    background: rgba(239, 20, 78, 0.1);
    color: rgba(255, 255, 255, 0.82);
    border-color: rgba(239, 20, 78, 0.12);
}

.nav-item.is-active {
    background: rgba(239, 20, 78, 0.14);
    color: #ffffff;
    border-color: rgba(239, 20, 78, 0.3);
    box-shadow: inset 3px 0 0 #ef144e, 0 0 16px rgba(239, 20, 78, 0.1);
}

.nav-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item-icon svg {
    width: 16px;
    height: 16px;
}

.nav-item-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 14px 10px 20px;
    border-top: 1px solid rgba(239, 20, 78, 0.1);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.44);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
    font-family: inherit;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.08);
}

.theme-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.6);
}

.theme-toggle-label {
    font-size: 13px;
}

.theme-icon {
    width: 16px;
    height: 16px;
}

/* ── Content area ───────────────────────────────────────── */

.app-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 32px 0;
    flex-wrap: wrap;
}

.content-eyebrow {
    margin: 0 0 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    opacity: 0.75;
}

.content-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.15;
}

.content-body {
    padding: 24px 32px 48px;
    max-width: 1080px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 600;
}

.layout {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.form-panel {
    padding: 24px;
}

.result-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.panel-header h2,
.result-block h3 {
    margin: 0;
}

.panel-header p {
    margin: 8px 0 0;
    color: var(--muted);
}

form {
    margin-top: 24px;
}

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.grid.one {
    grid-template-columns: 1fr;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field small {
    margin: 0;
}

.field span {
    font-size: 0.95rem;
}

.label-with-help {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.help-dot {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(239, 20, 78, 0.14);
    color: var(--accent-dark);
    font-size: 0.72rem;
    font-weight: 800;
    cursor: help;
}

.help-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    width: 240px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: 0 10px 24px rgba(239, 20, 78, 0.14);
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 140ms ease, visibility 140ms ease;
    z-index: 5;
    font-size: 0.78rem;
    line-height: 1.45;
    font-weight: 500;
}

.help-dot:hover .help-tooltip,
.help-dot:focus .help-tooltip {
    opacity: 1;
    visibility: visible;
}

.required-star {
    color: var(--accent);
    font-weight: 800;
}

.select-loading-wrap {
    position: relative;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    border: 1px solid rgba(239, 20, 78, 0.18);
    border-radius: 16px;
    background: var(--surface);
    padding: 14px 16px;
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

select.loading {
    opacity: 0.72;
    cursor: wait;
    padding-right: 52px;
}

.select-spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    pointer-events: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 20, 78, 0.14);
    transform: translateY(-1px);
}

input.input-error,
select.input-error {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 20, 78, 0.1);
}

.field-error {
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 600;
}

.toggles {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-tint);
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: var(--muted);
}

.toggle input {
    width: auto;
    margin: 0;
}

.custom-plan-entry {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    background: var(--surface-tint);
    border: 1px solid rgba(239, 20, 78, 0.1);
}

.custom-plan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.custom-plan-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid rgba(239, 20, 78, 0.12);
}

.custom-plan-summary strong {
    color: var(--accent-dark);
}

.custom-plan-summary ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.roles-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-height: 180px;
    overflow: auto;
    padding: 4px;
}

.role-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--surface-tint);
    border: 1px solid var(--line);
}

.role-chip-all {
    width: fit-content;
    margin-bottom: 4px;
}

.role-chip input {
    width: auto;
    margin: 0;
}

.actions {
    margin-top: 24px;
}

.card-help-button,
.secondary-button {
    width: fit-content;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(239, 20, 78, 0.16);
    background: rgba(239, 20, 78, 0.06);
    color: var(--accent-dark);
    box-shadow: none;
}

.system-accent-button {
    width: fit-content;
}

.card-help-table {
    display: flex;
    flex-direction: column;
}

.card-help-row {
    display: grid;
    grid-template-columns: 180px 1fr 1.2fr auto;
    gap: 14px;
    padding: 14px 16px;
    border-top: 1px solid rgba(239, 20, 78, 0.1);
    font-size: 0.84rem;
    line-height: 1.55;
}

.card-help-head {
    background: rgba(239, 20, 78, 0.08);
    color: var(--accent-dark);
    border-top: 0;
}

.card-select-button {
    align-self: start;
    width: fit-content;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(239, 20, 78, 0.08);
    color: var(--accent-dark);
    border: 1px solid rgba(239, 20, 78, 0.16);
    box-shadow: none;
    white-space: nowrap;
}

.card-select-button:hover:not(:disabled) {
    background: rgba(239, 20, 78, 0.14);
}

.card-help-row code {
    display: inline-flex;
    align-items: flex-start;
    width: fit-content;
    padding: 6px 8px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--accent-dark);
    border: 1px solid rgba(239, 20, 78, 0.14);
    font-size: 0.8rem;
    word-break: break-all;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--overlay);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    width: min(1100px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    background: var(--surface);
    border: 1px solid rgba(239, 20, 78, 0.16);
    box-shadow: 0 24px 50px rgba(239, 20, 78, 0.18);
    overflow: hidden;
}

.plan-modal-dialog {
    width: min(760px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(239, 20, 78, 0.12);
}

.modal-header h3 {
    margin: 0;
    color: var(--accent-dark);
}

.modal-close {
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(239, 20, 78, 0.16);
    background: rgba(239, 20, 78, 0.06);
    color: var(--accent-dark);
    box-shadow: none;
}

.modal-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.modal-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.plan-modal-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
}

.modal-grid {
    margin-bottom: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    padding: 18px 20px;
    border-top: 1px solid rgba(239, 20, 78, 0.12);
    background: var(--surface);
}

.modal-footer button {
    width: auto;
    max-width: 100%;
}

.plan-items-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.plan-item-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--surface-tint);
    border: 1px solid rgba(239, 20, 78, 0.1);
}

.plan-item-chip input {
    width: auto;
    margin: 0;
}

.plan-item-chip.is-disabled {
    opacity: 0.55;
}

button {
    border: none;
    border-radius: 999px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
    box-shadow: 0 14px 30px rgba(239, 20, 78, 0.24);
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button-spinner {
    width: 16px;
    height: 16px;
}

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.result-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid rgba(239, 20, 78, 0.16);
}

.summary-spinner {
    width: 30px;
    height: 30px;
}

.summary-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 150px;
}

.summary-empty {
    min-height: 150px;
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-soft);
    color: var(--ink);
    border: 1px solid rgba(239, 20, 78, 0.16);
    display: flex;
    align-items: center;
}

.summary-top-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-stat {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid rgba(239, 20, 78, 0.16);
}

.summary-stat-head,
.summary-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.summary-stat-label {
    display: block;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 8px;
}

.summary-stat-value {
    display: block;
    color: var(--accent-dark);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
}

.summary-card {
    padding: 18px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid rgba(239, 20, 78, 0.16);
    box-shadow: 0 10px 24px rgba(239, 20, 78, 0.08);
}

.summary-card h4 {
    margin: 0 0 12px;
    color: var(--accent-dark);
    font-size: 0.95rem;
}

.summary-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.summary-detail-item {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-tint);
    border: 1px solid rgba(239, 20, 78, 0.1);
}

.summary-copy-button {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(239, 20, 78, 0.06);
    color: var(--accent-dark);
    border: 1px solid rgba(239, 20, 78, 0.16);
    box-shadow: none;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.summary-copy-button:hover:not(:disabled) {
    background: rgba(239, 20, 78, 0.1);
}

.summary-detail-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
}

.summary-detail-value {
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 600;
    word-break: break-word;
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-tint);
    border: 1px solid rgba(239, 20, 78, 0.1);
}

.branch-list-item {
    display: block;
}

.summary-list-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-list-title {
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 700;
}

.summary-list-subtitle {
    color: var(--muted);
    font-size: 0.82rem;
    word-break: break-word;
}

.summary-branch-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.summary-branch-field {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-tint);
    border: 1px solid rgba(239, 20, 78, 0.1);
}

.inline-spinner {
    display: inline-block;
    border-radius: 999px;
    border: 2px solid rgba(239, 20, 78, 0.2);
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
}

.badge .inline-spinner {
    width: 14px;
    height: 14px;
}

button .inline-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #ef144e;
    color: #ffffff;
    box-shadow: 0 18px 36px rgba(239, 20, 78, 0.26);
    animation: toastIn 180ms ease-out;
}

.hidden {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 960px) {
    .grid.two,
    .roles-container,
    .plan-items-grid,
    .card-help-row,
    .summary-top-grid,
    .summary-detail-grid,
    .summary-branch-grid {
        grid-template-columns: 1fr;
    }

    .page-shell {
        width: min(100% - 20px, 1200px);
        padding-top: 24px;
    }

    .topbar {
        margin-bottom: 10px;
    }

    .hero-title {
        font-size: 0.68rem;
    }

    .help-tooltip {
        left: 0;
        transform: none;
        width: 220px;
    }

    .summary-list-item,
    .modal-header,
    .modal-footer,
    .result-head,
    .custom-plan-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-stat-head,
    .summary-detail-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal-footer button {
        width: 100%;
    }

    .custom-plan-actions button,
    .system-accent-button,
    .theme-toggle {
        width: 100%;
    }
}

/* ── Templates ─────────────────────────────────────────── */

.templates-section {
    margin-bottom: 32px;
}

.templates-header {
    margin-bottom: 16px;
}

.templates-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 4px;
}

.templates-header p {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

.templates-carousel {
    display: flex;
    align-items: center;
    gap: 8px;
}

.carousel-nav {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.carousel-nav svg {
    width: 16px;
    height: 16px;
}

.carousel-nav:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-tint);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.templates-grid {
    display: flex;
    flex: 1;
    gap: 12px;
    overflow-x: auto;
    overflow-y: visible;
    /* padding top/bottom cria espaço para o box-shadow e o translateY não serem cortados pelo overflow */
    padding: 12px 4px 12px 2px;
    margin: -12px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.templates-grid::-webkit-scrollbar {
    height: 4px;
}

.templates-grid::-webkit-scrollbar-track {
    background: transparent;
}

.templates-grid::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 999px;
}

.template-card {
    position: relative;
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    text-align: left;
    cursor: pointer;
    color: var(--ink);
    font-family: inherit;
    overflow: hidden;
    transition:
        transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 180ms ease,
        background 180ms ease,
        box-shadow 240ms ease;
}

/* cantos estilo circuito */
.template-card::before,
.template-card::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: var(--accent);
    border-style: solid;
    opacity: 0;
    transition: opacity 180ms ease;
}

.template-card::before {
    top: 6px;
    left: 6px;
    border-width: 1.5px 0 0 1.5px;
}

.template-card::after {
    bottom: 6px;
    right: 6px;
    border-width: 0 1.5px 1.5px 0;
}

.template-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    background: var(--surface-tint);
    box-shadow:
        0 14px 36px rgba(239, 20, 78, 0.2),
        0 0 0 1px rgba(239, 20, 78, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.template-card:hover::before,
.template-card:hover::after {
    opacity: 1;
}

.template-card.is-active {
    transform: translateY(-4px);
    border-color: var(--accent);
    background: var(--surface-tint-strong);
    box-shadow:
        0 10px 28px rgba(239, 20, 78, 0.22),
        0 0 0 1px rgba(239, 20, 78, 0.2);
}

.template-card.is-active::before,
.template-card.is-active::after {
    opacity: 1;
}

.template-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.template-card-desc {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
    flex: 1;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.template-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    line-height: 1.6;
    letter-spacing: 0.03em;
}

.template-selected-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    margin-bottom: 16px;
    font-size: 13px;
}

.template-selected-key {
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.template-selected-value {
    color: var(--ink);
    font-weight: 500;
}
