#view-editor { gap: 12px; }
#editor-auth-panel .login-card {
    flex: 0 0 auto; background: var(--surface); border-radius: 12px; padding: 16px;
    border: 1px solid var(--border-color); box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
#editor-auth-panel .login-tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 12px; }
#editor-auth-panel .login-tabs button {
    flex: 1; padding: 8px; border: none; background: transparent; font-weight: 600; cursor: pointer;
    color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
#editor-auth-panel .login-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
#editor-auth-panel label { display: block; font-size: 0.82rem; color: var(--text-light); margin: 10px 0 4px; }
#editor-auth-panel input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 1rem; box-sizing: border-box;
}
#editor-auth-panel .login-btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
#editor-auth-panel .login-primary {
    padding: 10px 18px; border-radius: 8px; border: none; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer;
}
#editor-auth-panel .login-secondary {
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--surface); font-weight: 600; cursor: pointer;
}
#editor-auth-panel .login-edit-link {
    display: inline-block; padding: 10px 18px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 600; text-decoration: none;
}
#editor-auth-panel .login-edit-link:hover { opacity: 0.92; }
#editor-auth-panel .err { color: #b91c1c; }
#editor-auth-panel .auth-notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 12px 0 16px;
    padding: 12px 14px;
    border: 2px solid var(--primary);
    border-radius: 10px;
    background: #fff5f5;
    box-shadow: 0 2px 6px rgba(204, 0, 0, 0.08);
}
#editor-auth-panel .auth-notice-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
#editor-auth-panel .auth-notice-text {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
}
#editor-auth-panel .auth-notice.auth-notice-registration {
    border-color: #ca8a04;
    background: #fefce8;
    box-shadow: 0 2px 6px rgba(202, 138, 4, 0.12);
}
#editor-auth-panel .auth-notice.auth-notice-registration .auth-notice-icon {
    background: #ca8a04;
}
#editor-auth-panel .auth-notice[hidden],
#editor-auth-panel .auth-register-disabled-notice[hidden] {
    display: none !important;
}
#editor-auth-panel .auth-notice.auth-notice-success {
    border-color: #15803d;
    background: #f0fdf4;
    box-shadow: 0 2px 6px rgba(21, 128, 61, 0.08);
}
#editor-auth-panel .auth-notice.auth-notice-success .auth-notice-icon {
    background: #15803d;
}
#editor-auth-panel .muted { color: var(--text-light); font-size: 0.9rem; }

#view-editor .editor-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
#view-editor #editor-app-panels {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#view-editor #editor-app-panels[hidden],
#view-editor #editor-auth-panel[hidden],
#view-editor #editor-no-access[hidden] {
    display: none !important;
}
#view-editor .err { color: #b91c1c; }
#view-editor .muted { color: var(--text-light); font-size: 0.9rem; }

#view-editor #editor-account-panel {
    margin-bottom: 0;
}
#view-editor .editor-user-name {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
#view-editor .editor-user-email {
    margin: 0 0 8px;
    font-size: 0.78rem;
    color: var(--text-light);
    opacity: 0.75;
    line-height: 1.35;
    word-break: break-all;
}
#view-editor .editor-role-line {
    margin: 0 0 12px;
    line-height: 1;
}
#view-editor .editor-role-line #role-display-name {
    display: inline-block;
    max-width: 100%;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    background: #eef2f6;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}
#view-editor .editor-account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
#view-editor .editor-account-actions button.editor-action-new {
    flex: 1 1 8rem;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
#view-editor .editor-account-actions button.editor-action-new:hover { opacity: 0.92; }
#view-editor .editor-account-actions button.editor-action-signout {
    flex: 1 1 8rem;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    font-weight: 600;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#view-editor .editor-account-actions button.editor-action-signout:hover {
    border-color: var(--text-light);
}

#view-editor #editor-edit-panel.editor-card {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
}
#view-editor #editor-edit-panel #editor-view-edit {
    padding: 16px;
}
#view-editor .editor-edit-header {
    margin-bottom: 0;
}
#view-editor .editor-edit-header .workout-id {
    font-size: 1.2rem;
    padding: 10px 12px;
    min-width: 44px;
}
#view-editor .editor-edit-header .workout-title {
    font-size: 0.95rem;
    padding: 8px 12px;
}
#view-editor .editor-edit-header .share-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
}
#view-editor .editor-workout-id[hidden] { display: none !important; }

#view-editor #editor-view-edit .editor-form-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    padding-top: 4px;
}
#view-editor #editor-view-edit .editor-action-primary {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
#view-editor #editor-view-edit .editor-action-primary:hover { opacity: 0.92; }
#view-editor #editor-view-edit .editor-action-delete {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: #991b1b;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
#view-editor #editor-view-edit .editor-action-delete:hover {
    border-color: #991b1b;
    background: rgba(153, 27, 27, 0.06);
}
#view-editor #editor-view-edit .editor-action-delete[hidden] { display: none !important; }
#view-editor #editor-view-edit label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-light);
    margin: 8px 0 3px;
}
#view-editor #editor-view-edit label:first-of-type { margin-top: 0; }
#view-editor #editor-view-edit select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
}
#view-editor #editor-view-edit #editor-msg:empty { display: none; }
#view-editor #editor-view-edit #editor-msg.err { font-size: 0.88rem; margin: 0 0 8px; }

.save-toast {
    position: fixed;
    left: 50%;
    bottom: calc(72px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(12px);
    z-index: 1000;
    max-width: min(90vw, 360px);
    padding: 12px 18px;
    border: 2px solid #15803d;
    border-radius: 10px;
    background: #f0fdf4;
    box-shadow: 0 4px 16px rgba(21, 128, 61, 0.18);
    color: #14532d;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.save-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#view-editor #editor-view-list .filters-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
#view-editor #editor-view-list .filter-row { display: flex; gap: 8px; }
#view-editor #editor-view-list .filter-row-full { width: 100%; }
#view-editor #editor-view-list .filter-row-full .filter-input { width: 100%; }
#view-editor #editor-view-list .filter-input {
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    box-sizing: border-box;
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    background: var(--surface);
    color: var(--text);
}
#view-editor #editor-view-list select.filter-input {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%236b7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 30px;
}
#view-editor #editor-view-list .workout-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
#view-editor #editor-view-list .workout-active-filters:empty { display: none; }
#view-editor #editor-view-list .workout-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px 2px 8px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    background: #eef2f6;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    max-width: 100%;
}
#view-editor #editor-view-list .workout-filter-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}
#view-editor #editor-view-list .workout-filter-chip-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#view-editor #editor-view-list .workout-filter-chip-remove:hover {
    color: var(--primary);
    background: rgba(204, 0, 0, 0.08);
}
#view-editor #editor-view-list .workout-list-author-chip {
    display: inline-block;
    max-width: 5.5rem;
    padding: 2px 7px;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
    background: #eef2f6;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
#view-editor #editor-view-list .tbl-creator-empty { color: var(--text-light); }

#view-editor .tbl { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-top: 4px; table-layout: fixed; }
#view-editor .tbl th, #view-editor .tbl td { border-bottom: 1px solid var(--border-color); padding: 6px 5px; text-align: left; vertical-align: middle; }
#view-editor .tbl th { font-size: 0.72rem; font-weight: 600; color: var(--text-light); }
#view-editor .tbl-col-id { width: 2.5rem; }
#view-editor .tbl-col-pattern { width: 25%; }
#view-editor .tbl-col-duration { width: 20%; }
#view-editor .tbl-col-creator { width: 29%; white-space: nowrap; }
#view-editor .tbl-col-actions { width: 3.5rem; text-align: right; }
#view-editor .td-actions button { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border-color); font-weight: 600; font-size: 0.72rem; cursor: pointer; background: var(--surface); }
#view-editor .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

#view-editor .movements-picker { display: flex; flex-direction: column; gap: 8px; }
#view-editor .movements-search-wrap { position: relative; }
#view-editor .movements-search-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    box-sizing: border-box;
    outline: none;
    background: var(--surface);
    color: var(--text);
}
#view-editor .movements-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(204, 0, 0, 0.12);
}
#view-editor .movements-search-input:disabled {
    background: #f3f4f6;
    color: var(--text-light);
    cursor: not-allowed;
}
#view-editor .movements-search-results {
    display: none;
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: min(220px, 40vh);
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
#view-editor .movements-search-results.open { display: block; }
#view-editor .movements-search-results:empty { display: none !important; }
#view-editor .movements-search-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#view-editor .movements-search-option:hover,
#view-editor .movements-search-option.active {
    background: #f3f4f6;
}
#view-editor .movements-search-empty {
    padding: 10px 12px;
    font-size: 0.9rem;
    color: var(--text-light);
}
#view-editor .movements-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#view-editor .movements-chips:empty::before {
    content: 'No movements selected.';
    color: var(--text-light);
    font-size: 0.85rem;
}
#view-editor .movement-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 4px 4px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    background: #eef2f6;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    max-width: 100%;
}
#view-editor .movement-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
#view-editor .movement-chip-remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#view-editor .movement-chip-remove:hover {
    color: var(--primary);
    background: rgba(204, 0, 0, 0.08);
}

#view-editor #f-tags-chips:empty::before {
    content: 'No tags selected.';
}

#view-editor .workout-rich-field { min-height: 96px; width: 100%; }
#view-editor #editor-view-edit .tox-tinymce { margin-top: 2px; margin-bottom: 2px; border-radius: 8px !important; max-width: 100%; }
#view-editor #editor-view-edit .tox .tox-toolbar,
#view-editor #editor-view-edit .tox .tox-toolbar__primary,
#view-editor #editor-view-edit .tox .tox-toolbar__overflow {
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
}
#view-editor #editor-view-edit .tox .tox-toolbar__group {
    flex-wrap: wrap !important;
    padding: 2px 4px;
}
@media (max-width: 600px) {
    #view-editor #editor-view-edit .tox .tox-toolbar,
    #view-editor #editor-view-edit .tox .tox-toolbar__primary {
        padding: 2px 0 !important;
        min-height: 0 !important;
    }
    #view-editor #editor-view-edit .tox .tox-toolbar__group {
        padding: 1px 2px;
    }
    #view-editor #editor-view-edit .tox .tox-toolbar__group:first-child {
        padding-left: 10px;
    }
    #view-editor #editor-view-edit .tox .tox-tbtn {
        width: 22px;
        height: 22px;
        margin: 0;
    }
    #view-editor #editor-view-edit .tox .tox-tbtn svg {
        transform: scale(0.85);
    }
    #view-editor #editor-view-edit .tox .tox-tbtn--select {
        width: auto;
        height: 22px;
        min-height: 22px;
        padding: 0 4px;
        font-size: 12px;
    }
}