/* ============================================================================
   Documents workspace  (/command/documents)
   Two-pane layout: a fixed document list on the left, a page-style editor
   canvas on the right. Built entirely on the shared dashboard design tokens so
   light/dark theming and spacing stay consistent with the rest of Command.
   ========================================================================== */

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.docs-workspace [hidden],
.docs-modal-overlay[hidden],
.docs-rowmenu[hidden],
.docs-panel-scrim[hidden] { display: none !important; }

/* Full-bleed: the workspace owns the whole content area (no default padding). */
body.docs-body .app-content { padding: 0; overflow: hidden; }
.docs-workspace {
    display: grid;
    grid-template-columns: 274px minmax(0, 1fr);
    height: calc(100vh - var(--tb-h) - 8px);
    background: var(--bg);
}

/* ---------------- Left panel ---------------- */
.docs-panel {
    display: flex; flex-direction: column; min-height: 0;
    background: var(--bg-elev); border-right: 1px solid var(--border);
}
.docs-panel-head { padding: var(--s-4) var(--s-4) var(--s-2); border-bottom: 1px solid var(--border); }
.docs-panel-top { display: flex; align-items: center; gap: var(--s-2); }
.docs-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    color: var(--text-muted); flex-shrink: 0;
}
.docs-back:hover { background: var(--bg-hover); color: var(--text); }
.docs-panel-title { font-size: 16px; font-weight: 600; flex: 1; letter-spacing: -.01em; }
.docs-new-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-elev-2);
    color: var(--text); cursor: pointer; flex-shrink: 0; transition: all .12s ease;
}
.docs-new-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.docs-panel-close {
    display: none; width: 30px; height: 30px; border-radius: var(--radius-sm);
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.docs-panel-close:hover { background: var(--bg-hover); color: var(--text); }

.docs-filter { display: flex; gap: var(--s-1); margin-top: var(--s-3); }
.docs-filter-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 var(--s-3); border-radius: var(--radius-pill);
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer;
}
.docs-filter-btn .fai { font-size: 11px; }
.docs-filter-btn:hover { background: var(--bg-hover); color: var(--text); }
.docs-filter-btn.is-active { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); }

.docs-list-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-2); }
.docs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.docs-row {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
    border-radius: var(--radius); cursor: pointer; position: relative;
    border: 1px solid transparent;
}
.docs-row:hover { background: var(--bg-hover); }
.docs-row.is-active { background: var(--accent-soft); border-color: var(--accent-ring); }
.docs-row-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm); flex-shrink: 0;
    background: var(--bg-elev-2); color: var(--text-muted); font-size: 14px;
}
.docs-row.is-active .docs-row-icon { background: var(--accent); color: var(--accent-fg); }
.docs-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.docs-row-title {
    font-size: 13px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.docs-row-star { color: var(--warning); font-size: 10px; margin-left: 4px; }
.docs-row-meta { font-size: 11px; color: var(--text-faint); }
.docs-row-menu {
    opacity: 0; flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--radius-sm);
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: opacity .12s ease;
}
.docs-row:hover .docs-row-menu, .docs-row.is-active .docs-row-menu,
.docs-row:focus-within .docs-row-menu { opacity: 1; }
.docs-row-menu:hover { background: var(--bg-elev-2); color: var(--text); }

.docs-skeleton { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-2); }
.docs-skel-row { height: 46px; border-radius: var(--radius); background: var(--skeleton); background-size: 400% 100%; animation: docs-shimmer 1.4s infinite; }
@keyframes docs-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.docs-empty { text-align: center; padding: var(--s-8) var(--s-5); }
.docs-empty-slim { padding: var(--s-6) var(--s-4); }
.docs-empty-icon {
    width: 56px; height: 56px; margin: 0 auto var(--s-4);
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-lg); background: var(--accent-soft); color: var(--accent); font-size: 24px;
}
.docs-empty-title { font-size: 15px; margin-bottom: 6px; }
.docs-empty-text { font-size: 13px; color: var(--text-muted); margin: 0 0 var(--s-4); line-height: 1.5; }
.docs-empty .btn { margin: 0 auto; }

.docs-panel-foot {
    padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-faint); flex-shrink: 0;
}

/* ---------------- Editor ---------------- */
.docs-editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); }

.docs-none { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--s-8); }
.docs-none-inner { text-align: center; max-width: 340px; }
.docs-none-icon {
    width: 64px; height: 64px; margin: 0 auto var(--s-4);
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--bg-elev-2); color: var(--text-faint); font-size: 26px;
}
.docs-none h2 { font-size: 18px; margin-bottom: 8px; }
.docs-none p { color: var(--text-muted); margin: 0 0 var(--s-5); }
.docs-none .btn { margin: 0 auto; }

.docs-editor-shell { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.docs-editor-head {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border);
    background: var(--bg-elev); flex-shrink: 0;
}
.docs-open-panel {
    display: none; width: 32px; height: 32px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); cursor: pointer;
}
.docs-title-input {
    flex: 1; min-width: 0; border: 1px solid transparent; background: transparent;
    font-size: 16px; font-weight: 600; color: var(--text); font-family: inherit;
    padding: 6px var(--s-3); border-radius: var(--radius-sm); letter-spacing: -.01em;
}
.docs-title-input:hover { background: var(--bg-hover); }
.docs-title-input:focus { background: var(--bg-elev-2); border-color: var(--border); outline: none; }
.docs-star {
    width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
    border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 16px;
}
.docs-star:hover { background: var(--bg-hover); color: var(--warning); }
.docs-star.is-on { color: var(--warning); }
.docs-star:disabled,
.docs-tb-btn:disabled,
.docs-tb-select:disabled,
.docs-fs-val:disabled {
    opacity: .45; cursor: not-allowed;
}
.docs-viewonly {
    flex-shrink: 0; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .02em; color: var(--text-muted); border: 1px solid var(--border);
    border-radius: var(--radius-pill); padding: 4px 8px; background: var(--bg-elev-2);
}
.docs-avatars { display: inline-flex; align-items: center; margin-left: var(--s-1); flex-shrink: 0; }
.docs-avatar {
    width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); border: 2px solid var(--bg-elev);
    font-size: 10px; font-weight: 800; margin-left: -7px; flex-shrink: 0;
}
.docs-avatars .docs-avatar:first-child { margin-left: 0; }
.docs-avatar-more { background: var(--bg-elev-2); color: var(--text-muted); }
.docs-share-btn {
    height: 32px; display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
    border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
    border-radius: var(--radius-sm); padding: 0 var(--s-3); cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
}
.docs-share-btn:hover { border-color: var(--accent-ring); color: var(--accent); background: var(--accent-soft); }
.docs-savestate {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    font-size: 12px; color: var(--text-muted); padding: 4px var(--s-2);
    border-radius: var(--radius-pill); min-width: 92px; justify-content: flex-end;
}
.docs-savestate .docs-save-ic { font-size: 13px; }
.docs-savestate.is-saved { color: var(--accent); }
.docs-savestate.is-saving { color: var(--text-muted); }
.docs-savestate.is-saving .docs-save-ic { animation: docs-spin 1s linear infinite; }
.docs-savestate.is-error { color: var(--danger); }
.docs-savestate.is-dirty { color: var(--text-faint); }
.docs-save-retry {
    height: 30px; padding: 0 var(--s-3); border-radius: var(--radius-sm);
    border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger);
    font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.docs-save-retry:hover { filter: brightness(1.05); }
@keyframes docs-spin { to { transform: rotate(360deg); } }

/* Toolbar */
.docs-toolbar {
    display: flex; align-items: center; gap: var(--s-1); flex-wrap: nowrap;
    padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--border);
    background: var(--bg-elev); overflow-x: auto; flex-shrink: 0; scrollbar-width: thin;
}
.docs-tb-group { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.docs-tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.docs-tb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 6px; border-radius: var(--radius-sm);
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
    font-size: 14px; position: relative; flex-shrink: 0;
}
.docs-tb-btn:hover { background: var(--bg-hover); color: var(--text); }
.docs-tb-btn.is-on { background: var(--accent-soft); color: var(--accent); }
.docs-tb-select {
    height: 30px; border: 1px solid var(--border); background: var(--bg-elev-2);
    color: var(--text); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
    padding: 0 var(--s-2); cursor: pointer; max-width: 140px;
}
.docs-tb-select.docs-tb-zoom { max-width: 78px; }
.docs-tb-select:hover { border-color: var(--border-strong); }

.docs-color-btn { position: relative; overflow: hidden; flex-direction: column; gap: 0; }
.docs-color-btn input[type="color"] {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0;
}
.docs-color-btn .fai { font-size: 13px; line-height: 1; }
.docs-color-bar { display: block; width: 16px; height: 3px; border-radius: 2px; margin-top: 1px; }

.docs-fontsize { display: inline-flex; align-items: center; gap: 2px; }
.docs-fs-btn { min-width: 26px; font-size: 14px; font-weight: 600; }
.docs-fs-val {
    width: 40px; height: 30px; text-align: center; border: 1px solid var(--border);
    background: var(--bg-elev-2); color: var(--text); border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit;
}

/* Canvas + page */
.docs-canvas {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: auto;
    background: var(--bg); padding: var(--s-8) var(--s-6);
    display: flex; justify-content: center; align-items: flex-start;
}
.docs-page {
    --doc-zoom: 1;
    width: 816px; max-width: 100%;
    transform: scale(var(--doc-zoom)); transform-origin: top center;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-elev);
    padding: 72px 84px; min-height: 1000px; margin-bottom: var(--s-8);
    transition: transform .12s ease;
}
[data-theme="light"] .docs-page { background: #ffffff; }
.docs-writer {
    outline: none; min-height: 860px; color: var(--text);
    font-size: 16px; line-height: 1.7; word-wrap: break-word; position: relative;
}
.docs-writer.is-empty::before {
    content: attr(data-placeholder); color: var(--text-faint); pointer-events: none; position: absolute;
}
.docs-writer:focus { outline: none; }
.docs-writer.is-readonly { cursor: default; }
.docs-writer h1 { font-size: 30px; margin: 18px 0 8px; font-weight: 700; }
.docs-writer h2 { font-size: 24px; margin: 16px 0 6px; font-weight: 600; }
.docs-writer h3 { font-size: 19px; margin: 14px 0 6px; font-weight: 600; }
.docs-writer p { margin: 0 0 10px; }
.docs-writer ul, .docs-writer ol { margin: 0 0 10px; padding-left: 26px; }
.docs-writer li { margin: 2px 0; }
.docs-writer img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 6px 0; }
.docs-writer hr { border: 0; border-top: 1px solid var(--border-strong); margin: 20px 0; }
.docs-writer blockquote {
    margin: 0 0 10px; padding: 4px 0 4px 16px; border-left: 3px solid var(--border-strong); color: var(--text-muted);
}

/* Checklist */
.docs-writer ul.doc-checklist { list-style: none; padding-left: 4px; }
.docs-writer ul.doc-checklist li { position: relative; padding-left: 30px; list-style: none; }
.docs-writer ul.doc-checklist li::before {
    content: ''; position: absolute; left: 0; top: 4px; width: 18px; height: 18px;
    border: 2px solid var(--border-strong); border-radius: 5px; cursor: pointer; background: var(--bg-elev);
}
.docs-writer ul.doc-checklist li[data-checked="true"]::before { background: var(--accent); border-color: var(--accent); }
.docs-writer ul.doc-checklist li[data-checked="true"]::after {
    content: '\2713'; position: absolute; left: 3px; top: 2px; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
}
.docs-writer ul.doc-checklist li[data-checked="true"] { color: var(--text-faint); text-decoration: line-through; }

/* ---------------- Row context menu ---------------- */
.docs-rowmenu { position: fixed; right: auto; bottom: auto; width: 200px; min-width: 200px; z-index: 120; }
.docs-rowmenu button {
    display: flex; align-items: center; gap: var(--s-2); width: 100%;
    padding: 9px var(--s-3); background: transparent; border: 0; text-align: left;
    color: var(--text); font-size: 13px; cursor: pointer; font-family: inherit; border-radius: var(--radius-sm);
}
.docs-rowmenu button .fai { width: 16px; color: var(--text-muted); font-size: 13px; }
.docs-rowmenu button:hover { background: var(--bg-hover); }
.docs-rowmenu button.menu-danger { color: var(--danger); }
.docs-rowmenu button.menu-danger .fai { color: var(--danger); }

/* ---------------- Modals ---------------- */
.docs-modal-overlay {
    position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.45); padding: var(--s-4); backdrop-filter: blur(2px);
}
.docs-modal {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elev); padding: var(--s-6); width: 100%; max-width: 400px; text-align: center;
}
.docs-share-modal { max-width: 560px; text-align: left; }
.docs-share-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.docs-icon-btn {
    width: 32px; height: 32px; border-radius: var(--radius-sm); border: 0; background: transparent;
    color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.docs-icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.docs-icon-btn.danger { color: var(--danger); }
.docs-share-invite { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.docs-share-invite .docs-modal-input { margin-bottom: 0; }
.docs-share-role { min-width: 112px; }

/* ---- Smart recipient picker ---- */
.docs-recipient { position: relative; }
.docs-recipient-box {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    min-height: 42px; padding: 6px 8px; border: 1px solid var(--border);
    background: var(--bg-elev-2); border-radius: var(--radius); cursor: text;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.docs-recipient-box:focus-within { border-color: var(--accent-ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.docs-recipient-pills { display: contents; }
.docs-recipient-input {
    flex: 1; min-width: 140px; height: 28px; border: 0; background: transparent;
    color: var(--text); font: inherit; font-size: 14px; padding: 0 4px; outline: none;
}
.docs-recipient-input::placeholder { color: var(--text-faint); }

/* selected recipient chips */
.docs-pill {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    height: 28px; padding: 0 4px 0 6px; border-radius: var(--radius-pill);
    background: var(--bg); border: 1px solid var(--border); font-size: 12.5px; color: var(--text);
}
.docs-pill-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.docs-pill-tag { font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em; }
.docs-pill-x {
    display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
    border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 11px;
}
.docs-pill-x:hover { background: var(--danger-soft); color: var(--danger); }

/* provider badge/icon */
.docs-provider-ico {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 20px; height: 20px; border-radius: 6px; font-size: 11px; color: #fff;
    background: var(--bg-elev-2);
}
.docs-provider-ico.pill-ico { width: 18px; height: 18px; border-radius: 5px; font-size: 10px; }
.docs-provider-ico.provider-google    { background: #ea4335; }
.docs-provider-ico.provider-workspace  { background: #1a73e8; }
.docs-provider-ico.provider-outlook    { background: #0f6cbd; }
.docs-provider-ico.provider-proton     { background: #6d4aff; }
.docs-provider-ico.provider-icloud     { background: #3693f3; }
.docs-provider-ico.provider-yahoo      { background: #6001d2; }
.docs-provider-ico.provider-custom     { background: #64748b; }

.docs-recipient-actions { display: grid; grid-template-columns: minmax(0,150px) auto; gap: var(--s-2); justify-content: flex-end; }
.docs-recipient-actions .btn { white-space: nowrap; }

/* dropdown menu */
.docs-recipient-menu {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
    max-height: 320px; overflow-y: auto; padding: 6px;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-elev);
}
.docs-recipient-menu[hidden] { display: none; }
.docs-menu-empty { padding: 12px; font-size: 13px; color: var(--text-faint); }
.docs-menu-row {
    display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
    padding: 8px; border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.docs-menu-row:hover, .docs-menu-row.is-active { background: var(--bg-hover); }
.docs-menu-row.is-disabled { cursor: default; opacity: .62; }
.docs-menu-row.is-disabled:hover { background: transparent; }
.docs-avatar.menu-avatar { margin-left: 0; width: 32px; height: 32px; border: 0; }
.docs-provider-ico.menu-ico { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.docs-menu-person { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.docs-menu-person strong { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-menu-person small { font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-menu-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.docs-provider-ico.menu-provider, .docs-provider-ico.card-provider { width: 18px; height: 18px; border-radius: 5px; font-size: 10px; }
.docs-menu-sub { font-size: 11px; color: var(--text-muted); }
.docs-menu-badge {
    font-size: 10.5px; font-weight: 700; color: var(--text-muted); background: var(--bg-elev-2);
    border-radius: var(--radius-pill); padding: 3px 8px; white-space: nowrap;
}
.docs-menu-state {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
    border-radius: var(--radius-pill); padding: 3px 8px; white-space: nowrap;
}
.docs-menu-state.collaborator { color: var(--success, #16a34a); background: var(--success-soft, color-mix(in srgb, #16a34a 16%, transparent)); }
.docs-menu-state.pending { color: var(--warning); background: var(--warning-soft, color-mix(in srgb, var(--warning) 18%, transparent)); }
.docs-menu-state.added { color: var(--accent); background: var(--accent-soft); }

/* avatar with real photo (connected accounts) */
.docs-avatar.has-photo { background: none; overflow: hidden; }
.docs-avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; }
.docs-share-error {
    color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
    border-radius: var(--radius); padding: 9px var(--s-3); font-size: 13px; margin-bottom: var(--s-3);
}
.docs-share-loading { color: var(--text-muted); font-size: 13px; margin-bottom: var(--s-3); }
.docs-share-section { border-top: 1px solid var(--border); padding-top: var(--s-4); margin-top: var(--s-4); }
.docs-share-section h3 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--s-2); }
.docs-share-list { display: flex; flex-direction: column; gap: 4px; }
.docs-share-row {
    display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 6px 0;
}
.docs-share-row .docs-avatar { margin-left: 0; border-color: var(--bg-elev-2); }
.docs-share-person { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.docs-share-person strong { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-share-person small { font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-owner-pill {
    font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft);
    border-radius: var(--radius-pill); padding: 4px 8px;
}
.docs-share-select {
    height: 30px; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
    border-radius: var(--radius-sm); font-size: 12px; font-family: inherit; padding: 0 var(--s-2);
}
.docs-share-empty { margin: 4px 0; color: var(--text-faint); font-size: 13px; }

/* ---- Connected accounts ---- */
.docs-connected-head { margin-bottom: var(--s-3); }
.docs-connected-sub { font-size: 12px; color: var(--text-faint); margin: 4px 0 0; line-height: 1.5; }
.docs-connected-list { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-3); }
.docs-connected-card {
    display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3);
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev-2);
}
.docs-connected-card.status-disconnected, .docs-connected-card.status-expired { opacity: .82; }
.docs-avatar.card-avatar { margin-left: 0; width: 38px; height: 38px; border: 0; font-size: 13px; }
.docs-connected-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.docs-connected-row1 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.docs-connected-row1 strong { font-size: 13.5px; color: var(--text); }
.docs-provider-name { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.docs-primary-badge {
    font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
    color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-pill); padding: 3px 8px;
}
.docs-connected-row2 .docs-acct-email { font-size: 12px; color: var(--text-faint); }
.docs-connected-row3 { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.docs-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.docs-status-dot.connected { background: var(--success, #16a34a); box-shadow: 0 0 0 3px color-mix(in srgb, #16a34a 20%, transparent); }
.docs-status-dot.expired { background: var(--warning); }
.docs-status-dot.disconnected { background: var(--text-faint); }
.docs-status-sep { opacity: .5; }
.docs-connected-actions { flex-shrink: 0; }
.docs-linkbtn {
    border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 12.5px;
    font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); text-decoration: none;
}
.docs-linkbtn:hover { background: var(--accent-soft); }
.docs-linkbtn.danger { color: var(--danger); }
.docs-linkbtn.danger:hover { background: var(--danger-soft); }

.docs-connect-buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.docs-connect-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
    border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
    border-radius: var(--radius); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: border-color .12s ease, background .12s ease;
}
.docs-connect-btn:hover { border-color: var(--accent-ring); background: var(--accent-soft); }
.docs-connect-note {
    margin: var(--s-3) 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.5;
    padding: 9px var(--s-3); background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.docs-connect-note[hidden] { display: none; }

.docs-modal-form { text-align: left; }
.docs-modal-icon {
    width: 48px; height: 48px; margin: 0 auto var(--s-4); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.docs-modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.docs-modal-title { font-size: 17px; margin-bottom: 8px; }
.docs-modal-text { font-size: 13px; color: var(--text-muted); margin: 0 0 var(--s-5); line-height: 1.5; }
.docs-modal-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.docs-modal-input {
    width: 100%; height: 38px; padding: 0 var(--s-3); border: 1px solid var(--border);
    background: var(--bg-elev-2); color: var(--text); border-radius: var(--radius); font-size: 14px;
    font-family: inherit; margin-bottom: var(--s-5);
}
.docs-modal-input:focus { outline: none; border-color: var(--accent-ring); }
.docs-modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }
.docs-modal-form .docs-modal-title { text-align: left; }

/* ---------------- Fallback toast ---------------- */
.docs-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
    background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 500; box-shadow: var(--shadow-elev); z-index: 300; opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
}
.docs-toast.show { opacity: 1; transform: translate(-50%, 0); }
.docs-toast.is-error { background: var(--danger); color: #fff; }

/* ---------------- Responsive: panel becomes a slide-over drawer ---------- */
@media (max-width: 860px) {
    .docs-workspace { grid-template-columns: 1fr; }
    .docs-panel {
        position: absolute; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 60;
        transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-elev);
    }
    .docs-workspace.panel-open .docs-panel { transform: translateX(0); }
    .docs-panel-close { display: inline-flex; align-items: center; justify-content: center; }
    .docs-panel-scrim { position: absolute; inset: 0; z-index: 55; background: rgba(0,0,0,.4); }
    .docs-open-panel { display: inline-flex; align-items: center; justify-content: center; }
    .docs-canvas { padding: var(--s-4) var(--s-3); }
    .docs-page { padding: 40px 28px; min-height: 720px; }
    .docs-writer { min-height: 600px; }
    .docs-share-btn span { display: none; }
    .docs-recipient-actions { grid-template-columns: 1fr; }
    .docs-connect-btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------------- Print: only the page canvas ---------------- */
@media print {
    .app-sidebar, .app-topbar, .mobile-nav, .docs-panel, .docs-panel-scrim,
    .docs-toolbar, .docs-editor-head, .chat-widget, .docs-rowmenu { display: none !important; }
    body.docs-body .app-content, .app-main { margin: 0 !important; }
    .docs-workspace { display: block; height: auto; }
    .docs-canvas { overflow: visible; padding: 0; display: block; }
    .docs-page { box-shadow: none; border: 0; width: 100%; transform: none; padding: 0; margin: 0; }
}

/* ============================================================
   Live collaboration: cursors, typing indicator, presence
   ============================================================ */
.docs-collab-mount { display: contents; }
.docs-collab-mount .ProseMirror { outline: none; min-height: 400px; }
.docs-collab-mount .ProseMirror:focus { outline: none; }
.docs-collab-mount .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder); float: left; color: var(--text-faint);
    pointer-events: none; height: 0;
}

/* Remote carets + name labels (Tiptap CollaborationCursor). Colour is applied
   inline per user from awareness, so it stays consistent and unique. */
.collaboration-cursor__caret {
    position: relative; margin-left: -1px; margin-right: -1px;
    border-left: 1px solid currentColor; border-right: 1px solid currentColor;
    word-break: normal; pointer-events: none;
}
.collaboration-cursor__label {
    position: absolute; top: -1.5em; left: -1px; font-size: 11px; font-weight: 700;
    line-height: 1; color: #fff; padding: 2px 6px; border-radius: 6px 6px 6px 0;
    white-space: nowrap; user-select: none; pointer-events: none;
    box-shadow: var(--shadow-elev);
}

/* Header typing indicator, near the collaborator avatars. */
.docs-typing {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
    color: var(--text-muted); max-width: 260px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0;
}
.docs-typing[hidden] { display: none; }
.docs-typing-dots { display: inline-flex; gap: 2px; flex-shrink: 0; }
.docs-typing-dots i {
    width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
    display: inline-block; animation: docs-typing-bounce 1.2s infinite;
}
.docs-typing-dots i:nth-child(2) { animation-delay: .15s; }
.docs-typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes docs-typing-bounce {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

/* Presence avatars (who's here now), coloured to match each person's cursor. */
.docs-avatar.docs-presence { border-width: 2px; border-style: solid; overflow: hidden; }
.docs-avatar.docs-presence.has-photo { background: none; }
.docs-avatar.docs-presence.has-photo img { width: 100%; height: 100%; object-fit: cover; }
.docs-avatar.docs-presence.is-typing { animation: docs-presence-pulse 1.1s infinite; }
@keyframes docs-presence-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
    50% { box-shadow: 0 0 0 3px var(--accent-soft); }
}

/* "Offline changes" save state. */
.docs-savestate.is-offline { color: var(--warning); }
.docs-savestate.is-offline .docs-save-ic { color: var(--warning); }
