/* «Файлы»: the cabinet's stored files. Loaded after bearmark.css, inbox.css
   and stats.css; kit roles only (design/core: BmTable rows, BmBadge soft,
   BmIconButton, BmSegmented, BmProgress meters, BmEmptyState, BmCard). The
   list is one surface with hairline rows, as «Доступ» and the journal. */

.files-view {
  gap: 16px;
}
.files-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.files-main {
  display: grid;
  gap: 12px;
  min-width: 0;
  container: files / inline-size;
}
.files-open {
  justify-self: start;
}

/* ---- conditions (BmCard with a disclosure) -------------------------------- */
.files-terms.section-card {
  display: block;
  padding: 0;
}
.files-terms > summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  min-height: 44px;
  padding: 15px 48px 15px 18px;
  list-style: none;
  border-radius: var(--bm-radius-lg);
}
.files-terms > summary::-webkit-details-marker {
  display: none;
}
.files-terms > summary::after {
  content: '';
  position: absolute;
  right: 20px;
  top: 21px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--bm-text-soft);
  border-bottom: 2px solid var(--bm-text-soft);
  rotate: 45deg;
  transition: rotate var(--bm-dur-fast) var(--bm-ease-standard);
}
.files-terms[open] > summary::after {
  border-color: var(--bm-accent-ink);
  rotate: 225deg;
  top: 24px;
}
.files-terms > summary:hover {
  background: color-mix(in srgb, var(--bm-text) 4%, transparent);
}
.files-terms-title {
  font: 700 17px/1.3 var(--bm-font-display);
  letter-spacing: -0.02em;
}
.files-terms-line {
  color: var(--bm-text-soft);
  font-size: 13px;
}
.files-terms[open] .files-terms-line {
  display: none;
}
.files-terms-body {
  display: grid;
  gap: 16px;
  padding: 0 18px 18px;
}
.files-facts {
  display: grid;
  gap: 2px;
  margin: 0;
}
.files-fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border-bottom: 1px solid var(--bm-border);
}
.files-fact dt,
.files-overline {
  margin: 0;
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.files-fact dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}
.files-fact dd .muted {
  font-weight: 400;
}
.files-change.link-button {
  min-height: var(--tb-control-sm);
  margin-right: -4px;
}
.files-numbers {
  display: grid;
  gap: 10px;
}
.files-number-meter .meter-head span {
  font: 600 13px/1.35 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
  color: var(--bm-text);
}
.files-rules {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 12px 14px 12px 30px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-raised);
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.45;
}

/* ---- filters ---------------------------------------------------------------- */
.files-tools {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.files-find {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.files-find .search-field {
  flex: 1 1 260px;
}
.files-number {
  flex: 0 1 240px;
  min-width: 190px;
}
.files-storage .segmented {
  width: min(100%, 440px);
}
.seg-count {
  margin-left: 2px;
  color: var(--bm-text-soft);
  font-variant-numeric: tabular-nums;
}
.seg-count:empty {
  display: none;
}
.files-kinds .count:empty {
  display: none;
}
.files-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  min-height: 44px;
}
.files-count {
  margin: 0;
  color: var(--bm-text-soft);
  font: 600 12px/1.4 var(--bm-font-mono);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.files-note {
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  font-size: 14px;
}

/* ---- the list (BmTable rows on one surface) --------------------------------- */
.files-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: clip;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  transition: opacity var(--bm-dur-base) var(--bm-ease-standard);
}
.files-list:empty {
  display: none;
}
.files-list[aria-busy='true'] {
  opacity: 0.6;
}
.file-row {
  display: grid;
  grid-template-columns: 28px 48px minmax(0, 1fr);
  grid-template-areas:
    'pick thumb name'
    'pick thumb facts'
    'pick thumb where'
    'pick thumb store'
    'pick thumb actions';
  column-gap: 12px;
  row-gap: 3px;
  align-items: start;
  padding: 12px 14px;
  border-top: 1px solid var(--bm-border);
  transition: background-color var(--bm-dur-fast) var(--bm-ease-standard);
}
.file-row:first-child {
  border-top: 0;
}
.file-row:hover {
  background: color-mix(in srgb, var(--bm-text) 3%, transparent);
}
.file-row[data-picked='true'] {
  background: var(--bm-wash-accent);
  box-shadow: inset 3px 0 0 var(--bm-accent-ink);
}
.file-pick {
  grid-area: pick;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -2px -8px 0;
  cursor: pointer;
}
.file-thumb {
  grid-area: thumb;
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: var(--bm-radius-md);
  background: var(--bm-wash-accent);
  color: var(--bm-accent-ink);
}
.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.file-thumb.sticker {
  background: transparent;
}
.file-thumb.sticker img {
  object-fit: contain;
}
a.file-thumb {
  cursor: zoom-in;
}
/* Over a picture the mark is a fixed dark disc in both themes. */
.file-play {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(
    in srgb,
    var(--bm-iron) 72%,
    transparent
  ); /* bm-allow-theme-blind: over a photo */
  color: var(--bm-ivory); /* bm-allow-theme-blind: over a photo */
}
.file-name {
  grid-area: name;
  min-width: 0;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.file-facts {
  grid-area: facts;
  color: var(--bm-text-soft);
  font: 600 11px/1.45 var(--bm-font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.file-facts:empty {
  display: none;
}
.file-where {
  grid-area: where;
  min-width: 0;
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.5;
}
.file-where .tag {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  margin-right: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.file-chat {
  color: var(--bm-text);
  font-weight: 500;
}
.file-store {
  grid-area: store;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-top: 3px;
  color: var(--bm-text-soft);
  font-size: 13px;
}
/* The storage class (BmBadge soft): the tone's ink on a wash of itself. */
.file-keep {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  border-radius: var(--bm-radius-pill);
  background: color-mix(in srgb, currentColor 12%, transparent);
  color: var(--bm-pending-ink);
  font: 700 11px/1.5 var(--bm-font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.file-keep[data-keep='pinned'],
.file-keep[data-keep='all'] {
  color: var(--bm-accent-ink);
}
.file-until {
  color: var(--bm-text);
}
.file-until[data-soon='true'] {
  color: var(--bm-caution-ink);
  font-weight: 600;
}
.file-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
/* BmIconButton: the control border, a faint fill on hover, pressed in brass. */
.file-actions .icon-button {
  width: var(--tb-control-sm);
  min-height: var(--tb-control-sm);
  padding: 0;
  color: var(--bm-text-soft);
}
.file-actions .icon-button:not(:disabled):hover {
  color: var(--bm-text);
}
.file-actions .icon-button[aria-pressed='true'] {
  border-color: var(--bm-accent-ink);
  background: var(--bm-wash-accent);
  color: var(--bm-accent-ink);
}
.file-actions .icon-button.danger {
  color: var(--bm-warn-ink);
  border-color: color-mix(in srgb, var(--bm-warn-ink) 45%, transparent);
}

/* A wide list: what is kept and how long gets a column, the actions sit at the end. */
@container files (min-width: 640px) {
  .file-row {
    grid-template-columns: 28px 52px minmax(0, 1fr) minmax(150px, 200px) auto;
    grid-template-areas:
      'pick thumb name store actions'
      'pick thumb facts store actions'
      'pick thumb where store actions';
    column-gap: 14px;
    padding: 12px 16px;
  }
  .file-thumb {
    width: 52px;
    height: 52px;
  }
  .file-store {
    flex-direction: column;
    align-items: flex-start;
    align-self: center;
    margin-top: 0;
  }
  .file-actions {
    flex-wrap: nowrap;
    align-self: center;
    margin-top: 0;
  }
}

/* The bulk bar's words: whole on a wide screen, short on a phone. */
.files-short {
  display: none;
}
.files-bulk .bulk-n {
  white-space: nowrap;
}

/* ---- empty, loading (BmEmptyState) ------------------------------------------- */
.files-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: 1px dashed var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  text-align: center;
}
.files-empty-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--bm-border);
  border-radius: 50%;
  background: var(--bm-raised);
  color: var(--bm-text-soft);
}
.files-empty-title {
  font: 700 16px/1.3 var(--bm-font-display);
}
.files-empty .muted {
  max-width: 48ch;
  font-size: 14px;
}
.files-empty .button {
  margin-top: 4px;
}
.files-loading {
  padding: 28px 16px;
  color: var(--bm-text-soft);
  text-align: center;
}

/* ---- confirmation and the chat it opens ----------------------------------- */
.files-dialog-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.files-dialog-list li {
  padding: 8px 12px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-bg);
  overflow-wrap: anywhere;
}
.files-dialog-list .muted {
  font-size: 13px;
}
/* «Открыть в чате» lands on the message: a brass ring for a moment. */
.bubble.located {
  box-shadow:
    0 0 0 2px var(--bm-accent-ink),
    0 0 0 6px color-mix(in srgb, var(--bm-accent) 30%, transparent);
  transition: box-shadow var(--bm-dur-moderate) var(--bm-ease-out);
}
.bubble[tabindex='-1']:focus {
  outline: none;
}

/* ---- wide screens: the conditions beside the list ---------------------------- */
@media (min-width: 1180px) {
  .files-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .files-terms {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: calc(var(--tb-topbar-h) + 20px);
  }
  .files-main {
    grid-column: 1;
    grid-row: 1;
  }
}
@media (min-width: 621px) and (max-width: 1179px) {
  .files-terms-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .files-rules {
    grid-column: 1 / -1;
  }
}

/* ---- phone --------------------------------------------------------------------- */
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .files-layout {
    gap: 12px;
  }
  .files-find {
    flex-direction: column;
  }
  .files-find .search-field,
  .files-number {
    flex: none;
    width: 100%;
  }
  /* Kinds scroll sideways edge to edge, like the number filter. */
  .files-kinds {
    margin: 0 calc(-1 * var(--tb-gutter));
    padding: 2px var(--tb-gutter);
  }
  .files-storage .segmented {
    width: 100%;
  }
  .files-storage .segmented button {
    padding: 0 6px;
    font-size: 11px;
    letter-spacing: 0.02em;
  }
  .files-terms > summary {
    padding: 13px 44px 13px 16px;
  }
  .files-terms-body {
    padding: 0 16px 16px;
  }
  .file-row {
    padding: 12px;
  }
  .files-bulk .files-long {
    display: none;
  }
  .files-bulk .files-short {
    display: inline;
  }
}
