/* T385 (doc 57 §4): Files page visual system from the prototype.
   Applied as a separate file — files.css is at the 1000-line limit. */

/* ── Files page header: the prototype's briefing tone ── */
.files-heading .page-header-kicker, #files-legacy-tab .page-header-kicker {
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-accent);
}
#files-legacy-tab h2 { font-family: var(--font-ui); font-size: 1.35rem; font-weight: 700;
  letter-spacing: -0.015em; color: var(--ui-text); }
#files-legacy-tab .page-header p { font-family: var(--font-ui); font-size: 0.88rem;
  color: var(--ui-text-soft); }

/* ── File tree: calmer, mono paths, phosphor freshness dots ── */
.files-tree-pane { border-right: 1px solid var(--ui-line-soft); }
.files-tree-pane .file-name { font-family: var(--font-ui); font-size: 0.82rem; }
.files-tree-pane .file-entry { border-radius: 0.5rem; transition: background 120ms ease; }
.files-tree-pane .file-entry:hover { background: var(--ui-panel-hover, rgba(255,255,255,0.04)); }
.files-tree-pane .file-entry.selected { background: color-mix(in srgb, var(--ui-accent) 8%, transparent); }
.files-tree-pane .file-path, .files-tree-pane time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ui-muted); }

/* ── Search: prominent, Inter, the §1b find-by-work affordance ── */
#files-legacy-tab input[type="search"] {
  font-family: var(--font-ui); font-size: 0.88rem;
  padding: 0.55rem 0.75rem 0.55rem 2.1rem; border-radius: 0.65rem;
  border: 1px solid var(--ui-line); background: var(--ui-panel);
  color: var(--ui-text); transition: border-color 140ms ease;
}
#files-legacy-tab input[type="search"]:focus { outline: none;
  border-color: color-mix(in srgb, var(--ui-accent) 45%, transparent); }
#files-legacy-tab input[type="search"]::placeholder { color: var(--ui-muted); }

/* ── Upload button: subtle ghost ── */
#files-legacy-tab .button.primary { font-family: var(--font-ui); font-weight: 650; }
#files-legacy-tab .button.quiet { font-family: var(--font-ui); }

/* ── Preview pane: the reading surface ── */
.file-preview-pane { border-left: 1px solid var(--ui-line-soft); }
.file-preview-title { font-family: var(--font-ui); font-weight: 650; }
.file-preview-path { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ui-muted); }
.file-preview-body { font-family: var(--font-ui); font-size: 0.88rem; line-height: 1.6; }

/* ── File tree controls: mono, compact ── */
.file-tree-controls { font-family: var(--font-mono); font-size: 0.68rem; }

/* ── Recency key: the freshness legend ── */
.file-recency-key { font-family: var(--font-mono); font-size: 0.62rem;
  color: var(--ui-muted); letter-spacing: 0.04em; }

/* T393 (doc 57): files view tabs — Browse / Recent / Pinned / Search. */
.files-view-tabs { display: flex; gap: 0.25rem; align-items: center; margin: 0 0 0.85rem;
  border-bottom: 1px solid var(--ui-line-soft); }
.files-view-tab { appearance: none; background: none; border: none; border-bottom: 2px solid transparent;
  padding: 0.5rem 0.9rem 0.45rem; font-family: var(--font-ui); font-size: 0.85rem; font-weight: 500;
  color: var(--ui-text-soft); cursor: pointer; }
.files-view-tab:hover { color: var(--ui-text); }
.files-view-tab[aria-selected="true"] { color: var(--ui-text); border-bottom-color: var(--ui-accent); }

#files-pane[data-files-view="pinned"] #files-tree,
#files-pane[data-files-view="recent"] #files-tree { display: none; }
#files-pane[data-files-view="pinned"] #files-pinned-pane,
#files-pane[data-files-view="recent"] #files-recent-pane { display: block; }

.files-alt-pane { padding: 0.4rem 0.2rem 1rem; }
.files-alt-title { font-family: var(--font-mono); font-size: 0.65rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-muted); margin: 0.4rem 0 0.6rem; }
.files-alt-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid transparent; border-radius: 0.65rem;
  background: transparent; cursor: pointer; text-align: left;
  transition: background 140ms ease, border-color 140ms ease; }
.files-alt-row:hover, .files-alt-row:focus-visible { background: var(--ui-panel-hover, var(--ui-hover)); border-color: var(--ui-line); }
.files-alt-name { font-family: var(--font-ui); font-size: 0.85rem; color: var(--ui-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-alt-row em { font-family: var(--font-mono); font-style: normal; font-size: 0.62rem;
  color: var(--ui-muted); flex: none; }
.files-alt-empty { color: var(--ui-muted); font-size: 0.8rem; padding: 0.6rem 0.2rem; }

/* T394: pinned folder cards + open-file tab strip polish. */
.pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.7rem; }
.pin-card { border: 1px solid var(--ui-line); border-radius: 0.85rem; background: var(--ui-panel); padding: 0.8rem 0.85rem; }
.pin-head { display: flex; align-items: flex-start; gap: 0.55rem; margin-bottom: 0.5rem; }
.pin-star { color: var(--ui-accent); flex: none; }
.pin-name { font-family: var(--font-ui); font-weight: 650; font-size: 0.88rem; color: var(--ui-text); }
.pin-path { font-family: var(--font-mono); font-size: 0.6rem; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }
.pin-count { margin-left: auto; font-family: var(--font-mono); font-size: 0.6rem; color: var(--ui-muted); flex: none; }
.pin-files .files-alt-row { padding: 0.4rem 0.5rem; }
/* T450: open-file tabs to prototype chip spec — mono chips, filled active chip, 16px close. */
.file-preview-tabs { border-bottom: 1px solid var(--ui-line-soft); gap: 0.25rem; padding: 0.35rem 0.6rem 0; }
.file-preview-tabs .file-preview-tab {
  border: 1px solid transparent; border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
  background: transparent; box-shadow: none;
  padding: 0 0.15rem 0 0.6rem;
}
.file-preview-tabs .file-preview-tab.active { background: var(--ui-hover); border-color: var(--ui-line); box-shadow: none; color: var(--ui-text); }
.file-preview-tabs .file-preview-tab-button { font: 500 0.7rem/1 ui-monospace, Menlo, monospace; padding: 0.35rem 0; color: var(--ui-muted); }
.file-preview-tabs .file-preview-tab-button:hover { color: var(--ui-text); }
.file-preview-tabs .file-preview-tab-close { width: 1rem; height: 1rem; border-radius: 0.3rem; padding: 0; margin-inline: 0.2rem 0.25rem; border: 0; background: transparent; color: var(--ui-muted); font-size: 0.8rem; line-height: 1; }
.file-preview-tabs .file-preview-tab-close:hover { background: var(--ui-hover); color: var(--ui-text); }
/* T450: even breadcrumb slash spacing (prototype renders one text run). */
.file-preview-header .file-preview-breadcrumb { gap: 0; }
.file-preview-header .file-preview-breadcrumb::before { margin-inline-end: 0.4rem; }
.file-preview-header .file-breadcrumb-separator { padding-inline: 0.4rem; }

/* T400: open-file tabs survive narrow widths — horizontal scroll + shrink. */
.file-preview-tabs { overflow-x: auto; scrollbar-width: thin; }
.file-preview-tabs button {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: none;
}

/* T406: files panes join the glass card system. */
.files-tree-pane,
.file-preview-pane {
  background: color-mix(in srgb, var(--ui-text) 3%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ui-line);
  border-radius: 1.125rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.files-tree-toolbar { padding: 0.8rem 0.85rem 0.4rem; }
.file-preview-header { padding-block: 0.8rem; }

/* T412: files page prototype parity — big header, generous rhythm. */
#files-legacy-tab .page-header h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.015em; }
#files-legacy-tab .page-header p { font-size: 0.92rem; }
#files-legacy-tab .files-pane { padding-top: 0.4rem; }
#files-legacy-tab .files-view-tabs { margin-top: 0.9rem; }

/* T433 (doc 57): files tab strip + pane geometry to prototype.
   Active tab = accent bottom underline; mono count chips; Upload ghost in
   the row; left pane 360px; the resize handle stays functional but
   invisible (prototype has separate cards with a gap). */
.files-view-tabs { border-bottom: 1px solid var(--ui-line-soft); gap: 0.25rem; }
.files-view-tab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.55rem 0.85rem 0.5rem;
  margin-bottom: -1px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ui-text-soft);
  background: transparent;
}
.files-view-tab:hover { color: var(--ui-text); background: transparent; }
.files-view-tab[aria-selected="true"] {
  color: var(--ui-text);
  border-bottom-color: var(--ui-accent);
}
.ft-count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ui-muted);
  margin-left: 0.3rem;
}
.files-view-tab[aria-selected="true"] .ft-count { color: var(--ui-accent); }
.ft-upload-slot { margin-left: auto; align-self: center; }

.files-split { --files-tree-width: 22.5rem; }
.files-divider, .files-split > .panel-divider {
  background: transparent;
  border: none;
  width: 10px;
}

/* T435: pinned cards to the exact prototype spec. */
#files-pane .pin-grid,
.pin-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.875rem; }
.pin-card {
  padding: 1rem 1.0625rem;             /* 16px 17px */
  border-radius: 1.125rem;             /* 18px */
  transition: background 140ms ease;
}
.pin-card:hover { background: var(--ui-panel-hover, var(--ui-hover)); }
.pin-head { gap: 0.6875rem; margin-bottom: 0.75rem; }
.pin-star { color: var(--ui-warning); } /* the prototype star is amber */
.pin-name { font-size: 0.9375rem; font-weight: 650; }   /* 15px/650 */
.pin-path { font-size: 0.6875rem; }
.pin-count { font-size: 0.6875rem; }
.pin-files { gap: 0.25rem; }
.pin-files .files-alt-row {
  padding: 0.4375rem 0.625rem;         /* 7px 10px */
  border-radius: 0.5625rem;            /* 9px */
  border: none;
  background: transparent;
  justify-content: space-between;
}
.pin-files .files-alt-row:hover { background: var(--ui-panel-hover, var(--ui-hover)); border-color: transparent; }
.pin-files .files-alt-name { font-size: 0.8125rem; color: var(--ui-text-soft); }
.pin-files .files-alt-row:hover .files-alt-name { color: var(--ui-text); }
.pin-files .files-alt-row em { font-size: 0.6875rem; }

/* T436: alt-pane visibility is explicit CSS, never the [hidden] attribute.
   Panes are display:none by default; the active view shows exactly one. */
#files-pinned-pane,
#files-recent-pane { display: none; }
#files-pane[data-files-view="pinned"] #files-pinned-pane { display: block; }
#files-pane[data-files-view="recent"] #files-recent-pane { display: block; }
#files-pane[data-files-view="pinned"] #files-tree,
#files-pane[data-files-view="recent"] #files-tree { display: none; }

/* T439 (doc 57): files page gap-close from the operator's two screenshots.
   Icon buttons truly borderless; count chips chip-like; Upload as a ghost
   button; pinned empty-state with icon; tree rows as rounded hover rows
   with breathing; search field prominent; preview empty state friendly;
   breadcrumb legible; radii to 18; rhythm relaxed. */

/* 1. Icon buttons: kill any residual border/box feel. */
.topbar .topbar-icon-control,
.topbar .button.quiet.topbar-icon-control {
  border-color: transparent !important;
  background: transparent;
}

/* 2. Count chips chip-like. */
.ft-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ui-text) 7%, transparent);
  vertical-align: 0.1em;
}
.files-view-tab[aria-selected="true"] .ft-count {
  background: color-mix(in srgb, var(--ui-accent) 15%, transparent);
}

/* 3. Upload reads as a ghost button. */
.ft-upload-slot .button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--ui-line);
  border-radius: 0.65rem;
  background: var(--ui-panel);
  color: var(--ui-text-soft);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
}
.ft-upload-slot .button:hover {
  background: var(--ui-panel-hover, var(--ui-hover));
  color: var(--ui-text);
}

/* 4. Pinned empty state: friendly, not bare. */
.files-alt-empty {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--ui-muted);
}
#files-pinned-pane .files-alt-empty::before {
  content: "★";
  font-size: 1.4rem;
  color: var(--ui-warning);
  opacity: 0.7;
}

/* 5. Tree rows: rounded hover rows with breathing (prototype tree). */
.files-tree .file-entry {
  border-radius: 0.55rem;
  padding: 0.45rem 0.55rem;
  transition: background 140ms ease;
}
.files-tree .file-entry:hover { background: var(--ui-panel-hover, var(--ui-hover)); }
.files-tree .file-name { font-size: 0.84rem; }
.files-tree .file-time { margin-left: auto; padding-left: 0.75rem; }

/* 6. Search field prominent, prototype-rounded. */
#files-search,
.files-tree-search {
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
  border: 1px solid var(--ui-line);
  background: var(--ui-panel);
}

/* 7. Preview empty state friendly. */
.file-preview-empty {
  display: grid;
  place-items: center;
  gap: 0.6rem;
  color: var(--ui-muted);
  font-size: 0.875rem;
}
.file-preview-body.file-preview-empty::before {
  content: "◇";
  font-size: 2rem;
  opacity: 0.35;
}

/* 8. Breadcrumb legible. */
.file-preview-breadcrumb, .file-preview-title {
  font-size: 0.875rem;
  font-weight: 600;
}

/* 9. Tree pane card radius to 18 + rhythm. */
.files-tree-pane, .file-preview-pane { border-radius: 1.125rem; }
.files-pane { gap: 0.9rem; display: grid; }
.files-split { gap: 0.9rem; }

/* T440 (doc 57): preview header detail — the Dock affordance stops wrapping,
   the header row breathes, actions align to one line. */
.file-preview-header { gap: 0.75rem; }
.file-preview-title-row { min-width: 0; flex: 1; }
.file-preview-actions { flex: none; white-space: nowrap; }
.file-action { white-space: nowrap; gap: 0.35rem; }
.file-action .file-action-label { white-space: nowrap; }
.file-focused-dock-open .file-action-label { display: inline; }
.file-preview-details { gap: 0.75rem; white-space: nowrap; overflow: hidden; }
.file-preview-size, .file-preview-lines { white-space: nowrap; }

/* T445 (doc 57): the prototype's empty states, fully composed.
   Pinned-empty: large muted illustration, heading, body copy, ghost
   Browse-files action. Preview-empty: large diamond, heading, body, hint. */

/* Pinned empty state — prototype composition. */
#files-pinned-pane .files-alt-empty {
  padding: 3.2rem 1.5rem;
  gap: 0.75rem;
}
#files-pinned-pane .files-alt-empty::before {
  content: "❐";
  font-size: 3.2rem;
  line-height: 1;
  color: var(--ui-muted);
  opacity: 0.45;
  border: none;
  background: none;
  width: auto;
  height: auto;
}
#files-pinned-pane .files-alt-empty::after {
  content: "Star files or folders to keep them close at hand";
  display: block;
  font-size: 0.8125rem;
  color: var(--ui-muted);
}
#files-pinned-pane .files-alt-empty { font-size: 0.95rem; font-weight: 600; color: var(--ui-text-soft); }
#files-pinned-pane .files-alt-empty .empty-browse-hint {
  display: block;
}

/* Preview empty state — prototype composition. */
.file-preview-body.file-preview-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.65rem;
  padding: 3rem 1.5rem;
}
.file-preview-body.file-preview-empty::before {
  content: "◇";
  font-size: 3rem;
  line-height: 1;
  opacity: 0.4;
}
.file-preview-body.file-preview-empty { font-size: 0.95rem; font-weight: 600; color: var(--ui-text-soft); }
.file-preview-body.file-preview-empty::after {
  content: "Choose from pinned, recent, or browse the workspace · Recent files appear here";
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ui-muted);
}

.files-empty-browse { margin-top: 0.35rem; }

/* T446 (doc 57): recent pane at prototype row scale; preview content at
   reading comfort. */
#files-recent-pane .files-alt-row {
  padding: 0.625rem 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid transparent;
}
#files-recent-pane .files-alt-row:hover {
  background: var(--ui-panel-hover, var(--ui-hover));
  border-color: var(--ui-line);
}
#files-recent-pane .files-alt-name { font-size: 0.875rem; font-weight: 600; color: var(--ui-text); }
#files-recent-pane .files-alt-row em { font-size: 0.6875rem; }
#files-recent-pane .files-alt-title { margin-bottom: 0.6rem; }

/* Preview content: reading comfort. */
.file-preview-body {
  max-width: 92ch;
  margin-inline: auto;
  font-size: 0.8125rem;
  line-height: 1.6;
  padding: 1.5rem 2rem 2.5rem;
}
.file-preview-body pre { font-size: 0.8125rem; line-height: 1.6; }
.file-preview-tabs button { font-size: 0.8rem; }

/* T448 (doc 57): files page top to prototype — header carries no controls
   (Recent is a tab now; the moved toolbar controls hide on desktop),
   heading at text-xl 20px, subline at soft 15px. */
@media (min-width: 821px) {
  #files-legacy-tab .files-actions .files-header-control { display: none; }
  #files-legacy-tab .files-actions:empty { display: none; }
}
#files-legacy-tab .page-header h2 { font-size: 1.25rem; }
#files-legacy-tab .page-header p {
  font-size: 0.9375rem;
  color: var(--ui-text-soft);
  margin-top: 0.2rem;
}

/* T449 (doc 57): the prototype's Search pane composition — friendly empty
   state (icon + heading + body + ⌘K hint) that yields to results on typing. */
#files-search-pane { display: none; }
#files-pane[data-files-view="search"] #files-search-pane { display: block; }
#files-pane[data-files-view="search"] #files-tree { display: none; }
.files-search-empty {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  text-align: center;
  padding: 3rem 1.5rem;
}
.files-search-empty .se-ico {
  font-size: 2.2rem;
  line-height: 1;
  color: var(--ui-muted);
  opacity: 0.5;
}
.files-search-empty h3 {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ui-text-soft);
  margin: 0;
}
.files-search-empty p {
  font-size: 0.8125rem;
  color: var(--ui-muted);
  margin: 0;
  max-width: 26rem;
}

/* T451: search results as prototype result cards. */
.files-search-results .files-search-option {
  display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 0.75rem; align-items: start;
  padding: 0.75rem 0.85rem; border-radius: 0.7rem; margin: 0 0 0.5rem; width: 100%;
  background: var(--ui-panel); border: 1px solid var(--ui-line);
  text-align: left; transition: background 140ms ease;
}
.files-search-results .files-search-option:hover,
.files-search-results .files-search-option[aria-selected="true"] { background: var(--ui-panel-hover, var(--ui-hover)); }
.files-search-results .files-search-icon {
  width: 30px; height: 30px; border-radius: 0.55rem; display: grid; place-items: center;
  background: var(--ui-hover); color: var(--ui-text-soft);
}
.files-search-results .files-search-copy { display: block; min-width: 0; }
.files-search-results .files-search-name { display: block; font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; color: var(--ui-text); }
.files-search-results .files-search-parent { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--ui-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-search-results .files-search-snippet { display: block; font-family: var(--font-ui); font-size: 12.5px; color: var(--ui-text-soft); margin-top: 6px; line-height: 1.5; }
.files-search-results .files-search-group-title {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ui-muted); margin: 0.4rem 0.45rem 0.55rem;
}
.files-search-results .files-search-summary {
  font-family: var(--font-mono); font-size: 11px; color: var(--ui-muted); text-align: center; padding: 0.4rem 0 0.2rem;
}
/* In the Search pane the results panel is pane content, not a floating dropdown. */
.files-search-pane .files-search-results {
  position: static; z-index: auto; max-height: none; overflow: visible;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  padding: 0.9rem 0.9rem 0.4rem; margin: 0;
}
.files-search-pane .files-search-empty { text-align: center; padding: 2.8rem 1.2rem; }

/* T458: responsive time labels per prototype .ft-wrap tiers. */
.files-alt-row { container-type: inline-size; }
.files-alt-row .ft-wrap {
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--ui-muted); flex: none;
  margin-left: auto; white-space: nowrap;
}
.files-alt-row .ft-wrap .t1, .files-alt-row .ft-wrap .t2 { display: none; }
@container (max-width: 380px) {
  .files-alt-row .ft-wrap .t0 { display: none; }
  .files-alt-row .ft-wrap .t1 { display: inline; }
}
@container (max-width: 300px) {
  .files-alt-row .ft-wrap .t1 { display: none; }
  .files-alt-row .ft-wrap .t2 { display: inline; }
}
@container (max-width: 230px) {
  .files-alt-row .ft-wrap { display: none; }
}
.pin-files .files-alt-row .ft-wrap { font-size: 0.6875rem; }
