/* ===== Shared panel components ===== */

.panel {
    display: flex;
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-4);
}

.panel-title {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.panel-subtitle {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-2);
}

/* Sub-group heading inside a gallery section (frame categories, …). */
.panel-subgroup {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text);
    margin: var(--space-3) 0 var(--space-2);
    padding-inline-start: var(--space-1);
    border-inline-start: 3px solid var(--color-primary);
}

/* Collapsible (accordion) gallery sections: collapsed by default, tap the
   header to expand. Keeps the bottom sheet compact. */
.collapsible-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    padding: var(--space-2) 0;
    cursor: pointer;
}

.collapsible-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text);
}

.collapsible-chev {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    margin-inline-end: var(--space-2);
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.collapsible-head.open .collapsible-chev {
    transform: rotate(-135deg);
}

.collapsible-body.collapsed {
    display: none;
}

/* Category heading with a thumbnail (template categories). */
.category-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border-inline-start: none;
    padding-inline-start: 0;
}

.category-parent {
    font-weight: 700;
    margin-top: var(--space-2);
}

.category-child {
    padding-inline-start: var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.category-thumb {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    flex: 0 0 auto;
    background: var(--color-border);
}

.category-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Template card with a real thumbnail image. */
.template-thumb-img {
    border-radius: 10px;
    background: var(--color-border);
}

.template-thumb-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sect {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border);
}

.sect:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.field:last-child {
    margin-bottom: 0;
}

.field-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
}

.field-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.field-row > * {
    flex: 1 1 0;
}

.field-row .grow-2 {
    flex: 2 1 0;
}

/* Inputs */
.input {
    width: 100%;
    height: var(--touch-min);
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.input-num {
    width: 76px;
    text-align: center;
    flex: 0 0 76px !important;
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

/* RTL: place the select arrow on the left side */
[dir="rtl"] select.input {
    background-position: left 12px center;
    padding-right: var(--space-3);
    padding-left: 36px;
}

/* Asset gallery category strips */
.asset-cats {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-2);
}

.asset-cats .chip {
    flex: 0 0 auto;
    padding: 0 var(--space-4);
}

.asset-status {
    padding: var(--space-5);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}

.asset-status.error {
    color: var(--color-danger);
}

/* Range slider */
.range-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

input[type="range"] {
    flex: 1 1 auto;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border-strong);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
    cursor: pointer;
}

input[type="range"]:disabled {
    opacity: 0.5;
}

/* Color picker */
.color-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

input[type="color"] {
    width: 46px;
    height: var(--touch-min);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    padding: 3px;
    cursor: pointer;
}

.color-swatch {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    flex-shrink: 0;
}

/* Tappable colour palette (Controls.colorPalette): a grid of presets above the
   custom picker, so التعبئة / لون الحدود / لون النص all offer the same choice
   and the user is never stuck with one hard-coded colour. */
.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: var(--space-2);
}

.color-chip {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-border-strong);
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.color-chip:hover {
    border-color: var(--color-primary);
}

.color-chip.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.color-palette .color-field {
    padding-top: var(--space-1);
}

/* The ONE colour control inside every panel: a labelled button whose square
   shows the current colour. The picker (and its grid) opens only on tap, so no
   colour grid is permanently displayed inside a bottom sheet (requirement 14). */
.color-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    height: var(--touch-min);
    padding: var(--space-1);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

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

.color-btn-checker {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-border);
    flex-shrink: 0;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
    background-color: var(--color-surface);
    overflow: hidden;
}

.color-btn-checker .color-btn-fill {
    display: block;
    width: 100%;
    height: 100%;
}

.color-btn-caret {
    color: var(--color-text-muted);
    margin-inline-start: auto;
    padding-inline-end: var(--space-2);
    font-size: 14px;
}

/* The app's own Arabic colour picker dialog (requirement 4). */
.color-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.color-picker-card {
    width: min(420px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(15, 23, 42, 0.35);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.color-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-picker-head .panel-title {
    margin: 0;
}

.color-picker-close {
    border: none;
    background: none;
    color: var(--color-text-muted);
    font-size: 16px;
    cursor: pointer;
    width: var(--touch-min);
    height: var(--touch-min);
}

.color-picker-current {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.color-picker-preview {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-border);
    overflow: hidden;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
    flex-shrink: 0;
}

.color-picker-preview-fill {
    display: block;
    width: 100%;
    height: 100%;
}

.color-picker-current-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.color-picker-hex {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.color-picker-native input[type="color"] {
    width: 100%;
}

.color-picker-opacity .range-wrap {
    align-items: center;
}

.color-picker-pct {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.color-picker-actions {
    display: flex;
    gap: var(--space-2);
}

.color-picker-actions .btn-primary,
.color-picker-actions .btn-ghost {
    flex: 1;
}

.switch-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.switch-field .field-label {
    margin: 0;
}

/* Buttons */
.btn-primary {
    height: var(--touch-min);
    padding: 0 var(--space-5);
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background var(--transition-fast), transform var(--transition-fast);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    width: 100%;
}

.btn-primary svg {
    width: 20px;
    height: 20px;
}

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

.btn-primary:active {
    transform: translateY(1px);
}

.btn-ghost {
    height: var(--touch-min);
    padding: 0 var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    background: var(--color-surface);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-ghost svg {
    width: 18px;
    height: 18px;
}

.btn-ghost:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-text-faint);
}

.btn-danger {
    height: var(--touch-min);
    padding: 0 var(--space-4);
    border-radius: var(--radius-md);
    background: rgba(220, 38, 38, 0.1);
    color: var(--color-danger);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background var(--transition-fast);
}

.btn-danger svg {
    width: 18px;
    height: 18px;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.18);
}

/* Grid of option buttons (frames, colors, etc.) */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: var(--space-2);
}

/* Same grid, used by the shapes / frames / emotions sections */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: var(--space-2);
}

.option-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    transition: border-color var(--transition-fast), transform var(--transition-fast);
    min-height: 72px;
}

.option-cell:hover {
    border-color: var(--color-border-strong);
}

.option-cell.active {
    border-color: var(--color-primary);
}

.option-thumb {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.option-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.option-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Filter strip: Instagram-style horizontal previews. */
.filter-strip {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    padding: var(--space-2) var(--space-1);
    margin: 0 calc(var(--space-1) * -1);
    scrollbar-width: thin;
}

.filter-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.filter-preview {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--color-border);
    border: 2px solid transparent;
}

.filter-item.active .filter-preview {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 30%, transparent);
}

.filter-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.filter-item.active .filter-label {
    color: var(--color-primary);
}

/* Template tiles: a mini stacked-layers glyph instead of a thumbnail image. */
.template-thumb {
    background: linear-gradient(135deg, var(--color-primary) 0%, #7c3aed 100%);
    border-radius: 10px;
}

.template-layers {
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    padding: 0 4px;
}

/* Shape thumbnails: CSS-drawn, so no icon file is needed per shape. */
.shape-preview {
    display: block;
    width: 30px;
    height: 30px;
    background: var(--color-text-muted);
}

.shape-rect { border-radius: 2px; }
.shape-rounded { border-radius: 8px; }
.shape-square { width: 26px; height: 26px; }
.shape-circle { width: 28px; height: 28px; border-radius: 50%; }
.shape-ellipse { width: 34px; height: 22px; border-radius: 50%; }
.shape-triangle {
    width: 0;
    height: 0;
    background: none;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 28px solid var(--color-text-muted);
}
.shape-line {
    height: 3px;
    border-radius: 2px;
    transform: rotate(-45deg);
    width: 34px;
}

/* Font list (config/fonts.json) */
.font-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.font-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: border-color var(--transition-fast);
}

.font-item:hover {
    border-color: var(--color-border-strong);
}

.font-item.active {
    border-color: var(--color-primary);
}

.font-sample {
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.15;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Selection chips for bg / effect options */
.chip-group {
    display: flex;
    gap: var(--space-2);
}

.chip {
    flex: 1 1 0;
    height: var(--touch-min);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.chip.active {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Icon row for rotate etc. */
.icon-row {
    display: flex;
    gap: var(--space-2);
}

.icon-row .field {
    flex: 1 1 0;
    margin: 0;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: var(--color-surface-muted);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* List row (e.g., layer controls) */
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}

.list-row:last-child {
    border-bottom: none;
}

.list-row .list-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.list-actions {
    display: flex;
    gap: var(--space-1);
}

/* Switch toggle */
.switch {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    border-radius: 13px;
    background: var(--color-border-strong);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
    transition: transform var(--transition-fast);
}

.switch input:checked + .slider {
    background: var(--color-primary);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

/* Frame preview */
.frame-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background:
        linear-gradient(45deg, var(--color-border) 25%, transparent 25%, transparent 75%, var(--color-border) 75%),
        linear-gradient(45deg, var(--color-border) 25%, transparent 25%, transparent 75%, var(--color-border) 75%);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.frame-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Bottom sheet contents inherit .panel styling */
.sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Quick toggles row */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
/* Layers panel (js/ui/LayersPanel.js) */
.layers-panel {
    gap: var(--space-2);
    padding: var(--space-3);
}

.layers-panel .panel-title {
    font-size: var(--font-size-md);
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    /* A comfortable, scrollable list: rows used to be packed into 320px and
       their controls ended up touching each other. */
    max-height: min(46vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Room for the selected row's outline so it is never clipped. */
    padding: var(--space-1);
}

.layer-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
    /* A clear, separate row that is comfortable to tap on a phone. */
    min-height: 56px;
}

.layer-row.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.layer-row.hidden-layer .layer-thumb {
    opacity: 0.4;
}

.layer-main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    /* Grows and shrinks freely; the actions keep their fixed size. */
    flex: 1 1 0;
    min-width: 0;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.layer-thumb {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 700;
}

/* A real preview of the image, cropped to a square like the glyph box. */
.layer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.layer-info {
    min-width: 0;
    flex: 1 1 auto;
}

.layer-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-name.faded {
    opacity: 0.5;
}

.layer-name.locked-name::after {
    content: ' 🔒';
    font-size: var(--font-size-xs);
}

.layer-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex: 0 0 auto;
    /* Pushed to the far end of the row and given breathing room, so the
       buttons never sit flush against the row edge or on top of the name. */
    margin-inline-start: auto;
    padding: var(--space-1);
}

.layer-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.layer-icon-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.layer-icon-btn.on {
    color: var(--color-primary);
}

.layer-icon-btn.off {
    color: var(--color-text-faint);
}

.layer-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    /* A full-width block of its own under the row, so the order buttons are
       never squeezed next to the name. */
    flex: 1 1 100%;
    width: 100%;
    padding: var(--space-2) 0 0;
    border-top: 1px solid var(--color-border);
    background: transparent;
}

.layer-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-height: 36px;
    padding: 0 var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
    color: var(--color-text);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
}

.layer-option:disabled {
    opacity: 0.4;
    cursor: default;
}

.layer-option:not(:disabled):hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.layer-option-icon {
    display: inline-flex;
    align-items: center;
}

.layer-rename-input {
    width: 100%;
    font-size: var(--font-size-sm);
}
/* Locked-layer notice shown at the top of a property panel */
.panel-notice {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 600;
}
/* Multi-selection / grouping panel (js/ui/SelectionPanel.js) */
.selection-panel {
    gap: var(--space-3);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.btn-row-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    flex: 1 1 auto;
    justify-content: center;
    min-height: 40px;
}

.btn-row-item:disabled {
    opacity: 0.45;
    cursor: default;
}

.btn-row-icon {
    display: inline-flex;
    align-items: center;
}

/* Group badge in the layers list */
.layer-name-line {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
}

.layer-group-tag {
    flex-shrink: 0;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
}

/* ============ Text bottom sheet — modern design v2 ============ */
/* Targets actual component classes. Brand blue. No hardcoded values in JS. */

.text-sheet {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

/* ---- Pinned quick controls ---- */
.text-quick {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.text-quick-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}

/* ---- Modern slider with value badge ---- */
.text-sheet .field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.text-sheet .field-label {
    font-weight: 600;
    font-size: var(--font-size-md);
}

.text-sheet .slider-val {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    min-width: 48px;
    text-align: center;
}

.text-sheet .range-wrap-single input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 99px;
    background: var(--color-border);
    outline: none;
}

.text-sheet .range-wrap-single input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.4);
    cursor: pointer;
}

.text-sheet .range-wrap-single input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.4);
    cursor: pointer;
}

/* ---- Circular color swatch ---- */
.text-sheet .color-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.text-sheet .color-btn-fill {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.text-sheet .color-btn-caret,
.text-sheet .color-btn-checker {
    display: none;
}

/* ---- Segmented chips ---- */
.text-sheet .chip-group {
    display: flex;
    background: var(--color-surface-muted);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    flex: 1;
}

.text-sheet .chip-group .chip {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 10px 8px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.text-sheet .chip-group .chip.active {
    background: #fff;
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    font-weight: 700;
}

/* ---- Accordions ---- */
.text-accordion {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-surface);
    overflow: hidden;
}

.text-accordion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--font-size-md);
    list-style: none;
}

.text-accordion-head::-webkit-details-marker {
    display: none;
}

.text-accordion-head::after {
    content: '';
    width: 10px;
    height: 10px;
    border-left: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(-45deg);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.text-accordion[open] .text-accordion-head::after {
    transform: rotate(135deg);
}

.text-accordion-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--color-border);
}

/* ---- Toggle switch modern ---- */
.text-sheet .switch {
    width: 48px;
    height: 28px;
}

.text-sheet .switch .slider {
    border-radius: 99px;
}

.text-sheet .switch .slider::before {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.text-sheet .switch input:checked + .slider {
    background: var(--color-primary);
}

/* ---- Delete button ---- */
.text-sheet .btn-danger {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    background: var(--color-danger-soft, #fef2f2);
    color: var(--color-danger);
    font-weight: 700;
    font-size: var(--font-size-md);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ---- Icon buttons row ---- */
.text-sheet .icon-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.text-sheet .icon-row button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-surface-muted);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
}

.text-sheet .icon-row button:active {
    transform: scale(0.95);
}
