/* Senko's Files - colours are the senko.tools rose theme (senko_site src/styles/global.css + themes.css).
   Follows the system light/dark setting: this is another origin, so it can't read the site's theme setting. */
:root {
  --bg-main: #1a1617;
  --bg-surface: #251f21;
  --bg-soft: #362d30;
  --border-subtle: #453a3d;
  --border-focus: #8c6a74;
  --accent-highlight: #eec1c8;
  --accent-primary: #d4a5b2;
  --accent-muted: #a3818a;
  --accent-glow: rgba(212, 165, 178, 0.15);
  --text-main: #f2ecee;
  --text-muted: #b0a2a6;
  --text-inverse: #1a1617;
  --link-color: #e2b2be;
  --link-hover: #fcd7dd;
  --blue: #6a6ca6;
  --green: #6aa694;
  --yellow: #e0b06b;
  --red: #ba465b;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-main: #f6f1f2;
    --bg-surface: #ffffff;
    --bg-soft: #efe5e8;
    --border-subtle: #e2d4d8;
    --border-focus: #b98b98;
    --accent-highlight: #8d4560;
    --accent-primary: #a9566f;
    --accent-muted: #96737d;
    --accent-glow: rgba(169, 86, 111, 0.14);
    --text-main: #2a2225;
    --text-muted: #6e6165;
    --text-inverse: #ffffff;
    --link-color: #9c4b65;
    --link-hover: #74344b;
    --blue: #4c4f9e;
    --green: #2f7d66;
    --yellow: #9a6a12;
    --red: #b0334a;
    color-scheme: light;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
}

a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover {
  color: var(--link-hover);
}

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.8rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
.brand {
  font-weight: 700;
  color: var(--accent-primary);
  font-size: 1.1rem;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  color: var(--text-muted);
}
.crumbs a,
.crumbs span {
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.crumbs a:hover {
  background: var(--bg-soft);
}
.crumbs span[aria-current] {
  color: var(--text-main);
}

/* ---------- Toolbar ---------- */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.search {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}
.search:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  flex: none;
}
.search input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0;
  border: 0;
  background: none;
  color: var(--text-main);
  font: inherit;
  outline: none;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle input {
  accent-color: var(--accent-primary);
}
.views {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}
.view_btn {
  all: unset;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.3rem;
  cursor: pointer;
  background: var(--bg-surface);
}
.view_btn + .view_btn {
  border-left: 1px solid var(--border-subtle);
}
.view_btn svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}
.view_btn:hover svg,
.view_btn[aria-pressed='true'] svg {
  fill: var(--accent-primary);
}
.view_btn[aria-pressed='true'] {
  background: var(--bg-soft);
}
.view_btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

/* ---------- List ---------- */
.list {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem 9.5rem 2rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.row.head {
  border-top: 0;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  background: var(--bg-soft);
}
.row.head button {
  all: unset;
  cursor: pointer;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.row.head button:hover,
.row.head button[aria-sort] {
  color: var(--accent-primary);
}
.row.head button[aria-sort='ascending']::after {
  content: ' \25B4';
}
.row.head button[aria-sort='descending']::after {
  content: ' \25BE';
}
/* A list row is a link (the name) stretched over the whole row, with the copy button on top of it */
.row.item {
  position: relative;
}
.row.item:hover,
.row.item:focus-within {
  background: var(--bg-soft);
}
.name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: var(--text-main);
}
.name:hover {
  color: var(--text-main);
}
.row .name::after {
  content: '';
  position: absolute;
  inset: 0;
}
.name:focus-visible {
  outline: none;
}
.row.item:has(.name:focus-visible) {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

/* Copy-link button: always there on touch screens, on hover/focus with a mouse */
.copy {
  all: unset;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
}
.copy svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}
.copy:hover {
  background: var(--bg-main);
}
.copy:hover svg {
  fill: var(--accent-primary);
}
.copy:focus-visible {
  outline: 2px solid var(--accent-primary);
}
@media (hover: hover) {
  .item .copy {
    opacity: 0;
  }
  .item:hover .copy,
  .item:focus-within .copy {
    opacity: 1;
  }
}
.name svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.name .text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.name .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.name .where {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.size,
.date {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.size {
  text-align: right;
}
.k-dir {
  fill: var(--accent-primary);
}
.k-image {
  fill: var(--green);
}
.k-video {
  fill: var(--blue);
}
.k-audio {
  fill: var(--yellow);
}
.k-file {
  fill: var(--text-muted);
}
.row.head > :nth-child(2) {
  text-align: right;
}

.status {
  color: var(--text-muted);
  text-align: center;
  min-height: 1.5em;
}
.status.error {
  color: var(--red);
}

@media (max-width: 600px) {
  .row {
    grid-template-columns: minmax(0, 1fr) 5rem 2.5rem;
  }
  .row .date,
  .row.head > :nth-child(3) {
    display: none;
  }
  .copy {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ---------- Grid view ---------- */
.list.grid {
  background: none;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.list.grid .row.head {
  display: flex;
  gap: 1.25rem;
  padding: 0.4rem 0.2rem 0.75rem;
  background: none;
}
.list.grid .row.head > span {
  display: none;
}
.list.grid .row.head > :nth-child(3) {
  display: inline;
}
.list.grid #rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}
.card:hover,
.card:focus-within {
  border-color: var(--border-focus);
}
.card:has(.thumb:focus-visible) {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}
.thumb {
  position: static;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  /* checkerboard, so transparent images are visible */
  background: repeating-conic-gradient(var(--bg-soft) 0 25%, var(--bg-main) 0 50%) 0 0 / 16px 16px;
  overflow: hidden;
}
.thumb::after {
  content: '';
  position: absolute;
  inset: 0;
}
.thumb:focus-visible {
  outline: none;
}
.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb > svg {
  width: 44px;
  height: 44px;
}
.thumb > svg.badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 22px;
  height: 22px;
  padding: 3px;
  border-radius: 6px;
  background: rgba(10, 8, 9, 0.7);
}
.card_foot {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 0.4rem 0.45rem 0.7rem;
}
.card_foot .text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.card_foot .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.card_foot .where {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .list.grid #rows {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 10;
  transform: translate(-50%, 1rem);
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.error {
  border-color: var(--red);
}
/* The preview is a modal in the top layer, so app.js moves the toast inside it while it's open */
.viewer .toast {
  border-color: #8c6a74;
  background: #251f21;
  color: #f2ecee;
}

/* ---------- Preview ---------- */
.viewer {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 8, 9, 0.92);
  color: #f2ecee;
}
.viewer[open] {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) 3.5rem;
  grid-template-rows: auto minmax(0, 1fr);
}
.viewer::backdrop {
  background: transparent;
}
.viewer_bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: #251f21;
  border-bottom: 1px solid #453a3d;
}
.viewer_title {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.viewer_name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer_meta {
  font-size: 0.8rem;
  color: #b0a2a6;
  font-variant-numeric: tabular-nums;
}

/* "Copy link" + a small arrow that opens the other formats */
.split {
  position: relative;
  display: flex;
}
.split > .btn {
  border-radius: 6px 0 0 6px;
}
.copy_as > summary {
  list-style: none;
  height: 100%;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  padding: 0.4rem 0.55rem;
}
.copy_as > summary::-webkit-details-marker {
  display: none;
}
.copy_menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.3rem;
  border: 1px solid #453a3d;
  border-radius: 8px;
  background: #251f21;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.copy_menu button {
  all: unset;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}
.copy_menu button:hover,
.copy_menu button:focus-visible {
  background: #362d30;
}
.copy_menu span {
  font-size: 0.88rem;
  color: #f2ecee;
}
.copy_menu code {
  font-size: 0.75rem;
  color: #b0a2a6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid #453a3d;
  border-radius: 6px;
  background: #362d30;
  color: #f2ecee;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn:hover {
  border-color: #8c6a74;
  color: #fcd7dd;
}
.btn.icon {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.3rem 0.65rem;
}
.viewer_body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  min-height: 0;
}
.viewer_body img,
.viewer_body video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.viewer_body audio {
  width: min(100%, 520px);
}
.nav {
  all: unset;
  cursor: pointer;
  font-size: 2.5rem;
  color: #b0a2a6;
  text-align: center;
  align-self: center;
}
.nav:hover {
  color: #eec1c8;
}
.nav[hidden] {
  visibility: hidden;
}
