/* ========================
   FILES PAGE — fully self-contained
   ======================== */

.files-page {
  background: #fdf6f0;
  min-height: 100svh;
  font-family: 'DM Mono', monospace;
  color: #1a1118;
}

.files-main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10rem clamp(1.5rem, 5vw, 4rem) 6rem;
}

/* ---- Header ---- */
.files-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #d4899e;
}

.files-home-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: #1a1118;
  background: #f0e4d7;
  border: 1px solid #d4899e;
  padding: 0.45rem 1rem;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.files-home-btn:hover {
  background: #f5d7df;
  border-color: #9e3a52;
}

.files-title {
  font-family: 'bastelurA', 'Instrument Serif', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: #1a1118;
  line-height: 1;
  font-weight: normal;
  margin: 0;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  margin-bottom: 1.5rem;
}

.breadcrumb ol {
  list-style: none !important;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.5rem 0.8rem !important;
  margin: 0 !important;
  gap: 0;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  background: #f0e4d7;
  border: 1px solid #d4899e;
  width: fit-content;
  counter-reset: none !important;
}

.breadcrumb ol li {
  display: flex;
  align-items: center;
  list-style: none !important;
}

.breadcrumb ol li::before {
  display: none !important;
  content: none !important;
}

.breadcrumb ol li + li::before {
  content: '/' !important;
  display: inline !important;
  padding: 0 0.5rem;
  color: #d4899e;
  pointer-events: none;
}

.crumb-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  color: #4a3040;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  transition: background 0.15s, color 0.15s;
  display: inline-block;
}
.crumb-btn:hover:not(:disabled) {
  background: #f5d7df;
  color: #1a1118;
}
.crumb-btn:disabled {
  color: #1a1118;
  font-weight: 500;
  cursor: default;
}

/* ---- File grid ---- */
.file-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1px;
  background: #d4899e;
  border: 1px solid #d4899e;
  min-height: 200px;
}

.file-grid-empty {
  grid-column: 1 / -1;
  background: #fdf6f0;
  padding: 3rem;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: #4a3040;
  letter-spacing: 0.06em;
  line-height: 2;
}

.file-item {
  background: #fdf6f0;
  border: none !important;
  padding: 1.5rem 1rem;
  cursor: pointer;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  width: 100%;
  transition: background 0.15s;
  font-family: 'DM Mono', monospace;
}
.file-item:hover { background: #f5d7df; }
.file-item:focus-visible {
  outline: 2px solid #9e3a52;
  outline-offset: -2px;
}

/* ---- Icons ---- */
.file-icon {
  width: 2.4rem !important;
  height: 2.4rem !important;
  font-size: unset !important;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  flex-shrink: 0;
}

.file-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.5;
}

.file-icon[data-type="folder"] { color: #c8913a; }
.file-icon[data-type="image"]  { color: #9e3a52; }
.file-icon[data-type="video"]  { color: #7a5abf; }
.file-icon[data-type="audio"]  { color: #3a8f6e; }
.file-icon[data-type="text"]   { color: #4a3040; }
.file-icon[data-type="pdf"]    { color: #c04a2a; }
.file-icon[data-type="unknown"]{ color: #4a3040; }

.file-name {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: #1a1118;
  word-break: break-all;
  line-height: 1.4;
}

.file-size {
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  color: #4a3040;
}

/* ---- Viewer ---- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #fdf6f0;
  display: flex;
  flex-direction: column;
}

.viewer-topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid #d4899e;
  background: #fdf6f0;
  flex-shrink: 0;
}

.viewer-close-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  color: #1a1118;
  background: #f0e4d7;
  border: 1px solid #d4899e;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.viewer-close-btn:hover {
  background: #f5d7df;
  border-color: #9e3a52;
}

.viewer-filename {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: #4a3040;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.viewer-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: #fffaf7;
  background: #9e3a52;
  border: 1px solid #9e3a52;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  margin-left: auto;
  transition: background 0.2s;
  white-space: nowrap;
}
.viewer-dl-btn:hover {
  background: #c4607a;
  border-color: #c4607a;
}
.viewer-dl-btn svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.viewer-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #f0e4d7;
}

.viewer-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.viewer-body video {
  max-width: 100%;
  max-height: 100%;
}
.viewer-body audio {
  width: 100%;
  max-width: 600px;
}
.viewer-body .txt-wrap {
  width: 100%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  background: #fffaf7;
  border: 1px solid #d4899e;
  padding: 2rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  color: #1a1118;
  white-space: pre-wrap;
  word-break: break-word;
  align-self: flex-start;
  margin: auto;
  text-align: left;
}
.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 70vh;
}
.viewer-body .no-preview {
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: #4a3040;
  line-height: 2.5;
}
.viewer-body .no-preview a {
  color: #9e3a52;
  text-decoration: underline;
}

/* ---- Readme ---- */
.readme-panel {
  margin-top: 2rem;
  border: 1px solid #d4899e;
  background: #fdf6f0;
}

.readme-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.2rem;
  background: #f0e4d7;
  border-bottom: 1px solid #d4899e;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: #4a3040;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.readme-header svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: #4a3040;
}

.readme-body {
  padding: 1.5rem 2rem;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1rem;
  line-height: 1.75;
  color: #1a1118;
}
.readme-body h1 { font-family: 'bastelurA', serif; font-size: 2rem; margin-bottom: 0.75rem; line-height: 1.1; font-weight: normal; }
.readme-body h2 { font-family: 'bastelurA', serif; font-size: 1.4rem; margin: 1.5rem 0 0.5rem; font-weight: normal; }
.readme-body h3 { font-family: 'bastelurA', serif; font-size: 1.1rem; margin: 1.2rem 0 0.4rem; font-weight: normal; }
.readme-body p  { margin-bottom: 1em; }
.readme-body p:last-child { margin-bottom: 0; }
.readme-body a  { color: #9e3a52; text-decoration: underline; }
.readme-body strong { font-weight: 600; }
.readme-body em { font-style: italic; }
.readme-body code {
  font-family: 'DM Mono', monospace;
  font-size: 0.85em;
  background: #f0e4d7;
  border: 1px solid #d4899e;
  padding: 0.1em 0.35em;
}
.readme-body pre {
  background: #1a1118;
  color: #fdf6f0;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.6;
}
.readme-body pre code { background: none; border: none; padding: 0; color: inherit; }
.readme-body blockquote {
  border-left: 3px solid #d4899e;
  padding-left: 1rem;
  color: #4a3040;
  margin: 1rem 0;
}
.readme-body ul, .readme-body ol { padding-left: 1.5rem; margin-bottom: 1em; }
.readme-body ul { list-style: disc; }
.readme-body ol { list-style: decimal; }
.readme-body li { margin-bottom: 0.25em; }
.readme-body hr { border: none; border-top: 1px solid #d4899e; margin: 1.5rem 0; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .files-title { font-size: 1.6rem; }
}