/* explorer — Steve-Jobs-quality bar.
   Restraint with the palette, generous whitespace, hairline rules,
   tabular numerals, subtle interactions. Accent appears only for
   actually-active states. */

:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --rule: rgba(39, 35, 32, 0.08);
  --rule-strong: rgba(39, 35, 32, 0.16);
  --text: #1f1d1a;
  --text-soft: #6f6a5f;
  --text-muted: #a09c92;
  --selection: rgba(216, 80, 0, 0.08);
  --selection-strong: rgba(216, 80, 0, 0.18);
  --accent: #d85000;
  --shadow-sm: 0 1px 2px rgba(39, 35, 32, 0.04);
  --shadow-md: 0 6px 24px rgba(39, 35, 32, 0.06);

  --type-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --type-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* HTML's [hidden] attribute is `display: none`. Any rule that sets
   display (e.g. flex on .preview / .toast) overrides it; restore the
   intended behaviour. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--type-ui);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss03";
  letter-spacing: -0.005em;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* — topbar — */

.topbar {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 0 28px;
}
.topbar-inner {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sub {
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar-id {
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  background: var(--selection);
  padding: 4px 12px;
  border-radius: 999px;
  font-feature-settings: "tnum";
}

/* — main grid — */

.layout {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.layout.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}
.layout.sidebar-collapsed .sidebar { display: none; }

main {
  max-width: 1100px;
  margin: 0;
  padding: 24px 28px 60px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.layout.sidebar-collapsed main {
  margin: 0 auto;
  padding: 24px 28px 60px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sidebar {
    display: none;  /* mobile: sidebar hidden, use ☰ to toggle as overlay later */
  }
  main {
    margin: 0 auto;
    padding: 24px 28px 60px;
  }
}

/* — sidebar — */

.sidebar {
  margin: 24px 0 24px 28px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  position: sticky;
  top: 24px;
}
.sidebar-header {
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-title {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.sidebar-pod {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 80ms ease, color 80ms ease;
  font-size: 12.5px;
  color: var(--text);
  position: relative;
}
.sidebar-pod:hover {
  background: var(--selection);
  color: var(--accent);
}
.sidebar-pod.active {
  background: var(--selection-strong);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-pod-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 120ms ease;
}
.sidebar-pod.active .sidebar-pod-dot { background: var(--accent); }
.sidebar-pod.authed .sidebar-pod-dot { background: #5a9c4a; }
.sidebar-pod-label {
  flex: 1;
  font-family: var(--type-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-pod-remove {
  visibility: hidden;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.sidebar-pod:hover .sidebar-pod-remove { visibility: visible; }
.sidebar-pod-remove:hover {
  background: rgba(177, 67, 29, 0.1);
  color: #b1431d;
}
.sidebar-empty {
  padding: 18px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}
.sidebar-footer {
  padding: 8px 12px 14px;
  border-top: 1px solid var(--rule);
}
.sidebar-add {
  width: 100%;
  border: 1px dashed var(--rule-strong);
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.sidebar-add:hover {
  background: var(--selection);
  color: var(--accent);
  border-color: var(--selection-strong);
}
.topbar-collapse {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  font-size: 13px;
  margin-right: 4px;
}

/* — URL bar — */

.urlbar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
}
.urlbar input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 8px 10px;
  background: transparent;
  font-family: var(--type-mono);
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0;
}
.urlbar input::placeholder {
  color: var(--text-muted);
}

/* — nav buttons — */

.nav-btn {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nav-btn:hover:not(:disabled) {
  background: var(--selection);
  color: var(--accent);
  border-color: var(--selection-strong);
}
.nav-btn:disabled {
  color: var(--text-muted);
  opacity: 0.45;
  cursor: not-allowed;
}

/* — breadcrumb — */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  min-height: 24px;
  font-family: var(--type-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 6px;
  transition: background 100ms ease, color 100ms ease;
}
.breadcrumb a:hover {
  background: var(--selection);
  color: var(--accent);
}
.breadcrumb .sep {
  color: var(--text-muted);
  user-select: none;
}

/* — view: panes + preview/acl-editor — */

.view {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.view:has(.pane[data-pane="1"]:not([hidden])),
.view:has(.preview:not([hidden])),
.view:has(.acl-editor:not([hidden])) {
  grid-template-columns: 1fr 1fr;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Active-pane indicator: only meaningful when split is on. The active
   pane gets a subtle accent ring on its urlbar so the user knows which
   pane the keyboard, popover, and global UI commands target. */
body.split .pane.active .urlbar {
  border-color: var(--selection-strong);
  box-shadow: 0 0 0 3px var(--selection), var(--shadow-sm);
}
body.split .pane:not(.active) .listing-wrap {
  opacity: 0.94;
}

.btn-split, .btn-close-pane {
  font-size: 12px;
}

/* — listing — */

.listing-wrap {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.listing-header,
.listing li {
  display: grid;
  grid-template-columns: 1fr 50px 80px 130px;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
}
.col-acl {
  text-align: center;
}
.listing-header {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(39, 35, 32, 0.015);
  border-bottom: 1px solid var(--rule);
}
.col-size, .col-modified {
  text-align: right;
  font-feature-settings: "tnum";
}

.listing {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 540px;
  overflow-y: auto;
}
.listing li {
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 80ms ease;
}
.listing li:last-child {
  border-bottom: 0;
}
.listing li:hover {
  background: var(--selection);
}
.listing li.selected {
  background: var(--selection-strong);
}
.listing li.empty {
  grid-template-columns: 1fr;
  cursor: default;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 40px 16px;
}
.listing li.empty:hover { background: transparent; }

.row-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.row-icon {
  width: 18px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  flex-shrink: 0;
}
.row-icon.container { color: var(--accent); }
.row-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}
.row-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  font-feature-settings: "tnum";
}

/* — preview pane — */

.preview {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: 580px;
  overflow: hidden;
}
.preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.preview-title {
  font-family: var(--type-mono);
  font-size: 12.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-meta {
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--text-muted);
  font-feature-settings: "tnum";
  display: flex;
  gap: 14px;
}
.preview-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: var(--type-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.preview-body img,
.preview-body audio,
.preview-body video {
  max-width: 100%;
  border-radius: 6px;
}
.preview-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--selection-strong);
}
.preview-body a:hover {
  border-bottom-color: var(--accent);
}

/* — status bar — */

.status {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 4px;
  height: 16px;
  font-feature-settings: "tnum";
}
.status.busy {
  color: var(--accent);
}
.status.error {
  color: #b1431d;
}

/* — popover (New menu) — */

.popover-host {
  position: relative;
}
.popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: popover-rise 140ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popover-rise {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.popover-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  transition: background 80ms ease, color 80ms ease;
}
.popover-item:hover {
  background: var(--selection);
  color: var(--accent);
}

.urlbar-sep {
  width: 1px;
  height: 20px;
  background: var(--rule);
  margin: 0 4px;
}

/* — drop overlay — */

.listing-wrap {
  position: relative;
}
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(216, 80, 0, 0.05);
  border: 2px dashed var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  animation: drop-rise 160ms ease;
}
@keyframes drop-rise {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.drop-overlay-inner {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
}

/* — toast — */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fafaf6;
  border-radius: 10px;
  padding: 10px 14px 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  animation: toast-rise 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toast-rise {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast-msg {
  font-feature-settings: "tnum";
  letter-spacing: 0;
}
.toast-action {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fafaf6;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 120ms ease, border-color 120ms ease;
}
.toast-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}
.toast-close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.toast-close:hover { color: #fff; }

/* — keyboard focus on a listing row — */

.listing li:focus,
.listing li.kbd-focus {
  outline: none;
  background: var(--selection-strong);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* — rename: inline edit on the name cell — */

.rename-input {
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font: inherit;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  min-width: 80px;
  box-shadow: 0 0 0 3px var(--selection);
}

/* — drag-and-drop visual feedback — */

.listing li.dragging {
  opacity: 0.4;
}
.listing li.drop-target {
  background: var(--selection-strong);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* — responsive — */

@media (max-width: 900px) {
  .view:has(.preview:not([hidden])),
  .view:has(.acl-editor:not([hidden])) {
    grid-template-columns: 1fr;
  }
  .listing-header, .listing li {
    grid-template-columns: 1fr 44px 64px 100px;
    padding: 9px 12px;
  }
}

/* — per-row ACL chip — */

.row-acl {
  text-align: center;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.92;
  transition: opacity 120ms ease, transform 120ms ease;
  user-select: none;
  display: inline-block;
}
.row-acl:hover {
  opacity: 1;
  transform: scale(1.18);
}
.row-acl.inherited { opacity: 0.55; }
.row-acl.unknown {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.65;
}
.row-acl.loading {
  color: var(--text-muted);
  opacity: 0.5;
  font-size: 13px;
  letter-spacing: 1px;
}

/* — ACL editor panel — */

.acl-editor {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: 580px;
  overflow: hidden;
}
.acl-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.acl-title {
  font-family: var(--type-mono);
  font-size: 12.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acl-meta {
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.acl-meta .acl-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--selection);
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 8px;
}
.acl-meta .acl-badge.inherited {
  background: rgba(39, 35, 32, 0.05);
  color: var(--text-soft);
}
.acl-body {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.acl-card {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(39, 35, 32, 0.015);
}
.acl-card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 12px;
}
.acl-card-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 56px;
}
.acl-subject-type {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  outline: none;
}
.acl-subject-value {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  padding: 5px 8px;
  font-family: var(--type-mono);
  font-size: 12px;
  outline: none;
}
.acl-subject-value:focus {
  border-color: var(--selection-strong);
  box-shadow: 0 0 0 3px var(--selection);
}
.acl-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.acl-mode input { margin: 0; cursor: pointer; }
.acl-mode.checked { color: var(--accent); font-weight: 500; }
.acl-default {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-soft);
  cursor: pointer;
}
.acl-default input { margin: 0; }
.acl-remove {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 100ms ease, color 100ms ease;
}
.acl-remove:hover {
  background: rgba(177, 67, 29, 0.08);
  color: #b1431d;
}
.acl-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  background: rgba(39, 35, 32, 0.015);
}
.acl-spacer { flex: 1; }
.acl-save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.acl-save:hover:not(:disabled) {
  background: #c14600;
  border-color: #c14600;
  color: #fff;
}
.acl-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
  text-align: center;
  padding: 16px;
}
