/* ============================================================
   Penguin Boat Club — Design System
   ============================================================

   TABLE OF CONTENTS
   -----------------
   0. Table of Contents (you are here)
   1. Design Tokens
   2. Reset & Base
   3. Layout (shell, sidebar, header, content)
   4. Components (buttons, inputs, cards, badges, dialogs,
      dropdowns, tabs, tooltips, separators, sheets, toasts,
      empty states)
   5. Patterns (library grids, data tables, upload zones,
      search bars, pagination)
   6. Editor (toolbar, tools panel, properties panel, canvas)
   7. Pages (login, dashboard, admin)
   8. Utilities (visually-hidden, truncate, scrollbar)
   9. Responsive (tablet 768px, desktop 1280px, wide 1536px)

   ============================================================ */


/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */

:root {
    /* --- Colors: Light Theme --- */
    --background:             hsl(0 0% 100%);
    --foreground:             hsl(0 0% 4%);
    --card:                   hsl(0 0% 100%);
    --card-foreground:        hsl(0 0% 4%);
    --popover:                hsl(0 0% 100%);
    --popover-foreground:     hsl(0 0% 4%);
    --primary:                hsl(0 0% 9%);
    --primary-foreground:     hsl(0 0% 98%);
    --secondary:              hsl(0 0% 96%);
    --secondary-foreground:   hsl(0 0% 9%);
    --muted:                  hsl(0 0% 96%);
    --muted-foreground:       hsl(0 0% 45%);
    --accent:                 hsl(0 0% 96%);
    --accent-foreground:      hsl(0 0% 9%);
    --destructive:            hsl(0 84% 60%);
    --destructive-foreground: hsl(0 0% 98%);
    --success:                hsl(142 71% 45%);
    --success-foreground:     hsl(0 0% 98%);
    --warning:                hsl(38 92% 50%);
    --warning-foreground:     hsl(0 0% 9%);
    --border:                 hsl(0 0% 90%);
    --input:                  hsl(0 0% 90%);
    --ring:                   hsl(0 0% 64%);

    /* Sidebar */
    --sidebar:                        hsl(0 0% 98%);
    --sidebar-foreground:             hsl(0 0% 4%);
    --sidebar-primary:                hsl(0 0% 9%);
    --sidebar-primary-foreground:     hsl(0 0% 98%);
    --sidebar-accent:                 hsl(0 0% 96%);
    --sidebar-accent-foreground:      hsl(0 0% 9%);
    --sidebar-border:                 hsl(0 0% 90%);
    --sidebar-muted:                  hsl(0 0% 45%);

    /* --- Typography --- */
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system,
                 BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --text-4xl:  2.25rem;

    --leading-tight:   1.25;
    --leading-normal:  1.5;
    --leading-relaxed: 1.75;
    --tracking-tight: -0.025em;

    /* --- Spacing (4px base) --- */
    --sp-0:  0;
    --sp-px: 1px;
    --sp-0-5: 0.125rem;
    --sp-1:  0.25rem;
    --sp-1-5: 0.375rem;
    --sp-2:  0.5rem;
    --sp-3:  0.75rem;
    --sp-4:  1rem;
    --sp-5:  1.25rem;
    --sp-6:  1.5rem;
    --sp-8:  2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;
    --sp-16: 4rem;
    --sp-20: 5rem;
    --sp-24: 6rem;

    /* --- Border Radius --- */
    --radius:      0.625rem;
    --radius-sm:   0.5rem;
    --radius-md:   0.625rem;
    --radius-lg:   0.75rem;
    --radius-xl:   1rem;
    --radius-full: 9999px;

    /* --- Shadows --- */
    --shadow-xs:  0 1px 1px 0 rgb(0 0 0 / 0.05);
    --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* --- Transitions --- */
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast:   150ms;
    --duration-normal: 200ms;
    --duration-slow:   300ms;

    /* --- Layout --- */
    --sidebar-width:      16rem;
    --sidebar-width-icon: 3rem;
    --header-height:      3.5rem;
    --content-max-width:  1400px;

    /* --- Z-Index Scale --- */
    --z-dropdown:  50;
    --z-sticky:    100;
    --z-overlay:   200;
    --z-modal:     300;
    --z-popover:   400;
    --z-toast:     500;
    --z-tooltip:   600;
}

/* --- Colors: Dark Theme (straight black) --- */
[data-theme="dark"] {
    --background:             hsl(0 0% 0%);
    --foreground:             hsl(0 0% 98%);
    --card:                   hsl(0 0% 7%);
    --card-foreground:        hsl(0 0% 98%);
    --popover:                hsl(0 0% 10%);
    --popover-foreground:     hsl(0 0% 98%);
    --primary:                hsl(0 0% 98%);
    --primary-foreground:     hsl(0 0% 0%);
    --secondary:              hsl(0 0% 12%);
    --secondary-foreground:   hsl(0 0% 98%);
    --muted:                  hsl(0 0% 12%);
    --muted-foreground:       hsl(0 0% 64%);
    --accent:                 hsl(0 0% 18%);
    --accent-foreground:      hsl(0 0% 98%);
    --destructive:            hsl(0 63% 31%);
    --destructive-foreground: hsl(0 84% 70%);
    --success:                hsl(142 71% 35%);
    --success-foreground:     hsl(0 0% 98%);
    --warning:                hsl(38 92% 40%);
    --warning-foreground:     hsl(0 0% 98%);
    --border:                 hsl(0 0% 15%);
    --input:                  hsl(0 0% 15%);
    --ring:                   hsl(0 0% 40%);

    --sidebar:                        hsl(0 0% 4%);
    --sidebar-foreground:             hsl(0 0% 98%);
    --sidebar-primary:                hsl(0 0% 98%);
    --sidebar-primary-foreground:     hsl(0 0% 0%);
    --sidebar-accent:                 hsl(0 0% 12%);
    --sidebar-accent-foreground:      hsl(0 0% 98%);
    --sidebar-border:                 hsl(0 0% 15%);
    --sidebar-muted:                  hsl(0 0% 64%);

    --shadow-xs:  0 1px 1px 0 rgb(0 0 0 / 0.2);
    --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--foreground);
    background: var(--background);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img, svg {
    display: block;
    max-width: 100%;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
    border: none;
    background: none;
    outline: none;
}

button {
    cursor: pointer;
}

table {
    border-collapse: collapse;
    width: 100%;
}

:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::selection {
    background: var(--primary);
    color: var(--primary-foreground);
}

/* Scrollbar base */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}


/* ============================================================
   3. LAYOUT
   ============================================================ */

/* --- App Shell --- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--duration-normal) var(--ease-default);
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    transition: width var(--duration-normal) var(--ease-default);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-width-icon);
}

.sidebar-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding: 0 var(--sp-4);
    gap: var(--sp-3);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    transition: padding var(--duration-normal) var(--ease-default);
}

.sidebar.collapsed .sidebar-header {
    padding: 0;
    gap: 0;
    justify-content: center;
}

.sidebar-collapse-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-muted);
    flex-shrink: 0;
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-foreground);
}

.sidebar-collapse-btn svg {
    width: 16px;
    height: 16px;
    transition: transform var(--duration-normal) var(--ease-default);
}

.sidebar.collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-collapse-btn {
    margin-left: 0;
}

.sidebar.collapsed .sidebar-mark {
    display: none;
}

/* Inline masthead: penguin <g> keeps a fixed fill; wordmark <g> uses currentColor,
   which we point at the theme foreground so the text (only) tracks light/dark. */
.sidebar-mark {
    height: 38px;
    width: auto;
    max-width: 100%;
    flex-shrink: 0;
    color: var(--sidebar-foreground);
}

[data-theme="dark"] .login-logo-img {
    filter: invert(1);
}

.sidebar-title {
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--duration-fast) var(--ease-default);
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2) var(--sp-2);
}

.sidebar-section {
    margin-bottom: var(--sp-2);
}

.sidebar-section-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-2) var(--sp-2) var(--sp-1);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--radius-md);
    color: var(--sidebar-foreground);
    font-size: var(--text-sm);
    white-space: nowrap;
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
    text-decoration: none;
}

.sidebar-link:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

.sidebar-link.active {
    background: var(--sidebar-accent);
    color: var(--sidebar-primary);
    font-weight: 600;
}

.sidebar-link svg,
.sidebar-link .sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link.active .sidebar-icon {
    opacity: 1;
}

.sidebar-link-text {
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--duration-fast) var(--ease-default);
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    gap: 0;
    padding: var(--sp-2);
}

.sidebar.collapsed .sidebar-link-text {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar-separator {
    height: 1px;
    background: var(--sidebar-border);
    margin: var(--sp-2) var(--sp-2);
}

.sidebar-footer {
    flex-shrink: 0;
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 1;
    transition: opacity var(--duration-fast) var(--ease-default),
                padding var(--duration-normal) var(--ease-default);
}

.sidebar-footer-copy {
    font-size: 10px;
    color: var(--sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.3;
}

.sidebar.collapsed .sidebar-footer {
    padding: var(--sp-2) var(--sp-1);
    align-items: center;
}

.sidebar.collapsed .sidebar-footer-copy {
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Header Bar --- */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--sp-6);
    border-bottom: 1px solid var(--border);
    background: var(--background);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    min-width: 0;
}

.breadcrumb-item,
.breadcrumb-link,
.breadcrumb-current {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-link {
    color: var(--muted-foreground);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb-link:hover {
    color: var(--foreground);
}

.breadcrumb-item:last-child,
.breadcrumb-current {
    color: var(--foreground);
    font-weight: 600;
}

.breadcrumb-sep {
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.breadcrumb-sep svg {
    width: 16px;
    height: 16px;
}

/* User avatar dropdown */
.team-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    background: var(--muted);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    white-space: nowrap;
    max-width: 15ch;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    cursor: default;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--duration-fast) var(--ease-default);
}

.user-avatar:hover {
    opacity: 0.9;
}

/* --- Content Area --- */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-6);
}

.content-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* Page header (title + actions) */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
    gap: var(--sp-4);
}

.page-title {
    font-family: 'Bricolage Grotesque', var(--font-sans);
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    color: var(--foreground);
}

.page-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}


/* ============================================================
   4. COMPONENTS
   ============================================================ */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    white-space: nowrap;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    height: 36px;
    padding: 0 var(--sp-4);
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default),
                border-color var(--duration-fast) var(--ease-default),
                opacity var(--duration-fast) var(--ease-default);
    cursor: pointer;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Default variant */
.btn-default,
.btn {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-default:hover,
.btn:not([class*="btn-"]):hover {
    opacity: 0.9;
}

/* Destructive */
.btn-destructive {
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-destructive:hover {
    opacity: 0.9;
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

/* Secondary */
.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

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

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--foreground);
}

.btn-ghost:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

/* Link */
.btn-link {
    background: transparent;
    color: var(--primary);
    padding: 0;
    height: auto;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Button sizes */
.btn-sm {
    height: 32px;
    padding: 0 var(--sp-3);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    height: 40px;
    padding: 0 var(--sp-6);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

.btn-icon.btn-lg {
    width: 40px;
    height: 40px;
}

/* --- Inputs --- */
.input {
    display: flex;
    height: 36px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--input);
    background: transparent;
    padding: 0 var(--sp-3);
    font-size: var(--text-sm);
    color: var(--foreground);
    transition: border-color var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default);
}

.input::placeholder {
    color: var(--muted-foreground);
}

.input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px var(--ring);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Textarea */
.textarea {
    display: flex;
    width: 100%;
    min-height: 80px;
    border-radius: var(--radius-md);
    border: 1px solid var(--input);
    background: transparent;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    color: var(--foreground);
    resize: vertical;
    transition: border-color var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default);
}

.textarea:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px var(--ring);
}

/* Select */
.select {
    display: flex;
    height: 36px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--input);
    background: var(--background);
    padding: 0 var(--sp-8) 0 var(--sp-3);
    font-size: var(--text-sm);
    color: var(--foreground);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='0.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-default);
}

.select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px var(--ring);
}

/* Checkbox / Radio — base styles for ALL checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--background);
    transition: background var(--duration-fast) var(--ease-default),
                border-color var(--duration-fast) var(--ease-default);
    position: relative;
}

input[type="radio"] {
    border-radius: var(--radius-full);
}

input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    /* tick in the primary's own foreground: white on the dark light-mode
       primary, dark on the white dark-mode primary (was always white, so
       every ticked box read as an empty white circle in dark mode) */
    border: solid var(--primary-foreground, white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="radio"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}
input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    transform: translate(-50%, -50%);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Class aliases (legacy) */
.checkbox { /* inherits from input[type="checkbox"] */ }
.radio { /* inherits from input[type="radio"] */ }

/* Label */
.label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    display: block;
    margin-bottom: var(--sp-1-5);
}

/* Form group */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--destructive);
    margin-top: var(--sp-1);
}

/* --- Cards --- */
.card {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1-5);
    padding: var(--sp-6);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
}

.card-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

.card-content {
    padding: 0 var(--sp-6) var(--sp-6);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-full);
    padding: 2px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--duration-fast) var(--ease-default);
}

.badge-default {
    background: var(--primary);
    color: var(--primary-foreground);
}

.badge-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.badge-destructive {
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.badge-outline {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.badge-success {
    background: var(--success);
    color: var(--success-foreground);
}

.badge-warning {
    background: var(--warning);
    color: var(--warning-foreground);
}

/* --- Dialogs / Modals --- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.8);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    animation: fade-in var(--duration-normal) var(--ease-default);
}

.dialog-overlay[data-closing] {
    animation: fade-out var(--duration-fast) var(--ease-default) forwards;
}

.dialog {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 32rem;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: dialog-in var(--duration-normal) var(--ease-default);
}

.dialog-overlay[data-closing] .dialog {
    animation: dialog-out var(--duration-fast) var(--ease-default) forwards;
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.dialog-title {
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
}

.dialog-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

.dialog-body {
    padding: var(--sp-4) var(--sp-6) var(--sp-6);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
}

.dialog-close {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
}

.dialog-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

/* --- Dropdown Menus --- */
.dropdown {
    position: relative;
    display: inline-flex;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: var(--z-dropdown);
    min-width: 12rem;
    background: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--sp-1);
    display: none;
    animation: fade-in var(--duration-fast) var(--ease-default);
}

.dropdown.open .dropdown-content {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default);
}

.dropdown-item:hover {
    background: var(--accent);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.dropdown-separator {
    height: 1px;
    background: var(--border);
    margin: var(--sp-1) 0;
}

.dropdown-label {
    padding: var(--sp-2) var(--sp-2) var(--sp-1);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
}

/* --- Tabs --- */
.tabs-list {
    display: inline-flex;
    align-items: center;
    background: var(--muted);
    border-radius: var(--radius-lg);
    padding: var(--sp-1);
    gap: var(--sp-1);
}

.tab-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: var(--radius-md);
    padding: var(--sp-1-5) var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--muted-foreground);
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default);
    cursor: pointer;
}

.tab-trigger:hover {
    color: var(--foreground);
}

.tab-trigger.active {
    background: var(--background);
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
}

.tab-content {
    margin-top: var(--sp-4);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* --- Tooltips --- */
.tooltip {
    position: relative;
}

.tooltip-content {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: var(--text-xs);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-md);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: var(--z-tooltip);
    transition: opacity var(--duration-fast) var(--ease-default) 150ms;
}

.tooltip:hover .tooltip-content {
    opacity: 1;
}

/* --- Separators --- */
.separator {
    height: 1px;
    background: var(--border);
    width: 100%;
}

.separator-vertical {
    width: 1px;
    height: 100%;
    background: var(--border);
}

/* --- Sheets (slide-over panels) --- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.8);
    z-index: var(--z-overlay);
    animation: fade-in var(--duration-normal) var(--ease-default);
}

.sheet-overlay[data-closing] {
    animation: fade-out var(--duration-fast) var(--ease-default) forwards;
}

.sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100%;
    background: var(--background);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-overlay);
    overflow-y: auto;
    animation: sheet-in var(--duration-normal) var(--ease-default);
}

.sheet-overlay[data-closing] + .sheet,
.sheet[data-closing] {
    animation: sheet-out var(--duration-fast) var(--ease-default) forwards;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.sheet-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.sheet-body {
    padding: var(--sp-6);
}

/* --- Toasts --- */
.toast-container {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--sp-3);
    pointer-events: none;
}

.toast {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 420px;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    pointer-events: auto;
    animation: toast-in var(--duration-normal) var(--ease-default);
}

.toast[data-closing] {
    animation: toast-out var(--duration-fast) var(--ease-default) forwards;
}

.toast[data-variant="success"] {
    border-left: 3px solid var(--success);
}

.toast[data-variant="error"] {
    border-left: 3px solid var(--destructive);
}

.toast[data-variant="warning"] {
    border-left: 3px solid var(--warning);
}

.toast[data-variant="info"] {
    border-left: 3px solid var(--border);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-icon[data-variant="success"] { color: var(--success); }
.toast-icon[data-variant="error"]   { color: var(--destructive); }
.toast-icon[data-variant="warning"] { color: var(--warning); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
}

.toast-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-foreground);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
}

.toast-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

/* Optional toast action (Toast.show({ action: { label, onClick } }), v1.80: Undo) */
.toast-action {
    align-self: center;
    flex-shrink: 0;
}

/* --- Empty States --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-16) var(--sp-6);
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    color: var(--muted-foreground);
    margin-bottom: var(--sp-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-2);
}

.empty-state-description {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    max-width: 24rem;
    margin-bottom: var(--sp-6);
}


/* ============================================================
   5. PATTERNS
   ============================================================ */

/* --- Library Grid --- */
.library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
}

.library-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default);
    cursor: pointer;
}

.library-card:hover {
    border-color: var(--ring);
    box-shadow: var(--shadow-md);
}

.library-card-thumb {
    aspect-ratio: 3 / 4;
    background: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    padding: 12px;
    position: relative;   /* anchors the card kebab overlay */
}

.library-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 2px;
}

.library-card-thumb img[src="pbc-favicon.svg"] {
    width: 48px;
    height: 48px;
    border: none;
}

.library-card-body {
    padding: var(--sp-3) var(--sp-4);
}

.library-card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.library-card-title[data-rename-id] {
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background 0.15s;
}
.library-card-title[data-rename-id]:hover {
    background: var(--muted);
}

/* Inline rename input on library cards */
.inline-rename-input {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    background: var(--background);
    border: 1px solid var(--ring);
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    width: 100%;
    outline: none;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 25%, transparent);
}

.library-card-meta {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
    display: flex;
    align-items: center;
    gap: var(--sp-1) var(--sp-2);
    flex-wrap: wrap;   /* narrow cards wrap badges to a second line, never clip */
    min-width: 0;
}
/* Safety net for pathological single badges (very long category names) */
.library-card-meta .badge {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.library-card-meta .library-card-action { flex-shrink: 0; }

/* Card kebab: a circular ellipsis button overlaying the preview's top-right
   corner. Contrast adapts to the preview (black dot on light previews, white
   on dark — set by applyKebabContrast sampling the corner). Hover-revealed on
   fine pointers; always visible on touch, which has no hover. */
.card-kebab {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform .12s ease;
}
.card-kebab:hover { transform: scale(1.08); }
.card-kebab.kebab-light { background: rgba(255, 255, 255, 0.95); color: #1a1a1a; }
@media (hover: hover) and (pointer: fine) {
    .card-kebab { opacity: 0; transition: opacity .12s ease, transform .12s ease; }
    .library-card:hover .card-kebab,
    .library-card:focus-within .card-kebab { opacity: 1; }
}
.card-kebab-menu {
    position: absolute;
    top: 40px;
    right: 8px;
    z-index: 5;
    min-width: 140px;
    padding: var(--sp-1);
    background: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: none;
    flex-direction: column;
}
.card-kebab-menu.open { display: flex; }
.card-kebab-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: none;
    background: none;
    font-size: var(--text-sm);
    color: inherit;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.card-kebab-item:hover { background: var(--accent); }
.card-kebab-item.destructive { color: var(--destructive); }

/* --- Document folders (v1.80) ---
   A rail INSIDE the Documents page (not the app sidebar), shown once the
   team has a folder; with none, the page is unchanged apart from the quiet
   "New folder" button. Markup: modules/doc-folders.js; state: app.js
   renderDocumentsList. Existing tokens only, so dark mode follows. */
.doc-new-folder[hidden],
.folder-rail[hidden],
.folder-results[hidden],
.folder-selbar[hidden],
.folder-row-error[hidden] { display: none; }

.doc-library.has-rail {
    display: grid;
    grid-template-columns: 216px minmax(0, 1fr);
    gap: var(--sp-6);
    align-items: start;
}
.doc-library-main { min-width: 0; }
.doc-library.has-rail .library-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

.folder-rail {
    position: sticky;
    top: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* A long folder list scrolls inside the rail instead of off screen */
    max-height: calc(100vh - var(--header-height) - var(--sp-12));
    max-height: calc(100dvh - var(--header-height) - var(--sp-12));
    overflow-y: auto;
    scrollbar-width: thin;
}
.folder-rail-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    padding: var(--sp-3) var(--sp-1) var(--sp-1) 10px;
}
.folder-rail-add {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    color: var(--muted-foreground);
}
.folder-rail-add:hover { background: var(--accent); color: var(--foreground); }

.folder-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 34px;
    padding: 7px 8px 7px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--foreground);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.folder-row > svg { flex: none; }
.folder-row:hover { background: var(--accent); }
.folder-row[aria-current="true"] { background: var(--accent); font-weight: 600; }
.folder-row.is-muted { color: var(--muted-foreground); }
.folder-row-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-row-count {
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}
.folder-row-more {
    width: 22px;
    height: 22px;
    margin-right: -2px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    color: var(--muted-foreground);
    opacity: 0;
}
.folder-row-more:hover { background: var(--border); color: var(--foreground); }
.folder-row:hover .folder-row-more,
.folder-row:focus-within .folder-row-more,
.folder-row-more[aria-expanded="true"] { opacity: 1; }
.folder-row:has(.folder-row-more):hover .folder-row-count,
.folder-row:has(.folder-row-more):focus-within .folder-row-count,
.folder-row:has(.folder-row-more[aria-expanded="true"]) .folder-row-count { display: none; }
@media (hover: none) {
    .folder-row-more { opacity: 1; }
    .folder-row:has(.folder-row-more) .folder-row-count { display: none; }
}
/* Search spans every folder, so no row reads as "current" while searching */
.folder-rail.is-searching .folder-row[aria-current="true"] { background: none; font-weight: 400; }
.folder-rail.is-searching .folder-row[aria-current="true"]:hover { background: var(--accent); }
/* Drag a card over the rail: every target outlines, the hovered one fills */
.folder-rail.is-dragging .folder-row[data-drop] { box-shadow: inset 0 0 0 1px var(--border); }
.folder-rail .folder-row.is-drop-target {
    background: var(--accent);
    box-shadow: inset 0 0 0 2px var(--foreground);
}
.folder-rail-sep { height: 1px; background: var(--border); margin: var(--sp-2) 10px; }
.folder-rail-hint {
    font-size: var(--text-xs);
    line-height: 1.45;
    color: var(--muted-foreground);
    padding: var(--sp-2) 10px 0;
}
.folder-row-input {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 4px 6px 4px 10px;
    color: var(--muted-foreground);
}
.folder-row-input > svg { flex: none; }
.folder-row-input .input {
    height: 30px;
    padding: 0 var(--sp-2);
    min-width: 0;
    border-color: var(--ring);
    color: var(--foreground);
}
.folder-row-input .input[aria-invalid="true"] { border-color: var(--destructive); }
.folder-row-error { margin: 0; padding: 2px 10px 2px 34px; }

/* Cards: the where-is-it line, the selection tick, selected + dragging */
.card-folder {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    margin-top: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
}
.card-folder svg { flex: none; }
.card-folder span { overflow: hidden; text-overflow: ellipsis; }
.card-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid var(--ring);
    background: var(--background);
    color: var(--background);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-xs);
}
.card-check svg { stroke-width: 3; }
@media (hover: hover) and (pointer: fine) {
    .card-check { opacity: 0; transition: opacity .12s ease; }
    .library-card:hover .card-check,
    .library-card:focus-within .card-check,
    .library-grid.is-selecting .card-check { opacity: 1; }
}
.library-card.is-selected { border-color: transparent; box-shadow: 0 0 0 2px var(--foreground); }
.library-card.is-selected .card-check { background: var(--foreground); border-color: var(--foreground); opacity: 1; }
.library-card.is-dragging { opacity: .45; }
.doc-library.has-rail .library-card { user-select: none; -webkit-user-select: none; }
.doc-library.has-rail .library-card .inline-rename-input { user-select: text; -webkit-user-select: text; }

.folder-results {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin: calc(-1 * var(--sp-1)) 0 var(--sp-3);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}
.folder-results-clear {
    color: var(--foreground);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Popovers: folder menu, delete confirm, Move to folder (on .view-menu) */
.folder-pop { min-width: 220px; max-width: 280px; }
.folder-pop .view-menu-heading {
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--text-xs);
    font-weight: 400;
    padding: 6px var(--sp-2) 2px;
}
.folder-pop .view-menu-item > svg { flex: none; }
.folder-pop .view-menu-item.is-active { background: var(--accent); }
.folder-pop .view-menu-item.is-danger { color: var(--destructive); }
.folder-pop .view-menu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-pop-tick { margin-left: auto; display: inline-flex; }
.folder-pop-search { padding: var(--sp-1); }
.folder-pop-search .input { height: 32px; }
.folder-pop-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.folder-pop-empty { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); color: var(--muted-foreground); }
.folder-pop-confirm p { padding: var(--sp-2) var(--sp-2) var(--sp-3); font-size: var(--text-sm); line-height: 1.45; }
.folder-pop-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-1) var(--sp-1); }

/* Floating bar for a multi-selection */
.folder-selbar {
    position: fixed;
    left: 50%;
    bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px var(--sp-4);
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    white-space: nowrap;
}
.folder-selbar button {
    height: 30px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    font-weight: 600;
}
.folder-selbar button:hover { background: color-mix(in srgb, var(--primary-foreground) 15%, transparent); }
.folder-selbar button:focus-visible { outline-color: var(--primary-foreground); }

/* Drag image for a multi-document drag ("3 documents"), parked off screen */
.folder-drag-ghost {
    position: fixed;
    top: -1000px;
    left: -1000px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

/* Narrow (tablet portrait): the rail becomes a scrolling row of chips */
@media (max-width: 820px) {
    .doc-library.has-rail { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
    .folder-rail {
        position: static;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .folder-rail > * { flex: none; }
    .folder-rail .folder-row {
        width: auto;
        min-height: 32px;
        padding: 5px 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-full);
    }
    .folder-rail .folder-row-more,
    .folder-rail-label span,
    .folder-rail-sep,
    .folder-rail-hint { display: none; }
    .folder-rail-label { padding: 0; }
    .folder-rail .folder-row:has(.folder-row-more) .folder-row-count { display: inline; }
    .folder-row-input .input { width: 160px; }
    .doc-library.has-rail .library-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }
}

.library-card-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-4) var(--sp-3);
}

.library-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    transition: color var(--duration-fast) var(--ease-default),
                background var(--duration-fast) var(--ease-default);
}

.library-card-action:first-of-type {
    margin-left: auto;
}

.library-card-action:hover {
    color: var(--foreground);
    background: var(--accent);
}

.library-card-action.library-card-delete:hover {
    color: var(--destructive);
}

/* --- Data Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    white-space: nowrap;
}

.data-table td {
    font-size: var(--text-sm);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--duration-fast) var(--ease-default);
}

.data-table tbody tr:hover {
    background: var(--muted);
}

/* --- Upload Drop Zone --- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-10) var(--sp-6);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-default),
                background var(--duration-fast) var(--ease-default);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--accent);
}

.upload-zone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--sp-3);
    color: var(--muted-foreground);
}

.upload-zone-text {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

.upload-zone-text strong {
    color: var(--foreground);
}

/* --- Search Bar --- */
.search-bar {
    position: relative;
    width: 100%;
    max-width: 24rem;
}

.search-bar .input {
    padding-left: var(--sp-10);
}

.search-bar-icon {
    position: absolute;
    left: var(--sp-3);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    pointer-events: none;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    margin-top: var(--sp-6);
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: background var(--duration-fast) var(--ease-default);
}

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

.pagination-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

.pagination-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-info {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    margin: 0 var(--sp-2);
}

/* --- Library Toolbar (search + filters row) --- */
.library-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}

.search-bar-clear {
    position: absolute;
    right: var(--sp-2);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--muted-foreground);
    cursor: pointer;
    border: none;
    background: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast);
    padding: 0;
}

.search-bar.has-value .search-bar-clear {
    opacity: 1;
    pointer-events: auto;
}

.search-bar-clear:hover {
    color: var(--foreground);
    background: var(--accent);
}

.search-bar .input {
    padding-right: var(--sp-8);
}

/* --- Filter Select --- */
.filter-select {
    height: 36px;
    font-size: var(--text-sm);
    padding: 0 var(--sp-8) 0 var(--sp-3);
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: var(--background);
    color: var(--foreground);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='0.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 25%, transparent);
}

/* Selects sharing the base .input component get the same treatment as
   .filter-select / select.prop-input — appearance:none + inset chevron.
   Without this, native selects render the caret glued to the right edge. */
select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: var(--sp-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='0.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    cursor: pointer;
}

/* --- Tag Pills --- */
.tag-pills {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 var(--sp-3);
    font-size: var(--text-xs);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
    transition: all var(--duration-fast);
    white-space: nowrap;
}

.tag-pill:hover {
    border-color: var(--ring);
    background: var(--accent);
}

.tag-pill.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* --- Tag Editor (inline chips + input) --- */
.tag-editor {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    padding: var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    min-height: 36px;
    align-items: center;
    cursor: text;
}

.tag-editor:focus-within {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 25%, transparent);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    font-size: var(--text-xs);
    background: var(--secondary);
    border-radius: var(--radius-sm);
    color: var(--secondary-foreground);
}

.tag-chip-remove {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--muted-foreground);
    border: none;
    background: none;
    padding: 0;
}

.tag-chip-remove:hover {
    color: var(--destructive);
    background: var(--accent);
}

.tag-editor-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--text-sm);
    color: var(--foreground);
    flex: 1;
    min-width: 80px;
}

/* --- Image Detail Dialog --- */
.image-detail-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--sp-6);
}

.image-detail-preview {
    background: var(--muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 300px;
}

.image-detail-preview img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
}

.image-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.image-detail-meta dt {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.image-detail-meta dd {
    font-size: var(--text-sm);
    color: var(--foreground);
    margin-bottom: var(--sp-3);
}

/* --- Category Assign Dialog --- */
.category-option {
    display: flex;
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background var(--duration-fast);
}

.category-option:hover {
    background: var(--accent);
}

.category-option.selected {
    background: var(--primary);
    color: var(--primary-foreground);
}

.category-new-input {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .image-detail-content {
        grid-template-columns: 1fr;
    }
}


/* ============================================================
   6. EDITOR
   ============================================================ */

/* --- Editor Layout --- */
.editor-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--background);
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--border);
    background: var(--background);
    flex-shrink: 0;
    gap: var(--sp-2);
}

/* Zoom-step selector — % readout + caret grouped as one dropdown trigger */
.zoom-step-wrap { position: relative; display: inline-flex; align-items: center; }
.zoom-step-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}
.zoom-step-trigger:hover { background: var(--accent); border-color: var(--border); }
.zoom-step-trigger #ed-zoom-label { min-width: 32px; text-align: right; }
.zoom-step-caret { width: 8.25px; height: 8.25px; flex: none; opacity: 0.75; }
.zoom-step-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    z-index: 200;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 64px;
}
.zoom-step-menu[hidden] { display: none; }
.zoom-step-menu button {
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    font-size: var(--text-xs);
    color: var(--foreground);
    padding: 5px 9px;
    border-radius: var(--radius-sm);
}
.zoom-step-menu button:hover { background: var(--accent); }
.zoom-step-menu button.active { background: var(--accent); font-weight: 600; }

/* Fit menu (fit canvas / fit to width): tick on the active mode + shortcut hint.
   The ticked entry is what Ctrl/Cmd+0 applies (persisted fit mode). */
.fit-menu button {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
}
.fit-menu .fit-check {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    visibility: hidden;
}
.fit-menu button.active .fit-check { visibility: visible; }
.fit-menu .fit-kbd {
    margin-left: auto;
    padding-left: 14px;
    font-size: 10px;
    color: var(--muted-foreground);
    visibility: hidden;
}
.fit-menu button.active .fit-kbd { visibility: visible; }

/* Editor entity name input */
.ed-entity-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    height: 32px;
    min-width: 120px;
    max-width: 240px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.ed-entity-name:hover {
    border-color: var(--border);
    background: var(--muted);
}
.ed-entity-name:focus {
    border-color: var(--ring);
    background: var(--background);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 25%, transparent);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--foreground);
    transition: background var(--duration-fast) var(--ease-default);
}

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

.toolbar-btn.active {
    background: var(--accent);
    color: var(--primary);
}

.guide-edit-badge,
.guide-eye-badge {
    color: var(--primary);
    filter: drop-shadow(0 0 1px var(--background));
}

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

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 var(--sp-1);
}

/* Editor Body (panels + canvas) */
.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tools Strip (compact icon toolbar) */
.tools-strip {
    width: 48px;
    background: var(--background);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-2) 0;
    gap: var(--sp-1);
}

.tool-strip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--muted-foreground);
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

.tool-strip-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

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

/* Section separator in properties panel */
.prop-section-separator {
    height: 1px;
    background: var(--border);
    margin: var(--sp-2) 0;
}

/* --- Editor Image Library Panel --- */
.image-library-panel {
    width: 220px;
    background: var(--background);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.image-library-panel.open {
    display: flex;
}

.image-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
    font-weight: 600;
}

.image-library-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--muted-foreground);
    border: none;
    background: none;
    padding: 0;
}

.image-library-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

.image-library-search {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.image-library-grid {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
    align-content: start;
}

.ed-img-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: grab;
    transition: border-color var(--duration-fast);
}

.ed-img-item:hover {
    border-color: var(--ring);
}

.ed-img-item:active {
    cursor: grabbing;
}

.ed-img-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.ed-img-name {
    display: block;
    font-size: 10px;
    color: var(--muted-foreground);
    padding: 2px var(--sp-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-library-footer {
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
    border-top: 1px solid var(--border);
}

.image-library-footer .btn {
    width: 100%;
    justify-content: center;
}

.tool-strip-btn.panel-active {
    background: var(--accent);
    color: var(--primary);
}

/* Canvas Viewport */
.canvas-viewport {
    flex: 1;
    overflow: hidden;
    background: var(--muted);
    display: grid;
    grid-template-columns: 20px 1fr;
    grid-template-rows: 20px 1fr;
    position: relative;
}

/* ──────────────────────────────────────────────────────────────────────
   Document (fill-in) mode — strip the editor to only what the template
   leaves editable, for CREATORS only. Driven by .doc-restricted (+ caps-*)
   on #editor-root, set by applyDocToolPolicy() in editor.js. Designers and
   master_admin never get this class, so they keep the full toolset.
   ────────────────────────────────────────────────────────────────────── */
/* Left tools strip: keep only the Select tool (+ Comment — reviewing isn't authoring) */
.doc-restricted #ed-tools-strip [data-tool]:not([data-tool="select"]):not([data-tool="comment"]),
.doc-restricted #ed-tools-strip .tools-strip-sep,
/* Right props strip: keep only Layers / History / Pages */
.doc-restricted #ed-props-strip [data-flyout="position"],
.doc-restricted #ed-props-strip [data-flyout="shape"],
.doc-restricted #ed-props-strip [data-flyout="group"],
.doc-restricted #ed-props-strip [data-flyout="selection"],
.doc-restricted #ed-props-strip [data-flyout="effects"],
.doc-restricted #ed-props-strip [data-flyout="align"],
.doc-restricted #ed-props-strip [data-flyout="swatches"],
.doc-restricted #ed-props-strip .props-strip-sep,
/* Top toolbar: drop page/document settings, header/footer, view toggles
   (Export follows the member's export permissions: .no-export below) */
.doc-restricted #ed-btn-page-settings,
.doc-restricted #ed-btn-layout-guides,
.doc-restricted #ed-tool-edit-header,
.doc-restricted #ed-tool-edit-footer,
.doc-restricted #ed-btn-view-menu,
.doc-restricted .editor-toolbar .toolbar-sep,
/* Layers panel: select + rename only — no lock/unlock/duplicate/hide/delete/reorder */
.doc-restricted .layers-tb-btn,
.doc-restricted .layer-actions,
.doc-restricted .layer-drag-handle,
.doc-restricted [data-layers-unlock],
/* Pages flyout: keep navigation (click a thumb), drop add/duplicate/delete/settings */
.doc-restricted .page-thumb-action,
.doc-restricted #ed-pages-add,
/* Top toolbar Group/Ungroup button (separate from the hidden Group flyout) */
.doc-restricted #ed-btn-group { display: none !important; }

/* Member permissions (v1.79): no export format allowed = no Export button */
.no-export #ed-btn-export { display: none !important; }

/* Capability-gated controls (hidden only when the template locks that capability) */
.doc-restricted.caps-no-textstyle #ed-font-family,
.doc-restricted.caps-no-textstyle #ed-font-size,
.doc-restricted.caps-no-textstyle #ed-font-weight,
.doc-restricted.caps-no-textstyle #ed-btn-bold,
.doc-restricted.caps-no-textstyle #ed-btn-italic,
.doc-restricted.caps-no-textstyle #ed-btn-underline,
.doc-restricted.caps-no-textstyle #ed-btn-align-left,
.doc-restricted.caps-no-textstyle #ed-btn-align-center,
.doc-restricted.caps-no-textstyle #ed-btn-align-right,
.doc-restricted.caps-no-textstyle #ed-props-strip [data-flyout="character"],
.doc-restricted.caps-no-textstyle #ed-props-strip [data-flyout="paragraph"],
.doc-restricted.caps-no-textstyle #ed-props-strip [data-flyout="pstyles"],
.doc-restricted.caps-no-textstyle #ed-props-strip [data-flyout="cstyles"],
.doc-restricted.caps-no-swap #ed-props-strip [data-flyout="image"],
.doc-restricted.caps-no-colour #ed-tool-color { display: none !important; }

/* Hide the rulers and reclaim their grid tracks */
.doc-restricted .canvas-viewport { grid-template-columns: 0 1fr; grid-template-rows: 0 1fr; }
.doc-restricted .ruler-corner,
.doc-restricted .ruler-h-container,
.doc-restricted .ruler-v-container { display: none !important; }

/* New Template dialog — intent cards (step 1) + page setup (step 2) */
.kind-options { display: flex; flex-direction: column; gap: var(--sp-3); }
.kind-option {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    width: 100%; padding: var(--sp-4);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--card); color: var(--foreground);
    text-align: left; cursor: pointer; font: inherit;
    transition: border-color .15s ease, background-color .15s ease;
}
.kind-option:hover:not(:disabled) { border-color: var(--ring); background: var(--accent); }
.kind-option:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.kind-option:disabled { opacity: .5; cursor: not-allowed; }
.kind-option[hidden] { display: none; }

/* Member permissions (Admin > Users > Edit > Permissions, v1.79).
   Divider lists: rules between rows only, label left, explanation right. */
/* .dialog.perm-dialog outranks the tablet rule that stretches every dialog */
.dialog.perm-dialog {
    max-width: min(42rem, calc(100vw - var(--sp-8)));
    display: flex; flex-direction: column;
    overflow: hidden;
}
.perm-dialog .dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.perm-team-name { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--sp-4); }
.perm-note {
    font-size: var(--text-xs); line-height: 1.45;
    background: var(--muted); color: var(--foreground);
    border-radius: var(--radius-md);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-4);
}
.perm-panel[hidden] { display: none; }
.perm-section + .perm-section { margin-top: var(--sp-6); }
.perm-section-title {
    font-size: var(--text-sm); font-weight: 600;
    color: var(--foreground);
    margin: 0 0 var(--sp-1);
}
.perm-section-hint {
    font-size: var(--text-xs); line-height: 1.45;
    color: var(--muted-foreground);
    margin: 0 0 var(--sp-1);
}
.perm-row {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: var(--sp-3);
    align-items: start;
    padding: 0.625rem 0;
    cursor: pointer;
}
.perm-row + .perm-row { border-top: 1px solid var(--border); }
.perm-control {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: var(--text-sm); font-weight: 600;
    color: var(--foreground);
}
.perm-desc {
    font-size: var(--text-xs); line-height: 1.5;
    color: var(--muted-foreground);
    padding-top: 1px;
}
.perm-section .form-error[hidden] { display: none; }
.perm-footer { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.perm-footer-note {
    flex: 1 1 14rem;
    font-size: var(--text-xs); line-height: 1.45;
    color: var(--muted-foreground);
    margin: 0;
}
.perm-footer-actions { display: flex; gap: var(--sp-2); margin-left: auto; }
/* Admin > Users > Edit: Details | Permissions in one dialog */
.user-dialog-tabs { display: flex; margin-bottom: var(--sp-5); }
.user-dialog-tabs .tab-trigger { flex: 1 1 0; }
[data-user-panel][hidden] { display: none; }
.perm-team-picker { margin-bottom: var(--sp-5); }
.perm-team-picker .select { width: 100%; }
.user-password-title { margin-top: var(--sp-6); margin-bottom: var(--sp-3); }
.user-email-action {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
    border-top: 1px solid var(--border);
    padding-top: var(--sp-4);
    margin-bottom: var(--sp-4);
}
.user-email-action-title { font-size: var(--text-sm); font-weight: 600; margin: 0; }
.user-email-action-desc {
    font-size: var(--text-xs); line-height: 1.45;
    color: var(--muted-foreground);
    margin: 2px 0 0;
}
.user-email-action .btn { flex: none; }
@media (max-width: 560px) {
    .user-email-action { flex-direction: column; align-items: stretch; }
}
@media (max-width: 560px) {
    .perm-row { grid-template-columns: 1fr; gap: var(--sp-1); }
    .perm-desc { padding-left: calc(16px + var(--sp-2)); }
}
.kind-option > svg { flex: none; margin-top: 1px; color: var(--muted-foreground); }
.kind-option .kind-text { display: block; min-width: 0; }
.kind-option .kind-title { display: block; font-weight: 600; font-size: var(--text-sm); }
.kind-option .kind-desc {
    display: block; margin-top: 2px;
    font-size: var(--text-xs); line-height: 1.45;
    color: var(--muted-foreground); white-space: normal;
}
.tpl-setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.tpl-setup-grid .full { grid-column: 1 / -1; }
.tpl-setup-grid .form-label {
    display: block; margin-bottom: var(--sp-1);
    font-size: var(--text-xs); font-weight: 600; color: var(--muted-foreground);
}
.tpl-margin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.tpl-margin-cap {
    display: block; margin-top: 2px; text-align: center;
    font-size: 10px; color: var(--muted-foreground);
}
/* Chain-link toggle beside a 4-input row: linked = one value drives all sides */
.tpl-link-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; padding: 0;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: transparent; color: var(--muted-foreground); cursor: pointer;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.tpl-link-btn:hover { background: var(--accent); color: var(--foreground); }
.tpl-link-btn.is-linked { color: var(--primary); border-color: var(--border); background: var(--secondary); }
.tpl-link-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* The View menu: labelled checklist popover from the toolbar eye button
   (Figma view-menu pattern; labels + checkmarks carry the state) */
.view-menu {
    position: fixed;
    z-index: 10001;
    min-width: 220px;
    padding: var(--sp-1);
    background: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}
.view-menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: none;
    background: none;
    font-size: var(--text-sm);
    color: inherit;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.view-menu-item:hover { background: var(--accent); }
.view-menu-check { width: 14px; display: inline-flex; align-items: center; flex: none; }
.view-menu-label { flex: 1; }
.view-menu-hint { font-size: var(--text-xs); color: var(--muted-foreground); }
.view-menu-indent { padding-left: calc(var(--sp-3) + 14px + var(--sp-2)); }
.view-menu-indent .view-menu-check { width: 14px; }
.view-menu-sep { border-top: 1px solid var(--border); margin: var(--sp-1) 0; }
.view-menu-heading {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted-foreground);
    padding: var(--sp-1) var(--sp-2);
}
.view-menu-item:disabled { color: var(--muted-foreground); cursor: default; opacity: 0.6; }
.view-menu-item:disabled:hover { background: none; }
.field-menu { max-height: 70vh; overflow-y: auto; }

/* Master pages (v1.64): [A] tag on page thumbs + editing-mode hint */
.page-thumb-master-tag {
    position: absolute; top: 3px; left: 3px;
    font-size: 9px; font-weight: 600; line-height: 1;
    padding: 2px 4px; border-radius: 4px;
    background: var(--secondary); color: var(--secondary-foreground);
    border: 1px solid var(--border); pointer-events: none;
}
.page-thumb-item { position: relative; }
.editing-master #ed-canvas-wrapper { outline: 2px solid #8b5cf6; outline-offset: -2px; }
.masters-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.master-tile { flex: 0 0 76px; width: 76px; max-width: 76px; min-width: 0; cursor: grab; }
.master-tile .page-thumb-label { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-thumb-item.master-drop { outline: 2px solid #8b5cf6; outline-offset: 1px; border-radius: var(--radius-sm); }
.master-ctx .view-menu-item.destructive { color: var(--destructive); }

/* Presence (v1.70): toolbar avatar stack + Pages panel viewer dots + sync banner */
.presence-stack { display: flex; align-items: center; margin-right: var(--sp-2); }
.presence-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--secondary); color: var(--secondary-foreground);
    border: 2px solid var(--border);
    font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
    margin-left: -6px; cursor: default; user-select: none;
}
.presence-stack .presence-avatar:first-child { margin-left: 0; }
.presence-more { border-color: var(--border) !important; color: var(--muted-foreground); }
.page-presence { position: absolute; bottom: 22px; right: 4px; display: flex; gap: 2px; }
.page-presence-dot {
    width: 8px; height: 8px; border-radius: 50%;
    border: 1.5px solid var(--card); box-shadow: var(--shadow-xs);
}
.claim-banner {
    position: absolute; left: 50%; top: 52px; transform: translateX(-50%);
    z-index: var(--z-overlay, 50);
    background: var(--popover); color: var(--popover-foreground);
    border: 1px solid var(--border); border-left: 3px solid #8b5cf6;
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: var(--sp-2) var(--sp-4); font-size: var(--text-sm);
    pointer-events: none;
}
.sync-view-only .canvas-wrapper { cursor: default; }

.sync-banner {
    position: absolute; left: 50%; top: 52px; transform: translateX(-50%);
    z-index: var(--z-overlay, 50);
    display: flex; align-items: center; gap: var(--sp-3);
    background: var(--popover); color: var(--popover-foreground);
    border: 1px solid var(--warning, #d97706); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-2) var(--sp-4); font-size: var(--text-sm);
}

/* Autosave status IN the Save button (v1.73.4): the BUTTON's colour is the
   status (green whole-button = saved, black = an action is available, red =
   not saved) and the ICON carries the motion: disk (action), spinner while
   saving, tick when saved. No dot. */
#ed-btn-save.save-ok,
#ed-btn-save.save-ok:hover { background: #12915f; color: #fff; }
#ed-btn-save.save-err,
#ed-btn-save.save-err:hover { background: var(--destructive, #dc2626); color: #fff; }
#ed-save-icon.spin { animation: save-spin 0.9s linear infinite; }
@keyframes save-spin { to { transform: rotate(360deg); } }

/* View & Guides modal (design-system rebuild of the old inline-styled
   Layout & Guides). Rides .dialog-overlay/.dialog + .settings-tab*. */
.lg-dialog { width: 480px; max-width: calc(100vw - 32px); max-height: 85vh; display: flex; flex-direction: column; overflow-x: hidden; }
/* Here the tab bar sits directly in the dialog, not inside a padded body, so
   the shared negative side margins pushed it 24px past both edges and the
   dialog grew a horizontal scrollbar. Flush margins; the padding lines the
   first tab's label up with the title. */
.lg-dialog > .settings-tabs { margin: 0; padding: 0 var(--sp-3); flex-shrink: 0; }
.lg-body { overflow-y: auto; overflow-x: hidden; flex: 1; }
.lg-section-label {
    font-size: var(--text-xs); font-weight: 600;
    margin: var(--sp-3) 0 var(--sp-2); color: var(--foreground);
}
.lg-check-row {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: var(--text-xs); cursor: pointer; margin-bottom: var(--sp-1);
}
.lg-check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1) var(--sp-3); }
.lg-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.lg-divider { border-top: 1px solid var(--border); margin: var(--sp-3) 0; }
.lg-subhead { font-size: 10px; color: var(--muted-foreground); margin-bottom: 4px; }
.lg-hint { font-size: var(--text-xs); color: var(--muted-foreground); margin-top: var(--sp-3); }
.prop-input.lg-colour { width: 40px; height: 28px; padding: 2px; cursor: pointer; flex: 0 0 40px; }

/* Appearance (v1.92): interface + pasteboard segments, guide colours as a
   2 x 2 swatch grid instead of four sparse label rows */
.lg-app { display: flex; flex-direction: column; gap: var(--sp-3); }
.lg-app-row { display: flex; align-items: center; gap: var(--sp-3); }
.lg-app-label { font-size: var(--text-xs); color: var(--muted-foreground); min-width: 76px; }
.lg-seg {
    display: inline-flex; flex: 1;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    overflow: hidden; background: var(--background);
}
.lg-seg button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 30px; padding: 0 var(--sp-2);
    font-size: var(--text-xs); color: var(--muted-foreground);
    background: none; border: none; cursor: pointer;
}
.lg-seg button + button { border-left: 1px solid var(--border); }
.lg-seg button:hover { color: var(--foreground); }
.lg-seg button[aria-checked="true"] {
    color: var(--foreground); font-weight: 600;
    background: color-mix(in srgb, var(--accent) 90%, black);
}
[data-theme="dark"] .lg-seg button[aria-checked="true"] { background: color-mix(in srgb, var(--accent) 90%, white); }
.lg-paste-chip { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); flex: 0 0 12px; }
.lg-paste-light { background: #e0e0e0; }
.lg-paste-dark { background: #1a1a1a; }
.lg-paste-match { background: linear-gradient(135deg, #e0e0e0 50%, #1a1a1a 50%); }
.lg-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-3); }
.lg-swatch {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: 6px var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: var(--text-xs); color: var(--foreground); cursor: pointer; background: var(--background);
}
.lg-swatch:hover { border-color: var(--muted-foreground); }
.lg-swatch input.lg-colour {
    width: 22px; height: 22px; flex: 0 0 22px; padding: 0; border: none; border-radius: 5px;
    background: none; cursor: pointer;
}
.lg-swatch input.lg-colour::-webkit-color-swatch-wrapper { padding: 0; }
.lg-swatch input.lg-colour::-webkit-color-swatch { border: 1px solid rgba(0,0,0,0.15); border-radius: 5px; }
.lg-swatch input.lg-colour::-moz-color-swatch { border: 1px solid rgba(0,0,0,0.15); border-radius: 5px; }
/* Footer: Preview on the left, Cancel / OK on the right */
.lg-footer { align-items: center; }
.lg-footer .lg-preview { margin: 0; font-size: var(--text-xs); }

/* FLOW documents (kind='flow') for restricted creators: the Word-like "just
   type" surface. Pages auto-create and auto-remove as they type, so the
   layout/guide chrome would only mislead. */
.doc-flow.doc-restricted #ed-tool-toggle-snap,
.doc-flow.doc-restricted #ed-btn-layers,
.doc-flow.doc-restricted #ed-props-strip [data-flyout="locks"] { display: none !important; }

/* Flow DOCUMENTS (any role): text-box creation and threading are template
   work — the drawing tools disappear for everyone (_setActiveTool guards the
   keyboard shortcuts; _canThreadFrame kills the thread ports). */
.doc-flow-doc #ed-tools-strip [data-tool="text"],
.doc-flow-doc #ed-tools-strip [data-tool="textOnPath"] { display: none !important; }

/* Header/footer editing buttons: since v1.62 they are the FLOW Word-style
   header/footer editor (layout templates keep their zone semantics until
   Master Pages retires them). Flow tooltips drop the "Zone" wording via JS.
   Word model (v1.63): in flow docs the editor is a DOCUMENT-USER feature, so
   the two buttons survive the restricted toolbar strip; enterZoneEditMode
   enforces the template's locked_header/locked_footer switches. */
.doc-restricted.doc-flow #ed-tool-edit-header,
.doc-restricted.doc-flow #ed-tool-edit-footer { display: flex !important; }

/* Editor preloader — record-style spinning disc (held for >= 2 turns by editor.js) */
@keyframes pbc-disc-spin { to { transform: rotate(360deg); } }
.pbc-disc-spin {
    animation: pbc-disc-spin 1.98s linear infinite;   /* 1.98s/rev (~30 rpm); JS _PL_SPIN_MS must match */
    transform-origin: 50% 50%;
    will-change: transform;
    filter: drop-shadow(0 1px 7px rgba(0, 0, 0, 0.16));
    border-radius: 50%;
}
@media (prefers-reduced-motion: reduce) {
    .pbc-disc-spin { animation-duration: 3.96s; }   /* one calm turn over the minimum hold */
}

/* Input with a trailing affix button (e.g. password show/hide eye) */
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix > .input { flex: 1; padding-right: 40px; }
.input-affix-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.input-affix-btn:hover { color: var(--foreground); background: var(--accent); }
.input-affix-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* Admin Activity — expandable item groups */
.activity-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    margin-bottom: 8px;
    overflow: hidden;
}
.activity-group > summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.activity-group > summary::-webkit-details-marker { display: none; }
.activity-group > summary::before {
    content: '▸';
    color: var(--muted-foreground);
    margin-right: 8px;
    font-size: 11px;
    transition: transform 0.15s ease;
    display: inline-block;
}
.activity-group[open] > summary::before { transform: rotate(90deg); }
.activity-group > summary:hover { background: var(--accent); }
.activity-group-title { font-weight: 600; font-size: var(--text-sm); flex: 1; }
.activity-group-meta { font-size: var(--text-xs); color: var(--muted-foreground); white-space: nowrap; }
.activity-group-body { border-top: 1px solid var(--border); padding: 4px 14px 8px 34px; }
.activity-row {
    display: grid;
    grid-template-columns: 150px 1fr 130px 1fr;
    gap: 12px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--text-xs);
}
.activity-row:last-child { border-bottom: none; }
.activity-when { color: var(--muted-foreground); white-space: nowrap; }
.activity-action { font-weight: 600; color: var(--foreground); }
.activity-user { color: var(--muted-foreground); }
.activity-details { color: var(--muted-foreground); }

/* Canvas right-click context menu + asset link picker */
.ed-ctx-menu {
    position: fixed;
    z-index: 1000;
    min-width: 210px;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ed-ctx-item {
    border: none;
    background: none;
    text-align: left;
    font-size: var(--text-sm);
    color: var(--foreground);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.ed-ctx-item:hover { background: var(--accent); }
.ed-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}
.ed-link-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
}
.ed-link-item:hover { border-color: var(--ring); background: var(--accent); }
.ed-link-item img {
    width: 100%;
    height: 84px;
    object-fit: contain;
    background: repeating-conic-gradient(#f0f0f3 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    border-radius: var(--radius-sm);
}
.ed-link-item span {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ruler-corner {
    grid-column: 1;
    grid-row: 1;
    background: var(--background);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    z-index: 3;
}

.ruler-h-container {
    grid-column: 2;
    grid-row: 1;
    overflow: hidden;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    z-index: 2;
    min-width: 0;
}

.ruler-h-container canvas {
    display: block;
}

.ruler-v-container {
    grid-column: 1;
    grid-row: 2;
    overflow: hidden;
    background: var(--background);
    border-right: 1px solid var(--border);
    z-index: 2;
    min-height: 0;
}

.ruler-v-container canvas {
    display: block;
}

.canvas-scroll-area {
    grid-column: 2;
    grid-row: 2;
    overflow: auto;
    min-width: 0;
    min-height: 0;
    background: var(--pasteboard, transparent);
}
#editor-root.presenting .canvas-scroll-area { background: #000; }

.canvas-wrapper {
    position: relative;
    /* Background + shadow are on the canvas-container, not the
       wrapper, because the wrapper is oversized for over-scroll */
}
.canvas-wrapper .canvas-container {
    box-shadow: var(--shadow-lg);
}

/* Properties Icon Strip (right edge) */
.props-strip {
    width: 40px;
    background: var(--background);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-2) 0;
    gap: var(--sp-1);
}

.props-strip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    color: var(--muted-foreground);
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

.props-strip-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

.props-strip-btn.active {
    background: color-mix(in srgb, var(--accent) 90%, black);
    color: var(--primary);
}
[data-theme="dark"] .props-strip-btn.active {
    background: color-mix(in srgb, var(--accent) 90%, white);
}
/* View menu: Appearance as one row with a segmented icon toggle */
.view-menu-item.view-menu-static { cursor: default; }
.view-menu-item.view-menu-static:hover { background: none; }
.theme-seg {
    display: inline-flex;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.theme-seg button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 24px;
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
}
.theme-seg button + button { border-left: 1px solid var(--border); }
.theme-seg button:hover { color: var(--foreground); }
.theme-seg button[aria-checked="true"] {
    background: color-mix(in srgb, var(--accent) 90%, black);
    color: var(--primary);
}
[data-theme="dark"] .theme-seg button[aria-checked="true"] {
    background: color-mix(in srgb, var(--accent) 90%, white);
}

.props-strip-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

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

.props-strip-sep {
    height: 1px;
    width: 24px;
    background: var(--border);
    margin: var(--sp-1) 0;
}

/* Flyout Panel */
.flyout-panel {
    width: 280px;
    min-width: 200px;
    max-width: 400px;
    background: var(--background);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: flyout-in var(--duration-fast) var(--ease-default);
}

.flyout-panel[data-closing] {
    animation: flyout-out var(--duration-fast) var(--ease-default) forwards;
}

.flyout-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    z-index: 1;
    background: transparent;
    transition: background var(--duration-fast);
}

.flyout-resize-handle:hover,
.flyout-resize-handle.dragging {
    background: var(--ring);
}

.flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.flyout-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

/* Panel header actions (v1.72.10): title is a plain label on the left; the
   right side stacks [ellipsis panel menu, when registered] then the minimise
   arrow as its own standalone button on the far right, pointing at the edge
   the panel collapses into. No separate X. */
.flyout-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: -4px -6px -4px 0;
}
.flyout-minimise {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--muted-foreground);
}
.flyout-minimise:hover {
    background: var(--accent);
    color: var(--foreground);
}

/* Panel menu button (v1.69.1): ellipsis top right of the header opens the
   panel's flyout menu (InDesign panel-menu pattern) */
.flyout-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--muted-foreground);
}
.flyout-menu-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}
.panel-menu .view-menu-item:disabled { color: var(--muted-foreground); cursor: default; opacity: 0.6; }

.flyout-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--muted-foreground);
    border: none;
    background: none;
    padding: 0;
}

.flyout-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

.flyout-body {
    flex: 1;
    padding: var(--sp-3);
    overflow-y: auto;
}

/* --- Panel dock (v1.87): stacked, tabbed panels --- */
.dock-stacks {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.dock-stack {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    border-bottom: 1px solid var(--border);
}
.dock-stack:last-child { border-bottom: none; }
.dock-stack.collapsed { flex: 0 0 auto; }
.dock-stack.collapsed .dock-body { display: none; }
.flyout-header.dock-tabs {
    padding: 0 var(--sp-1) 0 0;
    gap: var(--sp-1);
    background: var(--muted, var(--accent));
}
.dock-tabbar {
    display: flex;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.dock-tabbar::-webkit-scrollbar { display: none; }
.dock-tabstrip {
    display: flex;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;      /* scrolls (wheel / trackpad / drag), no bar */
    overscroll-behavior-x: contain;
}
.dock-tabstrip::-webkit-scrollbar { display: none; }
.dock-tabstrip { user-select: none; -webkit-user-select: none; position: relative; }
/* Edge fades (v1.92.3): a soft fade on whichever side has tabs out of view,
   so the strip reads as swipeable */
.dock-tabstrip.fade-r {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}
.dock-tabstrip.fade-l {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 32px);
    mask-image: linear-gradient(to right, transparent, #000 32px);
}
.dock-tabstrip.fade-l.fade-r {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}
.dock-tabstrip.dragging, .dock-tabstrip.dragging .dock-tab { cursor: grabbing; }
.dock-tab {
    flex: 0 0 auto;
    padding: 9px 10px 7px;
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted-foreground);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--duration-fast) var(--ease-default);
}
.dock-tab:hover { color: var(--foreground); }
.dock-tab.active {
    color: var(--foreground);
    background: var(--background);
    border-bottom-color: var(--primary);
}
.dock-more {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    align-self: center;
    padding: 0;
    color: var(--muted-foreground);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.dock-more:hover { color: var(--foreground); }
.dock-body { flex: 1; min-height: 0; }

/* --- Hyperlinks panel --- */
.links-head, .links-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 5px 4px;
    font-size: var(--text-xs);
}
.links-head {
    color: var(--muted-foreground);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.links-row { border-bottom: 1px solid var(--border); cursor: pointer; }
.links-row:hover { background: var(--accent); }
.links-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links-page { flex: 0 0 28px; text-align: right; color: var(--primary); font-variant-numeric: tabular-nums; }
.links-status { flex: 0 0 40px; display: flex; justify-content: center; }

/* --- Gradient multi-stop slider --- */
.grad-ramp-wrap {
    position: relative;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    overflow: visible;
}
.grad-ramp-checker {
    position: absolute;
    inset: 0;
    border-radius: 3px;
    background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;
}
.grad-ramp {
    position: absolute;
    inset: 0;
    border-radius: 3px;
    cursor: crosshair;
}
.grad-stops {
    position: absolute;
    left: 0; right: 0;
    bottom: -10px;
    height: 14px;
    pointer-events: none;
}
.grad-stop {
    position: absolute;
    width: 14px;
    height: 14px;
    transform: translateX(-50%);
    cursor: pointer;
    pointer-events: all;
    z-index: 2;
}
.grad-stop-handle {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 2px solid var(--border);
    box-sizing: border-box;
    transition: border-color 0.1s;
}
.grad-stop.selected .grad-stop-handle {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.grad-midpoints {
    position: absolute;
    left: 0; right: 0;
    top: -8px;
    height: 10px;
    pointer-events: none;
}
.grad-midpoint {
    position: absolute;
    width: 8px;
    height: 8px;
    transform: translateX(-50%) rotate(45deg);
    background: var(--muted-foreground);
    cursor: ew-resize;
    pointer-events: all;
    opacity: 0.5;
    transition: opacity 0.1s;
}
.grad-midpoint:hover {
    opacity: 1;
}
.grad-stop-editor {
    padding-top: 10px;
}
.grad-btn-icon {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--muted-foreground);
    transition: background 0.15s, color 0.15s;
}
.grad-btn-icon:hover { background: var(--accent); }
.grad-btn-icon:disabled { opacity: 0.3; cursor: default; pointer-events: none; }

.flyout-subsection {
    margin-bottom: var(--sp-4);
}

.flyout-subsection-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    margin-bottom: var(--sp-2);
}

.lock-toggle-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--muted-foreground);
    transition: background 0.15s, color 0.15s;
}
.lock-toggle-btn:hover {
    background: var(--accent);
}
.lock-toggle-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}
.lock-toggle-btn svg {
    width: 14px;
    height: 14px;
}

@keyframes flyout-in {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes flyout-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(8px); }
}

/* --- Image Alternatives — flyout grid + document swap popover --- */
.alt-current-thumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}
.alt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}
.alt-grid-item {
    position: relative;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--duration-fast);
    aspect-ratio: 1;
}
.alt-grid-item:hover {
    border-color: var(--ring);
}
.alt-grid-item.active {
    border-color: var(--primary);
}
.alt-grid-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--muted);
    display: block;
}
.alt-remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--destructive);
    color: var(--destructive-foreground);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--duration-fast);
    padding: 0;
}
.alt-grid-item:hover .alt-remove-btn {
    opacity: 1;
}

/* Fit mode button strip */
.alt-fit-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}
.alt-fit-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--muted-foreground);
    font-size: 10px;
    cursor: pointer;
    transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
    white-space: nowrap;
}
.alt-fit-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}
.alt-fit-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}
.alt-fit-btn svg {
    flex-shrink: 0;
}
.alt-fit-btn span {
    line-height: 1;
}

/* Inline library picker within alternatives flyout */
.alt-lib-picker {
    border-top: 1px solid var(--border);
    padding-top: var(--sp-2);
    margin-top: var(--sp-2);
}
.alt-lib-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: var(--sp-1);
    max-height: 240px;
    overflow-y: auto;
    padding: 2px; /* prevent border clipping from overflow:auto */
}
.alt-lib-item {
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--duration-fast);
    background: var(--muted);
}
.alt-lib-item:hover {
    border-color: var(--primary);
}
.alt-lib-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ------------------------------------------------------------------
   Drawing kind (v1.81, modules/drawing.js): chrome only shows on a drawing */
[data-dwchrome] { display: none !important; }
#editor-root.doc-drawing [data-dwchrome] { display: flex !important; }
#editor-root.doc-drawing.doc-restricted [data-tool="wire"] { display: none !important; }
.dw-search { width: 100%; margin-bottom: var(--sp-2); }
.dw-hint { font-size: var(--text-xs); color: var(--muted-foreground); line-height: 1.45; margin: 0 0 var(--sp-2); }
.dw-sec + .dw-sec { border-top: 1px solid var(--border); }
.dw-sec h3 { margin: var(--sp-3) 0 var(--sp-2); }
.dw-sec-t { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 4px 2px; margin: 0 -2px; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); border-radius: var(--radius-sm); }
.dw-sec-t:hover { color: var(--foreground); background: var(--accent); }
.dw-sec-t svg { width: 13px; height: 13px; flex: none; transition: transform var(--duration-fast); }
.dw-sec-t .dw-cnt { margin-left: auto; font-weight: 500; letter-spacing: 0; text-transform: none; background: var(--muted); border-radius: 10px; padding: 1px 7px; }
.dw-sec.is-collapsed .dw-sec-t svg { transform: rotate(-90deg); }
.dw-sec.is-collapsed .dw-tiles { display: none; }
.is-searching .dw-sec.is-collapsed .dw-tiles { display: grid; }
.dw-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dw-tile { display: flex; flex-direction: column; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); padding: 8px 4px 7px; cursor: pointer; font: inherit; font-size: 11.5px; line-height: 1.25; text-align: center; color: var(--foreground); }
.dw-tile:hover { border-color: var(--ring); }
.dw-tile.is-armed { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.dw-tile img { width: 92px; height: 40px; object-fit: contain; }
[data-theme="dark"] .dw-tile img, [data-theme="dark"] .dw-var img { filter: invert(1); }
.dw-pop { min-width: 0; max-width: min(720px, calc(100vw - 24px)); padding: var(--sp-2); }
.dw-pop-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dw-pop-row + .dw-pop-row { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.dw-pop-size span { font-size: var(--text-xs); color: var(--muted-foreground); padding: 0 4px; }
.dw-var { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); padding: 4px 5px 3px; cursor: pointer; min-width: 56px; font: inherit; color: var(--muted-foreground); }
.dw-var img { width: 46px; height: 24px; object-fit: contain; }
.dw-var span { font-size: 10.5px; white-space: nowrap; }
.dw-var:hover { border-color: var(--ring); }
.dw-var.is-on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); color: var(--foreground); }
.dw-size { border: 1px solid var(--border); background: var(--card); color: var(--foreground); border-radius: var(--radius-sm); padding: 5px 9px; min-width: 30px; cursor: pointer; font: inherit; font-size: 12px; }
.dw-size.is-on { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.dw-dsec { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); margin: var(--sp-4) 0 var(--sp-2); }
.dw-dsec span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.dw-fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-2); }
.dw-fld > span { font-size: var(--text-xs); color: var(--muted-foreground); }
.dw-fld .input { width: 100%; }
.dw-row2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--sp-2); }
.dw-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; align-self: flex-start; }
.dw-seg button { border: 0; border-right: 1px solid var(--border); background: var(--card); color: var(--foreground); padding: 6px 14px; cursor: pointer; font: inherit; font-size: 12px; }
.dw-seg button:last-child { border-right: 0; }
.dw-seg button.is-on { background: var(--primary); color: var(--primary-foreground); }
.dw-lrow { display: flex; gap: 6px; margin-bottom: 6px; }
.dw-tiles-wide { grid-template-columns: 1fr; }
.dw-tiles-wide .dw-tile img { width: 100%; height: 58px; }
.dw-tile-lib { position: relative; }
.dw-rm { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); font-size: 13px; line-height: 15px; display: none; }
.dw-tile-lib:hover .dw-rm { display: block; }
.dw-rm:hover { color: var(--foreground); border-color: var(--ring); }
.dw-nothumb { display: block; width: 100%; height: 58px; background: var(--muted); border-radius: 4px; }
.dw-empty { grid-column: 1 / -1; margin: 0; }
.dw-pop-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.dw-check { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--muted-foreground); margin-top: 4px; }
.dw-drawer { width: 236px; }
.dw-drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-3); }
#editor-root.doc-drawing.doc-restricted [data-tool="parts"] { display: flex !important; }
.alt-swap-popover.dw-pop { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; min-width: 0; max-width: min(900px, calc(100vw - 24px)); }
.dw-pop-title { font-weight: 600; white-space: nowrap; padding: 0 4px; }
.dw-pop-lbl { font-size: var(--text-xs); color: var(--muted-foreground); white-space: nowrap; }
.dw-pop .dw-seg button { padding: 5px 9px; min-width: 30px; }
.dw-pop .dw-lines button { display: flex; align-items: center; padding: 5px 7px; }
.dw-len { width: 68px; height: 28px; padding: 0 6px; text-align: right; }
.dw-act { border: 1px solid var(--border); background: var(--card); color: var(--foreground); border-radius: var(--radius-sm); padding: 6px 9px; cursor: pointer; font: inherit; font-size: 12px; white-space: nowrap; }
.dw-act:hover { background: var(--accent); }
.dw-act.is-danger { color: hsl(0 72% 45%); }
.dw-sec h3, .dw-grp h4 { display: flex; align-items: center; gap: 4px; margin: var(--sp-3) 0 var(--sp-2); }
.dw-grp h4 { margin: var(--sp-2) 0; }
.dw-grp { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 8px 8px; }
.dw-grp .dw-sec-t { text-transform: none; letter-spacing: 0; font-size: 12px; }
.dw-grp.is-collapsed .dw-tiles { display: none; }
.dw-grp.is-collapsed .dw-sec-t svg { transform: rotate(-90deg); }
.dw-mini { border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); border-radius: var(--radius-sm); padding: 2px 7px; font: inherit; font-size: 11px; cursor: pointer; white-space: nowrap; }
.dw-mini:hover { color: var(--foreground); border-color: var(--ring); }
.dw-gdel { padding: 0 6px; font-size: 14px; line-height: 1.4; }
.dw-drop { grid-column: 1 / -1; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); padding: 12px 8px; font-size: 11.5px; color: var(--muted-foreground); text-align: center; transition: all var(--duration-fast); }
.dw-drop.is-over { border-color: var(--primary); border-style: solid; color: var(--foreground); background: var(--accent); }
.dw-lrow .input { flex: 1; min-width: 0; }

/* Document-mode swap popover */
.alt-swap-popover {
    position: fixed;
    z-index: 1000;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-3);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    max-width: 200px;
    animation: alt-swap-in var(--duration-fast) var(--ease-default);
}
.alt-swap-header {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    margin-bottom: var(--sp-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.alt-swap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
}
.alt-swap-item {
    position: relative;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--duration-fast), transform var(--duration-fast);
    aspect-ratio: 1;
}
.alt-swap-item:hover {
    border-color: var(--ring);
    transform: scale(1.04);
}
.alt-swap-item.active {
    border-color: var(--primary);
}
.alt-swap-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--muted);
    display: block;
}
.alt-swap-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 9px;
    text-align: center;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 1px 0;
}

@keyframes alt-swap-in {
    from { opacity: 0; transform: translateY(-50%) scale(0.95); }
    to   { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* Pen Tool active state — crosshair cursor on canvas */
.pen-tool-active .canvas-container {
    cursor: crosshair !important;
}
.pen-tool-active .upper-canvas {
    cursor: crosshair !important;
}

/* Left tools strip separator */
.tools-strip-sep {
    height: 1px;
    width: 28px;
    background: var(--border);
    margin: var(--sp-2) 0;
}

.prop-section {
    margin-bottom: var(--sp-4);
}

.prop-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-2);
}

.prop-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}

.prop-label {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    min-width: 52px;
    flex-shrink: 0;
}
.prop-hint {
    font-size: 11px;
    color: var(--muted-foreground);
    flex-shrink: 0;
    white-space: nowrap;
}

.prop-input {
    flex: 1;
    height: 28px;
    font-size: var(--text-xs);
    padding: 0 var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--foreground);
}
select.prop-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: var(--sp-7);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' opacity='0.5'%3E%3Cpath d='m3.5 5.25 3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-2) center;
    cursor: pointer;
}

.prop-input:focus {
    border-color: var(--ring);
}

/* Editor Status Bar */
.editor-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    padding: 0 var(--sp-3);
    border-top: 1px solid var(--border);
    background: var(--background);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    flex-shrink: 0;
}

/* Toolbar text labels */
.toolbar-btn strong { font-weight: 700; }
.toolbar-btn em { font-style: italic; }
.toolbar-btn u { text-decoration: underline; }

.toolbar-btn.active {
    background: var(--accent);
    color: var(--accent-foreground);
    font-weight: 600;
}

/* Toolbar selects/inputs */
.editor-toolbar .prop-input {
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
}

/* Color swatch inputs */
.editor-toolbar input[type="color"] {
    -webkit-appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
}
.editor-toolbar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.editor-toolbar input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
}

/* Brand colour swatches in editor */
.color-picker-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.color-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.color-swatch-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color var(--duration-fast);
}

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

.color-swatch-btn.selected {
    border-color: var(--foreground);
    box-shadow: 0 0 0 1px var(--background);
}

.swatch-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color var(--duration-fast);
}

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

/* Color popover — Figma-style, anchored to left toolbar button */
.color-popover {
    position: absolute;
    left: 56px;
    z-index: 100;
    width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: var(--sp-3);
    display: none;
}
.color-popover.open { display: block; }

/* Shapes picker popover (anchored to the Shapes tool button) */
.shapes-popover {
    position: absolute;
    left: 56px;
    z-index: 100;
    width: 218px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: var(--sp-3);
    display: none;
}
.shapes-popover.open { display: block; }
.shapes-popover-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    margin-bottom: var(--sp-2);
}
.shapes-popover-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.shapes-popover .shape-pick {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--foreground);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.shapes-popover .shape-pick:hover {
    background: var(--accent);
    border-color: var(--ring);
}
.shapes-popover .shape-pick svg { width: 22px; height: 22px; }
.shapes-popover-hint {
    margin-top: var(--sp-2);
    font-size: 10px;
    color: var(--muted-foreground);
    text-align: center;
}

.color-popover .color-swatch-grid {
    display: grid;
    grid-template-columns: repeat(5, 28px);
    gap: 4px;
    margin-bottom: var(--sp-2);
}

.toolbar-swatches {
    display: flex;
    gap: 2px;
    align-items: center;
    margin-right: 4px;
}

.toolbar-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    transition: border-color var(--duration-fast), transform var(--duration-fast);
}

.toolbar-swatch:hover {
    border-color: var(--ring);
    transform: scale(1.15);
}

/* Illustrator-style fill / stroke control (left tools strip) */
.fs-control { position: relative; width: 34px; height: 34px; margin: 4px auto; }
.fs-sq {
    position: absolute; width: 21px; height: 21px;
    border-radius: 3px; padding: 0; cursor: pointer;
    background: var(--card); border: 1px solid #5b6577;
}
.fs-fill { top: 0; left: 0; z-index: 2; }
.fs-stroke { right: 0; bottom: 0; z-index: 1; }
.fs-fill.active, .fs-stroke.active { z-index: 4; box-shadow: 0 0 0 1.6px var(--ring), 0 1px 2px rgba(0,0,0,0.25); }
.fs-fillin { position: absolute; inset: 1px; border-radius: 2px; background: #000; }
.fs-ring { position: absolute; inset: 1px; border-radius: 2px; border: 4px solid #000; background: transparent; box-sizing: border-box; }
.fs-swap {
    position: absolute; top: -4px; right: -5px; width: 13px; height: 13px;
    padding: 0; border: none; background: none; cursor: pointer;
    color: var(--muted-foreground); z-index: 5;
}
.fs-swap svg { width: 13px; height: 13px; }
.fs-swap:hover { color: var(--foreground); }
/* "None" — red diagonal slash */
.fs-sq.is-none .fs-fillin { background: var(--card) !important; }
.fs-sq.is-none .fs-ring { border-color: #cbd2da !important; }
.fs-sq.is-none::after {
    content: ''; position: absolute; inset: 1px; border-radius: 2px; pointer-events: none;
    background: linear-gradient(to top right, transparent 45%, #ef4444 45%, #ef4444 55%, transparent 55%);
}

/* Colour swatch readability — a solid inner edge so white / light swatches show on the card */
.swatch-btn,
.color-swatch-btn { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22); }
[data-theme="dark"] .swatch-btn,
[data-theme="dark"] .color-swatch-btn { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }

/* Snap guide lines (drawn programmatically on canvas) */
.canvas-wrapper canvas {
    display: block;
}

/* Editor mode: hide sidebar + header, let main content fill the screen */
body.editor-active .sidebar {
    display: none;
}
body.editor-active .header-bar {
    display: none;
}
body.editor-active .app-main {
    margin-left: 0;
}
body.editor-active .content-area {
    padding: 0;
    overflow: hidden;
}
body.editor-active .toast-container {
    z-index: 10001;
}

/* Full screen presentation (View menu, v1.76.0): only the page, on black.
   #editor-root.presenting is set by startPresentation() in editor.js. */
#editor-root.presenting { background: #000; }
#editor-root.presenting .editor-toolbar,
#editor-root.presenting .tools-strip,
#editor-root.presenting .image-library-panel,
#editor-root.presenting .flyout-panel,
#editor-root.presenting .props-strip,
#editor-root.presenting .editor-status,
#editor-root.presenting .ruler-corner,
#editor-root.presenting .ruler-h-container,
#editor-root.presenting .ruler-v-container,
#editor-root.presenting .color-popover,
#editor-root.presenting .shapes-popover { display: none !important; }
#editor-root.presenting .canvas-viewport {
    background: #000;
    grid-template-columns: 0 1fr;
    grid-template-rows: 0 1fr;
}
#editor-root.presenting .canvas-scroll-area { overflow: hidden; scrollbar-width: none; }
#editor-root.presenting .canvas-scroll-area::-webkit-scrollbar { display: none; }
#editor-root.presenting .canvas-wrapper .canvas-container { box-shadow: none; }
#editor-root.presenting .presentation-counter {
    position: absolute; right: 20px; bottom: 16px; z-index: 60;
    font-size: 12px; color: rgba(255, 255, 255, 0.55); letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums; pointer-events: none;
}
#editor-root.presenting .presentation-hint {
    position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
    padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: #fff;
    font-size: 13px; white-space: nowrap; pointer-events: none; opacity: 1; transition: opacity 0.6s ease;
}
#editor-root.presenting .presentation-hint.fade { opacity: 0; }
body.presenting { cursor: default; }


/* Lock overlay badge */
.lock-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: var(--muted);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.lock-badge svg {
    width: 10px;
    height: 10px;
    color: var(--muted-foreground);
}


/* ============================================================
   7. PAGES
   ============================================================ */

/* --- Login --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-6);
    background: var(--background);
}

.login-card {
    width: 100%;
    max-width: 24rem;
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 0;
}

.login-logo-img {
    width: auto;
    height: 180px;
}

.login-logo-text {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
}

/* --- Dashboard --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-4);
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-6);
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
}

.stat-change {
    font-size: var(--text-xs);
    margin-top: var(--sp-2);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

/* --- Admin --- */
.admin-section {
    margin-bottom: var(--sp-8);
}

.admin-section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-4);
}

.storage-bar {
    height: 8px;
    background: var(--muted);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--duration-slow) var(--ease-default);
}

.storage-bar-fill.warning {
    background: var(--warning);
}

.storage-bar-fill.danger {
    background: var(--destructive);
}


/* --- Brand Settings --- */
.brand-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: var(--sp-3);
}

.brand-section-desc {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-bottom: var(--sp-4);
}

.brand-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-default),
                background var(--duration-fast) var(--ease-default);
    margin-bottom: var(--sp-4);
}

.brand-upload-zone:hover,
.brand-upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--accent);
}

.brand-upload-zone-text {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
}

.brand-upload-zone-text strong {
    color: var(--foreground);
}

.font-upload-progress {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.font-upload-progress-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.font-upload-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

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

.brand-fonts-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.brand-font-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border);
}

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

.brand-font-preview {
    font-size: var(--text-lg);
    min-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-font-info {
    flex: 1;
    min-width: 0;
}

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

.brand-font-meta {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.brand-font-delete {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    padding: var(--sp-1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast), border-color var(--duration-fast);
}

.brand-font-delete:hover {
    color: var(--destructive);
    border-color: var(--destructive);
}

.brand-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}

.brand-swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.brand-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
    cursor: pointer;
}

.brand-swatch-color {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    transition: border-color var(--duration-fast), transform var(--duration-fast);
}

.brand-swatch:hover .brand-swatch-color {
    border-color: var(--ring);
    transform: scale(1.05);
}

.brand-swatch-label {
    font-size: 10px;
    color: var(--muted-foreground);
    text-align: center;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-swatch-add .brand-swatch-color {
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-foreground);
}

.brand-swatch-add:hover .brand-swatch-color {
    border-color: var(--primary);
    color: var(--primary);
}

.brand-color-editor {
    margin-top: var(--sp-2);
    margin-bottom: var(--sp-4);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
}

.brand-color-editor-row {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    margin-bottom: var(--sp-3);
    flex-wrap: wrap;
}

.brand-color-editor-row:last-child {
    margin-bottom: 0;
}

.brand-color-preview {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-color-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-color-field label {
    font-size: 10px;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.brand-color-field input {
    height: 32px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-size: var(--text-sm);
}

.brand-color-field input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring);
}

.brand-color-field .cmyk-input {
    width: 56px;
}

.brand-color-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}


/* --- Brand Page (style guide) --- */

.brand-anchor-nav {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.brand-anchor-link {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    text-decoration: none;
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast), background var(--duration-fast);
}

.brand-anchor-link:hover {
    color: var(--foreground);
    background: var(--accent);
}

.brand-section {
    margin-bottom: var(--sp-2);
}

.brand-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}

.brand-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}

.brand-empty {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    padding: var(--sp-4);
    text-align: center;
}

.brand-error {
    font-size: var(--text-sm);
    color: var(--destructive);
    padding: var(--sp-4);
    text-align: center;
}

/* Role-based visibility */
.brand-readonly .brand-edit-controls {
    display: none;
}

/* Swatch extras */
.brand-swatch-hex {
    font-size: 9px;
    color: var(--muted-foreground);
    font-family: var(--font-mono, monospace);
    text-transform: uppercase;
}

.brand-swatch-meta {
    font-size: 9px;
    color: var(--muted-foreground);
    text-align: center;
    line-height: 1.3;
}

.brand-swatch-editable {
    cursor: pointer;
}

/* Badges */
.brand-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 9999px;
    background: var(--muted);
    color: var(--muted-foreground);
    white-space: nowrap;
}

.brand-badge-variable {
    background: hsl(258 60% 93%);
    color: hsl(258 60% 45%);
}

.brand-badge-static {
    background: var(--muted);
    color: var(--muted-foreground);
}

.brand-badge-category {
    background: hsl(200 60% 92%);
    color: hsl(200 60% 38%);
}

.brand-badge-italic {
    background: hsl(330 50% 93%);
    color: hsl(330 50% 42%);
    font-style: italic;
}

/* Font cards */
.brand-font-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
}

.brand-font-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.brand-font-card-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--foreground);
}

.brand-font-card-actions {
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.brand-font-preview-area {
    font-size: 28px;
    line-height: 1.3;
    color: var(--foreground);
    margin-bottom: var(--sp-3);
    word-break: break-word;
}

.brand-font-samples {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.brand-font-weight-sample {
    font-size: var(--text-lg);
    color: var(--foreground);
    white-space: nowrap;
}

.brand-font-weight-sample small {
    display: block;
    font-size: 10px;
    color: var(--muted-foreground);
    font-weight: 400;
    font-family: var(--font-sans, sans-serif);
    margin-top: 2px;
}

/* Variable font axis controls */
.brand-font-axes {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--muted);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-3);
}

.brand-font-axis {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.brand-font-axis-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--muted-foreground);
    min-width: 100px;
    flex-shrink: 0;
}

.brand-font-axis-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.brand-font-axis-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--foreground);
    cursor: pointer;
}

.brand-font-axis-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--foreground);
    border: none;
    cursor: pointer;
}

.brand-font-axis-value {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--foreground);
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Font allowed-range controls */
.brand-font-range {
    margin-bottom: var(--sp-2);
}

.brand-font-range label {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    display: block;
    margin-bottom: var(--sp-1);
}

.brand-range-inputs {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.brand-range-inputs span {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.brand-range-min,
.brand-range-max {
    height: 28px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}

.brand-range-min:focus,
.brand-range-max:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring);
}

/* Font category + usage */
.brand-font-category-select {
    height: 32px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-2);
}

.brand-font-category-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring);
}

.brand-font-usage {
    width: 100%;
    padding: var(--sp-2);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-size: var(--text-sm);
    resize: vertical;
    margin-bottom: var(--sp-2);
    font-family: inherit;
}

.brand-font-usage:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring);
}

.brand-font-usage-text {
    font-size: var(--text-sm);
    color: var(--muted-foreground);
    font-style: italic;
    margin-bottom: var(--sp-2);
}

.brand-font-meta-row {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    align-items: center;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--sp-2);
}

/* Logo grid */
.brand-logo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-4);
}

.brand-logo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    overflow: hidden;
}

.brand-logo-thumb {
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: var(--muted);
    overflow: hidden;
}

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

.brand-logo-bg-dark {
    background: hsl(0 0% 15%);
}

.brand-logo-bg-checker {
    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: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.brand-logo-info {
    padding: var(--sp-3);
}

.brand-logo-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: var(--sp-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-logo-meta {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
    margin-bottom: var(--sp-1);
}

.brand-logo-notes {
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    margin-top: var(--sp-1);
    line-height: 1.4;
}

.brand-logo-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

.brand-logo-edit,
.brand-logo-delete {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    padding: var(--sp-1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast), border-color var(--duration-fast);
}

.brand-logo-edit:hover {
    color: var(--foreground);
    border-color: var(--foreground);
}

.brand-logo-delete:hover {
    color: var(--destructive);
    border-color: var(--destructive);
}

/* Logo picker dialog */
.brand-logo-picker-item {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-2);
    background: var(--muted);
}

.brand-logo-picker-item:hover {
    border-color: var(--ring);
}

.brand-logo-picker-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--ring);
}

.brand-logo-picker-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Paragraph style cards */
.brand-pstyle-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
}

.brand-pstyle-preview {
    margin-bottom: var(--sp-2);
    word-break: break-word;
    line-height: 1.3;
}

.brand-pstyle-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.brand-pstyle-actions {
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* Character style rows */
.brand-cstyle-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    margin-bottom: var(--sp-2);
}

.brand-cstyle-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
    min-width: 80px;
    flex-shrink: 0;
}

.brand-cstyle-preview {
    font-size: var(--text-base);
    color: var(--foreground);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.brand-cstyle-meta {
    flex: 1;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-cstyle-actions {
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* Dark mode badge adjustments */
[data-theme="dark"] .brand-badge-variable {
    background: hsl(258 40% 25%);
    color: hsl(258 60% 75%);
}

[data-theme="dark"] .brand-badge-category {
    background: hsl(200 40% 22%);
    color: hsl(200 60% 72%);
}

[data-theme="dark"] .brand-badge-italic {
    background: hsl(330 35% 25%);
    color: hsl(330 50% 75%);
}

/* Responsive */
@media (max-width: 640px) {
    .brand-logo-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .brand-cstyle-row {
        flex-wrap: wrap;
    }

    .brand-cstyle-meta {
        white-space: normal;
        flex-basis: 100%;
    }

    .brand-font-axis {
        flex-wrap: wrap;
    }

    .brand-font-axis-label {
        min-width: auto;
        flex-basis: 100%;
    }
}

/* --- Paragraph / Character Style Editor Dialog --- */

.pse-body {
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-4);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.pse-settings {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.pse-preview-col {
    flex: 0 0 240px;
    display: flex;
    flex-direction: column;
}

.pse-preview {
    flex: 1;
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    overflow-wrap: break-word;
    min-height: 120px;
}

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

.pse-row {
    display: flex;
    gap: var(--sp-3);
    align-items: flex-end;
}

.pse-color-row {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

.pse-toggle-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.pse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    background: var(--background);
    border: none;
    border-right: 1px solid var(--border);
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background var(--duration-fast), color var(--duration-fast);
}

.pse-toggle:last-child {
    border-right: none;
}

.pse-toggle:hover {
    background: var(--accent);
}

.pse-toggle.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

/* Character style preview box */
.cse-preview-box {
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    font-size: var(--text-lg);
    min-height: 60px;
    display: flex;
    align-items: center;
}

@media (max-width: 640px) {
    .pse-body {
        flex-direction: column;
    }

    .pse-preview-col {
        flex: none;
    }

    .pse-row {
        flex-wrap: wrap;
    }
}

/* --- Style Flyout Items (editor sidebar) --- */

.style-flyout-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.style-flyout-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--foreground);
    cursor: pointer;
    text-align: left;
    transition: background var(--duration-fast), border-color var(--duration-fast);
    width: 100%;
}

.style-flyout-item:hover {
    background: var(--accent);
    border-color: var(--border);
}

.style-flyout-item.active {
    background: var(--accent);
    border-color: var(--ring);
}

.style-flyout-name {
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.style-flyout-meta {
    font-size: 10px;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.style-flyout-preview {
    font-size: var(--text-sm);
    flex-shrink: 0;
}


/* -- Pages Flyout -- */
.pages-thumb-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}
.page-thumb-item {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
    width: calc(50% - var(--sp-1));
    max-width: 165px;
    min-width: 80px;
    flex-shrink: 0;
}
.page-thumb-item:hover { border-color: var(--muted-foreground); }
/* Loading placeholders (v1.90): tiles for pages still arriving + thumbnails
   still rendering shimmer until the real image replaces them */
.page-thumb-skel {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: calc(50% - var(--sp-1));
    max-width: 165px;
    min-width: 80px;
    flex-shrink: 0;
}
.page-thumb-img.page-thumb-skeleton {
    background: linear-gradient(100deg, var(--muted) 30%, color-mix(in srgb, var(--muted) 40%, var(--background)) 50%, var(--muted) 70%);
    background-size: 300% 100%;
    animation: pbc-skeleton 1.4s ease-in-out infinite;
}
@keyframes pbc-skeleton { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .page-thumb-img.page-thumb-skeleton { animation: none; } }
.page-thumb-item.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.page-thumb-img {
    width: 100%;
    display: block;
    background: var(--card);
    object-fit: contain;
}
.page-thumb-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 2px 6px;
    font-size: 10px;
    background: rgba(0,0,0,0.5);
    color: white;
    text-align: center;
    z-index: 2;
}
.page-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1;
}
.page-thumb-item:hover .page-thumb-overlay { opacity: 1; }
.page-thumb-action {
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}
.page-thumb-action:hover { background: rgba(255,255,255,0.3); }
.page-thumb-action--delete:hover { background: rgba(239,68,68,0.6); }

/* -- Settings Modal Tabs -- */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin: 0 calc(-1 * var(--sp-6)) var(--sp-3);
    padding: 0 var(--sp-6);
}
.settings-tab {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--muted-foreground);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: var(--foreground); }
.settings-tab.active {
    color: var(--foreground);
    border-bottom-color: var(--primary);
}
.settings-tab-panel { display: none !important; }
.settings-tab-panel.active { display: flex !important; flex-direction: column; gap: var(--sp-3); }
.settings-override-note {
    font-size: 11px;
    color: var(--muted-foreground);
    background: var(--muted);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-2);
    line-height: 1.4;
}
.settings-page-selector {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-xs);
    margin-bottom: var(--sp-3);
}
.settings-page-selector select { width: auto; }

/* --- Layers Panel --- */
.layers-toolbar {
    display: flex;
    margin-bottom: var(--sp-2);
}
.layers-unlock-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    width: 100%;
    justify-content: center;
    padding: var(--sp-1) var(--sp-2);
    height: 28px;
    border: 1px solid var(--border);
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.layers-unlock-btn:hover { background: var(--accent); border-color: var(--ring); }

.layers-toolbar.layers-multi {
    justify-content: space-between;
    align-items: center;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-2);
}
.layers-sel-head { display: inline-flex; align-items: center; gap: 6px; }
.layers-sel-count { font-size: var(--text-xs); font-weight: 600; color: var(--foreground); }
.layers-clear-pill {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-full);
    background: var(--secondary); color: var(--muted-foreground);
    cursor: pointer; transition: background 0.1s, color 0.1s;
}
.layers-clear-pill:hover { background: var(--accent); color: var(--foreground); }
.layers-tb-actions { display: inline-flex; gap: 2px; }
.layers-tb-btn {
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; color: var(--muted-foreground);
    border-radius: var(--radius-sm); cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.layers-tb-btn:hover { background: var(--accent); color: var(--foreground); }
.layers-tb-btn.layers-tb-danger:hover { background: color-mix(in srgb, var(--destructive) 18%, transparent); color: var(--destructive); }

.layers-selrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: var(--sp-2);
}
.layers-selrow-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    margin-right: 2px;
}
.layers-type-chip {
    font-size: 11px;
    line-height: 1;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--secondary);
    color: var(--secondary-foreground);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.layers-type-chip b { font-weight: 600; opacity: 0.6; }
.layers-type-chip:hover { background: var(--accent); border-color: var(--ring); color: var(--foreground); }
.layers-type-chip.layers-chip-alt { background: none; border-style: dashed; }
.layers-type-chip.layers-chip-alt:hover { background: var(--accent); }

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.layers-empty {
    padding: var(--sp-4) var(--sp-2);
    text-align: center;
    color: var(--muted-foreground);
    font-size: var(--text-xs);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 4px 4px 4px 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
    color: var(--foreground);
    transition: background 0.1s;
    min-height: 28px;
    user-select: none;
}
.layer-item:hover { background: var(--accent); }
.layer-item.layer-selected { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.layer-item.layer-hidden { opacity: 0.45; }
.layer-item.layer-locked-item .layer-name { font-style: italic; }

.layer-drag-handle {
    cursor: grab;
    color: var(--muted-foreground);
    flex-shrink: 0;
    padding: 2px;
    display: flex;
    align-items: center;
}
.layer-drag-handle:active { cursor: grabbing; }

.layer-type-icon {
    flex-shrink: 0;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
}

.layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    padding: 1px 2px;
    border-radius: 2px;
}
.layer-name:hover { background: color-mix(in srgb, var(--foreground) 8%, transparent); }

.layer-rename-input {
    flex: 1;
    font-size: var(--text-xs);
    padding: 1px 4px;
    border: 1px solid var(--primary);
    border-radius: 2px;
    background: var(--background);
    color: var(--foreground);
    outline: none;
    min-width: 0;
}

.layer-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}
.layer-action-btn.layer-hover-only { display: none; }
.layer-item:hover .layer-action-btn.layer-hover-only,
.layer-item.layer-selected .layer-action-btn.layer-hover-only { display: flex; }

.layer-action-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--muted-foreground);
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    transition: background 0.1s, color 0.1s;
}
.layer-action-btn:hover { background: var(--accent); color: var(--foreground); }
.layer-action-btn.active { color: var(--primary); }

/* Drag drop indicators */
.layer-item.dragging { opacity: 0.3; }
.layer-item.drag-over-above { box-shadow: inset 0 2px 0 var(--primary); }
.layer-item.drag-over-below { box-shadow: inset 0 -2px 0 var(--primary); }

/* --- History Panel --- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 8px;
    cursor: pointer;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}
.history-item:hover { background: var(--accent); color: var(--foreground); }
.history-disclose {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: transform .12s ease;
}
.history-disclose:hover { background: var(--secondary); color: var(--foreground); }
.history-disclose.open { transform: rotate(180deg); }
.history-detail {
    padding: 2px var(--sp-3) var(--sp-1) 26px;
    font-size: 11px;
    color: var(--muted-foreground);
}
.history-item.history-current {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    color: var(--foreground);
    font-weight: 600;
}
.history-item.history-redo { opacity: 0.4; }

.history-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted-foreground);
    flex-shrink: 0;
}
.history-item.history-current .history-dot { background: var(--primary); }
.history-dot.history-dot-start { background: var(--primary); }

.history-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-item.history-page-op .history-dot {
    background: var(--warning, #f59e0b);
    border-radius: 2px;
}
.history-item.history-page-op .history-label { font-style: italic; }

/* --- Raster Export (two-panel Photoshop-style) --- */
.export-raster-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    height: min(680px, 70vh);
    overflow: hidden;
}

/* Override base .dialog max-width for the wide raster export layout */
.export-modal-overlay .dialog {
    max-width: none;
}

.export-preview-area {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-width: 0;
    overflow: hidden;
}

.export-preview-container {
    flex: 1;
    background: #1a1a1a;
    position: relative;
    overflow: hidden;
    min-height: 0;
}
.export-preview-container.dragging { cursor: grabbing; }

.export-preview-container img {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: auto;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: 0 0;
}
.export-preview-container.transparent img {
    background: repeating-conic-gradient(#333 0% 25%, #555 0% 50%) 0 0 / 16px 16px;
}

.export-preview-zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--border);
    background: var(--card);
    font-size: var(--text-xs);
}
.export-preview-zoom button {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    cursor: pointer;
    font-size: 14px;
    color: var(--foreground);
}
.export-preview-zoom button:hover { background: var(--accent); }
.export-preview-zoom-pct {
    min-width: 48px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.export-settings-panel {
    padding: var(--sp-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    font-size: var(--text-xs);
}

.export-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    margin-bottom: var(--sp-1);
    color: var(--foreground);
}

.export-field {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.export-field-label {
    min-width: 52px;
    color: var(--muted-foreground);
    text-align: right;
}
.export-field-value {
    flex: 1;
}
.export-px-input {
    width: 72px;
    height: 28px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.export-px-unit {
    color: var(--muted-foreground);
    font-size: 11px;
}
.export-lock-icon {
    color: var(--muted-foreground);
    font-size: 11px;
    margin-left: var(--sp-1);
}
.export-lock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0;
    margin-left: var(--sp-1);
}
.export-lock-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

.export-size-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.export-size-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
}
.export-size-row:hover { background: var(--accent); }
.export-size-row.active {
    background: var(--accent);
    font-weight: 600;
}
.export-size-row-label { color: var(--foreground); }
.export-size-row-value { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

.export-progress {
    height: 4px;
    background: var(--muted);
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}
.export-progress > div {
    height: 100%;
    background: var(--primary);
    transition: width 0.1s linear;
}

/* ============================================================
   8. UTILITIES
   ============================================================ */

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

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-muted {
    color: var(--muted-foreground);
}

.text-sm {
    font-size: var(--text-sm);
}

.text-xs {
    font-size: var(--text-xs);
}

.font-semibold {
    font-weight: 600;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.gap-2 {
    gap: var(--sp-2);
}

.gap-3 {
    gap: var(--sp-3);
}

.gap-4 {
    gap: var(--sp-4);
}

.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: var(--sp-4);
}

.mb-4 {
    margin-bottom: var(--sp-4);
}


/* ============================================================
   9. ANIMATIONS
   ============================================================ */

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes dialog-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes dialog-out {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}

@keyframes sheet-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

@keyframes sheet-out {
    from { transform: translateX(0); }
    to   { transform: translateX(100%); }
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

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

@keyframes save-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.9; }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}


/* ============================================================
   10. RESPONSIVE
   ============================================================ */

/* Tablet: sidebar collapsed, grids 3-col */
@media (max-width: 1279px) {
    .image-library-panel {
        position: fixed;
        top: 0;
        left: 48px;
        bottom: 0;
        z-index: 50;
        box-shadow: var(--shadow-xl);
    }

    .sidebar {
        width: var(--sidebar-width-icon);
    }

    .sidebar .sidebar-title,
    .sidebar .sidebar-link-text,
    .sidebar .sidebar-section-label {
        opacity: 0;
        width: 0;
        pointer-events: none;
    }

    .sidebar .sidebar-footer-copy {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .sidebar .sidebar-footer {
        align-items: center;
        padding: var(--sp-2) var(--sp-1);
    }

    .sidebar:hover {
        width: var(--sidebar-width);
        box-shadow: var(--shadow-xl);
    }

    .sidebar:hover .sidebar-title,
    .sidebar:hover .sidebar-link-text,
    .sidebar:hover .sidebar-section-label {
        opacity: 1;
        width: auto;
    }

    .sidebar:hover .sidebar-footer-copy {
        opacity: 1;
        width: auto;
        height: auto;
    }

    .sidebar:hover .sidebar-footer {
        align-items: flex-start;
        padding: var(--sp-3) var(--sp-4);
    }

    .app-main {
        margin-left: var(--sidebar-width-icon);
    }

    .library-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    /* Editor: flyout panel as overlay on tablet */
    .flyout-panel {
        position: fixed;
        top: 0;
        right: 40px;
        bottom: 0;
        z-index: var(--z-overlay);
        box-shadow: var(--shadow-xl);
    }

    /* Tools strip stays same width on tablet */

    .dialog {
        max-width: calc(100vw - var(--sp-8));
    }
}

/* Desktop: sidebar expanded, full editor layout */
@media (min-width: 1280px) {
    .app-main {
        margin-left: var(--sidebar-width);
    }

    .sidebar.collapsed ~ .app-main {
        margin-left: var(--sidebar-width-icon);
    }

    .library-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Wide desktop: 6-col grids */
@media (min-width: 1536px) {
    .library-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ──────────────────────────────────────────────────────────────────────
   Comment pins — compose/thread popovers (approval workflow, v1.51.x)
   ────────────────────────────────────────────────────────────────────── */
.pbc-comment-popover {
    position: fixed;
    z-index: 10000;
    width: 300px;
    background: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-3);
}
.pbc-comment-popover .pbc-comment-input {
    width: 100%;
    resize: vertical;
    min-height: 40px;
    font-size: var(--text-sm);
    margin-top: var(--sp-2);
}
.pbc-comment-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}
.pbc-comment-thread {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.pbc-comment-msg {
    background: var(--secondary);
    border-radius: var(--radius);
    padding: var(--sp-2);
}
.pbc-comment-meta {
    font-size: 10px;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}
.pbc-comment-meta .pbc-comment-del {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.pbc-comment-meta .pbc-comment-del:hover { color: var(--destructive); }
.pbc-comment-body {
    font-size: var(--text-xs);
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 2px;
}
.pbc-comment-row:hover { background: var(--accent); }

/* Context-action menu additions (registry, v1.52.x) */
.ed-ctx-menu { max-height: calc(100vh - 16px); overflow-y: auto; }
.ed-ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; flex: none; }
.ed-ctx-item:disabled { color: var(--muted-foreground); cursor: default; }
.ed-ctx-item:disabled:hover { background: none; }

/* v1.92: tips, notes and hints never end on a lone word. The longhand is
   inherited (and leaves wrap mode alone); the shorthand on note-like
   elements covers engines without the longhand. */
body { text-wrap-style: pretty; }
p, .lg-hint, .settings-override-note, [id$="-note"], .flyout-body > p { text-wrap: pretty; }

/* v1.92: range sliders app-wide are solid (theme foreground: black in light,
   white in dark), never the browser's blue; and panel rows never overflow.
   Inputs default to a ~150px intrinsic minimum, so a row of flex:1 fields
   pushed its last controls past the panel edge (the clipped "100%", the
   missing Y and Soften fields) — form controls may now shrink. */
input[type="range"] { accent-color: var(--foreground); cursor: pointer; }
input[type="range"].prop-input { padding: 0; border: none; background: none; }
.prop-input, .prop-row input, .prop-row select { min-width: 0; }
.prop-label { flex-shrink: 0; }
.flyout-body, .dock-body { overflow-x: hidden; }

/* --- Info panel (v1.93): InDesign's Info layout. Position | size quadrants,
   a fill | stroke band, then document, image or text details --- */
.info-panel { container-type: inline-size; font-size: var(--text-xs); }
.info-quad, .info-band { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.info-quad > .info-cell:first-child, .info-band > .info-cell:first-child { padding-right: var(--sp-2); }
.info-quad > .info-cell + .info-cell, .info-band > .info-cell + .info-cell { border-left: 1px solid var(--border); padding-left: var(--sp-2); }
.info-quad .info-cell {
    display: grid;
    grid-template-columns: 14px 10px minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 4px;
    align-items: center;
    align-content: start;
}
.info-ico { grid-column: 1; grid-row: 1 / span 2; width: 14px; height: 14px; color: var(--muted-foreground); }
.info-ico-r3 { grid-row: 3; }
.info-k { grid-column: 2; color: var(--muted-foreground); }
.info-f, .info-v { grid-column: 3; min-width: 0; }
.info-f { position: relative; }
.info-in {
    width: 100%;
    min-width: 0;
    height: 26px;
    padding: 0 24px 0 6px;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--foreground);
    background: transparent;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    appearance: textfield;
    -moz-appearance: textfield;
}
.info-in::-webkit-outer-spin-button, .info-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.info-in:focus { outline: none; border-color: var(--ring); }
.info-f > i {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-style: normal;
    color: var(--muted-foreground);
    pointer-events: none;
}
.info-v {
    height: 26px;
    line-height: 26px;
    padding: 0 7px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.info-band { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.info-sw { display: flex; align-items: flex-start; gap: 7px; min-width: 0; }
.info-chip {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    margin-top: 1px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
}
.info-chip.stroke { border-width: 3px; border-color: var(--foreground); }
.info-chip.none {
    border-width: 1px;
    border-color: var(--border);
    background: linear-gradient(to top right, transparent calc(50% - 0.75px), var(--destructive) calc(50% - 0.75px), var(--destructive) calc(50% + 0.75px), transparent calc(50% + 0.75px));
}
.info-chip.mixed { background: repeating-linear-gradient(45deg, var(--muted-foreground) 0 2px, transparent 2px 4px); }
.info-sw-t { min-width: 0; line-height: 1.35; }
.info-sw-t b, .info-sw-t span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-sw-t b { font-weight: 500; }
.info-sw-t span { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.info-list {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--sp-3);
    row-gap: 6px;
    margin: var(--sp-3) 0 0;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
}
.info-list dt { color: var(--muted-foreground); text-align: right; white-space: nowrap; }
.info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@container (max-width: 230px) {
    .info-quad, .info-band { grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-3); }
    .info-quad > .info-cell:first-child, .info-band > .info-cell:first-child { padding-right: 0; }
    .info-quad > .info-cell + .info-cell, .info-band > .info-cell + .info-cell { border-left: none; padding-left: 0; }
}

/* --- Stroke caps (v1.93): InDesign's Start/End, Scale, Offset rows --- */
.cap-grid {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 24px minmax(0, 1fr);
    column-gap: 6px;
    row-gap: var(--sp-2);
    align-items: center;
    margin-bottom: var(--sp-2);
}
.cap-grid .prop-label { min-width: 0; white-space: nowrap; }
.cap-grid .prop-input { width: 100%; min-width: 0; }
.cap-grid input:disabled, .cap-check:has(input:disabled) { opacity: 0.45; cursor: default; }
.cap-pick {
    --cap-bg: var(--background);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
    height: 28px;
    padding: 0 4px 0 8px;
    color: var(--foreground);
    background: transparent;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.cap-pick:hover { border-color: var(--ring); }
.cap-pick[aria-expanded="true"] { border-color: var(--ring); }
.cap-pick-chev { flex: 0 0 14px; color: var(--muted-foreground); opacity: 0.7; }
.cap-g { display: block; flex: 0 1 40px; min-width: 0; }
.cap-g-t { font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    color: var(--muted-foreground);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.cap-mid:hover { color: var(--foreground); background: var(--accent); }
.cap-mid.on { color: var(--foreground); }
.cap-f { position: relative; min-width: 0; }
.cap-f .prop-input { padding-right: 20px; }
.cap-f > i {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-style: normal;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
    pointer-events: none;
}
.cap-check { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: var(--text-xs); color: var(--muted-foreground); cursor: pointer; }
.cap-check input { margin: 0; }
.cap-custom { display: grid; grid-template-columns: 58px minmax(0, 1fr); column-gap: 6px; row-gap: 6px; align-items: center; margin-bottom: var(--sp-2); }
.cap-custom-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.cap-custom .btn { height: 24px; padding: 0 8px; font-size: var(--text-xs); }
.cap-thumb { width: 28px; height: 28px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--background); }
.cap-xy { display: flex; align-items: center; gap: 4px; }
.cap-xy i { font-style: normal; font-size: var(--text-xs); color: var(--muted-foreground); }
.cap-xy .prop-input { flex: 0 0 48px; width: 48px; }
.cap-picker { grid-column: 1 / -1; }
.cap-menu {
    --cap-bg: var(--popover);
    position: fixed;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    padding: 4px;
    max-height: min(360px, calc(100vh - 16px));
    overflow-y: auto;
    color: var(--popover-foreground, var(--foreground));
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.cap-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 30px;
    padding: 0 8px;
    font-size: var(--text-xs);
    text-align: left;
    color: inherit;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.cap-opt:hover, .cap-opt:focus-visible { background: var(--accent); outline: none; }
.cap-opt.on { font-weight: 600; }
.cap-opt-g { display: flex; flex: 0 0 40px; align-items: center; }

/* Hyperlinks panel (v1.93): the selection's rows, a note for part-linked
   frames, and no rule under the last row */
.links-row.sel { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.links-row.sel .links-name { font-weight: 600; }
.links-row:last-child { border-bottom: none; }
.links-note { margin: 0 0 var(--sp-2); font-size: 11px; color: var(--muted-foreground); text-wrap: pretty; }

/* Brand guide icon fonts (v1.93): icons instead of a text specimen */
.brand-font-card.brand-font-pending .brand-font-preview-area,
.brand-font-card.brand-font-pending .brand-font-samples { visibility: hidden; }
.brand-badge-icons { background: hsl(35 70% 92%); color: hsl(30 60% 36%); }
.brand-font-preview-area.brand-icon-preview { font-size: var(--text-sm); line-height: normal; word-break: normal; }
.brand-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--sp-2); }
.brand-icon-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 14px 6px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--background);
}
.brand-icon-glyph { font-size: 24px; line-height: 1; color: var(--foreground); font-style: normal; }
.brand-icon-name {
    max-width: 100%;
    overflow: hidden;
    font-family: var(--font-sans, sans-serif);
    font-size: 11px;
    color: var(--muted-foreground);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.brand-icon-more { margin-top: var(--sp-3); }
.brand-icon-count { font-size: var(--text-sm); color: var(--muted-foreground); }
.brand-font-samples:empty { display: none; }

/* Gradient midpoints (v1.93.2): draggable, selectable like InDesign's */
.grad-midpoint.selected { opacity: 1; background: var(--primary); }
.grad-midpoint { width: 9px; height: 9px; }

/* Live shape options in the Shape panel (v1.94) */
.ls-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: var(--sp-3); }
.ls-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 7px 2px 5px;
    font-size: 10px;
    color: var(--muted-foreground);
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.ls-preset:hover { border-color: var(--ring); color: var(--foreground); }
.ls-preset.on { border-color: var(--foreground); color: var(--foreground); }
.ls-preset svg { width: 22px; height: 22px; fill: currentColor; }
.ls-preset span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-num { position: relative; flex: 0 0 60px; min-width: 0; }
.ls-num.wide { flex: 1 1 auto; }
.ls-num .prop-input { width: 100%; padding-right: 18px; }
.ls-num > i { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: var(--text-xs); color: var(--muted-foreground); pointer-events: none; }
.ls-check { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--foreground); cursor: pointer; }
.ls-check input { margin: 0; }

/* Shape size dialog (v1.94.1): width + height with a chain link toggle */
.so-pair { display: flex; align-items: center; gap: var(--sp-2); }
.so-pair-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.so-rest { display: flex; flex-direction: column; gap: var(--sp-3); padding-right: calc(28px + var(--sp-2)); }
.so-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--muted-foreground);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.so-link:hover { color: var(--foreground); background: var(--accent); }
.so-link.on { color: var(--foreground); background: var(--accent); }
/* bracket from the chain to both fields */
.so-link::before, .so-link::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 7px;
    height: var(--so-bracket, 12px);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
}
.so-link::before { bottom: 100%; border-top: 1px solid var(--border); }
.so-link::after { top: 100%; border-bottom: 1px solid var(--border); }

/* Settings margins chain (v1.94.2): same toggle as the shape size dialog */
.margin-link-wrap { display: flex; align-items: center; gap: var(--sp-2); --so-bracket: 6px; }

/* Hyperlinks panel (v1.94.2): the editor stays on top while the list scrolls,
   and the address or page picker gets its own full-width line */
.links-sticky {
    position: sticky;
    top: calc(-1 * var(--sp-3));
    z-index: 3;
    margin: calc(-1 * var(--sp-3)) calc(-1 * var(--sp-3)) var(--sp-2);
    padding: var(--sp-3) var(--sp-3) var(--sp-2);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}
.link-editor .prop-row { margin-bottom: var(--sp-2); }
.link-editor .link-target { display: block; width: 100%; margin-bottom: var(--sp-1); }

/* Skeleton placeholders (v1.94.3): one shimmer for anything still loading */
.skel-bar, .skel-dot, .skel-block {
    display: block;
    background: linear-gradient(100deg, var(--muted) 30%, color-mix(in srgb, var(--muted) 40%, var(--background)) 50%, var(--muted) 70%);
    background-size: 300% 100%;
    animation: pbc-skeleton 1.4s ease-in-out infinite;
    border-radius: 4px;
}
.skel-bar { height: 10px; max-width: 100%; }
.skel-dot { width: 9px; height: 9px; border-radius: 50%; }
.skel-row { pointer-events: none; cursor: default; }
.skel-row:hover { background: none; }
@media (prefers-reduced-motion: reduce) { .skel-bar, .skel-dot, .skel-block { animation: none; } }
.skel-tile { aspect-ratio: 1; width: 100%; border-radius: var(--radius-sm); }
.skel-card { pointer-events: none; cursor: default; }
.skel-card:hover { border-color: var(--border); box-shadow: none; }
.skel-card .library-card-thumb .skel-block { width: 100%; height: 100%; border-radius: 2px; }
.skel-card .library-card-body { display: flex; flex-direction: column; gap: 8px; }
.skel-table { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.skel-table-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--sp-4); align-items: center; padding: 16px var(--sp-4); }
.skel-table-row + .skel-table-row { border-top: 1px solid var(--border); }
.dw-skel { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-2) 0; }

/* History (v1.95): audit trail rows with author, date and time */
.history-item { align-items: flex-start; }
.history-item.history-static { cursor: default; }
.history-item.history-static:hover { background: none; }
.history-item .history-dot { width: 8px; height: 8px; margin-top: 4px; }
.history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.history-text .history-label { flex: none; font-size: var(--text-xs); color: var(--foreground); font-weight: 500; }
.history-item.history-current .history-label { font-weight: 700; }
.history-sub, .history-meta { font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.history-meta { opacity: 0.85; }
.history-pending { color: var(--warning, #d97706); }
.history-open {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin: 6px 0;
    padding: 8px;
    font-size: 11px;
    color: var(--muted-foreground);
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}
.history-open strong { color: var(--foreground); font-weight: 600; }
.history-older { align-self: center; margin-top: var(--sp-2); }
.history-note { font-size: 11px; color: var(--muted-foreground); padding: 6px 8px; margin: 0; }

/* ── Tables (InDesign model, v1.96 tables branch): Table panel ─────────────────── */
.tbl-panel { display: flex; flex-direction: column; }
.tbl-empty { color: var(--muted-foreground); font-size: var(--text-sm); margin: 0; }
.tbl-scope {
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2);
    font-size: var(--text-xs); color: var(--foreground); font-weight: 600;
    padding-bottom: var(--sp-2); margin-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
}
.tbl-scope-dims { color: var(--muted-foreground); font-weight: 400; white-space: nowrap; }
.tbl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-3); }
.tbl-field {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
    font-size: var(--text-xs); color: var(--foreground); margin-bottom: var(--sp-2); min-width: 0;
}
.tbl-grid2 .tbl-field { margin-bottom: 0; }
.tbl-field > span:first-child { color: var(--muted-foreground); white-space: nowrap; }
.tbl-input-wrap { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.tbl-input-wrap em { font-style: normal; font-size: 11px; color: var(--muted-foreground); }
.tbl-num { width: 64px; height: 28px; padding: 0 6px; font-size: var(--text-xs); text-align: right; }
.tbl-select { height: 28px; padding: 0 6px; font-size: var(--text-xs); max-width: 150px; }
.tbl-rowh .tbl-select { width: 86px; }
.tbl-btnrow { display: flex; gap: var(--sp-2); margin-top: var(--sp-1); }
.tbl-btnrow.tbl-wrap { flex-wrap: wrap; }
.tbl-btnrow .btn { font-size: 11px; height: 26px; padding: 0 8px; }
.tbl-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tbl-seg-btn {
    width: 28px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--background); color: var(--foreground); border: 0; cursor: pointer;
}
.tbl-seg-btn + .tbl-seg-btn { border-left: 1px solid var(--border); }
.tbl-seg-btn:hover { background: var(--accent); }
.tbl-seg-btn.active { background: var(--foreground); color: var(--background); }
.tbl-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: var(--sp-2); }
.tbl-swatch {
    width: 22px; height: 22px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    padding: 0; cursor: pointer; background: var(--background);
}
.tbl-swatch:hover { border-color: var(--ring); }
.tbl-swatch.selected { outline: 2px solid var(--foreground); outline-offset: 1px; }
.tbl-swatch-none { background: linear-gradient(to top right, transparent calc(50% - 1px), #e11d48 calc(50% - 1px), #e11d48 calc(50% + 1px), transparent calc(50% + 1px)), var(--background); }
.tbl-swatch-custom { width: 26px; height: 24px; padding: 1px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--background); }
.tbl-sub { font-size: 11px; color: var(--muted-foreground); margin: var(--sp-1) 0; }
.tbl-strokes { display: flex; gap: var(--sp-3); align-items: flex-start; margin-bottom: var(--sp-2); }
.tbl-stroke-fields { flex: 1; min-width: 0; }
.tbl-proxy { flex: 0 0 72px; }
.tbl-proxy-line { stroke: var(--muted-foreground); stroke-width: 5; stroke-linecap: round; opacity: .28; cursor: pointer; }
.tbl-proxy-line:hover { opacity: .55; }
.tbl-proxy-line.on { stroke: var(--primary); opacity: 1; }
