textarea,
input {
    -webkit-user-select: text;
    user-select: text;
}

.viewer-header {
    min-height: 62px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 18px;
    border-bottom: 1px solid #29292c;
    background: #0b0b0d;
}

.viewer-heading-wrap {
    flex: 1;
    min-width: 0;
}

.viewer-heading {
    font-size: var(--ui-font-size);
    font-weight: 600;
}

.viewer-crumbs {
    margin-top: 3px;
    color: #77777d;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-actions {
    display: flex;
    gap: 7px;
}

.viewer-button {
    border: 1px solid #353539;
    border-radius: 9px;
    padding: 7px 11px;
    background: #1c1c1e;
    color: #eee;
    font-size: var(--ui-font-size);
    white-space: nowrap;
}

.viewer-button:hover:not(:disabled) { background: #26262a; }
.viewer-button:disabled { opacity: .4; }

.save-button { color: #0a84ff; }

/* ---------- files ---------- */
.file-layout {
    min-height: 0;
    flex: 1;
    display: flex;
}

.file-list-pane {
    width: 270px;
    flex: 0 0 270px;
    overflow-y: auto;
    border-right: 1px solid #29292c;
    background: #111113;
}

.file-tree {
    padding: 8px;
}

.tree-row {
    width: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #c7c7cc;
    text-align: left;
    font-size: var(--ui-font-size);
}

.tree-row:hover { background: #222225; }

.tree-row.active {
    background: #2c2c2f;
    color: #fff;
}

.tree-chevron {
    width: 12px;
    flex: 0 0 12px;
    color: #77777d;
    font-size: 10px;
    text-align: center;
    transition: transform .12s ease;
}

.tree-row.folder.open .tree-chevron { transform: rotate(90deg); }

.tree-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tree-row.folder .tree-icon { color: #98989f; }
.tree-row.file .tree-icon { color: #0a84ff; }

.tree-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-empty {
    padding: 12px 10px;
    color: #77777d;
}

.editor-pane {
    min-width: 0;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b0b0d;
}

.editor-header {
    min-height: 58px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px;
    border-bottom: 1px solid #29292c;
}

.editor-titles { min-width: 0; }

.editor-title {
    font-size: var(--ui-font-size);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-meta {
    margin-top: 3px;
    color: #77777d;
    font-size: 11px;
}

.editor-meta.dirty { color: #ffb340; }

#viewer-editor {
    flex: 1;
    width: 100%;
    min-height: 180px;
    border: 0;
    border-radius: 0;
    outline: 0;
    resize: none;
    padding: 16px;
    background: #0b0b0d;
    color: #e7e7ea;
    font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 4;
}

#viewer-editor:disabled { color: #55555a; }

.versions-section {
    flex: 0 0 auto;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px 16px 14px;
    border-top: 1px solid #29292c;
}

.versions-heading {
    margin-bottom: 6px;
    color: #77777d;
    font-size: 11px;
    font-weight: 600;
}

.versions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.version-button {
    border: 1px solid #303034;
    border-radius: 7px;
    padding: 5px 8px;
    background: #18181a;
    color: #a8a8ae;
    font-size: 11px;
}

.version-button:hover { background: #222225; color: #fff; }

/* ---------- profile ---------- */
.profile-pane {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 18px;
}

.profile-pane[hidden] { display: none; }

.profile-card {
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-card h2 {
    font-size: 20px;
    font-weight: 600;
}

.profile-hint {
    margin-bottom: 14px;
    color: #8e8e93;
}

.profile-card label {
    margin-top: 6px;
    color: #c7c7cc;
    font-weight: 600;
}

.profile-card input,
.profile-card textarea {
    width: 100%;
    border: 1px solid #353539;
    border-radius: 10px;
    padding: 10px 12px;
    background: #1c1c1e;
    color: #fff;
    font-size: 16px;
    outline: 0;
}

.profile-card input:focus,
.profile-card textarea:focus { border-color: #55555a; }

.profile-card textarea {
    min-height: 160px;
    resize: vertical;
    line-height: 1.45;
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.profile-status { color: #77777d; }

.danger-zone {
    margin-top: 36px;
    padding: 16px;
    border: 1px solid rgba(255,69,58,.35);
    border-radius: 12px;
    background: rgba(255,69,58,.06);
}

.danger-zone h3 {
    margin-bottom: 6px;
    font-size: var(--ui-font-size);
    font-weight: 600;
}

.danger-zone p {
    margin-bottom: 12px;
    color: #a8a8ae;
    line-height: 1.45;
}

.danger-button {
    border-color: rgba(255,69,58,.5);
    color: #ff453a;
}

.danger-button:hover:not(:disabled) { background: rgba(255,69,58,.14); }

.editor-back { display: none; }

/* ---------- small screens: full-screen list, full-screen editor ---------- */
@media (max-width: 700px) {
    .viewer-header { padding: 8px 14px; }

    .file-list-pane {
        width: 100%;
        flex: 1 1 100%;
        border-right: 0;
    }

    .editor-pane { display: none; }

    .file-view.editing .file-list-pane { display: none; }

    .file-view.editing .editor-pane {
        display: flex;
        width: 100%;
        flex: 1 1 100%;
    }

    .file-view.editing .editor-back { display: grid; }

    .tree-row { min-height: 44px; font-size: 16px; }

    #viewer-editor { font-size: 15px; }

    .viewer-button { padding: 9px 12px; }
}
