:root {
  --bg: #111315;
  --panel: #17191d;
  --panel-soft: #1b1e22;
  --line: #2a2e34;
  --line-dark: #3a4048;
  --text: #e6e8eb;
  --muted: #9aa1aa;
  --accent: #3b82f6;
  --accent-soft: #1e2a3d;
  --green: #4ade80;
  --orange: #e0a95e;
  --red: #f87171;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); }

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--panel-soft);
  font-size: 13px;
  color: var(--accent);
}
.brand-name { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-note { color: var(--muted); font-size: 12px; }
.menu-button {
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--panel);
  padding: 6px 12px;
  font-size: 12px;
}
.mobile-only { display: none; }

.shell {
  height: calc(100dvh - 52px);
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr) 300px;
  background: var(--panel);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel-soft);
  border-right: 1px solid var(--line);
}
.side-title {
  padding: 16px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.tree { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; }
.tree-node { margin: 1px 0; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.tree-row:hover { background: #22262b; }
.tree-row.active { background: var(--accent-soft); border-color: #2f4a73; color: #cfe0ff; }
.tree-caret { width: 12px; flex: none; color: var(--muted); font-size: 10px; }
.tree-caret.open { transform: rotate(90deg); }
.tree-caret.blank { visibility: hidden; }
.tree-icon { display: flex; width: 14px; height: 14px; flex: none; color: #c9a35a; }
.tree-icon svg { width: 14px; height: 14px; fill: currentColor; }
.tree-icon.archive { color: var(--orange); }
.tree-icon.android { color: var(--green); }
.tree-icon.roku { color: #c4b5fd; }
.tree-icon.code { color: #93c5fd; }
.tree-icon.doc { color: #aeb7c2; }
.tree-icon.image { color: #f9a8d4; }
.tree-icon.script { color: #bef264; }
.tree-row.file { color: var(--muted); }
.tree-row.file .tree-name { font-size: 12px; }
.tree-row.file.active { background: var(--accent-soft); border-color: #2f4a73; color: #cfe0ff; }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-badge { margin-left: auto; font-size: 10px; color: var(--muted); }
.tree-children { margin-left: 11px; border-left: 1px solid var(--line); padding-left: 5px; }
.tree-children[hidden] { display: none; }
.side-foot {
  border-top: 1px solid var(--line);
  padding: 11px 16px;
  font-size: 11px;
  color: var(--muted);
}

.workspace { min-width: 0; min-height: 0; overflow-y: auto; background: var(--panel); }

.pathbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.nav-button, .view-button {
  flex: none;
  padding: 5px 9px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}
.nav-button { width: 28px; padding: 5px 0; text-align: center; font-size: 13px; }
.nav-button:hover:not(:disabled), .view-button:hover { background: var(--panel-soft); color: var(--text); }
.nav-button:disabled { opacity: .45; cursor: default; }
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  font-size: 12px;
}
.breadcrumbs button {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 4px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--muted);
}
.breadcrumbs button:hover { background: var(--panel-soft); color: var(--text); }
.breadcrumbs button:last-child { color: var(--text); }
.breadcrumbs i { color: var(--line-dark); font-style: normal; }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(230px, 28vw);
  flex: none;
  padding: 5px 8px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: var(--panel);
}
.search:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, .18); }
.search svg { width: 13px; height: 13px; flex: none; fill: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; outline: none; background: none; font-size: 12px; }
.search input::placeholder { color: #6f7882; }

.folder-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 10px;
}
.folder-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.folder-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.folder-meta { display: flex; gap: 12px; flex: none; font-size: 11px; color: var(--muted); padding-bottom: 3px; }

.listing { padding: 0 12px 24px; }
.list-head {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 86px 74px 96px 18px;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}
.list-head span:nth-child(3),
.list-head span:nth-child(4),
.list-head span:nth-child(5) { text-align: right; }

.row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 86px 74px 96px 18px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--text);
  text-align: left;
}
.row:hover { background: #20242a; }
.row.selected { background: var(--accent-soft); border-color: #2f4a73; }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.file-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 4px;
  background: #23272d;
  color: #aab3bd;
}
.file-icon svg { width: 15px; height: 15px; fill: currentColor; }
.file-icon.folder { background: #2a2416; color: #d6b35a; }
.file-icon.archive { background: #2a2116; color: var(--orange); }
.file-icon.android { background: #17271c; color: var(--green); }
.file-icon.roku { background: #241b33; color: #c4b5fd; }
.file-icon.code { background: #17233a; color: #93c5fd; }
.file-icon.doc { background: #20242a; color: #aeb7c2; }
.file-icon.image { background: #2a1a22; color: #f9a8d4; }
.file-icon.script { background: #20261a; color: #bef264; }

.row-main { min-width: 0; display: grid; gap: 0; }
.row-name { min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.row-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: none;
  padding: 0 4px;
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  color: var(--muted);
  font-size: 9px;
}
.badge.app { border-color: #31527d; background: var(--accent-soft); color: #bcd7ff; }
.row-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.row-type, .row-size, .row-date { color: var(--muted); font-size: 11px; text-align: right; white-space: nowrap; }
.row-chevron { color: #737b84; text-align: right; font-size: 12px; }

.listing.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  padding-top: 8px;
}
.grid-view .list-head { display: none; }
.grid-view .row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  min-height: 138px;
  padding: 12px;
  border-color: var(--line);
}
.grid-view .file-icon { width: 36px; height: 36px; }
.grid-view .file-icon svg { width: 19px; height: 19px; }
.grid-view .row-main { width: 100%; margin-top: auto; }
.grid-view .row-sub, .grid-view .row-type, .grid-view .row-size, .grid-view .row-date, .grid-view .row-chevron { display: none; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.empty-state p { margin: 0; font-size: 12px; }

.foot {
  display: flex;
  align-items: center;
  padding: 10px 20px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.details {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #17191d;
  border-left: 1px solid var(--line);
}
.details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.details-body { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 2px 16px 20px; }
.close-button {
  padding: 4px 9px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}
.close-button:hover { color: var(--text); }

.detail-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 6px; margin-bottom: 10px; background: #23272d; color: #aab3bd; }
.detail-icon svg { width: 21px; height: 21px; fill: currentColor; }
.detail-icon.folder { background: #2a2416; color: #d6b35a; }
.detail-icon.archive { background: #2a2116; color: var(--orange); }
.detail-icon.android { background: #17271c; color: var(--green); }
.detail-icon.roku { background: #241b33; color: #c4b5fd; }
.detail-icon.code { background: #17233a; color: #93c5fd; }
.detail-icon.doc { background: #20242a; color: #aeb7c2; }
.detail-icon.image { background: #2a1a22; color: #f9a8d4; }
.detail-icon.script { background: #20261a; color: #bef264; }
.detail-preview { width: 100%; max-height: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; background: var(--panel); }
.detail-name { margin: 0 0 3px; font-size: 15px; font-weight: 600; word-break: break-word; }
.detail-sub { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.detail-desc { margin: 0 0 13px; color: #b8c0c8; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.detail-meta { display: grid; gap: 1px; width: 100%; min-width: 0; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--line); }
.detail-meta div { display: flex; justify-content: space-between; gap: 10px; min-width: 0; padding: 6px 8px; background: var(--panel); font-size: 11px; }
.detail-meta span { flex: none; color: var(--muted); }
.detail-meta b { min-width: 0; max-width: 64%; font-weight: 400; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hash-box { display: flex; align-items: center; gap: 5px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.hash-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9.5px; color: var(--muted); }
.hash-box button { border: 0; background: none; color: var(--accent); font-size: 10px; }
.detail-actions { display: grid; gap: 6px; min-width: 0; margin-top: 12px; }
.primary-action, .secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.primary-action { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-action:hover { background: #2563eb; text-decoration: none; }
.secondary-action { border: 1px solid var(--line-dark); background: var(--panel); color: var(--text); }
.secondary-action:hover { background: var(--panel-soft); text-decoration: none; }

.modal {
  width: min(500px, calc(100vw - 24px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal p, .modal li { color: #b8c0c8; font-size: 12.5px; line-height: 1.65; }
.modal ol { padding-left: 20px; }
.modal li { margin: 4px 0; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.preview-modal { width: min(760px, calc(100vw - 24px)); max-height: 85vh; overflow: auto; }
.preview-body { margin-top: 6px; color: #c2c9d1; font-size: 12.5px; line-height: 1.7; }
.preview-body h1, .preview-body h2, .preview-body h3 { color: var(--text); margin: 1.2em 0 .4em; }
.preview-body h1 { font-size: 18px; }
.preview-body h2 { font-size: 16px; }
.preview-body h3 { font-size: 13px; }
.preview-body p { margin: .6em 0; }
.preview-body ul { margin: .5em 0; padding-left: 20px; }
.preview-body code { padding: 1px 3px; border-radius: 3px; background: #23272d; font-size: 11px; }
.preview-body pre { margin: .9em 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); overflow-x: auto; }
.preview-body pre code { padding: 0; background: none; font-size: 11px; line-height: 1.6; }
.preview-body img { max-width: 100%; border: 1px solid var(--line); border-radius: 5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  transform: translate(-50%, 12px);
  padding: 8px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #2a2e34;
  color: #e6e8eb;
  font-size: 11.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.scrim { position: fixed; inset: 52px 0 0; z-index: 20; background: rgba(0, 0, 0, .55); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 225px minmax(0, 1fr) 275px; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 225px minmax(0, 1fr); }
  .details {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(330px, 92vw);
    transform: translateX(105%);
    transition: transform .18s ease;
    background: var(--panel);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .35);
  }
  .details.open { transform: translateX(0); }
  .details .mobile-only, .details .close-button { display: inline-block; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .mobile-only { display: inline-block; }
  .topbar-note { display: none; }
  .shell { display: block; height: auto; min-height: calc(100dvh - 52px); overflow: visible; }
  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    z-index: 45;
    width: min(280px, 85vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    background: var(--panel-soft);
  }
  .sidebar.open { transform: translateX(0); }
  .workspace { overflow: visible; }
  .pathbar { padding: 8px 12px; }
  .search { width: min(190px, 40vw); }
  .folder-head { padding: 16px 14px 8px; align-items: flex-start; flex-direction: column; gap: 6px; }
  .listing { padding: 0 8px 20px; }
  .list-head { grid-template-columns: 30px minmax(0, 1fr) 74px 64px 18px; }
  .list-head span:nth-child(5) { display: none; }
  .row { grid-template-columns: 30px minmax(0, 1fr) 74px 64px 18px; }
  .row-date { display: none; }
  .foot { padding: 10px 14px 16px; }
  .details { top: 52px; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; }
  .pathbar { flex-wrap: wrap; gap: 6px; }
  .breadcrumbs { order: 3; flex-basis: 100%; }
  .search { flex: 1; width: auto; }
  .nav-button { display: none; }
  .view-button { display: none; }
  .folder-head h1 { font-size: 19px; }
  .list-head { display: none; }
  .row { grid-template-columns: 30px minmax(0, 1fr) 18px; padding: 8px 6px; }
  .row-type, .row-size { display: none; }
  .listing.grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Windows shell icons are standalone images, not colored tiles. */
.file-icon,
.file-icon.folder,
.file-icon.archive,
.file-icon.android,
.file-icon.roku,
.file-icon.code,
.file-icon.doc,
.file-icon.image,
.file-icon.script {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
}
.file-icon img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.tree-icon img {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.detail-icon,
.detail-icon.folder,
.detail-icon.archive,
.detail-icon.android,
.detail-icon.roku,
.detail-icon.code,
.detail-icon.doc,
.detail-icon.image,
.detail-icon.script {
  background: transparent !important;
  border: 0 !important;
}
.detail-icon img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}
