/* ==========================================================================
   MusiCanvas — Design System
   Paleta: Azul Marinho #0A1B33 · Teal #00C3B2 · Aqua #4EE7E0 · Âmbar #FFB020
           Off White #F6F8FA · Grafite #1F2937
   Tipografia: Poppins (títulos) · Inter (texto e interface)
   Temas: claro (padrão) e escuro via body[data-theme="dark"]
   ========================================================================== */

:root {
    /* Marca */
    --mc-navy: #0A1B33;
    --mc-teal: #00C3B2;
    --mc-teal-strong: #00A091;
    --mc-aqua: #4EE7E0;
    --mc-amber: #FFB020;
    --mc-offwhite: #F6F8FA;
    --mc-graphite: #1F2937;

    /* Tokens semânticos — tema claro */
    --bg: #F6F8FA;
    --surface: #ffffff;
    --surface-2: #EEF3F7;
    --surface-3: #E2EAF1;
    --ink: #0A1B33;
    --muted: #5C6B80;
    --line: #DCE4EC;
    --line-strong: #C4D0DC;
    --accent: #00C3B2;
    --accent-strong: #00A091;
    --accent-contrast: #05263F;
    --accent-soft: rgba(0, 195, 178, .12);
    --accent-ring: rgba(0, 195, 178, .22);
    --warn: #FFB020;
    --warn-soft: rgba(255, 176, 32, .16);
    --warn-ink: #7A5200;
    --danger: #D64545;
    --danger-strong: #B23434;
    --danger-soft: rgba(214, 69, 69, .1);
    --page-bg: #ffffff;
    --select-arrow: #5C6B80;
    --backdrop: rgba(6, 17, 33, .45);

    --shadow-sm: 0 1px 2px rgba(10, 27, 51, .06);
    --shadow-md: 0 10px 28px rgba(10, 27, 51, .12);
    --shadow-lg: 0 24px 56px rgba(10, 27, 51, .18);
    --shadow: var(--shadow-lg);

    --font-body: "Inter", "Segoe UI", Arial, sans-serif;
    --font-display: "Poppins", "Inter", "Segoe UI", sans-serif;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --header-height: 128px;
    --touch-actions-height: 70px;
    --documents-sidebar-width: 332px;
    --editor-sidebar-width: 356px;
}

body[data-theme="dark"] {
    --bg: #081221;
    --surface: #102338;
    --surface-2: #0C1B2E;
    --surface-3: #1A3049;
    --ink: #F6F8FA;
    --muted: #93A5BC;
    --line: #1F3650;
    --line-strong: #2C4763;
    --accent: #00C3B2;
    --accent-strong: #4EE7E0;
    --accent-contrast: #05263F;
    --accent-soft: rgba(0, 195, 178, .16);
    --accent-ring: rgba(78, 231, 224, .24);
    --warn-soft: rgba(255, 176, 32, .14);
    --warn-ink: #FFCE73;
    --danger: #E05C5C;
    --danger-strong: #C24444;
    --danger-soft: rgba(224, 92, 92, .14);
    --page-bg: #101B2C;
    --select-arrow: #9DB0C7;
    --backdrop: rgba(2, 8, 16, .6);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .38);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, .5);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    color: var(--ink);
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 8% 8%, rgba(0, 195, 178, .1), transparent 28%),
        radial-gradient(circle at 88% 4%, rgba(78, 231, 224, .1), transparent 25%),
        linear-gradient(150deg, #F2F6F9, var(--bg) 44%, #F0F5F9);
    transition: background .35s ease, color .3s ease;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background:
        radial-gradient(circle at 24% 18%, rgba(0, 195, 178, .07), transparent 38%),
        radial-gradient(circle at 78% 72%, rgba(10, 27, 51, .05), transparent 34%);
}

body[data-theme="dark"] {
    background:
        radial-gradient(circle at 10% 12%, rgba(0, 195, 178, .1), transparent 30%),
        radial-gradient(circle at 86% 4%, rgba(78, 231, 224, .06), transparent 28%),
        linear-gradient(160deg, #060D18, var(--bg) 48%, #0A1B33);
}

body[data-theme="dark"]::before {
    background:
        radial-gradient(circle at 22% 16%, rgba(0, 195, 178, .08), transparent 36%),
        radial-gradient(circle at 74% 70%, rgba(78, 231, 224, .05), transparent 32%);
}

body.auth-locked {
    overflow: hidden;
}

body.auth-locked .app-header,
body.auth-locked .app-shell,
body.auth-locked #exportBoardMenu,
body.auth-locked #mobilePanelBackdrop,
body.auth-locked #orientationHint,
body.auth-locked #touchActions,
body.auth-locked #textFloatingToolbar,
body.auth-locked #textListMenu,
body.auth-locked #markerContextMenu,
body.auth-locked #itemContextMenu,
body.auth-locked #pageContextMenu,
body.auth-locked #pageTemplateMenu,
body.auth-locked #shapeInsertMenu,
body.auth-locked #tuningPopup,
body.auth-locked #tabTuningPopup,
body.auth-locked #documentManager {
    display: none !important;
}

/* ==========================================================================
   Marca
   ========================================================================== */

.brand-wordmark {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -.01em;
}

.brand-accent {
    color: var(--accent);
}

/* ==========================================================================
   Tela de autenticação
   ========================================================================== */

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(900px 640px at 18% 12%, rgba(0, 195, 178, .2), transparent 58%),
        radial-gradient(760px 560px at 86% 18%, rgba(78, 231, 224, .12), transparent 56%),
        linear-gradient(145deg, #071527, #0A1B33 48%, #0D2440);
}

.auth-page {
    width: min(504px, 100%);
    display: grid;
    gap: 20px;
    align-content: center;
}

.auth-logo-wrapper {
    text-align: center;
    display: grid;
    gap: 11px;
    justify-items: center;
}

.auth-logo-badge {
    width: 64px;
    height: 64px;
    display: block;
    border-radius: 18px;
    filter: drop-shadow(0 16px 30px rgba(0, 195, 178, .28));
}

.auth-logo-wrapper h1 {
    margin: 0;
    color: var(--mc-offwhite);
    font-size: 30px;
    line-height: 1;
}

.auth-logo-wrapper p {
    margin: 0;
    color: rgba(222, 234, 249, .8);
    font-size: 15px;
    line-height: 1.45;
}

.auth-card {
    width: 100%;
    display: grid;
    gap: 20px;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid rgba(78, 231, 224, .18);
    background: linear-gradient(180deg, rgba(246, 248, 250, .1), rgba(16, 35, 56, .32));
    backdrop-filter: blur(16px);
    box-shadow: 0 24px 58px rgba(3, 10, 20, .5);
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.auth-tabs button {
    min-height: 36px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 700;
}

.auth-tabs button.is-active {
    border-color: var(--accent);
    color: var(--accent-contrast);
    background: linear-gradient(90deg, var(--mc-teal), var(--mc-aqua));
}

.auth-form {
    display: grid;
    gap: 15px;
}

.auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.auth-input-group {
    position: relative;
}

.auth-input-group input {
    width: 100%;
    min-height: 52px;
    padding: 16px 14px;
    border-radius: 13px;
    border: 1px solid rgba(196, 208, 220, .34);
    background: rgba(246, 248, 250, .97);
    color: var(--mc-navy);
    font-size: 15px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.auth-input-group input:focus {
    border-color: var(--mc-teal);
    box-shadow: 0 0 0 4px rgba(0, 195, 178, .18);
    background: #ffffff;
}

.auth-input-group label {
    position: absolute;
    left: 14px;
    top: 14px;
    color: #5C6B80;
    font-size: 13px;
    pointer-events: none;
    transition: .2s ease;
    padding: 0 7px;
    border-radius: 8px;
}

.auth-input-group.has-value label,
.auth-input-group input:focus + label,
.auth-input-group input:valid + label {
    top: -10px;
    left: 12px;
    color: #05435C;
    font-size: 11px;
    background: #E4FAF7;
    border: 1px solid rgba(0, 160, 145, .4);
    box-shadow: 0 2px 6px rgba(4, 18, 34, .16);
}

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 30px;
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #3C5068;
    background: rgba(10, 27, 51, .08);
    box-shadow: none;
}

.auth-password-toggle:hover {
    transform: translateY(-50%);
    color: var(--mc-navy);
    background: rgba(10, 27, 51, .16);
    box-shadow: none;
}

.btn-login {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 13px;
    color: var(--accent-contrast);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(90deg, var(--mc-teal), var(--mc-aqua));
    box-shadow: 0 14px 30px rgba(0, 195, 178, .26);
}

.btn-login:hover {
    border: 0;
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(0, 195, 178, .34);
}

.auth-alt-actions {
    display: grid;
    gap: 9px;
    margin-top: 3px;
}

.auth-alt-actions p {
    margin: 0;
    display: grid;
    grid-template-columns: 160px 160px;
    justify-content: center;
    align-items: center;
    column-gap: 10px;
    font-size: 13px;
    line-height: 1.4;
    color: rgba(218, 233, 250, .95);
    font-weight: 500;
}

.auth-alt-label {
    text-align: right;
}

.auth-link-btn {
    min-height: 28px;
    min-width: 160px;
    width: 160px;
    padding: 3px 11px;
    margin-left: 0;
    border-radius: 999px;
    border: 1px solid rgba(78, 231, 224, .44);
    color: #C9F8F4;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 195, 178, .18);
    box-shadow: none;
}

.auth-link-btn:hover {
    transform: none;
    border-color: rgba(78, 231, 224, .8);
    background: rgba(0, 195, 178, .34);
    box-shadow: none;
}

.auth-alt-actions.is-center p {
    justify-content: center;
}

.auth-message {
    min-height: 24px;
    margin: 5px 0 0;
    color: #C9E4F8;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.auth-message.is-error {
    color: #FFC9B8;
}

/* ==========================================================================
   Controles base
   ========================================================================== */

button,
input,
select,
textarea {
    font: inherit;
    font-family: var(--font-body);
}

button {
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 0 14px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, color .16s ease;
}

button:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px var(--accent-ring);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

button:disabled:hover {
    border-color: var(--line-strong);
    transform: none;
    box-shadow: var(--shadow-sm);
}

button.primary {
    border-color: var(--accent-strong);
    color: var(--accent-contrast);
    background: linear-gradient(180deg, var(--mc-teal), var(--mc-teal-strong));
}

button.primary:hover {
    border-color: var(--mc-teal);
    background: linear-gradient(180deg, var(--mc-aqua), var(--mc-teal));
}

button.danger {
    border-color: var(--danger-strong);
    color: #ffffff;
    background: linear-gradient(180deg, var(--danger), var(--danger-strong));
}

button.danger:hover {
    border-color: var(--danger);
    box-shadow: 0 8px 18px var(--danger-soft);
}

/* ==========================================================================
   Cabeçalho
   ========================================================================== */

.app-header {
    position: sticky;
    top: 0;
    z-index: 45;
    display: grid;
    gap: 8px;
    padding: 10px 12px 9px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(18px) saturate(115%);
    box-shadow: var(--shadow-sm);
    animation: slideDown .55s cubic-bezier(.22,.88,.28,1) both;
}

.header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}

.theme-toggle,
.mobile-menu-toggle {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border-color: var(--line-strong);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
    background: var(--surface);
}

.mobile-menu-toggle {
    display: none;
}

.theme-toggle:hover {
    box-shadow: 0 8px 16px var(--accent-ring);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.brand-mark {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    box-shadow: 0 10px 20px rgba(10, 27, 51, .2);
}

.app-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -.01em;
    color: var(--ink);
}

.app-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.header-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.header-actions {
    display: grid;
    grid-template-columns: minmax(420px, 1.18fr) minmax(250px, .74fr) minmax(320px, .9fr);
    gap: 7px;
    margin-top: 0;
    padding-top: 7px;
    border-top: 1px solid var(--line);
}

.action-group {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    opacity: 0;
    transform: translateY(12px);
    animation: riseIn .5s cubic-bezier(.22,.84,.24,1) forwards;
}

.action-group:nth-child(1) { animation-delay: .06s; }
.action-group:nth-child(2) { animation-delay: .16s; }
.action-group:nth-child(3) { animation-delay: .26s; }

.action-group__label {
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.action-group__row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.header-actions button {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}

.header-actions #addFretboardBtn {
    border-color: var(--accent-strong);
    color: var(--accent-contrast);
    background: linear-gradient(180deg, var(--mc-teal), var(--mc-teal-strong));
}

.header-actions #addChordFretboardBtn {
    border-color: var(--mc-navy);
    color: var(--mc-offwhite);
    background: linear-gradient(180deg, #16304F, var(--mc-navy));
}

body[data-theme="dark"] .header-actions #addChordFretboardBtn {
    border-color: var(--line-strong);
    background: linear-gradient(180deg, #2A4A75, #1B3355);
}

.header-actions #addTablatureBtn {
    border-color: #E09400;
    color: #4A3100;
    background: linear-gradient(180deg, #FFC14D, var(--mc-amber));
}

body[data-theme="dark"] .header-actions #addTablatureBtn {
    border-color: #C98600;
    background: linear-gradient(180deg, var(--mc-amber), #E09400);
}

.header-actions #addTextBtn,
.header-actions #addShapeBtn,
.header-actions #addPageBtn {
    border-color: var(--line-strong);
    color: var(--ink);
    background: var(--surface);
}

.header-actions #deleteItemBtn {
    border-color: color-mix(in srgb, var(--danger) 46%, transparent);
    color: var(--danger-strong);
    background: var(--danger-soft);
}

body[data-theme="dark"] .header-actions #deleteItemBtn {
    color: #FFB3B3;
}

.header-actions #addFretboardBtn:hover {
    filter: brightness(1.06);
    box-shadow: 0 8px 18px var(--accent-ring);
}

.header-actions #addChordFretboardBtn:hover {
    filter: brightness(1.14);
    box-shadow: 0 8px 18px rgba(10, 27, 51, .26);
}

.header-actions #addTablatureBtn:hover {
    filter: brightness(1.05);
    border-color: var(--mc-amber);
    box-shadow: 0 8px 18px rgba(255, 176, 32, .3);
}

.header-actions #addTextBtn:hover,
.header-actions #addShapeBtn:hover,
.header-actions #addPageBtn:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 18px var(--accent-ring);
}

.header-actions #deleteItemBtn:hover {
    border-color: var(--danger);
    box-shadow: 0 8px 18px var(--danger-soft);
}

.doc-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease, color .18s ease, background .18s ease;
}

.doc-status.is-dirty {
    border-color: color-mix(in srgb, var(--warn) 62%, transparent);
    color: var(--warn-ink);
    background: var(--warn-soft);
    box-shadow: 0 0 0 3px rgba(255, 176, 32, .14);
}

.language-switch {
    display: flex;
    align-items: center;
    gap: 4px;
}

.language-button {
    display: grid;
    place-items: center;
    width: 34px;
    min-height: 28px;
    padding: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.language-button.is-active {
    border-color: var(--accent);
    color: var(--accent-strong);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.manual-link {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: var(--surface);
    transition: border-color .16s ease, box-shadow .16s ease;
}

.manual-link:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 16px var(--accent-ring);
}

.user-display {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    background: var(--surface);
}

#logoutBtn {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

/* ==========================================================================
   Estrutura principal
   ========================================================================== */

.app-shell {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    height: calc(100vh - var(--header-height));
    height: calc(100svh - var(--header-height));
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 1081px) {
    .panel {
        position: fixed;
        top: var(--header-height);
        left: 0;
        z-index: 40;
        align-self: start;
        width: min(var(--editor-sidebar-width), calc(100vw - 16px));
        height: calc(100vh - var(--header-height));
        height: calc(100svh - var(--header-height));
        overflow: auto;
        padding: 14px;
        border-right: 1px solid var(--line);
        background: color-mix(in srgb, var(--surface-2) 82%, transparent);
        backdrop-filter: blur(14px);
        box-shadow: 18px 0 34px rgba(10, 27, 51, .1);
        transform: translateX(calc(-100% - 18px));
        opacity: 0;
        pointer-events: none;
        transition: transform .28s cubic-bezier(.22,.84,.24,1), opacity .28s cubic-bezier(.22,.84,.24,1);
    }

    body.left-panel-open .panel {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
        animation: editorPanelSlideIn .28s cubic-bezier(.22,.84,.24,1) both;
    }
}

.panel section {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    margin: 0 0 13px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--ink);
}

.subsection-title {
    margin: 14px 0 8px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--ink);
}

.hint {
    margin: -4px 0 12px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

label {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    min-height: 37px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    padding: 7px 9px;
    color: var(--ink);
    background: var(--surface);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

select {
    appearance: none;
    padding-right: 32px;
    white-space: nowrap;
    text-overflow: ellipsis;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--select-arrow) 50%),
        linear-gradient(135deg, var(--select-arrow) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% + 1px),
        calc(100% - 11px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

input[type="color"] {
    min-height: 38px;
    padding: 4px;
}

/* ==========================================================================
   Paleta de cores livre (conteúdo do usuário — sem restrição de cor)
   ========================================================================== */

.color-input-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    align-items: stretch;
    gap: 6px;
    width: 100%;
}

.color-input-shell input[type="color"] {
    width: 100%;
    min-width: 0;
}

.color-memory-button {
    display: grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 9px;
}

.color-memory-icon {
    display: grid;
    grid-template-columns: repeat(2, 8px);
    grid-auto-rows: 8px;
    gap: 2px;
}

.color-memory-icon span {
    display: block;
    border-radius: 3px;
    border: 1px solid rgba(10, 27, 51, .18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .38);
}

.color-memory-icon span:nth-child(1) { background: var(--memory-color-1, #111111); }
.color-memory-icon span:nth-child(2) { background: var(--memory-color-2, #ffffff); }
.color-memory-icon span:nth-child(3) { background: var(--memory-color-3, #0f7a7a); }
.color-memory-icon span:nth-child(4) { background: var(--memory-color-4, #ffffff); }

.color-palette {
    position: fixed;
    z-index: 76;
    display: grid;
    gap: 6px;
    width: 244px;
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.color-palette-group {
    display: grid;
    gap: 4px;
}

.color-palette-free {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    background: var(--surface-2);
}

.color-palette-custom-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.color-palette-preview {
    display: block;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(10, 27, 51, .24);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .42);
}

.color-palette-preview.is-invalid {
    border-color: var(--danger);
}

.color-palette-free input[type="text"] {
    width: 100%;
    min-height: 34px;
    margin: 0;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.color-palette-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.color-palette-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-swatch {
    width: 20px;
    min-width: 20px;
    min-height: 20px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid rgba(10, 27, 51, .24);
    background: linear-gradient(135deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0)), var(--swatch-color);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .42);
}

.color-swatch:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 16px rgba(10, 27, 51, .12), inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.color-swatch.is-active {
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 2px var(--accent-ring), inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.color-swatch:disabled {
    opacity: .45;
    transform: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3);
    cursor: not-allowed;
}

body[data-theme="dark"] .color-palette-preview,
body[data-theme="dark"] .color-swatch,
body[data-theme="dark"] .color-memory-icon span {
    border-color: rgba(246, 248, 250, .22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.color-palette-popover.is-compact {
    width: 172px;
    gap: 3px;
    padding: 8px;
}

.color-palette-popover.is-compact .color-palette-free {
    gap: 5px;
    padding: 6px;
    font-size: 8px;
}

.color-palette-popover.is-compact .color-palette-custom-row {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 5px;
}

.color-palette-popover.is-compact .color-palette-preview {
    width: 24px;
    height: 24px;
    border-radius: 6px;
}

.color-palette-popover.is-compact .color-palette-free input[type="text"] {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 11px;
}

.color-palette-popover.is-compact .color-palette-label {
    font-size: 8px;
}

.color-palette-popover.is-compact .color-palette-swatches {
    gap: 3px;
}

.color-palette-popover.is-compact .color-swatch {
    width: 14px;
    min-width: 14px;
    min-height: 14px;
    border-radius: 4px;
}

.text-floating-toolbar .color-input-shell {
    grid-template-columns: 30px 18px;
    gap: 2px;
    width: 50px;
}

.text-floating-toolbar .color-memory-button {
    width: 18px;
    min-width: 18px;
    min-height: 27px;
    border-radius: 6px;
}

.text-floating-toolbar .color-memory-icon {
    grid-template-columns: repeat(2, 5px);
    grid-auto-rows: 5px;
    gap: 1px;
}

.text-floating-toolbar .color-memory-icon span {
    border-radius: 2px;
}

input[type="file"] {
    padding: 7px;
}

/* ==========================================================================
   Campos e utilitários do painel
   ========================================================================== */

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tuning-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
}

.tuning-cell {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.tuning-cell span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.tuning-cell input {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 12px;
}

.tuning-spinner {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 6px;
}

.tuning-step-btn {
    min-height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.tuning-note-display {
    min-height: 32px;
    text-align: center;
    font-weight: 700;
    letter-spacing: .03em;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
    min-height: auto;
    accent-color: var(--accent);
}

#editorPanel > section.is-hidden {
    display: none;
}

.panel.panel-empty {
    min-height: calc(100vh - var(--header-height));
    background:
        linear-gradient(rgba(92, 107, 128, .09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(92, 107, 128, .09) 1px, transparent 1px);
    background-size: 28px 28px;
}

.marker-editor.is-disabled,
.text-editor.is-disabled,
.shape-editor.is-disabled,
.tablature-editor.is-disabled {
    opacity: .55;
}

.marker-editor.is-hidden,
.text-editor.is-hidden,
.shape-editor.is-hidden,
.tablature-editor.is-hidden {
    display: none;
}

.text-editor.is-disabled button,
.text-editor.is-disabled input,
.text-editor.is-disabled select,
.shape-editor.is-disabled button,
.shape-editor.is-disabled input,
.shape-editor.is-disabled select,
.tablature-editor.is-disabled button,
.tablature-editor.is-disabled input,
.tablature-editor.is-disabled select {
    pointer-events: none;
}

.tab-display-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 8px;
}

.tab-rhythm-status {
    min-height: 18px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}

.tab-rhythm-status.is-invalid {
    color: var(--danger);
}

/* ==========================================================================
   Área de trabalho
   ========================================================================== */

.workspace-wrap {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background:
        linear-gradient(rgba(92, 107, 128, .09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(92, 107, 128, .09) 1px, transparent 1px);
    background-size: 28px 28px;
    transition: padding .32s cubic-bezier(.22,.84,.24,1);
}

body.documents-open .workspace-wrap {
    padding-right: calc(16px + min(var(--documents-sidebar-width), calc(100vw - 16px)));
}

body.left-panel-open .workspace-wrap {
    padding-left: calc(16px + min(var(--editor-sidebar-width), calc(100vw - 16px)));
}

.workspace-ruler {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.workspace-chrome {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 16px 8px;
    pointer-events: none;
}

.workspace-chrome > * {
    pointer-events: auto;
}

.zoom-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 5px 6px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}

.zoom-button,
.zoom-fit-button {
    display: inline-grid;
    place-items: center;
    height: 30px;
    min-height: 30px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: none;
}

.zoom-button {
    width: 30px;
    padding: 0;
    font-size: 17px;
    line-height: 1;
}

.zoom-fit-button {
    padding: 0 11px;
}

.zoom-range {
    width: 128px;
    min-height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    accent-color: var(--accent);
}

.zoom-value-field {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 70px;
    height: 30px;
    min-height: 30px;
    margin: 0;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--ink);
    background: var(--surface-2);
    box-shadow: none;
    line-height: 1;
    align-self: center;
}

.zoom-value-field span {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.zoom-value {
    flex: 0 0 34px;
    width: 34px;
    min-width: 0;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border: 0;
    color: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: right;
    line-height: 24px;
    background: transparent;
    box-shadow: none;
    appearance: textfield;
}

.zoom-value::-webkit-outer-spin-button,
.zoom-value::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}

.zoom-value:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-ring);
}

.page-viewport {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 4px 24px 28px;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
}

.page-scaler {
    position: relative;
    width: 794px;
    min-height: 0;
    margin: 0 auto;
}

.pages-stack {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 794px;
    transform-origin: top left;
}

.page-frame {
    display: grid;
    gap: 8px;
}

.page-frame-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0;
    margin-bottom: 12px;
}

.page-orientation-select {
    width: 150px;
    min-height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0 34px 0 14px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    background:
        linear-gradient(45deg, transparent 50%, var(--select-arrow) 50%),
        linear-gradient(135deg, var(--select-arrow) 50%, transparent 50%),
        linear-gradient(180deg, var(--surface), var(--surface-2));
    background-position:
        calc(100% - 16px) calc(50% + 1px),
        calc(100% - 11px) calc(50% + 1px),
        0 0;
    background-size: 5px 5px, 5px 5px, 100% 100%;
    background-repeat: no-repeat;
    box-shadow: var(--shadow-sm);
}

.page-add-button {
    justify-self: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--accent-strong);
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

body[data-theme="dark"] .page-add-button {
    color: var(--mc-aqua);
}

.page-add-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 10px 20px var(--accent-ring);
}

.page-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.a4-page {
    position: relative;
    width: 794px;
    min-width: 794px;
    height: 1123px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: var(--page-bg);
    box-shadow: var(--shadow);
    transform-origin: top center;
}

.a4-page.active-page {
    outline: 3px solid var(--accent-ring);
    outline-offset: 5px;
}

.a4-page.drop-target-page {
    outline: 3px solid rgba(78, 231, 224, .5);
    outline-offset: 7px;
    box-shadow: var(--shadow), 0 0 0 8px rgba(78, 231, 224, .1);
}

.page-center-guides {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: opacity .12s ease;
}

.page-center-guides.is-visible {
    opacity: 1;
}

.page-center-guide {
    position: absolute;
    opacity: 0;
    box-shadow: none;
    transition: opacity .12s ease, box-shadow .12s ease, background .12s ease;
}

.page-center-guide.is-active {
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .62), 0 0 18px rgba(0, 195, 178, .34);
}

.page-center-guide-vertical {
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(
        180deg,
        rgba(0, 195, 178, .34) 0 12px,
        rgba(0, 195, 178, .12) 12px 24px
    );
}

.page-center-guide-vertical.is-active {
    background: repeating-linear-gradient(
        180deg,
        rgba(0, 195, 178, .98) 0 14px,
        rgba(0, 195, 178, .42) 14px 28px
    );
}

.page-center-guide-horizontal {
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    transform: translateY(-50%);
    background: repeating-linear-gradient(
        90deg,
        rgba(0, 195, 178, .34) 0 12px,
        rgba(0, 195, 178, .12) 12px 24px
    );
}

.page-center-guide-horizontal.is-active {
    background: repeating-linear-gradient(
        90deg,
        rgba(0, 195, 178, .98) 0 14px,
        rgba(0, 195, 178, .42) 14px 28px
    );
}

/* ==========================================================================
   Itens da página
   ========================================================================== */

.page-item {
    position: absolute;
    border: 1px solid transparent;
    border-radius: var(--radius);
    user-select: none;
    transition: box-shadow .16s ease, border-color .16s ease;
}

.page-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Itens de texto controlam o próprio box-shadow (borda + seleção) inline */
.page-item.text-item.selected {
    box-shadow: none;
}

.fretboard-item {
    width: 680px;
    height: 300px;
    background: transparent;
    transform-origin: center center;
}

.fretboard-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: var(--radius);
}

.tablature-item {
    width: 680px;
    height: 230px;
    padding: 12px;
    background: transparent;
    cursor: grab;
}

.tablature-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 10px;
    cursor: crosshair;
    user-select: none;
}

.shape-item {
    width: 220px;
    height: 140px;
    background: transparent;
    cursor: grab;
}

.shape-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 4px;
    user-select: none;
}

.tab-inline-editor {
    position: fixed;
    z-index: 125;
    width: 68px;
    min-height: 34px;
    padding: 2px 6px;
    border: 2px solid var(--accent);
    border-radius: 7px;
    color: var(--mc-graphite);
    background: #ffffff;
    font-family: "Roboto Mono", "Courier New", Consolas, monospace;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.tab-inline-editor-header {
    font-family: var(--font-body);
    font-size: 14px;
}

.fretboard-inline-editor {
    position: fixed;
    z-index: 125;
    min-height: 28px;
    padding: 2px 10px;
    border: 2px solid var(--accent);
    border-radius: 7px;
    color: var(--mc-graphite);
    background: #ffffff;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.marker-label-editor {
    min-height: unset;
    border-radius: 50%;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-item {
    width: 280px;
    min-height: 70px;
    padding: 12px;
    background: transparent;
    cursor: grab;
    overflow: visible;
    box-sizing: border-box;
}

/* Wrapper de forma — borda/fundo/raio ficam no próprio .text-item */
.text-item[data-text-shape]:not([data-text-shape="none"]) {
    overflow: visible;
}

/* SVG de cauda injetado pelo JS */
.text-shape-tail {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.rich-text-editor {
    width: 100%;
    height: 100%;
    min-height: 54px;
    overflow: auto;
    border: 1px dashed var(--line-strong);
    color: #16181c;
    background: transparent;
    outline: none;
    font-style: normal;
    font-weight: 400;
    line-height: 1.15;
    user-select: text;
    white-space: normal;
    cursor: text;
    position: relative;
    z-index: 0;
}

.rich-text-editor:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.rich-text-editor ul,
.rich-text-editor ol {
    margin: 0 0 .35em 1.55em;
    padding: 0 0 0 .25em;
}

.rich-text-editor p {
    margin: 0 0 .5em;
}

.rich-text-editor h1,
.rich-text-editor h2 {
    margin: 0 0 .35em;
    font-weight: 700;
    line-height: 1.12;
}

.rich-text-editor h1 {
    font-size: 1.7em;
}

.rich-text-editor h2 {
    font-size: 1.32em;
}

.rich-text-editor blockquote {
    margin: .2em 0 .45em 1em;
    padding-left: .75em;
    border-left: 3px solid #c4cedb;
    color: #4f5c6d;
}

/* ==========================================================================
   Painel de texto
   ========================================================================== */

#textEditor {
    border-color: var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

#textEditor .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

#textEditor label {
    margin-bottom: 0;
}

#textEditor select,
#textEditor input {
    min-height: 34px;
}

.text-tool-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-2);
}

.tool-row-line {
    display: flex;
    align-items: center;
    width: 100%;
}

.tool-row-line .tool-group {
    flex: 1;
    gap: 3px;
    padding-right: 0;
    margin-right: 0;
    border-right: 0;
}

.tool-row-line .tool-group:not(:last-child) {
    padding-right: 6px;
    margin-right: 6px;
    border-right: 1px solid var(--line-strong);
}

.tool-row-line .tool-group-clear {
    flex: none;
}

.tool-row-line .tool-group button,
.tool-row-line .tool-group .list-picker-button {
    flex: 1;
    width: auto;
    min-width: 0;
}

.tool-group,
.floating-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-right: 8px;
    margin-right: 2px;
    border-right: 1px solid var(--line-strong);
}

.tool-group:last-child,
.floating-group:last-child {
    padding-right: 0;
    margin-right: 0;
    border-right: 0;
}

.text-tool-row button,
.text-floating-toolbar button:not(.list-picker-button) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: var(--ink);
    background: var(--surface);
    font-size: 12px;
    box-shadow: none;
}

.text-tool-row button:hover,
.text-floating-toolbar button:not(.list-picker-button):hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.text-tool-row button:focus-visible,
.text-floating-toolbar button:not(.list-picker-button):focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.tool-group-clear button {
    width: 52px;
    min-width: 52px;
    font-size: 12px;
    font-weight: 700;
}

.list-picker-button {
    display: inline-grid;
    grid-template-columns: minmax(0, 1fr) 19px;
    align-items: stretch;
    min-width: 50px;
    min-height: 32px;
    padding: 0;
    overflow: hidden;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: none;
}

.list-picker-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.list-picker-button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.list-picker-main,
.list-picker-caret {
    display: grid;
    place-items: center;
    min-height: 32px;
}

.list-picker-main {
    padding: 0 4px 0 5px;
}

.list-picker-caret {
    position: relative;
    background: var(--surface-2);
}

.list-picker-caret::before {
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 1px;
    background: var(--line-strong);
    content: "";
}

.list-picker-button:hover .list-picker-caret {
    background: var(--surface-3);
}

.list-icon {
    position: relative;
    display: block;
    flex: 0 0 auto;
    width: 24px;
    height: 17px;
    margin-left: 0;
}

.list-icon::before,
.list-icon::after,
.list-icon span,
.list-icon i {
    position: absolute;
    content: "";
}

.list-icon::before,
.list-icon::after,
.list-icon span {
    left: 10px;
    width: 13px;
    height: 1.8px;
    border-radius: 999px;
    background: var(--muted);
}

.list-icon::before { top: 1px; }
.list-icon span { top: 7px; }
.list-icon::after { top: 13px; }

.bullet-list-icon i,
.bullet-list-icon i::before,
.bullet-list-icon i::after {
    position: absolute;
    left: 0;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    content: "";
}

.bullet-list-icon i { top: 0; }
.bullet-list-icon i::before { top: 6px; }
.bullet-list-icon i::after { top: 12px; }

.number-list-icon i,
.number-list-icon i::before,
.number-list-icon i::after {
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 7px;
    font-weight: 800;
    line-height: 1;
    background: transparent;
}

.number-list-icon i {
    top: 0;
    left: 0;
    font-style: normal;
}
.number-list-icon i::before { top: 6px; content: "2"; }
.number-list-icon i::after { top: 12px; content: "3"; }

.chevron {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    margin-top: 1px;
    border-top: 5px solid var(--muted);
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

.text-list-menu {
    position: fixed;
    z-index: 70;
    display: grid;
    gap: 3px;
    width: 220px;
    padding: 7px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.list-menu-option {
    display: grid;
    grid-template-columns: 26px 1fr;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    box-shadow: none;
}

.list-menu-option:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.list-symbols {
    display: grid;
    gap: 3px;
}

.list-symbols b {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.list-lines {
    display: grid;
    gap: 6px;
}

.list-lines i {
    display: block;
    width: 108px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
}

/* Ícones de alinhamento */

.align-icon {
    position: relative;
    color: var(--ink);
}

.align-icon span,
.align-icon::before,
.align-icon::after,
.align-icon span::before,
.align-icon span::after {
    position: absolute;
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    content: "";
}

.align-icon span {
    inset: 0;
    background: transparent;
}

.align-icon::before { top: 8px; }
.align-icon span::before { top: 14px; }
.align-icon span::after { top: 20px; }
.align-icon::after { top: 26px; }

.align-left::before,
.align-left::after,
.align-left span::before {
    left: calc(50% - 10px);
    width: 20px;
}

.align-left span::after {
    left: calc(50% - 10px);
    width: 13px;
}

.align-center::before,
.align-center::after,
.align-center span::before {
    left: calc(50% - 10px);
    width: 20px;
}

.align-center span::after {
    left: calc(50% - 6px);
    width: 12px;
}

.align-right::before,
.align-right::after,
.align-right span::before {
    right: calc(50% - 10px);
    width: 20px;
}

.align-right span::after {
    right: calc(50% - 10px);
    width: 13px;
}

.align-justify::before,
.align-justify::after,
.align-justify span::before,
.align-justify span::after {
    left: calc(50% - 10px);
    width: 20px;
}

/* ==========================================================================
   Barra flutuante de texto
   ========================================================================== */

.text-floating-toolbar {
    position: fixed;
    z-index: 55;
    display: flex;
    align-items: center;
    max-width: min(760px, calc(100vw - 20px));
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
}

.floating-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
    width: 100%;
    overflow: visible;
    padding-bottom: 0;
}

.text-floating-toolbar select {
    min-height: 27px;
    border-color: var(--line-strong);
    background-color: var(--surface);
    box-shadow: none;
    padding: 2px 6px;
    font-size: 11px;
}

#floatTextBlockInput {
    width: 82px;
}

#floatTextFontFamilyInput {
    width: 90px;
}

#floatTextLineHeightInput {
    width: 50px;
}

.text-floating-toolbar select[aria-label="Espacamento"],
.text-floating-toolbar select[aria-label="Marcadores"],
.text-floating-toolbar select[aria-label="Numeracao"] {
    width: 58px;
    text-align: center;
}

.text-floating-toolbar input[type="number"] {
    width: 50px;
    min-height: 27px;
    padding: 2px 6px;
    font-size: 11px;
    border-color: var(--line-strong);
    background: var(--surface);
}

.text-floating-toolbar input[type="color"] {
    width: 30px;
    min-height: 27px;
    padding: 2px;
    border-color: var(--line-strong);
    background: var(--surface);
}

.text-floating-toolbar .list-picker-button {
    width: 40px;
    min-width: 40px;
    min-height: 27px;
}

.text-floating-toolbar .list-picker-main,
.text-floating-toolbar .list-picker-caret {
    min-height: 27px;
}

.text-floating-toolbar button:not(.list-picker-button) {
    width: 26px;
    min-width: 26px;
    min-height: 26px;
}

.text-floating-toolbar .floating-group-align .align-icon::before { top: 5px; }
.text-floating-toolbar .floating-group-align .align-icon span::before { top: 9px; }
.text-floating-toolbar .floating-group-align .align-icon span::after { top: 13px; }
.text-floating-toolbar .floating-group-align .align-icon::after { top: 17px; }

.text-floating-toolbar .floating-group-align .align-left::before,
.text-floating-toolbar .floating-group-align .align-left::after,
.text-floating-toolbar .floating-group-align .align-left span::before {
    left: 5px;
    width: 15px;
}

.text-floating-toolbar .floating-group-align .align-left span::after {
    left: 5px;
    width: 11px;
}

.text-floating-toolbar .floating-group-align .align-center::before,
.text-floating-toolbar .floating-group-align .align-center::after,
.text-floating-toolbar .floating-group-align .align-center span::before {
    left: 4px;
    width: 16px;
}

.text-floating-toolbar .floating-group-align .align-center span::after {
    left: 7px;
    width: 11px;
}

.text-floating-toolbar .floating-group-align .align-right::before,
.text-floating-toolbar .floating-group-align .align-right::after,
.text-floating-toolbar .floating-group-align .align-right span::before {
    right: 5px;
    width: 15px;
}

.text-floating-toolbar .floating-group-align .align-right span::after {
    right: 5px;
    width: 11px;
}

.text-floating-toolbar .floating-group-align .align-justify::before,
.text-floating-toolbar .floating-group-align .align-justify::after,
.text-floating-toolbar .floating-group-align .align-justify span::before,
.text-floating-toolbar .floating-group-align .align-justify span::after {
    left: 5px;
    width: 15px;
}

.floating-align-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    padding-top: 0;
    margin-top: 0;
    border-top: 0;
}

/* ==========================================================================
   Alças de redimensionamento e rotação
   ========================================================================== */

.resize-handle {
    position: absolute;
    z-index: 4;
    opacity: 0;
    transition: opacity .14s ease;
}

.page-item.selected .resize-handle {
    opacity: 1;
}

.page-item:not(.selected) .resize-handle,
.page-item:not(.selected) .rotate-handle {
    pointer-events: none;
}

.resize-n,
.resize-s {
    left: 14px;
    right: 14px;
    height: 10px;
}

.resize-e,
.resize-w {
    top: 14px;
    bottom: 14px;
    width: 10px;
}

.resize-n {
    top: -6px;
    cursor: ns-resize;
}

.resize-s {
    bottom: -6px;
    cursor: ns-resize;
}

.resize-e {
    right: -6px;
    cursor: ew-resize;
}

.resize-w {
    left: -6px;
    cursor: ew-resize;
}

.resize-ne,
.resize-se,
.resize-sw,
.resize-nw {
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 5px;
    background: var(--accent);
    box-shadow: 0 6px 14px rgba(0, 195, 178, .3);
}

.resize-ne {
    top: -7px;
    right: -7px;
    cursor: nesw-resize;
}

.resize-se {
    right: -7px;
    bottom: -7px;
    cursor: nwse-resize;
}

.resize-sw {
    left: -7px;
    bottom: -7px;
    cursor: nesw-resize;
}

.resize-nw {
    top: -7px;
    left: -7px;
    cursor: nwse-resize;
}

.rotate-handle {
    position: absolute;
    left: 50%;
    bottom: -43px;
    z-index: 5;
    display: inline-grid;
    place-items: center;
    width: 58px;
    height: 30px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    color: var(--accent-contrast);
    background: linear-gradient(180deg, var(--mc-teal), var(--mc-teal-strong));
    cursor: pointer;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity .14s ease, transform .14s ease, box-shadow .14s ease;
    box-shadow: 0 8px 18px rgba(0, 195, 178, .32);
}

.page-item.selected .rotate-handle {
    opacity: 1;
}

.rotate-handle:hover {
    transform: translateX(-50%) translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 195, 178, .4);
}

.orientation-icon {
    position: relative;
    display: block;
    width: 34px;
    height: 18px;
}

.orientation-icon span {
    position: absolute;
    border: 2px solid currentColor;
    border-radius: 4px;
    opacity: .68;
    transition: opacity .14s ease, background .14s ease;
}

.orientation-icon-horizontal {
    left: 0;
    top: 4px;
    width: 18px;
    height: 10px;
}

.orientation-icon-vertical {
    right: 0;
    top: 1px;
    width: 10px;
    height: 16px;
}

.fretboard-item:not(.is-vertical) .orientation-icon-horizontal,
.fretboard-item.is-vertical .orientation-icon-vertical {
    background: rgba(255, 255, 255, .35);
    opacity: 1;
}

.fretboard-orientation-buttons button.is-active {
    color: var(--accent-contrast);
    border-color: var(--accent-strong);
    background: var(--accent);
}

/* ==========================================================================
   Popups e menus de contexto
   ========================================================================== */

.marker-context-menu,
.floating-popup {
    position: fixed;
    z-index: 50;
    width: 240px;
    padding: 12px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
}

.marker-context-menu {
    display: grid;
    gap: 10px;
}

.marker-context-menu .field-grid {
    align-items: start;
}

.marker-context-menu .field-grid > label {
    align-self: start;
    min-width: 0;
}

.mobile-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 46;
    background: var(--backdrop);
    backdrop-filter: blur(2px);
}

.touch-actions {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    z-index: 58;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.orientation-hint {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(var(--touch-actions-height) + 20px + env(safe-area-inset-bottom, 0px));
    z-index: 57;
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink);
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}

.orientation-hint strong {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.orientation-hint p {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
}

.touch-actions button {
    min-height: 42px;
    padding: 0 9px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

body.is-touch-device .marker-context-menu,
body.is-touch-device .floating-popup,
body.is-touch-device .color-palette-popover {
    left: 10px !important;
    right: 10px;
    top: auto !important;
    bottom: calc(var(--touch-actions-height) + 16px);
    width: auto;
    max-height: min(60vh, 440px);
    overflow: auto;
}

/* ==========================================================================
   Documentos
   ========================================================================== */

.document-manager {
    position: fixed;
    inset: 0;
    z-index: 70;
}

.documents-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    z-index: 40;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 10px;
    width: min(var(--documents-sidebar-width), calc(100vw - 16px));
    height: calc(100vh - var(--header-height));
    height: calc(100svh - var(--header-height));
    padding: 12px;
    border-left: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: -16px 0 36px rgba(10, 27, 51, .1);
    backdrop-filter: blur(16px);
    animation: documentsSlideIn .28s cubic-bezier(.22,.84,.24,1) both;
}

body[data-theme="dark"] .documents-sidebar {
    box-shadow: -18px 0 34px rgba(0, 0, 0, .5);
}

.documents-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.documents-sidebar__head strong {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.documents-sidebar__toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.documents-sidebar__head button,
.documents-sidebar__toolbar button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.document-manager__hint {
    margin: -2px 0 8px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.document-manager__list {
    display: grid;
    gap: 8px;
    align-content: start;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 4px 10px 2px;
}

.document-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.document-card__rename {
    justify-self: start;
    min-height: 28px;
    margin-top: 4px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: none;
}

.document-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: none;
}

.document-card.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.document-card__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.document-card strong {
    font-size: 13px;
    color: var(--ink);
}

.document-card__meta {
    color: var(--muted);
    font-size: 11px;
}

.document-card__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    color: var(--accent-strong);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--accent-soft);
}

body[data-theme="dark"] .document-card__badge {
    color: var(--mc-aqua);
}

.document-manager__empty {
    padding: 20px 16px;
    border: 1px dashed var(--line-strong);
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
    background: var(--surface-2);
}

/* ==========================================================================
   Diálogos de sistema
   ========================================================================== */

.system-dialog {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 18px;
    background: var(--backdrop);
    backdrop-filter: blur(5px);
    animation: dialogFadeIn .18s ease both;
}

.system-dialog__panel {
    width: min(430px, 100%);
    display: grid;
    gap: 13px;
    padding: 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: dialogPanelIn .22s cubic-bezier(.22,.84,.24,1) both;
}

.system-dialog__panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

.system-dialog__panel p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.system-dialog__field {
    margin: 2px 0 0;
}

.system-dialog__field input {
    min-height: 44px;
}

.system-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 3px;
}

.system-dialog__actions button {
    min-width: 96px;
}

/* ==========================================================================
   Menus flutuantes de inserção
   ========================================================================== */

.floating-popup {
    width: 260px;
}

.export-board-menu,
.page-template-menu,
.shape-insert-menu {
    z-index: 64;
    display: grid;
    gap: 8px;
    width: 280px;
}

.page-template-menu {
    width: 300px;
}

.export-board-menu button,
.page-template-menu button,
.shape-insert-menu button {
    width: 100%;
    min-height: 38px;
    text-align: left;
}

body.is-touch-device .export-board-menu,
body.is-touch-device .page-template-menu,
body.is-touch-device .shape-insert-menu {
    left: 10px !important;
    right: 10px;
    top: auto !important;
    bottom: calc(var(--touch-actions-height) + 16px + env(safe-area-inset-bottom, 0px));
    width: auto;
}

.popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.popup-head strong {
    font-family: var(--font-display);
    font-weight: 600;
}

.popup-head button {
    width: auto;
    min-height: 30px;
    padding: 0 9px;
}

.marker-context-menu label {
    margin-bottom: 0;
}

.marker-context-menu button:not(.color-swatch) {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    line-height: 1.2;
    white-space: normal;
}

.marker-context-menu button:disabled {
    opacity: .52;
    color: var(--muted);
    border-color: var(--line);
    background: var(--surface-2);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.marker-context-menu button:disabled:hover {
    border-color: var(--line);
    background: var(--surface-2);
    box-shadow: none;
}

.context-action-copy {
    color: var(--accent-strong);
    border-color: color-mix(in srgb, var(--accent) 42%, transparent);
    background: var(--accent-soft);
}

.context-action-copy:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}

.context-action-paste {
    color: var(--accent-strong);
    border-color: color-mix(in srgb, var(--accent) 42%, transparent);
    background: var(--accent-soft);
}

.context-action-paste:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}

body[data-theme="dark"] .context-action-copy,
body[data-theme="dark"] .context-action-paste {
    color: var(--mc-aqua);
}

.marker-context-menu .context-action-copy:disabled,
.marker-context-menu .context-action-paste:disabled {
    opacity: .52;
    color: var(--muted);
    border-color: var(--line);
    background: var(--surface-2);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.marker-context-menu .context-action-copy:disabled:hover,
.marker-context-menu .context-action-paste:disabled:hover {
    border-color: var(--line);
    background: var(--surface-2);
    box-shadow: none;
    transform: none;
}

/* ==========================================================================
   Menu e ícones de formas
   ========================================================================== */

.shape-insert-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 360px;
}

.shape-insert-menu button,
.shape-preset-grid button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
}

.shape-preset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.shape-menu-icon {
    position: relative;
    flex: 0 0 24px;
    width: 24px;
    height: 20px;
    display: inline-block;
}

.shape-menu-icon::before {
    position: absolute;
    content: "";
    inset: 3px;
    border: 2px solid currentColor;
}

.shape-menu-rounded::before {
    border-radius: 7px;
}

.shape-menu-ellipse::before {
    border-radius: 50%;
}

.shape-menu-triangle::before {
    inset: 2px 4px;
    border: 0;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.shape-menu-diamond::before {
    inset: 3px 5px;
    transform: rotate(45deg);
}

.shape-menu-hexagon::before {
    inset: 2px 3px;
    border: 0;
    background: currentColor;
    clip-path: polygon(24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%, 0 50%);
}

.shape-menu-pentagon::before {
    inset: 2px 4px;
    border: 0;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%);
}

.shape-menu-star::before {
    inset: 1px 3px;
    border: 0;
    background: currentColor;
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 92%, 50% 70%, 21% 92%, 32% 56%, 2% 35%, 39% 35%);
}

.shape-menu-line::before,
.shape-menu-arrow::before,
.shape-menu-double-arrow::before {
    inset: 9px 2px auto 2px;
    height: 2px;
    border: 0;
    background: currentColor;
}

.shape-menu-arrow::after,
.shape-menu-double-arrow::after {
    position: absolute;
    content: "";
    inset: 5px 1px auto auto;
    width: 8px;
    height: 8px;
    border-width: 2px 2px 0 0;
    border-style: solid;
    border-color: currentColor;
    transform: rotate(45deg);
}

.shape-menu-double-arrow::before {
    box-shadow: none;
}

.shape-menu-double-arrow::after {
    box-shadow: -18px 18px 0 -5px currentColor;
}

.shape-menu-curve::before {
    inset: 3px 2px;
    border: 0;
    border-top: 2px solid currentColor;
    border-radius: 50% 50% 0 0;
    transform: rotate(-10deg);
}

.shape-menu-freehand::before {
    inset: 3px 2px auto 2px;
    height: 9px;
    border: 0;
    border-top: 2px solid currentColor;
    border-radius: 70% 30% 0 0;
    transform: rotate(-16deg);
}

.shape-menu-freehand::after {
    position: absolute;
    content: "";
    inset: auto 2px 3px auto;
    width: 12px;
    height: 8px;
    border-bottom: 2px solid currentColor;
    border-radius: 0 0 30% 70%;
    transform: rotate(-16deg);
}

body.shape-drawing-mode .a4-page,
body.shape-drawing-mode .a4-page * {
    cursor: crosshair !important;
}

.shape-draw-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 60;
    pointer-events: none;
}

.shape-item .shape-canvas {
    transform-origin: center center;
}

.rotate-handle--shape {
    width: 34px;
    font-size: 18px;
    line-height: 1;
    color: #fff;
    cursor: grab;
}

.rotate-handle--shape:active {
    cursor: grabbing;
}

.button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 2px;
}

.button-row button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* ==========================================================================
   Animações
   ========================================================================== */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes documentsSlideIn {
    from {
        opacity: .4;
        transform: translateX(22px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes editorPanelSlideIn {
    from {
        opacity: .4;
        transform: translateX(-22px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialogPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-header,
    .action-group,
    .documents-sidebar,
    .system-dialog,
    .system-dialog__panel {
        animation: none !important;
    }

    * {
        transition: none !important;
    }
}

/* ==========================================================================
   Responsivo
   ========================================================================== */

@media (max-width: 1080px) {
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        padding: 0 12px;
        font-size: 13px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .panel {
        position: fixed;
        top: var(--header-height);
        left: 0;
        z-index: 48;
        align-self: start;
        width: min(360px, calc(100vw - 16px));
        height: calc(100vh - var(--header-height));
        height: calc(100svh - var(--header-height));
        overflow: auto;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 10px 14px;
        border-right: 1px solid var(--line);
        border-bottom: 0;
        background: color-mix(in srgb, var(--surface-2) 96%, transparent);
        box-shadow: 18px 0 34px rgba(10, 27, 51, .14);
        transform: translateX(calc(-100% - 18px));
        transition: transform .24s ease;
    }

    body.mobile-panel-open .panel {
        transform: translateX(0);
    }

    .panel section {
        margin: 0;
    }

    .header-actions {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 3px;
        scrollbar-width: thin;
        scroll-snap-type: x proximity;
    }

    .action-group {
        flex: 0 0 min(340px, 86vw);
        scroll-snap-align: start;
    }

    .action-group__row {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .page-viewport {
        padding-bottom: calc(var(--touch-actions-height) + 78px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 760px) {
    .auth-screen {
        padding: 14px;
    }

    .auth-page {
        width: min(468px, 100%);
        gap: 16px;
    }

    .auth-card {
        gap: 16px;
        padding: 15px;
        border-radius: 17px;
    }

    .auth-input-group input {
        min-height: 48px;
        padding: 14px 13px;
        font-size: 14px;
    }

    .btn-login {
        min-height: 46px;
        font-size: 15px;
    }

    .app-header {
        gap: 7px;
        padding: 8px 9px 7px;
    }

    .header-top {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 7px;
    }

    .header-meta {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-left: 0;
    }

    .theme-toggle {
        flex: 1 1 132px;
    }

    .language-switch {
        justify-content: flex-start;
    }

    .header-actions {
        padding-top: 7px;
    }

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

    .header-actions button {
        flex: 0 0 auto;
        min-height: 38px;
        padding: 0 11px;
        font-size: 13px;
    }

    .doc-status {
        flex: 1 1 100%;
        min-width: 0;
        text-align: center;
    }

    .panel {
        width: calc(100vw - 12px);
        padding: 10px;
    }

    .workspace-chrome {
        justify-content: space-between;
        gap: 8px;
        padding: 8px 10px 6px;
    }

    .workspace-ruler {
        font-size: 11px;
    }

    .zoom-toolbar {
        gap: 5px;
        padding: 4px 5px;
    }

    .zoom-range {
        width: min(112px, 28vw);
    }

    .zoom-fit-button {
        padding: 0 9px;
    }

    .zoom-value-field {
        width: 62px;
        padding: 0 8px;
    }

    .zoom-value {
        flex-basis: 30px;
        width: 30px;
    }

    .page-viewport {
        padding: 4px 8px 28px;
        padding-bottom: calc(var(--touch-actions-height) + 72px + env(safe-area-inset-bottom, 0px));
    }

    body.documents-open .workspace-wrap {
        padding-right: 10px;
    }

    .documents-sidebar {
        top: auto;
        bottom: 0;
        width: 100%;
        height: min(62vh, 520px);
        height: min(62svh, 520px);
        border-left: 0;
        border-top: 1px solid var(--line);
        box-shadow: 0 -14px 34px rgba(10, 27, 51, .14);
    }
}

@media (max-width: 520px) {
    :root {
        --touch-actions-height: 116px;
    }

    .auth-screen {
        padding: 11px;
    }

    .auth-page {
        gap: 13px;
    }

    .auth-logo-wrapper {
        gap: 8px;
    }

    .auth-logo-badge {
        width: 54px;
        height: 54px;
        border-radius: 15px;
    }

    .auth-logo-wrapper h1 {
        font-size: 25px;
    }

    .auth-logo-wrapper p {
        font-size: 14px;
    }

    .auth-card {
        gap: 14px;
        padding: 13px;
    }

    .auth-form {
        gap: 13px;
    }

    .auth-input-group input {
        min-height: 44px;
        padding: 13px 11px;
        font-size: 13px;
    }

    .auth-input-group label {
        top: 12px;
        left: 11px;
        font-size: 12px;
    }

    .btn-login {
        min-height: 44px;
        font-size: 14px;
    }

    .auth-alt-actions p {
        font-size: 12px;
        grid-template-columns: 132px 132px;
        column-gap: 8px;
    }

    .auth-link-btn {
        padding: 3px 9px;
        font-size: 11px;
        min-width: 132px;
        width: 132px;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .app-header h1 {
        font-size: 17px;
    }

    .app-header p {
        display: none;
    }

    .brand-block {
        min-width: 0;
    }

    .action-group {
        flex-basis: min(300px, 88vw);
        padding: 6px;
    }

    .action-group__label {
        font-size: 9px;
    }

    .header-actions button {
        min-height: 36px;
        padding: 0 9px;
        font-size: 12px;
    }

    .user-display,
    #logoutBtn,
    .theme-toggle {
        min-height: 34px;
    }

    .language-button {
        width: 32px;
        min-height: 30px;
    }

    .workspace-chrome {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace-ruler {
        text-align: center;
    }

    .zoom-toolbar {
        width: 100%;
        justify-content: center;
    }

    .zoom-range {
        flex: 1 1 92px;
        width: auto;
        max-width: 170px;
    }

    .field-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .touch-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .touch-actions button {
        min-height: 46px;
        padding: 0 10px;
        font-size: 13px;
    }

    .panel button,
    .panel input,
    .panel select {
        min-height: 44px;
    }

    .tuning-spinner {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }

    .tuning-step-btn {
        min-height: 44px;
        font-size: 22px;
    }

    .orientation-hint {
        bottom: calc(var(--touch-actions-height) + 14px + env(safe-area-inset-bottom, 0px));
    }

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