:root {
    --touch-size: 44px;

    /* ObraSync 360° — identidad visual */
    --brand-primary: #ff6b00;
    --brand-primary-hover: #e65100;
    --brand-dark: #d34800;
    --brand-darker: #b83800;
    --brand-accent: #ffb347;
    --brand-accent-light: #ffd699;
    --brand-surface: #fff7ed;
    --brand-gradient: linear-gradient(180deg, #ff6b00 0%, #d34800 55%, #b83800 100%);
    --brand-gradient-login: linear-gradient(135deg, #b83800 0%, #d34800 35%, #ff6b00 70%, #ff8533 100%);
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

.container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

@media (min-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

input,
select,
textarea,
button,
a[role="button"] {
    min-height: var(--touch-size);
}

table {
    min-width: 640px;
}

/* Layout con menú lateral */
body.app-has-sidebar {
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--brand-gradient);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 70;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
}

@media (max-width: 1023px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }
}

@media (min-width: 1024px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        align-self: flex-start;
    }
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 0.85rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.app-sidebar__brand-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.app-sidebar__logo {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.65rem;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.app-sidebar__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
}

.app-sidebar__subtitle {
    font-size: 0.7rem;
    opacity: 0.75;
    margin: 0.15rem 0 0;
    font-weight: 400;
}

.app-sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.35rem;
    line-height: 1;
    border: none;
    cursor: pointer;
}

@media (min-width: 1024px) {
    .app-sidebar__close {
        display: none;
    }
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.25rem 1rem 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.38) rgba(0, 0, 0, 0.12);
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar__nav {
        scroll-behavior: auto;
    }
}

/* Barra de desplazamiento del menú lateral (WebKit) */
.app-sidebar__nav::-webkit-scrollbar {
    width: 7px;
}

.app-sidebar__nav::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 999px;
    margin: 6px 2px;
}

.app-sidebar__nav::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.45) 0%,
        rgba(255, 214, 153, 0.55) 100%
    );
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    min-height: 40px;
}

.app-sidebar__nav::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.65) 0%,
        rgba(255, 214, 153, 0.75) 100%
    );
}

.app-sidebar__nav::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.75);
}

/* Contenedor del menú con indicadores de scroll */
.app-sidebar__nav-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.app-sidebar__nav-wrap::before,
.app-sidebar__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 4px;
    height: 18px;
    pointer-events: none;
    z-index: 2;
}

.app-sidebar__nav-wrap::before {
    top: 0;
    background: linear-gradient(180deg, rgba(211, 72, 0, 0.85) 0%, transparent 100%);
}

.app-sidebar__nav-wrap::after {
    bottom: 0;
    background: linear-gradient(0deg, rgba(184, 56, 0, 0.8) 0%, transparent 100%);
}

.app-sidebar__section {
    padding: 0.75rem 1rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.app-sidebar__section.hidden {
    display: none !important;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.1rem 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.875rem;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    min-height: 2.5rem;
}

.app-sidebar__link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.app-sidebar__link.is-active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-accent-light);
}

.app-sidebar__link.hidden {
    display: none !important;
}

.app-sidebar__footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.app-sidebar__logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    background: #dc2626;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.app-sidebar__logout:hover {
    background: #b91c1c;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 65;
}

.app-sidebar-backdrop[hidden] {
    display: none !important;
}

.app-main-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--brand-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

@media (min-width: 1024px) {
    .app-topbar {
        display: none;
    }
}

.app-topbar__menu {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    min-height: 2.5rem;
}

.app-topbar__menu:hover {
    background: rgba(255, 255, 255, 0.22);
}

.app-topbar__title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-main {
    flex: 1;
    min-width: 0;
}

.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scroll-x table {
    width: 100%;
}

/* Herramientas del editor de dibujos */
.tool-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    border-radius: 0.5rem;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.tool-btn-icon:hover {
    background-color: #f3f4f6;
}

.tool-btn-icon.bg-blue-100:hover {
    background-color: #ffedd5;
}

/* Pantalla de login */
.login-page {
    background: var(--brand-gradient-login);
    min-height: 100vh;
}

.login-card {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

.login-logo {
    width: 15rem;
    height: auto;
    margin: 0 auto 0.75rem;
    border-radius: 1rem;
    box-shadow: 0 8px 20px rgba(211, 72, 0, 0.25);
}

.btn-brand {
    background: var(--brand-primary);
    color: #fff;
    font-weight: 700;
    transition: background-color 0.15s;
}

.btn-brand:hover {
    background: var(--brand-primary-hover);
}

.input-brand:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.2);
}

/* Sustitución de azules Tailwind por marca ObraSync */
.brand-obrasync .bg-blue-600 { background-color: var(--brand-primary) !important; }
.brand-obrasync .bg-blue-700 { background-color: var(--brand-primary-hover) !important; }
.brand-obrasync .bg-blue-800 { background-color: var(--brand-dark) !important; }
.brand-obrasync .bg-blue-900 { background-color: var(--brand-darker) !important; }
.brand-obrasync .hover\:bg-blue-700:hover { background-color: var(--brand-primary-hover) !important; }
.brand-obrasync .hover\:bg-blue-50:hover { background-color: var(--brand-surface) !important; }
.brand-obrasync .hover\:bg-blue-800:hover { background-color: var(--brand-dark) !important; }
.brand-obrasync .text-blue-600 { color: var(--brand-primary) !important; }
.brand-obrasync .text-blue-700 { color: var(--brand-primary-hover) !important; }
.brand-obrasync .text-blue-800 { color: var(--brand-dark) !important; }
.brand-obrasync .border-blue-600 { border-color: var(--brand-primary) !important; }
.brand-obrasync .border-blue-300 { border-color: #fdba74 !important; }
.brand-obrasync .hover\:border-blue-300:hover { border-color: #fdba74 !important; }
.brand-obrasync .focus\:border-blue-500:focus { border-color: var(--brand-primary) !important; }
.brand-obrasync .ring-blue-200,
.brand-obrasync .hover\:ring-blue-200:hover { --tw-ring-color: rgba(255, 107, 0, 0.28) !important; }
.brand-obrasync .from-blue-900 { --tw-gradient-from: var(--brand-darker) var(--tw-gradient-from-position) !important; }
.brand-obrasync .to-blue-600 { --tw-gradient-to: var(--brand-primary) var(--tw-gradient-to-position) !important; }
.brand-obrasync .bg-blue-100 { background-color: #ffedd5 !important; }
.brand-obrasync .border-b-2.border-blue-600 { border-color: var(--brand-primary) !important; }
.brand-obrasync #global-loader .border-blue-600 { border-color: var(--brand-primary) !important; }

.tool-icon {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
}

.tool-btn.tool-btn-icon.border-2 {
    border-width: 2px;
}

/* Acciones en listas/tablas */
.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4b5563;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.action-btn:hover:not(:disabled) {
    background: #f3f4f6;
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.action-icon {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
}

.action-btn--primary { color: var(--brand-primary-hover); border-color: #fed7aa; }
.action-btn--primary:hover:not(:disabled) { background: var(--brand-surface); }

.action-btn--warning { color: #d97706; border-color: #fde68a; }
.action-btn--warning:hover:not(:disabled) { background: #fffbeb; }

.action-btn--success { color: #059669; border-color: #a7f3d0; }
.action-btn--success:hover:not(:disabled) { background: #ecfdf5; }

.action-btn--orange { color: #ea580c; border-color: #fed7aa; }
.action-btn--orange:hover:not(:disabled) { background: #fff7ed; }

.action-btn--danger { color: #dc2626; border-color: #fecaca; }
.action-btn--danger:hover:not(:disabled) { background: #fef2f2; }

.action-btn--info { color: #7c3aed; border-color: #ddd6fe; }
.action-btn--info:hover:not(:disabled) { background: #f5f3ff; }

/* Capas modales — sin depender de flex/hidden de Tailwind CDN */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-overlay--z40 { z-index: 75; }
.modal-overlay--z50 { z-index: 85; }
.modal-overlay--z60 { z-index: 90; }

.modal-overlay--column {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-overlay {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.modal-overlay:not(.hidden):not([hidden]) {
    display: flex !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

#modal-ver-foto:not(.hidden):not([hidden]) {
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
}

#toast.hidden,
#toast[hidden] {
    display: none !important;
    pointer-events: none !important;
}

/* Panel interno y botones de modales */
.modal-dialog {
    display: flex;
    flex-direction: column;
    max-height: min(90vh, calc(100dvh - 2rem));
    overflow: hidden;
    width: 100%;
}

.modal-dialog__header {
    flex-shrink: 0;
}

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

.modal-dialog__body--form {
    display: flex;
    flex-direction: column;
}

.modal-dialog__footer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    margin-top: auto;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    position: sticky;
    bottom: 0;
    z-index: 2;
}

.modal-overlay .modal-dialog__footer button {
    display: inline-flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.modal-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.modal-btn--secondary {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
}

.modal-btn--secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.modal-btn--primary {
    border: 1px solid transparent;
    background: #2563eb;
    color: #fff;
}

.modal-btn--primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.modal-btn--success {
    border: 1px solid transparent;
    background: #059669;
    color: #fff;
}

.modal-btn--success:hover:not(:disabled) {
    background: #047857;
}

.modal-btn--danger {
    border: 1px solid transparent;
    background: #dc2626;
    color: #fff;
}

.modal-btn--danger:hover:not(:disabled) {
    background: #b91c1c;
}

.modal-btn--warning {
    border: 1px solid transparent;
    background: #d97706;
    color: #fff;
}

.modal-btn--warning:hover:not(:disabled) {
    background: #b45309;
}

.modal-btn--indigo {
    border: 1px solid transparent;
    background: #4f46e5;
    color: #fff;
}

.modal-btn--indigo:hover:not(:disabled) {
    background: #4338ca;
}

.modal-btn--teal {
    border: 1px solid transparent;
    background: #0d9488;
    color: #fff;
}

.modal-btn--teal:hover:not(:disabled) {
    background: #0f766e;
}

.modal-btn--violet {
    border: 1px solid transparent;
    background: #7c3aed;
    color: #fff;
}

.modal-btn--violet:hover:not(:disabled) {
    background: #6d28d9;
}

.modal-btn-close {
    min-height: 2.25rem !important;
    min-width: 2.25rem !important;
    padding: 0.125rem 0.5rem !important;
    line-height: 1 !important;
    border: none !important;
    background: transparent !important;
    color: #6b7280 !important;
    border-radius: 0.375rem;
    font-size: 1.5rem;
}

.modal-btn-close:hover:not(:disabled) {
    color: #111827 !important;
    background: #f3f4f6 !important;
}

/* Visor de fotos y barras compactas */
#modal-ver-foto button,
.modal-overlay .modal-dialog__header .modal-btn-close {
    min-height: 2.25rem;
}

#modal-ver-foto button {
    min-width: auto;
    padding: 0.375rem 0.75rem;
    color: #fff;
}

/* Botones con color de marca en modales: mantener texto legible */
.modal-overlay button[class*="bg-"]:not(.modal-btn--secondary):not(.action-btn),
.modal-overlay button[type="submit"]:not(.modal-btn--secondary):not(.action-btn) {
    color: #fff;
}

.modal-overlay label.cursor-pointer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
}

/* ——— Responsive: móvil y tablet ——— */

@media (max-width: 1023px) {
    body.is-touch .action-btn,
    body.is-touch .tool-btn-icon {
        width: 2.75rem;
        height: 2.75rem;
        min-height: 2.75rem;
    }
}

@media (max-width: 767px) {
    :root {
        --touch-size: 48px;
    }

    .app-main .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .app-main .p-6 {
        padding: 1rem;
    }

    .app-main .p-4 {
        padding: 0.75rem;
    }

    /* Formularios: una columna en móvil */
    .app-main .grid.grid-cols-2,
    .app-main .responsive-form-grid,
    .modal-overlay .grid.grid-cols-2,
    .modal-overlay .responsive-form-grid {
        grid-template-columns: 1fr;
    }

    /* Filtros y selects a ancho completo */
    .app-main select[class*="min-w-"],
    .app-main input[class*="min-w-"],
    .app-main .flex-wrap > div > select,
    .app-main .flex-wrap > div > input[type="text"],
    .app-main .flex-wrap > div > input[type="date"],
    .app-main .flex-wrap > div > input[type="search"] {
        min-width: 0 !important;
        width: 100%;
    }

    .app-main .flex-wrap.gap-3 > div,
    .app-main .flex-wrap.gap-4 > div {
        flex: 1 1 100%;
        min-width: 0;
    }

    /* Modales: casi pantalla completa */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-overlay .modal-dialog,
    .modal-overlay > .bg-white {
        max-height: 92dvh;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-dialog__footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-dialog__footer .modal-btn,
    .modal-dialog__footer button {
        width: 100%;
        justify-content: center;
    }

    /* Toast centrado en móvil */
    #toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
    }

    /* Tablas: padding compacto */
    .scroll-x table th,
    .scroll-x table td {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.8125rem;
    }

    table {
        min-width: 520px;
    }
}

@media (max-width: 639px) {
    .page-toolbar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .page-toolbar > * {
        width: 100%;
    }

    .page-toolbar .flex-wrap {
        width: 100%;
    }

    .page-toolbar button,
    .page-toolbar .btn-full-mobile {
        width: 100%;
        justify-content: center;
    }
}

/* Lista en tarjetas (móvil) */
.data-cards {
    display: none;
}

@media (max-width: 767px) {
    .data-cards {
        display: block;
    }

    .data-table-desktop {
        display: none !important;
    }
}

.data-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.875rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.data-card + .data-card {
    margin-top: 0.75rem;
}

.data-card__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.data-card__label {
    color: #6b7280;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.data-card__value {
    text-align: right;
    font-weight: 500;
    word-break: break-word;
}

.data-card__title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #111827;
}

.data-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}

/* ——— Editor de dibujos responsive ——— */
.dibujo-editor-layout {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#vista-editor.hidden,
#vista-editor[hidden] {
    display: none !important;
}

.dibujo-editor-header {
    flex-shrink: 0;
}

.dibujo-header-btn {
    min-height: 2.5rem;
    white-space: nowrap;
}

.dibujo-editor-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.dibujo-canvas-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.dibujo-editor-toolbar {
    flex-shrink: 0;
}

.dibujo-toolbar-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Botones con icono + etiqueta */
.tool-btn-labeled {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-width: 3.75rem;
    min-height: 3.75rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.5rem;
    background: #fff;
    color: #374151;
    flex-shrink: 0;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.tool-btn-labeled span {
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-btn-labeled .tool-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.tool-btn-labeled.bg-blue-100,
.tool-btn-labeled.border-blue-600.border-2 {
    background-color: #ffedd5;
    border-color: var(--brand-primary);
    color: var(--brand-primary-hover);
}

.tool-btn-labeled.bg-purple-600 .tool-icon,
.tool-btn-labeled.bg-purple-600 span {
    color: #fff;
}

/* Botones de foto — siempre visibles sobre el lienzo */
.dibujo-foto-quick {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 20;
    display: flex;
    gap: 0.35rem;
    pointer-events: auto;
}

.dibujo-foto-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-width: 3.5rem;
    min-height: 3.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    cursor: pointer;
}

.dibujo-foto-btn .tool-icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.dibujo-foto-btn span {
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1;
}

.dibujo-foto-btn--cam {
    background: #7c3aed !important;
    border-color: #6d28d9 !important;
    color: #fff !important;
}

.dibujo-foto-btn--cam .tool-icon {
    stroke: #fff;
    color: #fff;
}

.dibujo-foto-btn--cam span {
    color: #fff;
}

.dibujo-foto-btn--subir {
    background: #fff !important;
    border-color: #7c3aed !important;
    color: #6d28d9 !important;
}

.dibujo-foto-btn--subir .tool-icon {
    stroke: #6d28d9;
    color: #6d28d9;
}

.dibujo-foto-btn--subir span {
    color: #6d28d9;
}

.dibujo-foto-btn--adjuntas {
    background: #fff !important;
    border-color: #059669 !important;
    color: #047857 !important;
}

.dibujo-foto-btn--adjuntas .tool-icon {
    stroke: #047857;
    color: #047857;
}

.dibujo-foto-btn--adjuntas span {
    color: #047857;
    font-size: 0.55rem;
}

.dibujo-galeria-count {
    font-weight: 700;
    color: var(--brand-primary);
}

.dibujo-galeria-section.has-fotos {
    border-color: #bbf7d0;
}

@media (max-width: 1023px) {
    .dibujo-galeria-section.has-fotos {
        border: 2px solid #86efac;
    }

    .dibujo-galeria-section.has-fotos[open] {
        max-height: 40vh;
    }

    #galeria-fotos.has-items {
        max-height: 35vh;
    }
}

@media (max-width: 1023px) {
    .dibujo-foto-btn {
        min-width: 3.75rem;
        min-height: 3.75rem;
    }

    .dibujo-foto-btn .tool-icon {
        width: 1.65rem;
        height: 1.65rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-foto-quick,
    #vista-editor:fullscreen .dibujo-foto-quick,
    #vista-editor.dibujo-fullscreen-mode .dibujo-foto-quick {
        top: 0.35rem;
        left: 0.35rem;
        z-index: 25;
    }
}

@media (min-width: 1024px) {
    .dibujo-foto-quick {
        top: 0.65rem;
        left: 0.65rem;
    }
}

.dibujo-tools-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.dibujo-tools-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    flex-shrink: 0;
    width: 3.25rem;
}

.dibujo-tools-scroll {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-width: 0;
    padding: 0.15rem 0;
    scrollbar-width: none;
}

.dibujo-tools-scroll::-webkit-scrollbar {
    display: none;
}

.dibujo-tools-options {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dibujo-opt-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
}

.dibujo-color-input {
    width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    padding: 0.15rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
}

.dibujo-num-input {
    width: 3.25rem;
    min-height: 2.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    text-align: center;
    font-size: 0.875rem;
}

.dibujo-opt-range input[type="range"] {
    width: 5.5rem;
    min-height: 2.75rem;
}

.canvas-viewport {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 12rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-fit-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.canvas-viewport #lienzo {
    display: block;
    max-width: none;
    touch-action: none;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.canvas-viewport.canvas-pan-mode {
    cursor: grab;
}

.canvas-viewport.canvas-pan-mode.is-panning {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}

.canvas-viewport.canvas-pan-mode #lienzo {
    cursor: grab;
}

.canvas-viewport.canvas-pan-mode.is-panning #lienzo {
    cursor: grabbing;
}

.canvas-zoom-bar {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    flex-shrink: 0;
}

/* Móvil y tablet: lienzo ocupa el espacio disponible, toolbar abajo */
@media (max-width: 1023px) {
    .dibujo-editor-layout {
        min-height: calc(100dvh - 3.5rem);
        max-width: 100%;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
        gap: 0.35rem;
    }

    .dibujo-editor-header {
        order: 1;
    }

    .dibujo-editor-body {
        order: 2;
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .dibujo-editor-toolbar {
        order: 3;
    }

    .dibujo-canvas-section {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .dibujo-galeria-section {
        flex-shrink: 0;
    }

    .canvas-viewport {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }

    .dibujo-toolbar-dock {
        position: sticky;
        bottom: 0;
        z-index: 40;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }

    body.dibujo-landscape-active .dibujo-toolbar-dock,
    body.dibujo-fullscreen-active .dibujo-toolbar-dock {
        position: static !important;
        z-index: auto !important;
        box-shadow: none;
    }

    .tool-btn-labeled {
        min-width: 4rem;
        min-height: 4rem;
    }

    .tool-btn-labeled .tool-icon {
        width: 1.65rem;
        height: 1.65rem;
    }

    .tool-btn-labeled span {
        font-size: 0.6875rem;
    }

    .dibujo-galeria-section {
        flex-shrink: 0;
    }
}

/* Móvil/tablet en horizontal: lienzo a pantalla completa */
@media (max-width: 1023px) and (orientation: landscape) {
    body.dibujo-landscape-active {
        overflow: hidden;
    }

    body.dibujo-landscape-active .app-topbar {
        display: none !important;
    }

    body.dibujo-landscape-active .app-main {
        padding: 0;
    }

    #vista-editor.dibujo-landscape-mode {
        position: fixed;
        inset: 0;
        z-index: 55;
        width: 100%;
        max-width: 100%;
        min-height: 100dvh;
        max-height: 100dvh;
        height: 100dvh;
        margin: 0;
        padding: 0;
        padding-top: env(safe-area-inset-top, 0);
        padding-right: env(safe-area-inset-right, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        gap: 0;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: minmax(2.75rem, auto) 1fr;
        grid-template-areas:
            "header header"
            "canvas tools";
        background: #111827;
        overflow-x: hidden;
        overflow-y: hidden;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-header {
        grid-area: header;
        grid-row: 1;
        grid-column: 1 / -1;
        order: unset;
        border-radius: 0;
        padding: 0.25rem 0.5rem;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
        min-height: 2.75rem;
        overflow: hidden;
        position: relative;
        z-index: 50;
        flex-wrap: nowrap;
        gap: 0.35rem;
        background: #fff;
        isolation: isolate;
    }

    #vista-editor.dibujo-landscape-mode .editor-header-actions {
        order: -1;
        flex: 0 0 auto;
        flex-shrink: 0;
        display: flex;
        flex-wrap: nowrap;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: none;
        margin-right: 0.35rem;
        position: relative;
        z-index: 51;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-header > .min-w-0 {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        padding-right: 4.5rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-header h2 {
        font-size: 0.8125rem;
        line-height: 1.2;
    }

    #vista-editor.dibujo-landscape-mode #editor-subtitulo {
        display: none;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-header-btn {
        flex-shrink: 0;
        min-height: 2.25rem;
        min-width: 2.25rem;
        padding: 0.25rem 0.45rem;
        font-size: 0.8125rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-header-btn__label {
        display: none;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-body {
        grid-area: canvas;
        grid-row: 2;
        grid-column: 1;
        order: unset;
        flex: unset;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        gap: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-galeria-section {
        display: block !important;
        flex-shrink: 0;
        max-height: 32vh;
        overflow: hidden;
        border-radius: 0;
        border-top: 1px solid #e5e7eb;
        margin: 0;
        padding: 0.35rem 0.5rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-galeria-section.has-fotos .dibujo-galeria-content,
    #vista-editor.dibujo-landscape-mode .dibujo-galeria-section[open] .dibujo-galeria-content {
        display: block !important;
    }

    #vista-editor.dibujo-landscape-mode #galeria-fotos.has-items {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: 5.5rem;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    #vista-editor.dibujo-landscape-mode #galeria-fotos.has-items > div {
        flex: 0 0 5.5rem;
        min-width: 5.5rem;
        padding: 0.25rem;
    }

    #vista-editor.dibujo-landscape-mode #galeria-fotos.has-items img {
        height: 3.5rem;
        width: 100%;
        object-fit: cover;
        border-radius: 0.25rem;
    }

    #vista-editor.dibujo-landscape-mode #galeria-fotos.has-items p,
    #vista-editor.dibujo-landscape-mode #galeria-fotos.has-items .action-group {
        display: none;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-body {
        display: flex;
        flex-direction: column;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-canvas-section {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        display: flex;
        flex-direction: column;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        background: #111827;
    }

    #vista-editor.dibujo-landscape-mode .canvas-zoom-bar .dibujo-fs-btn--float {
        display: none;
    }

    #vista-editor.dibujo-landscape-mode .canvas-zoom-bar button {
        min-width: 2.25rem;
        min-height: 2.25rem;
        font-size: 1rem;
    }

    #vista-editor.dibujo-landscape-mode .canvas-viewport {
        height: 100%;
        min-height: 0;
        max-height: none;
        border: none;
        border-radius: 0;
        background: #1f2937;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-editor-toolbar {
        grid-area: tools;
        grid-row: 2;
        grid-column: 2;
        order: unset;
        width: 4.25rem;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        position: static !important;
        border-radius: 0;
        padding: 0.25rem 0.2rem;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.12);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        z-index: 10;
        align-self: stretch;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-toolbar-panel {
        gap: 0.35rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-tools-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-tools-label {
        display: none;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-tools-scroll {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: visible;
        align-items: center;
        gap: 0.25rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-tools-options {
        flex-direction: column;
        align-items: center;
        border-top: none;
        padding-top: 0.25rem;
        gap: 0.35rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-tools-row.border-t {
        border-top: 1px solid #e5e7eb;
        padding-top: 0.35rem;
    }

    #vista-editor.dibujo-landscape-mode .tool-btn-labeled {
        min-width: 3.5rem;
        min-height: 3.5rem;
        width: 3.5rem;
        padding: 0.25rem;
    }

    #vista-editor.dibujo-landscape-mode .tool-btn-labeled .tool-icon {
        width: 1.35rem;
        height: 1.35rem;
    }

    #vista-editor.dibujo-landscape-mode .tool-btn-labeled span {
        font-size: 0.5rem;
        max-width: 3.25rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-opt-chip span {
        font-size: 0.55rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-color-input {
        width: 2.5rem;
        height: 2.5rem;
        min-height: 2.5rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-num-input {
        width: 2.75rem;
        min-height: 2.25rem;
        font-size: 0.75rem;
    }

    #vista-editor.dibujo-landscape-mode .dibujo-opt-range input[type="range"] {
        width: 3.5rem;
        min-height: 2rem;
    }
}

/* Botón pantalla completa */
.dibujo-fs-btn.is-active {
    background: #ffedd5;
    border-color: var(--brand-primary);
    color: var(--brand-primary-hover);
}

.dibujo-fs-btn--float {
    min-width: 2.25rem;
    min-height: 2.25rem;
    font-size: 1.1rem;
    line-height: 1;
}

/* Pantalla completa (API nativa + fallback CSS) */
body.dibujo-fullscreen-active {
    overflow: hidden;
}

body.dibujo-fullscreen-active .app-topbar {
    display: none !important;
}

body.dibujo-fullscreen-active .app-main {
    padding: 0;
}

#vista-editor.dibujo-fullscreen-mode {
    position: fixed;
    inset: 0;
    z-index: 55;
}

#vista-editor:fullscreen,
#vista-editor:-webkit-full-screen,
#vista-editor.dibujo-fullscreen-mode {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding-top: env(safe-area-inset-top, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    gap: 0;
    background: #111827;
    overflow: hidden;
}

#vista-editor:fullscreen .dibujo-galeria-section,
#vista-editor:-webkit-full-screen .dibujo-galeria-section,
#vista-editor.dibujo-fullscreen-mode .dibujo-galeria-section {
    display: block !important;
    flex-shrink: 0;
    max-height: 30vh;
    overflow: auto;
}

#vista-editor:fullscreen .dibujo-editor-body,
#vista-editor:-webkit-full-screen .dibujo-editor-body,
#vista-editor.dibujo-fullscreen-mode .dibujo-editor-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#vista-editor:fullscreen .dibujo-canvas-section,
#vista-editor:-webkit-full-screen .dibujo-canvas-section,
#vista-editor.dibujo-fullscreen-mode .dibujo-canvas-section {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
}

#vista-editor:fullscreen .dibujo-editor-header,
#vista-editor:-webkit-full-screen .dibujo-editor-header,
#vista-editor.dibujo-fullscreen-mode .dibujo-editor-header {
    flex-shrink: 0;
    border-radius: 0;
    padding: 0.25rem 0.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    min-height: 2.75rem;
    overflow: hidden;
    position: relative;
    z-index: 50;
    flex-wrap: nowrap;
    background: #fff;
    isolation: isolate;
}

#vista-editor:fullscreen .editor-header-actions,
#vista-editor:-webkit-full-screen .editor-header-actions,
#vista-editor.dibujo-fullscreen-mode .editor-header-actions {
    order: -1;
    flex: 0 0 auto;
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 51;
    margin-right: 0.35rem;
}

#vista-editor:fullscreen .dibujo-header-btn,
#vista-editor:-webkit-full-screen .dibujo-header-btn,
#vista-editor.dibujo-fullscreen-mode .dibujo-header-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
}

#vista-editor:fullscreen #editor-subtitulo,
#vista-editor:-webkit-full-screen #editor-subtitulo,
#vista-editor.dibujo-fullscreen-mode #editor-subtitulo {
    display: none;
}

#vista-editor:fullscreen .dibujo-canvas-section,
#vista-editor:-webkit-full-screen .dibujo-canvas-section,
#vista-editor.dibujo-fullscreen-mode .dibujo-canvas-section {
    height: 100%;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background: #111827;
}

#vista-editor:fullscreen .canvas-viewport,
#vista-editor:-webkit-full-screen .canvas-viewport,
#vista-editor.dibujo-fullscreen-mode .canvas-viewport {
    height: 100%;
    min-height: 0;
    max-height: none;
    border: none;
    border-radius: 0;
    background: #1f2937;
}

#vista-editor:fullscreen .canvas-zoom-bar,
#vista-editor:-webkit-full-screen .canvas-zoom-bar,
#vista-editor.dibujo-fullscreen-mode .canvas-zoom-bar {
    right: 0.35rem;
    bottom: 0.35rem;
}

@media (max-width: 1023px) and (orientation: landscape) {
    #vista-editor:fullscreen .canvas-zoom-bar .dibujo-fs-btn--float,
    #vista-editor:-webkit-full-screen .canvas-zoom-bar .dibujo-fs-btn--float,
    #vista-editor.dibujo-fullscreen-mode .canvas-zoom-bar .dibujo-fs-btn--float {
        display: none;
    }

    #vista-editor:fullscreen .dibujo-editor-header > .min-w-0,
    #vista-editor:-webkit-full-screen .dibujo-editor-header > .min-w-0,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-header > .min-w-0 {
        order: 1;
        flex: 1 1 auto;
        max-width: none;
        padding-right: 4.5rem;
    }

    #vista-editor:fullscreen .dibujo-editor-body,
    #vista-editor:-webkit-full-screen .dibujo-editor-body,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-body {
        grid-row: 2;
        grid-column: 1;
        overflow: hidden;
        max-height: 100%;
    }

    #vista-editor:fullscreen .dibujo-editor-toolbar,
    #vista-editor:-webkit-full-screen .dibujo-editor-toolbar,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-toolbar {
        grid-row: 2;
        grid-column: 2;
        position: static !important;
        max-height: 100%;
        z-index: 10;
    }
}

/* Inmersivo vertical (portrait) */
@media (orientation: portrait) {
    #vista-editor:fullscreen,
    #vista-editor:-webkit-full-screen,
    #vista-editor.dibujo-fullscreen-mode {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
        max-height: 100dvh;
    }

    #vista-editor:fullscreen .dibujo-editor-header,
    #vista-editor:-webkit-full-screen .dibujo-editor-header,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-header {
        order: 1;
    }

    #vista-editor:fullscreen .dibujo-editor-header > .min-w-0,
    #vista-editor:-webkit-full-screen .dibujo-editor-header > .min-w-0,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-header > .min-w-0 {
        max-width: 40%;
    }

    #vista-editor:fullscreen .editor-header-actions,
    #vista-editor:-webkit-full-screen .editor-header-actions,
    #vista-editor.dibujo-fullscreen-mode .editor-header-actions {
        max-width: 60%;
    }

    #vista-editor:fullscreen .dibujo-editor-body,
    #vista-editor:-webkit-full-screen .dibujo-editor-body,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-body {
        flex: 1 1 auto;
        min-height: 0;
        order: 2;
        display: flex;
        flex-direction: column;
    }

    #vista-editor:fullscreen .dibujo-editor-toolbar,
    #vista-editor:-webkit-full-screen .dibujo-editor-toolbar,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-toolbar {
        order: 3;
        flex-shrink: 0;
        border-radius: 0;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        max-height: 42vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Inmersivo horizontal (móvil/tablet) */
@media (max-width: 1023px) and (orientation: landscape) {
    #vista-editor:fullscreen,
    #vista-editor:-webkit-full-screen,
    #vista-editor.dibujo-fullscreen-mode {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: minmax(2.75rem, auto) 1fr;
        grid-template-areas:
            "header header"
            "canvas tools";
    }

    #vista-editor:fullscreen .dibujo-editor-header,
    #vista-editor:-webkit-full-screen .dibujo-editor-header,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-header {
        grid-area: header;
    }

    #vista-editor:fullscreen .dibujo-header-btn__label,
    #vista-editor:-webkit-full-screen .dibujo-header-btn__label,
    #vista-editor.dibujo-fullscreen-mode .dibujo-header-btn__label {
        display: none;
    }

    #vista-editor:fullscreen .dibujo-editor-body,
    #vista-editor:-webkit-full-screen .dibujo-editor-body,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-body {
        grid-area: canvas;
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #vista-editor:fullscreen .dibujo-canvas-section,
    #vista-editor:-webkit-full-screen .dibujo-canvas-section,
    #vista-editor.dibujo-fullscreen-mode .dibujo-canvas-section {
        flex: 1 1 auto;
        min-height: 0;
        height: auto !important;
    }

    #vista-editor:fullscreen .dibujo-galeria-section,
    #vista-editor:-webkit-full-screen .dibujo-galeria-section,
    #vista-editor.dibujo-fullscreen-mode .dibujo-galeria-section {
        flex-shrink: 0;
        max-height: 32vh;
        border-radius: 0;
        border-top: 1px solid #e5e7eb;
    }

    #vista-editor:fullscreen #galeria-fotos.has-items,
    #vista-editor:-webkit-full-screen #galeria-fotos.has-items,
    #vista-editor.dibujo-fullscreen-mode #galeria-fotos.has-items {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        overflow-x: auto;
        max-height: 5.5rem;
    }

    #vista-editor:fullscreen .dibujo-editor-toolbar,
    #vista-editor:-webkit-full-screen .dibujo-editor-toolbar,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-toolbar {
        grid-area: tools;
        width: 4.25rem;
        height: 100%;
        overflow-y: auto;
        border-radius: 0;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.12);
    }

    #vista-editor:fullscreen .dibujo-tools-row,
    #vista-editor:-webkit-full-screen .dibujo-tools-row,
    #vista-editor.dibujo-fullscreen-mode .dibujo-tools-row {
        flex-direction: column;
    }

    #vista-editor:fullscreen .dibujo-tools-label,
    #vista-editor:-webkit-full-screen .dibujo-tools-label,
    #vista-editor.dibujo-fullscreen-mode .dibujo-tools-label {
        display: none;
    }

    #vista-editor:fullscreen .dibujo-tools-scroll,
    #vista-editor:-webkit-full-screen .dibujo-tools-scroll,
    #vista-editor.dibujo-fullscreen-mode .dibujo-tools-scroll {
        flex-direction: column;
        align-items: center;
    }

    #vista-editor:fullscreen .dibujo-tools-options,
    #vista-editor:-webkit-full-screen .dibujo-tools-options,
    #vista-editor.dibujo-fullscreen-mode .dibujo-tools-options {
        flex-direction: column;
        align-items: center;
    }
}

/* Inmersivo en desktop */
@media (min-width: 1024px) {
    #vista-editor:fullscreen,
    #vista-editor:-webkit-full-screen,
    #vista-editor.dibujo-fullscreen-mode {
        display: flex;
        flex-direction: column;
    }

    #vista-editor:fullscreen .dibujo-editor-body,
    #vista-editor:-webkit-full-screen .dibujo-editor-body,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-body {
        flex: 1 1 auto;
        min-height: 0;
        display: block;
    }

    #vista-editor:fullscreen .dibujo-editor-toolbar,
    #vista-editor:-webkit-full-screen .dibujo-editor-toolbar,
    #vista-editor.dibujo-fullscreen-mode .dibujo-editor-toolbar {
        flex-shrink: 0;
    }
}

/* Desktop: toolbar arriba del lienzo, galería lateral */
@media (min-width: 1024px) {
    .dibujo-editor-layout {
        display: flex;
        flex-direction: column;
    }

    .dibujo-editor-header {
        order: 1;
    }

    .dibujo-editor-toolbar {
        order: 2;
    }

    .dibujo-editor-body {
        order: 3;
    }

    .dibujo-editor-header .editor-header-actions {
        order: unset;
        margin-right: 0;
    }

    .dibujo-editor-body {
        display: grid;
        grid-template-columns: 1fr 280px;
        gap: 0.75rem;
        align-items: start;
    }

    .dibujo-galeria-section {
        position: sticky;
        top: 1rem;
    }

    .dibujo-galeria-mobile summary {
        display: none;
    }

    .dibujo-galeria-mobile .dibujo-galeria-content {
        display: block !important;
    }

    .canvas-viewport {
        min-height: 420px;
        max-height: calc(100vh - 320px);
    }
}

.canvas-zoom-bar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    font-size: 1.125rem;
    line-height: 1;
    color: #374151;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.canvas-zoom-bar span {
    font-size: 0.8125rem;
    color: #6b7280;
    min-width: 3rem;
    text-align: center;
}

.dibujo-galeria-mobile summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.5rem 0;
    list-style: none;
}

.dibujo-galeria-mobile summary::-webkit-details-marker {
    display: none;
}

.dibujo-galeria-mobile summary::before {
    content: "▸ ";
}

.dibujo-galeria-mobile[open] summary::before {
    content: "▾ ";
}

@media (min-width: 1024px) {
    .dibujo-galeria-mobile summary {
        display: none;
    }

    .dibujo-galeria-mobile .dibujo-galeria-content {
        display: block !important;
    }
}

/* Modal de entrada móvil (texto / medida) */
.proyecto-fotos-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.proyecto-fotos-grid:not(.hidden) {
    display: flex !important;
}

.proyecto-fotos-grupo {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.proyecto-fotos-grupo__titulo {
    font-size: 0.875rem;
    font-weight: 700;
    color: #374151;
}

.proyecto-fotos-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.75rem;
}

.proyecto-foto-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.proyecto-foto-card__thumb {
    position: relative;
    aspect-ratio: 1;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.proyecto-foto-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.proyecto-foto-card__pdf {
    font-size: 0.75rem;
    font-weight: 700;
    color: #b45309;
    text-transform: uppercase;
}

.proyecto-foto-card__body {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.proyecto-foto-card__badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
}

.proyecto-foto-card__desc {
    font-size: 0.7rem;
    color: #4b5563;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.proyecto-foto-card__fecha {
    font-size: 0.65rem;
    color: #9ca3af;
}

.proyecto-foto-card__actions {
    display: flex;
    gap: 0.35rem;
    margin-top: auto;
}

.proyecto-foto-card__actions a,
.proyecto-foto-card__actions button {
    flex: 1;
    text-align: center;
    font-size: 0.7rem;
    padding: 0.25rem 0.35rem;
    border-radius: 0.25rem;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    text-decoration: none;
}

.proyecto-foto-card__actions a:hover,
.proyecto-foto-card__actions button:hover {
    background: #f9fafb;
}

.proyecto-foto-card__actions .is-primary {
    border-color: #2563eb;
    color: #1d4ed8;
}

.proyecto-foto-card__actions .is-download {
    border-color: #0d9488;
    color: #0f766e;
}

.proyecto-dibujo-card__badge {
    background: #eef2ff;
    color: #4338ca;
}

.proyecto-dibujo-card__thumb {
    background: #f8fafc;
}

.proyecto-dibujo-card__link {
    display: inline-block;
}

.mobile-input-overlay {
    z-index: 95;
}

.mobile-input-overlay .mobile-input-dialog {
    width: 100%;
    max-width: 24rem;
    margin: auto;
}

@media (max-width: 639px) {
    .mobile-input-overlay {
        align-items: center !important;
        padding: 1rem !important;
    }

    .mobile-input-overlay .mobile-input-dialog {
        border-radius: 0.75rem;
        max-width: none;
    }
}
