/* Palette A (light-only) styles for Doc workspace panels:
 * - Full-text search modal (desktop) / full-screen panel (mobile)
 * - Version history right drawer (desktop, 300-340px) / BottomSheet (mobile) + diff preview + restore confirmation
 * - Attachment & image upload inline tray (desktop) / BottomSheet (mobile) + ProgressBar
 *
 * Strictly references `--ui-*` tokens from `static/design/system/tokens.json` only.
 */

/* ---------- Top bar & sidebar panel triggers ---------- */

.doc-app .main header .wp-top-btn,
.wp-top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-4);
  width: auto;
  height: var(--ui-control-sm);
  min-width: var(--ui-control-sm);
  padding: 0 var(--ui-space-6);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  font: inherit;
  font-size: var(--ui-small-size);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.wp-top-btn:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-top-btn.is-active {
  background: var(--ui-bg-active);
  color: var(--ui-text);
}

.wp-top-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--ui-space-16);
  height: var(--ui-space-16);
  padding: 0 var(--ui-space-4);
  border-radius: var(--ui-radius-full);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-size: var(--ui-caption-size);
  font-weight: 500;
}

/* ---------- Full-text search overlay ---------- */

.wp-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-popover);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: var(--ui-space-48);
  padding-inline: var(--ui-space-16);
  background: var(--ui-overlay);
  box-sizing: border-box;
}

.wp-search-dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-dialog);
  box-shadow: var(--ui-shadow-dialog);
  overflow: hidden;
  box-sizing: border-box;
}

.wp-search-header {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  padding: var(--ui-space-10) var(--ui-space-12);
  border-bottom: 1px solid var(--ui-line);
}

.wp-search-icon {
  display: inline-flex;
  align-items: center;
  color: var(--ui-text-muted);
  flex: none;
}

.wp-search-input {
  flex: 1;
  min-width: 0;
  height: var(--ui-control-md);
  padding: 0 var(--ui-space-8);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-panel-title-size);
  outline: none;
  box-sizing: border-box;
}

.wp-search-input:focus {
  border-color: var(--ui-text-faint);
  box-shadow: var(--ui-focus-input);
}

.wp-search-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-control-sm);
  height: var(--ui-control-sm);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  cursor: pointer;
  flex: none;
}

.wp-search-close:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-search-close:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-search-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  padding: var(--ui-space-8) var(--ui-space-12);
  border-bottom: 1px solid var(--ui-line-soft);
  background: var(--ui-bg-popover);
}

.wp-scope-chips {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
}

.wp-scope-chip {
  height: var(--ui-control-xs);
  padding: 0 var(--ui-space-8);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text-muted);
  font-size: var(--ui-small-size);
  cursor: pointer;
}

.wp-scope-chip:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-scope-chip.is-active {
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}

.wp-scope-chip:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-kbd-hint {
  font-family: var(--ui-font-mono);
  font-size: var(--ui-caption-size);
  color: var(--ui-text-faint);
}

.wp-search-body {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: var(--ui-space-8);
}

.wp-search-list {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.wp-search-hit {
  display: flex;
  align-items: flex-start;
  gap: var(--ui-space-8);
  width: 100%;
  padding: var(--ui-space-8) var(--ui-space-10);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.wp-search-hit:hover {
  background: var(--ui-bg-soft);
}

.wp-search-hit.is-selected {
  background: var(--ui-bg-selected);
}

.wp-search-hit:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-search-hit-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
}

.wp-search-hit-title {
  font-size: var(--ui-ui-size);
  font-weight: 500;
  color: var(--ui-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-search-hit-path {
  font-size: var(--ui-caption-size);
  color: var(--ui-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-search-hit-snippet {
  font-size: var(--ui-small-size);
  color: var(--ui-text-body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.wp-search-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-8);
  padding: var(--ui-space-28) var(--ui-space-16);
  text-align: center;
  color: var(--ui-text-muted);
  font-size: var(--ui-ui-size);
}

.wp-search-state[data-status="error"] {
  color: var(--ui-error);
}

.wp-load-more {
  width: 100%;
  height: var(--ui-control-md);
  margin-top: var(--ui-space-8);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: var(--ui-ui-size);
  cursor: pointer;
}

.wp-load-more:hover:not(:disabled) {
  background: var(--ui-bg-soft);
}

.wp-load-more:disabled {
  color: var(--ui-text-faint);
  cursor: not-allowed;
}

/* ---------- Version history right drawer (desktop: 300-340px) ---------- */

.wp-history-drawer {
  width: clamp(var(--ui-panel-width), 24vw, var(--ui-panel-max));
  flex: none;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--ui-line);
  background: var(--ui-bg);
  color: var(--ui-text);
  box-sizing: border-box;
  overflow: hidden;
}

.wp-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  min-height: var(--ui-touch);
  padding: 0 var(--ui-space-12);
  border-bottom: 1px solid var(--ui-line);
  box-sizing: border-box;
}

.wp-panel-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
  font-size: var(--ui-panel-title-size);
  font-weight: 600;
  color: var(--ui-text);
}

.wp-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--ui-space-10) var(--ui-space-12);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-10);
}

.wp-history-groups {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-12);
}

.wp-history-day-group {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
}

.wp-history-day-label {
  padding: 0 var(--ui-space-8);
  font-size: var(--ui-label-size);
  font-weight: var(--ui-label-weight);
  color: var(--ui-text-muted);
}

.wp-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.wp-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  width: 100%;
  min-height: var(--ui-tree-row);
  padding: var(--ui-space-8) var(--ui-space-10);
  border: 1px solid transparent;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.wp-history-row:hover {
  background: var(--ui-bg-soft);
}

.wp-history-row.is-selected {
  background: var(--ui-bg-selected);
}

.wp-history-row:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-history-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
}

.wp-history-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-6);
}

.wp-history-row-trail {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.wp-history-seq {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-mono-sm-size);
  font-weight: var(--ui-section-title-weight);
  color: var(--ui-text);
}

.wp-history-actor {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-6);
  font-size: var(--ui-small-size);
  color: var(--ui-text-muted);
}

.wp-history-time {
  font-size: var(--ui-caption-size);
  color: var(--ui-text-faint);
  flex: none;
}

.wp-history-foot {
  padding: var(--ui-space-10) var(--ui-space-14);
  border-top: 1px solid var(--ui-line);
  font-size: var(--ui-caption-size);
  color: var(--ui-text-faint);
  flex: none;
}

.wp-mono {
  font-family: var(--ui-font-mono);
}

.wp-tag {
  display: inline-flex;
  align-items: center;
  padding: var(--ui-space-2) var(--ui-space-6);
  border-radius: var(--ui-radius-sm);
  font-size: var(--ui-caption-size);
  font-weight: var(--ui-label-weight);
  line-height: 1.2;
  white-space: nowrap;
}

.wp-tag-blue {
  background: var(--ui-tag-blue);
  color: var(--ui-tag-blue-text);
}

.wp-tag-green {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.wp-kind-tag {
  display: inline-flex;
  align-items: center;
  padding: var(--ui-space-2) var(--ui-space-6);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-tag-gray);
  color: var(--ui-tag-gray-text);
  font-size: var(--ui-caption-size);
  font-weight: var(--ui-label-weight);
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- Main-canvas full-width read-only version history preview (H1 / H2-a) ---------- */

.reader.wp-reader-hidden {
  display: none;
}

.wp-h-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
  background: var(--ui-bg);
  color: var(--ui-text);
}

.wp-h-mobile-head,
.wp-h-mobile-controls,
.wp-h-mobile-switcher {
  display: none;
}

.wp-h-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--ui-touch);
  padding: var(--ui-space-6) var(--ui-space-16);
  background: var(--ui-bg-sidebar);
  border-bottom: 1px solid var(--ui-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-12);
  flex-wrap: wrap;
  box-sizing: border-box;
}

.wp-h-banner-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-8);
  font-size: var(--ui-small-size);
  color: var(--ui-text-muted);
  min-width: 0;
}

.wp-h-banner-time {
  color: var(--ui-text);
  font-weight: var(--ui-section-title-weight);
}

.wp-h-banner-author {
  color: var(--ui-text-muted);
}

.wp-h-banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-8);
}

.wp-h-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
  font-size: var(--ui-small-size);
  color: var(--ui-text-body);
  cursor: pointer;
  user-select: none;
}

.wp-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: var(--ui-control-md);
  min-height: var(--ui-space-20);
  height: var(--ui-space-20);
  padding: var(--ui-space-2);
  border: 0;
  border-radius: var(--ui-radius-full);
  background: var(--ui-line-strong);
  cursor: pointer;
  transition: background 120ms ease;
  box-sizing: border-box;
}

.wp-switch[aria-checked="true"] {
  background: var(--ui-accent);
}

.wp-switch-knob {
  width: var(--ui-space-16);
  height: var(--ui-space-16);
  border-radius: var(--ui-radius-full);
  background: var(--ui-bg);
  box-shadow: var(--ui-shadow-knob);
  transform: translateX(0);
  transition: transform 120ms ease;
}

.wp-switch[aria-checked="true"] .wp-switch-knob {
  transform: translateX(var(--ui-space-12));
}

.wp-h-base-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
}

.wp-h-canvas {
  flex: 1;
  max-width: var(--ui-content-max);
  width: 100%;
  margin: 0 auto;
  padding: var(--ui-space-28) var(--ui-space-40) var(--ui-space-48);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-16);
  font: var(--ui-font-body);
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

.wp-h-title {
  margin: 0;
  font: var(--ui-font-page-title);
  color: var(--ui-text);
}

.wp-h-ro-note {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  font-size: var(--ui-small-size);
  color: var(--ui-text-muted);
}

.wp-h-diff-warn {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  padding: var(--ui-space-8) var(--ui-space-12);
  border-radius: var(--ui-radius-md);
  border-left: 3px solid var(--ui-error);
  background: var(--ui-diff-removed);
  color: var(--ui-diff-removed-text);
  font-size: var(--ui-small-size);
  overflow-wrap: anywhere;
}

.wp-h-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-12);
}

.wp-h-blocks p {
  margin: 0;
  color: var(--ui-text-body);
}

.wp-h-blocks ul,
.wp-h-blocks ol {
  margin: 0;
  padding-left: var(--ui-space-24);
}

.wp-h-diff-block {
  position: relative;
  border-radius: var(--ui-radius-md);
  padding: var(--ui-space-10) var(--ui-space-14);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-6);
  box-sizing: border-box;
}

.wp-h-diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  font-size: var(--ui-caption-size);
}

.wp-h-diff-pill {
  font-weight: var(--ui-label-weight);
}

.wp-h-diff-id {
  color: var(--ui-text-faint);
}

.wp-h-diff-block.is-added {
  background: var(--ui-tag-green);
  border-left: 3px solid var(--ui-tag-green-text);
}

.wp-h-diff-block.is-added .wp-h-diff-pill {
  color: var(--ui-tag-green-text);
}

.wp-h-diff-block.is-changed {
  background: var(--ui-highlight);
  border-left: 3px solid var(--ui-highlight-line);
}

.wp-h-diff-block.is-changed .wp-h-diff-pill {
  color: var(--ui-tag-yellow-text);
}

.wp-h-diff-block.is-removed {
  background: var(--ui-diff-removed);
  border-left: 3px solid var(--ui-diff-removed-text);
}

.wp-h-diff-block.is-removed .wp-h-diff-pill {
  color: var(--ui-diff-removed-text);
}

.wp-h-diff-removed-body,
.wp-h-diff-removed-body p {
  color: var(--ui-diff-removed-text);
  text-decoration: line-through;
}

.wp-h-diff-block.is-moved {
  background: var(--ui-tag-blue);
  border-left: 3px solid var(--ui-tag-blue-text);
}

.wp-h-diff-block.is-moved .wp-h-diff-pill {
  color: var(--ui-tag-blue-text);
}

.wp-h-diff-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  min-height: var(--ui-control-xs);
  padding: 0 var(--ui-space-6);
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-muted);
  font-size: var(--ui-caption-size);
  cursor: pointer;
}

.wp-h-diff-toggle:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-h-diff-compare-box {
  margin-top: var(--ui-space-4);
  padding: var(--ui-space-8) var(--ui-space-10);
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-md);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  font-size: var(--ui-small-size);
  overflow-wrap: anywhere;
}

.wp-h-diff-before-line {
  color: var(--ui-diff-removed-text);
  text-decoration: line-through;
}

.wp-h-diff-after-line {
  color: var(--ui-tag-green-text);
}

.wp-btn-primary {
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-10);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  font-size: var(--ui-ui-size);
  cursor: pointer;
}

.wp-btn-primary:hover:not(:disabled) {
  background: var(--ui-accent-hover);
}

.wp-btn-primary:disabled {
  background: var(--ui-bg-soft);
  color: var(--ui-text-faint);
  border: 1px solid var(--ui-line-strong);
  cursor: not-allowed;
}

.wp-btn-secondary {
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-10);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: var(--ui-ui-size);
  cursor: pointer;
}

.wp-btn-secondary:hover:not(:disabled) {
  background: var(--ui-bg-soft);
}

.wp-btn-secondary:disabled {
  color: var(--ui-text-faint);
  border-color: var(--ui-line-strong);
  cursor: not-allowed;
}

.wp-error-note {
  margin: 0;
  font-size: var(--ui-small-size);
  color: var(--ui-error);
  overflow-wrap: anywhere;
}

/* ---------- Restore confirmation dialog ---------- */

.wp-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-popover);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ui-space-16);
  background: var(--ui-overlay);
  box-sizing: border-box;
}

.wp-confirm-dialog {
  width: min(420px, 100%);
  padding: var(--ui-space-16);
  background: var(--ui-bg);
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-dialog);
  box-shadow: var(--ui-shadow-dialog);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-12);
  box-sizing: border-box;
}

.wp-confirm-dialog h2 {
  margin: 0;
  font-size: var(--ui-panel-title-size);
  font-weight: 600;
}

.wp-confirm-dialog p {
  margin: 0;
  font-size: var(--ui-ui-size);
  color: var(--ui-text-body);
  line-height: 1.6;
}

.wp-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--ui-space-8);
}

/* ---------- Attachment upload inline tray (desktop) ---------- */

.wp-upload-tray {
  position: fixed;
  right: var(--ui-space-16);
  bottom: var(--ui-space-16);
  z-index: var(--ui-z-popover);
  width: min(360px, calc(100vw - 32px));
  max-height: 440px;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-popover);
  overflow: hidden;
  box-sizing: border-box;
}

.wp-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ui-space-8);
  padding: var(--ui-space-12);
  border: 1px dashed var(--ui-line-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-bg-popover);
  text-align: center;
}

.wp-upload-dropzone.is-drag-over {
  border-color: var(--ui-accent);
  background: var(--ui-accent-faint);
}

.wp-upload-dropzone:focus-visible {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: var(--ui-focus-ring);
}

.wp-upload-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ui-space-6);
}

.wp-upload-limit-note {
  margin: 0;
  font-size: var(--ui-caption-size);
  color: var(--ui-text-muted);
}

.wp-upload-list {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.wp-upload-item {
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  padding: var(--ui-space-8) var(--ui-space-10);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-6);
}

.wp-upload-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
}

.wp-upload-item-title {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
  min-width: 0;
  flex: 1;
}

.wp-upload-filename {
  font-size: var(--ui-ui-size);
  color: var(--ui-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-upload-size {
  font-size: var(--ui-caption-size);
  color: var(--ui-text-faint);
  flex: none;
}

.wp-upload-item-ops {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  flex: none;
}

.wp-icon-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-control-xs);
  height: var(--ui-control-xs);
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-muted);
  cursor: pointer;
}

.wp-icon-mini:hover:not(:disabled) {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-icon-mini:disabled {
  color: var(--ui-text-faint);
  cursor: not-allowed;
}

/* Shared ProgressBar spec: 4px height, radius-xs, bg-soft track, accent fill */
.wp-progress-row {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
}

.wp-progress-track {
  flex: 1;
  height: 4px;
  border-radius: var(--ui-radius-xs);
  background: var(--ui-bg-soft);
  overflow: hidden;
}

.wp-progress-fill {
  height: 100%;
  border-radius: var(--ui-radius-xs);
  background: var(--ui-accent);
}

.wp-progress-fill.is-paused {
  background: var(--ui-text-faint);
}

.wp-progress-pct {
  font-family: var(--ui-font-mono);
  font-size: var(--ui-small-size);
  color: var(--ui-text-muted);
  flex: none;
}

.wp-file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Mobile BottomSheet & full-screen search (< 768px) ---------- */

.wp-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-popover);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--ui-overlay);
}

.wp-sheet {
  width: 100%;
  max-width: 100vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  border-top-left-radius: var(--ui-radius-sheet);
  border-top-right-radius: var(--ui-radius-sheet);
  box-shadow: var(--ui-shadow-sheet);
  padding-top: var(--ui-space-8);
  padding-bottom: var(--ui-space-24);
  box-sizing: border-box;
  overflow: hidden;
}

.wp-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto var(--ui-space-8);
  border-radius: var(--ui-radius-full);
  background: var(--ui-line-strong);
  flex: none;
}

.wp-search-fullscreen {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-popover);
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  box-sizing: border-box;
  overflow: hidden;
}

.wp-slash-upload-footer {
  display: flex;
  gap: var(--ui-space-4);
  padding: var(--ui-space-6) var(--ui-space-8);
  border-top: 1px solid var(--ui-line-soft);
}

.wp-slash-upload-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-4);
  height: var(--ui-control-sm);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: var(--ui-small-size);
  cursor: pointer;
}

.wp-slash-upload-btn:hover {
  background: var(--ui-bg-soft);
}

@media (max-width: 767px) {
  .wp-search-input {
    font-size: var(--ui-mobile-input-size);
    min-height: var(--ui-touch);
  }

  .wp-search-close,
  .wp-scope-chip,
  .wp-search-hit,
  .wp-load-more,
  .wp-history-row,
  .wp-btn-primary,
  .wp-btn-secondary,
  .wp-icon-mini,
  .wp-top-btn {
    min-height: var(--ui-touch);
  }

  .wp-search-close,
  .wp-icon-mini,
  .doc-app .main header .wp-top-btn,
  .wp-top-btn {
    min-width: var(--ui-touch);
    min-height: var(--ui-touch);
  }

  .doc-app .main header .wp-top-btn {
    height: var(--ui-touch);
    padding: 0 var(--ui-space-8);
  }

  .wp-search-header {
    padding: var(--ui-space-8) var(--ui-space-12);
  }

  .wp-kbd-hint {
    display: none;
  }

  .wp-history-drawer {
    display: none;
  }

  .wp-upload-tray {
    display: none;
  }

  .doc-app[data-history-canvas="mainCanvasReadOnly"] .main > header {
    display: none;
  }

  .wp-h-banner {
    display: none;
  }

  .wp-h-mobile-head {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: var(--ui-touch);
    padding: 0 var(--ui-space-8);
    border-bottom: 1px solid var(--ui-line);
    background: var(--ui-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ui-space-6);
    box-sizing: border-box;
  }

  .wp-h-m-head-btn {
    min-height: var(--ui-touch);
    min-width: var(--ui-touch);
    padding: 0 var(--ui-space-8);
    border: 0;
    background: transparent;
    color: var(--ui-text);
    font-size: var(--ui-ui-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ui-space-4);
    cursor: pointer;
  }

  .wp-h-m-head-btn.is-accent {
    color: var(--ui-accent);
    font-weight: var(--ui-section-title-weight);
  }

  .wp-h-m-head-spacer {
    min-width: var(--ui-touch);
    height: var(--ui-touch);
  }

  .wp-h-m-head-title {
    font-family: var(--ui-font-mono);
    font-size: var(--ui-ui-size);
    font-weight: var(--ui-section-title-weight);
    color: var(--ui-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wp-h-mobile-controls {
    min-height: var(--ui-touch);
    padding: var(--ui-space-6) var(--ui-space-16);
    background: var(--ui-bg-sidebar);
    border-bottom: 1px solid var(--ui-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ui-space-8);
    box-sizing: border-box;
  }

  .wp-h-canvas {
    padding: var(--ui-space-16) var(--ui-space-20) calc(var(--ui-touch) + var(--ui-space-28));
    gap: var(--ui-space-12);
  }

  .wp-h-title {
    font: var(--ui-font-mobile-title);
  }

  .wp-h-mobile-switcher {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    min-height: var(--ui-touch);
    width: 100%;
    border: 0;
    border-top: 1px solid var(--ui-line);
    border-radius: 0;
    background: var(--ui-bg-sidebar);
    padding: 0 var(--ui-space-16);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--ui-ui-size);
    color: var(--ui-text);
    cursor: pointer;
    box-sizing: border-box;
  }

  .wp-h-switcher-cue {
    display: inline-flex;
    align-items: center;
    gap: var(--ui-space-4);
    color: var(--ui-text-muted);
  }

  .wp-h-diff-toggle {
    min-height: var(--ui-touch);
    padding: 0 var(--ui-space-8);
  }
}

/* ---------- Document header collaborator avatar stack + modified bar (T1 / T2) ---------- */

.doc-meta-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-10);
  margin: 0 0 var(--ui-space-16);
  padding-bottom: var(--ui-space-12);
  border-bottom: 1px solid var(--ui-line-soft);
}

.doc-meta-bar .modified {
  margin: 0;
  font: var(--ui-font-small);
  color: var(--ui-text-faint);
}

.wp-meta-sep {
  font: var(--ui-font-small);
  color: var(--ui-text-faint);
}

.wp-collab-group {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-8);
  min-width: 0;
}

.wp-avatar-stack {
  display: inline-flex;
  align-items: center;
}

.doc-app .wp-collab-avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--ui-radius-full);
  min-width: var(--ui-avatar-xs);
  min-height: var(--ui-avatar-xs);
  height: var(--ui-avatar-xs);
  margin-left: calc(var(--ui-space-4) * -1);
  cursor: pointer;
}

.doc-app .wp-collab-avatar-btn:first-child {
  margin-left: 0;
}

.doc-app .wp-collab-avatar-btn .ui-avatar {
  border: var(--ui-space-2) solid var(--ui-bg);
  box-sizing: content-box;
}

.doc-app .wp-collab-avatar-btn:hover {
  z-index: 2;
  background: transparent;
}

.doc-app .wp-collab-avatar-btn:focus-visible {
  z-index: 3;
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.wp-collab-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ui-avatar-xs);
  padding: 0 var(--ui-space-6);
  margin-left: calc(var(--ui-space-4) * -1);
  border-radius: var(--ui-radius-full);
  border: var(--ui-space-2) solid var(--ui-bg);
  background: var(--ui-bg-soft);
  color: var(--ui-text-muted);
  font: var(--ui-font-caption);
  box-sizing: content-box;
}

.wp-collab-count {
  font: var(--ui-font-small);
  color: var(--ui-text-faint);
}

/* ---------- Desktop right-margin floating TOC rail (T1) ---------- */

.wp-toc-rail {
  width: calc(var(--ui-sidebar-width) - var(--ui-space-12));
  flex-shrink: 0;
  position: sticky;
  top: var(--ui-space-24);
  align-self: flex-start;
  max-height: calc(100vh - var(--ui-touch) - var(--ui-space-48));
  overflow-y: auto;
  margin: var(--ui-space-28) var(--ui-space-24) var(--ui-space-24) 0;
  padding: var(--ui-space-4) 0 var(--ui-space-4) var(--ui-space-12);
  border-left: 1px solid var(--ui-line);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  box-sizing: border-box;
}

.wp-toc-title {
  font: var(--ui-font-caption);
  color: var(--ui-text-faint);
  padding: var(--ui-space-4) var(--ui-space-6);
  letter-spacing: 0.04em;
}

.wp-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
}

.doc-app .wp-toc-item {
  display: block;
  width: 100%;
  min-height: var(--ui-control-sm);
  padding: var(--ui-space-4) var(--ui-space-8);
  padding-left: calc(var(--ui-space-8) + var(--wp-toc-indent, 0px));
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  box-sizing: border-box;
}

.doc-app .wp-toc-item[data-toc-level="3"] {
  font: var(--ui-font-caption);
}

.doc-app .wp-toc-item:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-app .wp-toc-item.is-active {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
  font-weight: var(--ui-section-title-weight);
}

.wp-toc-empty {
  margin: var(--ui-space-6) 0;
  padding: 0 var(--ui-space-6);
  font: var(--ui-font-small);
  color: var(--ui-text-faint);
}

/* ---------- Mobile TOC BottomSheet (T2) ---------- */

.wp-toc-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--ui-space-16) var(--ui-space-8);
  border-bottom: 1px solid var(--ui-line-soft);
}

.wp-toc-sheet-title {
  margin: 0;
  font: var(--ui-font-mobile-nav-title);
  color: var(--ui-text);
}

.wp-toc-sheet-close {
  min-height: var(--ui-touch);
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-accent);
  font: var(--ui-font-section-title);
  cursor: pointer;
}

.wp-toc-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--ui-space-8) var(--ui-space-16) 0;
}

.wp-toc-sheet-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--ui-touch);
  padding: 0 var(--ui-space-10);
  padding-left: calc(var(--ui-space-10) + var(--wp-toc-indent, 0px));
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-body);
  font: var(--ui-font-ui);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.wp-toc-sheet-item[data-toc-level="3"] {
  color: var(--ui-text-muted);
}

.wp-toc-sheet-item:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.wp-toc-sheet-item.is-active {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
  font-weight: var(--ui-section-title-weight);
}

.wp-toc-sheet-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-top-btn-label {
  font: var(--ui-font-small);
}

@media (max-width: 767px) {
  .wp-toc-rail {
    display: none;
  }

  .wp-collab-count,
  .wp-meta-sep {
    display: none;
  }

  .doc-app .wp-collab-avatar-btn {
    min-height: var(--ui-avatar-xs);
    min-width: var(--ui-avatar-xs);
    height: var(--ui-avatar-xs);
  }

  .doc-meta-bar {
    gap: var(--ui-space-8);
    padding-bottom: var(--ui-space-10);
  }

  .wp-top-btn-label {
    display: none;
  }
}

/* ==========================================================================
   Share & Permissions modal + Anonymous Guest Shell (Palette A, SharePanel)
   ========================================================================== */

.doc-app .main header .doc-share-top-btn,
.doc-share-top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-6);
  width: auto;
  min-width: 0;
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text);
  font: var(--ui-font-ui);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.doc-app .main header .doc-share-top-btn svg,
.doc-share-top-btn svg {
  color: var(--ui-text-muted);
}

.doc-app .main header .doc-share-top-btn:hover,
.doc-share-top-btn:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-app .main header .doc-share-top-btn:hover svg,
.doc-app .main header .doc-share-top-btn.is-active svg,
.doc-share-top-btn:hover svg,
.doc-share-top-btn.is-active svg {
  color: var(--ui-text);
}

.doc-app .main header .doc-share-top-btn.is-active,
.doc-share-top-btn.is-active {
  background: var(--ui-bg-active);
  color: var(--ui-text);
}

.doc-app .main header .doc-share-top-btn:focus-visible,
.doc-share-top-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Anonymous Guest Shell Top Bar & Main Column */
.doc-guest-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-left: 0;
}

.doc-guest-topbar {
  position: sticky;
  top: 0;
  z-index: var(--ui-z-popover);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-12);
  min-height: var(--ui-touch);
  padding: 0 var(--ui-space-16);
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-line);
  box-sizing: border-box;
  width: 100%;
}

.doc-guest-brand {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  min-width: 0;
  flex: 1 1 auto;
}

.doc-guest-title {
  color: var(--ui-text);
  font: var(--ui-font-ui);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.doc-guest-actions {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  flex-shrink: 0;
}

.doc-guest-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  height: var(--ui-control-xs);
  padding: 0 var(--ui-space-8);
  border-radius: var(--ui-radius-sm);
  font: var(--ui-font-small);
  white-space: nowrap;
}

.doc-guest-badge[data-guest-badge="read"] {
  background: var(--ui-tag-gray);
  color: var(--ui-tag-gray-text);
}

.doc-guest-badge[data-guest-badge="edit"] {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-guest-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-12);
  border-radius: var(--ui-radius-md);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  font: var(--ui-font-ui);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-guest-login-btn:hover {
  background: var(--ui-accent-hover);
}

.doc-guest-login-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Share Modal Overlay (Desktop 460px Card / Mobile BottomSheet) */
.doc-share-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--ui-z-popover) + 5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ui-space-16);
  background: var(--ui-overlay);
  box-sizing: border-box;
}

.doc-share-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(460px, calc(100vw - var(--ui-space-32)));
  background: var(--ui-bg);
  border: 0;
  border-radius: var(--ui-radius-dialog);
  box-shadow: var(--ui-shadow-dialog);
  color: var(--ui-text);
  overflow: visible;
  box-sizing: border-box;
}

.doc-share-sheet-handle {
  display: none;
}

/* Compact 1-row Header (48px) */
.doc-share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  min-height: var(--ui-space-48);
  padding: 0 var(--ui-space-12) 0 var(--ui-space-16);
  border-bottom: 1px solid var(--ui-line-soft);
  box-sizing: border-box;
}

.doc-share-header-main {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  min-width: 0;
  flex: 1 1 auto;
}

.doc-share-target-icon {
  display: inline-flex;
  align-items: center;
  color: var(--ui-text-muted);
  flex-shrink: 0;
}

.doc-share-title {
  margin: 0;
  color: var(--ui-text);
  font-size: var(--ui-panel-title-size);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-share-subtitle {
  color: var(--ui-text-muted);
  font: var(--ui-font-ui);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
}

.doc-share-exposure-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--ui-space-6);
  border-radius: var(--ui-radius-sm);
  font: var(--ui-font-caption);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-share-exposure-badge[data-share-exposure-badge="private"] {
  background: var(--ui-bg-soft);
  color: var(--ui-text-muted);
}

.doc-share-exposure-badge[data-share-exposure-badge="workspace"] {
  background: var(--ui-tag-blue);
  color: var(--ui-tag-blue-text);
}

.doc-share-exposure-badge[data-share-exposure-badge="internet"] {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-share-back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-8) 0 var(--ui-space-4);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  font: var(--ui-font-ui);
  cursor: pointer;
  flex-shrink: 0;
}

.doc-share-back-btn:hover:not(:disabled) {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-share-back-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-control-sm);
  height: var(--ui-control-sm);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.doc-share-close:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-share-close:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-error {
  display: flex;
  align-items: center;
  gap: var(--ui-space-6);
  margin: var(--ui-space-10) var(--ui-space-16) 0;
  padding: var(--ui-space-8) var(--ui-space-10);
  border-radius: var(--ui-radius-md);
  background: var(--ui-diff-removed);
  color: var(--ui-error);
  font: var(--ui-font-small);
}

.doc-share-loading {
  padding: var(--ui-space-10) var(--ui-space-16) 0;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
}

/* Two-Zone Body (overflow visible so popovers are never clipped) */
.doc-share-body {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-16);
  padding: var(--ui-space-14) var(--ui-space-16) var(--ui-space-16);
  overflow: visible;
  box-sizing: border-box;
}

.doc-share-section {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-8);
}

.doc-share-section-label {
  color: var(--ui-text-muted);
  font-size: var(--ui-label-size);
  font-weight: var(--ui-label-weight);
  line-height: 1.4;
}

.doc-share-dropdown-wrap {
  position: relative;
  min-width: 0;
}

/* Zone 1: Unified Single-Line Collaborator Search Bar + Inline Permission Dropdown */
.doc-share-add-wrap {
  position: relative;
  min-width: 0;
}

.doc-share-add-bar {
  display: flex;
  align-items: center;
  min-height: var(--ui-control-md);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  box-sizing: border-box;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.doc-share-add-bar:focus-within {
  border-color: var(--ui-text-faint);
  box-shadow: var(--ui-focus-input);
}

.doc-share-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.doc-share-search-icon {
  position: absolute;
  left: var(--ui-space-10);
  display: inline-flex;
  color: var(--ui-text-muted);
  pointer-events: none;
}

.doc-share-input {
  width: 100%;
  height: var(--ui-control-md);
  padding: 0 var(--ui-space-10);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font: var(--ui-font-ui);
  box-sizing: border-box;
  min-width: 0;
}

.doc-share-search-wrap .doc-share-input {
  padding-left: var(--ui-space-28);
}

.doc-share-dialog .doc-share-add-bar input.doc-share-search-input {
  border: 0;
  background: transparent;
  box-shadow: none;
  height: calc(var(--ui-control-md) - 2px);
  min-height: 0;
}

.doc-share-dialog .doc-share-add-bar input.doc-share-search-input:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

.doc-share-input:focus {
  outline: none;
  border-color: var(--ui-text-faint);
  box-shadow: var(--ui-focus-input);
}

.doc-share-add-divider {
  width: 1px;
  height: 16px;
  background: var(--ui-line);
  flex-shrink: 0;
}

.doc-share-add-perm-wrap {
  flex-shrink: 0;
  padding: 0 var(--ui-space-2);
}

.doc-share-add-perm-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  height: 26px;
  min-height: 0;
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-body);
  font: var(--ui-font-small);
  white-space: nowrap;
  cursor: pointer;
}

.doc-share-add-perm-btn:hover:not(:disabled),
.doc-share-add-perm-btn.is-open {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-share-add-perm-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Floating candidate popover (never shifts member list) */
.doc-share-candidate-popover {
  position: absolute;
  top: calc(100% + var(--ui-space-4));
  left: 0;
  right: 0;
  z-index: calc(var(--ui-z-popover) + 1);
  max-height: 224px;
  overflow-y: auto;
  padding: var(--ui-space-4);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-bg-popover);
  box-shadow: var(--ui-shadow-popover);
  box-sizing: border-box;
}

.doc-share-candidate-list,
.doc-share-collab-list,
.doc-share-transfer-list {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-share-collab-list.is-scrollable {
  max-height: 224px;
  overflow-y: auto;
  padding-right: var(--ui-space-2);
}

.doc-share-collab-list.has-open-menu,
.doc-share-collab-list.is-scrollable.has-open-menu {
  max-height: none;
  overflow: visible;
}

.doc-share-transfer-list {
  max-height: 248px;
  overflow-y: auto;
}

.doc-share-candidate-item {
  display: block;
}

.doc-share-candidate-row,
.doc-share-person-row {
  display: flex;
  align-items: center;
  gap: var(--ui-space-10);
  min-height: var(--ui-mobile-row);
  padding: var(--ui-space-4) var(--ui-space-6);
  border-radius: var(--ui-radius-md);
  box-sizing: border-box;
}

button.doc-share-candidate-row {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ui-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.doc-share-candidate-row:disabled {
  opacity: 0.6;
  cursor: default;
}

.doc-share-candidate-row:hover,
button.doc-share-candidate-row:hover:not(:disabled),
.doc-share-person-row:hover {
  background: var(--ui-bg-soft);
}

button.doc-share-candidate-row:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Deterministic 28px Initial Avatar (5 Palette A low-saturation tag pairs) */
.doc-share-person-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-control-sm);
  height: var(--ui-control-sm);
  border-radius: var(--ui-radius-full);
  background: var(--ui-tag-gray);
  color: var(--ui-tag-gray-text);
  font-size: var(--ui-label-size);
  font-weight: 600;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.doc-share-person-avatar.is-tone-gray {
  background: var(--ui-tag-gray);
  color: var(--ui-tag-gray-text);
}

.doc-share-person-avatar.is-tone-blue {
  background: var(--ui-tag-blue);
  color: var(--ui-tag-blue-text);
}

.doc-share-person-avatar.is-tone-green {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-share-person-avatar.is-tone-purple {
  background: var(--ui-tag-purple);
  color: var(--ui-tag-purple-text);
}

.doc-share-person-avatar.is-tone-yellow {
  background: var(--ui-tag-yellow);
  color: var(--ui-tag-yellow-text);
}

.doc-share-person-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1 1 auto;
  min-width: 0;
}

.doc-share-person-name {
  color: var(--ui-text);
  font: var(--ui-font-ui);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-share-person-uid {
  color: var(--ui-text-muted);
  font: var(--ui-font-caption);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Owner row inline controls (quiet label + lightweight ghost Transfer action) */
.doc-share-owner-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  flex-shrink: 0;
}

.doc-share-owner-tag {
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  padding: 0 var(--ui-space-4);
  white-space: nowrap;
}

.doc-share-transfer-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ui-control-xs);
  min-height: 0;
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}

.doc-share-person-row:hover .doc-share-transfer-ghost,
.doc-share-person-row:focus-within .doc-share-transfer-ghost,
.doc-share-transfer-ghost:focus-visible {
  opacity: 1;
}

.doc-share-transfer-ghost:hover:not(:disabled) {
  background: var(--ui-bg-active);
  color: var(--ui-text);
}

.doc-share-transfer-ghost:disabled {
  color: var(--ui-text-faint);
  cursor: default;
}

.doc-share-transfer-ghost:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

@media (hover: none) {
  .doc-share-transfer-ghost {
    opacity: 1;
  }
}

/* Borderless ghost collaborator permission trigger */
.doc-share-role-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-4);
  height: var(--ui-control-sm);
  min-height: 0;
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-body);
  font: var(--ui-font-small);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.doc-share-role-btn:hover:not(:disabled),
.doc-share-role-btn.is-open {
  background: var(--ui-bg-active);
  color: var(--ui-text);
}

.doc-share-role-btn:disabled {
  color: var(--ui-text-faint);
  cursor: default;
}

.doc-share-role-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-role-static {
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  padding: 0 var(--ui-space-6);
  flex-shrink: 0;
}

.doc-share-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-4);
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-10);
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg);
  color: var(--ui-text);
  font: var(--ui-font-small);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.doc-share-btn-secondary:hover:not(:disabled) {
  background: var(--ui-bg-soft);
}

.doc-share-btn-secondary:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-empty-row,
.doc-share-search-empty {
  padding: var(--ui-space-8) var(--ui-space-6);
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
}

/* Zone 2: General Access Card (Link Access + Semantic Icon Badge + Quick Mode Toggle) */
.doc-share-access-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-bg);
  box-sizing: border-box;
}

.doc-share-access-main {
  display: flex;
  align-items: center;
  gap: var(--ui-space-10);
  padding: var(--ui-space-10) var(--ui-space-12);
  min-width: 0;
}

.doc-share-access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-view-tab);
  height: var(--ui-view-tab);
  border-radius: var(--ui-radius-lg);
  flex-shrink: 0;
}

.doc-share-access-badge[data-access-audience="private"] {
  background: var(--ui-bg-soft);
  color: var(--ui-text-muted);
}

.doc-share-access-badge[data-access-audience="workspace"] {
  background: var(--ui-tag-blue);
  color: var(--ui-tag-blue-text);
}

.doc-share-access-badge[data-access-audience="internet"] {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-share-scope-trigger {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--ui-space-4) var(--ui-space-6);
  margin: calc(var(--ui-space-4) * -1) 0;
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.doc-share-scope-trigger:hover:not(:disabled) {
  background: var(--ui-bg-soft);
}

.doc-share-scope-trigger:disabled {
  cursor: default;
}

.doc-share-scope-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-scope-name-row {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-4);
  min-width: 0;
}

.doc-share-scope-name {
  color: var(--ui-text);
  font: var(--ui-font-ui);
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-share-scope-caret {
  display: inline-flex;
  color: var(--ui-text-muted);
  flex-shrink: 0;
}

.doc-share-scope-desc {
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  line-height: 1.35;
}

/* 1-click Quick Read / Edit mode toggle pill */
.doc-share-quick-mode {
  display: inline-flex;
  align-items: center;
  padding: var(--ui-space-2);
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg-soft);
  flex-shrink: 0;
}

.doc-share-quick-mode-btn {
  height: var(--ui-control-xs);
  min-height: 0;
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: transparent;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  white-space: nowrap;
  cursor: pointer;
}

.doc-share-quick-mode-btn:hover:not(:disabled):not(.is-active) {
  color: var(--ui-text);
}

.doc-share-quick-mode-btn.is-active {
  background: var(--ui-bg);
  color: var(--ui-text);
  font-weight: 500;
  box-shadow: var(--ui-shadow-knob);
}

.doc-share-quick-mode-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-access-folder-foot {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-6);
  padding: var(--ui-space-8) var(--ui-space-12);
  border-top: 1px solid var(--ui-line-soft);
  background: var(--ui-bg-popover);
  border-radius: 0 0 var(--ui-radius-lg) var(--ui-radius-lg);
}

.doc-share-hint {
  margin: 0;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  line-height: 1.4;
}

.doc-share-recursive-row {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
}

.doc-share-recursive-label {
  color: var(--ui-text-body);
  font: var(--ui-font-small);
  cursor: pointer;
  user-select: none;
}

/* Floating Menus (Scope & Role & AddPerm) */
.doc-share-menu {
  position: absolute;
  top: calc(100% + var(--ui-space-4));
  left: 0;
  right: 0;
  z-index: calc(var(--ui-z-popover) + 2);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  padding: var(--ui-space-4);
  background: var(--ui-bg-popover);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-popover);
  box-sizing: border-box;
}

.doc-share-role-menu {
  left: auto;
  right: 0;
  min-width: 136px;
}

.doc-share-role-menu.is-flip-up {
  top: auto;
  bottom: calc(100% + var(--ui-space-4));
}

.doc-share-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-8);
  width: 100%;
  min-height: var(--ui-control-md);
  padding: var(--ui-space-6) var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text);
  font: var(--ui-font-ui);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.doc-share-menu-item:hover {
  background: var(--ui-bg-soft);
}

.doc-share-menu-item.is-selected {
  background: var(--ui-bg-selected);
}

.doc-share-menu-item.is-danger {
  color: var(--ui-error);
}

.doc-share-menu-item:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--ui-radius-md);
  background: var(--ui-bg-soft);
  color: var(--ui-text-muted);
  flex-shrink: 0;
}

.doc-share-menu-item-icon[data-access-audience="workspace"] {
  background: var(--ui-tag-blue);
  color: var(--ui-tag-blue-text);
}

.doc-share-menu-item-icon[data-access-audience="internet"] {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-share-menu-item-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1 1 auto;
  min-width: 0;
}

.doc-share-menu-item-title {
  font: var(--ui-font-ui);
  color: inherit;
  line-height: 1.3;
}

.doc-share-menu-item-desc {
  font: var(--ui-font-small);
  color: var(--ui-text-muted);
  line-height: 1.3;
}

.doc-share-menu-item-check {
  display: inline-flex;
  align-items: center;
  color: var(--ui-accent);
  flex-shrink: 0;
}

.doc-share-menu-sep {
  height: 1px;
  margin: var(--ui-space-2) var(--ui-space-4);
  background: var(--ui-line);
}

/* Sticky Clean Footer */
.doc-share-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-10);
  padding: var(--ui-space-10) var(--ui-space-16);
  border-top: 1px solid var(--ui-line-soft);
  box-sizing: border-box;
}

.doc-share-footer-left {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.doc-share-link-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-6);
  max-width: 100%;
  min-width: 0;
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-8);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-mono-sm-size);
  cursor: pointer;
  box-sizing: border-box;
}

.doc-share-link-pill:hover {
  background: var(--ui-bg-soft);
  color: var(--ui-text);
}

.doc-share-link-pill:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

.doc-share-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.doc-share-readonly-note {
  margin: 0;
  color: var(--ui-text-muted);
  font: var(--ui-font-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.doc-share-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-6);
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-12);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  font: var(--ui-font-ui);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.doc-share-copy-btn:hover {
  background: var(--ui-accent-hover);
}

.doc-share-copy-btn.is-copied {
  background: var(--ui-tag-green);
  color: var(--ui-tag-green-text);
}

.doc-share-copy-btn.is-copied:hover {
  background: var(--ui-tag-green);
}

.doc-share-copy-btn:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Dedicated Owner Transfer Sub-View */
.doc-share-transfer-picker {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-10);
}

.doc-share-transfer-search-box {
  width: 100%;
}

/* Explicit second-step owner transfer confirmation modal */
.doc-share-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--ui-z-popover) + 6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ui-space-16);
  background: var(--ui-overlay);
  box-sizing: border-box;
}

.doc-share-confirm-card {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-12);
  width: 100%;
  max-width: 400px;
  padding: var(--ui-space-16);
  border: 0;
  border-radius: var(--ui-radius-dialog);
  background: var(--ui-bg);
  box-shadow: var(--ui-shadow-dialog);
  box-sizing: border-box;
}

.doc-share-confirm-head {
  display: flex;
  align-items: center;
  gap: var(--ui-space-8);
  color: var(--ui-error);
}

.doc-share-confirm-title {
  margin: 0;
  color: var(--ui-text);
  font-size: var(--ui-panel-title-size);
  font-weight: 600;
}

.doc-share-confirm-body {
  margin: 0;
  color: var(--ui-text-body);
  font: var(--ui-font-ui);
  line-height: 1.5;
}

.doc-share-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ui-space-8);
  padding-top: var(--ui-space-4);
}

.doc-share-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ui-control-sm);
  padding: 0 var(--ui-space-12);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  font: var(--ui-font-ui);
  font-weight: 500;
  cursor: pointer;
}

.doc-share-btn-primary:hover:not(:disabled) {
  background: var(--ui-accent-hover);
}

.doc-share-btn-primary:disabled {
  background: var(--ui-bg-soft);
  color: var(--ui-text-faint);
  cursor: default;
}

.doc-share-btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Mobile BottomSheet (<= 767px) */
@media (max-width: 767px) {
  .doc-app .main header .doc-share-top-btn,
  .doc-share-top-btn {
    min-height: var(--ui-touch);
    height: var(--ui-touch);
    min-width: var(--ui-touch);
    padding: 0 var(--ui-space-10);
  }

  .doc-share-backdrop,
  .doc-share-confirm-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .doc-share-dialog,
  .doc-share-confirm-card {
    max-width: 100%;
    max-height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--ui-radius-sheet);
    border-top-right-radius: var(--ui-radius-sheet);
    box-shadow: var(--ui-shadow-sheet);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .doc-share-sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: var(--ui-space-8) auto var(--ui-space-2);
    border-radius: var(--ui-radius-full);
    background: var(--ui-line-strong);
    flex-shrink: 0;
  }

  .doc-share-header {
    padding: 0 var(--ui-space-12) 0 var(--ui-space-16);
  }

  .doc-share-body {
    padding: var(--ui-space-12) var(--ui-space-16) var(--ui-space-14);
    gap: var(--ui-space-14);
  }

  .doc-share-collab-list.is-scrollable {
    max-height: 180px;
  }

  .doc-share-collab-list.is-scrollable.has-open-menu {
    max-height: none;
    overflow: visible;
  }

  .doc-share-close,
  .doc-share-back-btn,
  .doc-share-copy-btn,
  .doc-share-btn-primary,
  .doc-share-btn-secondary {
    min-height: var(--ui-touch);
    height: var(--ui-touch);
  }

  .doc-share-role-btn,
  .doc-share-add-perm-btn {
    min-height: var(--ui-control-md);
    height: var(--ui-control-md);
  }

  .doc-share-transfer-ghost {
    min-height: var(--ui-control-sm);
    height: var(--ui-control-sm);
    opacity: 1;
  }

  .doc-share-close {
    width: var(--ui-touch);
    height: var(--ui-touch);
  }

  .doc-share-add-bar {
    min-height: var(--ui-touch);
  }

  .doc-share-input,
  .doc-share-dialog .doc-share-add-bar input.doc-share-search-input {
    font-size: var(--ui-mobile-input-size);
    min-height: var(--ui-touch);
    height: var(--ui-touch);
  }

  .doc-share-access-main {
    flex-wrap: wrap;
    padding: var(--ui-space-10) var(--ui-space-12);
  }

  .doc-share-quick-mode {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .doc-share-quick-mode-btn {
    min-height: var(--ui-control-sm);
    height: var(--ui-control-sm);
  }

  .doc-share-scope-menu {
    top: auto;
    bottom: calc(100% + var(--ui-space-4));
  }

  .doc-share-footer {
    flex-direction: column;
    align-items: stretch;
    gap: var(--ui-space-8);
    padding: var(--ui-space-10) var(--ui-space-16) var(--ui-space-16);
  }

  .doc-share-link-pill {
    width: 100%;
    min-height: var(--ui-touch);
    height: var(--ui-touch);
    justify-content: flex-start;
    background: var(--ui-bg-soft);
  }

  .doc-share-copy-btn {
    width: 100%;
  }

  .doc-guest-topbar {
    padding: 0 var(--ui-space-12);
    gap: var(--ui-space-8);
  }
}
