:root {
  color-scheme: light;
  --bg-primary: #fff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #fff;
  --bg-hover: #fafafa;
  --text-primary: #24292e;
  --text-secondary: #5c5c5c;
  --text-tertiary: #586069;
  --text-accent: #0366d6;
  --svg-primary: #24292e;
  --svg-secondary: rgba(3, 47, 98, 0.5);
  --svg-tertiary: #24292e;
  --border-primary: #ddd;
  --border-secondary: #ced4da;
  --map-status-bg: rgba(255, 255, 255, 0.82);
}

html {
  font-family: -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--text-primary);
}

body {
  /* prevent premature breadcrumb wrapping on mobile */
  min-width: 538px;
  margin: 0;
  background-color: var(--bg-primary);
}

svg {
  fill: var(--svg-primary);
}

.hidden {
  display: none !important;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.6em 1em;
  position: sticky;
  top: 0;
  background-color: var(--bg-tertiary);
}

.breadcrumb {
  font-size: 1.25em;
  padding-right: 0.6em;
  word-break: break-all;
}

.breadcrumb>a {
  color: var(--text-accent);
  text-decoration: none;
}

.breadcrumb>a:hover {
  text-decoration: underline;
}

/* final breadcrumb */
.breadcrumb>b {
  color: var(--text-primary);
}

.breadcrumb>.separator {
  color: var(--text-tertiary);
  padding: 0 0.25em;
}

.breadcrumb svg {
  height: 100%;
  fill: var(--svg-secondary);
}

.toolbox {
  display: flex;
  margin-right: 10px;
}

.toolbox>a,
.toolbox>div {
  /* vertically align with breadcrumb text */
  height: 1.1rem;
}

.toolbox .control {
  cursor: pointer;
  padding-left: 0.25em;
}

.upload-file input {
  display: none;
}

.upload-file label {
  cursor: pointer;
}

.searchbar {
  display: flex;
  flex-wrap: nowrap;
  width: 246px;
  height: 22px;
  background-color: var(--bg-secondary);
  transition: all .15s;
  border: 1px var(--border-primary) solid;
  border-radius: 15px;
  margin-bottom: 2px;
}

.searchbar #search {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  font-size: 16px;
  line-height: 16px;
  padding: 1px;
  color: var(--text-primary);
  background-color: transparent;
  border: none;
  outline: none;
}

.searchbar .icon {
  color: var(--svg-tertiary);
  padding: 3px 3px;
  cursor: pointer;
}

.searchbar svg {
  fill: var(--svg-tertiary);
}

.main {
  padding: 0 1em;
}

.empty-folder {
  font-style: italic;
}

.live-status { margin: 8px 0; color: #64748b; font-size: 12px; }
.upload-trigger { display: inline-flex; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; }
.upload-trigger:focus-visible { outline: 2px solid #2563eb; outline-offset: 4px; }

.uploaders-table th,
.paths-table th {
  text-align: left;
  font-weight: unset;
  color: var(--text-secondary);
  white-space: nowrap;
}

.uploaders-table td,
.paths-table td {
  white-space: nowrap;
}

.uploaders-table .cell-status {
  padding-left: 0.6em;
}

.uploaders-table .cell-status span {
  display: inline-block;
}

.uploaders-table .cell-size,
.uploaders-table .cell-percent,
.uploaders-table .cell-speed,
.uploaders-table .cell-eta {
  text-align: right;
  padding-left: 0.6em;
  font-variant-numeric: tabular-nums;
}

.paths-table thead a {
  color: unset;
  text-decoration: none;
}

.paths-table thead a>span {
  padding-left: 2px;
}

.paths-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.paths-table .cell-actions {
  width: 90px;
  display: flex;
  padding-left: 0.5em;
}

.paths-table .cell-mtime {
  width: 120px;
  padding-left: 0.5em;
  font-variant-numeric: tabular-nums;
}

.paths-table .cell-size {
  text-align: right;
  width: 70px;
  padding-left: 0.5em;
  font-variant-numeric: tabular-nums;
}

.path svg {
  height: 16px;
  fill: var(--svg-secondary);
  padding-right: 0.5em;
  vertical-align: text-top;
}

.path {
  list-style: none;
}

.path a {
  color: var(--text-accent);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  display: block;
  text-decoration: none;
  max-width: calc(100vw - 375px);
  min-width: 170px;
}

.path a:hover {
  text-decoration: underline;
}

.action-btn {
  padding-right: 0.3em;
  cursor: pointer;
}

.uploaders-table {
  padding: 0.5em 0;
}

.uploader {
  padding-right: 1em;
}

.editor {
  width: 100%;
  height: calc(100vh - 5rem);
  border: 1px solid var(--border-secondary);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  padding: 5px;
}

.toolbox-right {
  margin-left: auto;
  margin-right: 2em;
}

.login-btn {
  cursor: pointer;
}

.login-btn,
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 5px;
  padding: 0.35rem 0.6rem;
  max-width: 100%;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(32vw, 280px);
}

.workspace-tabs {
  display: flex;
  gap: 0.25rem;
  margin-right: 1rem;
}

.workspace-tabs button,
.audit-panel button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-primary);
  border-radius: 5px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.workspace-tabs [aria-selected="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.workspace-tabs button:focus-visible,
.audit-panel :is(button, input, select):focus-visible,
.login-btn:focus-visible,
.logout-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.audit-mode .head > .toolbox,
.audit-mode .head > .searchbar {
  display: none;
}

.auth-notice {
  flex-basis: 100%;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #b42318;
}

.audit-panel {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
  padding: 1rem 1.25rem;
}

.audit-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.audit-heading h1 {
  margin: 0;
  font-size: 1.25rem;
}

.audit-heading p,
.audit-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.audit-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.audit-filters label:first-child {
  flex: 1 1 260px;
  max-width: 450px;
}

.audit-filters input,
.audit-filters select {
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  min-height: 36px;
  padding: 0.35rem 0.5rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
}

.audit-error {
  margin: 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 4px;
  color: #b42318;
  background: #fff1f0;
}

.audit-table-scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
}

.audit-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}

.audit-table th,
.audit-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-primary);
}

.audit-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.audit-table tbody tr:hover { background: var(--bg-hover); }
.audit-cell-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-cell-action { white-space: nowrap; }
.audit-cell-actor { min-width: 170px; overflow-wrap: anywhere; }
.audit-cell-path { min-width: 180px; overflow-wrap: anywhere; }
.audit-cell-result { min-width: 80px; }
.audit-actor-name { display: block; color: var(--text-secondary); font-size: 0.8rem; }
.audit-result-success { color: #15803d; }
.audit-result-failure, .audit-result-interrupted { color: #b42318; }
.audit-result-pending { color: #a16207; }
.audit-footer { text-align: center; }
.audit-panel button:disabled { cursor: default; opacity: 0.6; }

@media (prefers-color-scheme: dark) {
  .audit-result-success { color: #4ade80; }
  .audit-result-failure, .audit-result-interrupted, .auth-notice { color: #fca5a5; }
  .audit-result-pending { color: #facc15; }
}

.save-btn {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.logout-btn {
  cursor: pointer;
  display: flex;
  align-items: center;
}

.user-name {
  padding-left: 3px;
}

.not-editable {
  font-style: italic;
}

.retry-btn {
  cursor: pointer;
}

@media (min-width: 768px) {
  .path a {
    min-width: 400px;
  }
}

/* dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-primary: #000;
    --bg-secondary: #111;
    --bg-tertiary: #111;
    --bg-hover: #1a1a1a;
    --text-primary: #fff;
    --text-secondary: #ddd;
    --text-tertiary: #586069;  /*Unchanged in both color schemes*/
    --text-accent: #3191ff;
    --svg-primary: #fff;
    --svg-secondary: #fff;
    --svg-tertiary: #fff6;
    --border-primary: #fff6;
    --border-secondary: #ced4da; /*Unchanged in both color schemes*/
    --map-status-bg: rgba(17, 17, 17, 0.82);
  }
}

/* Geo workspace: only the list scrolls; neither pane can force the other away. */
body {
  min-width: 0;
}

body.index-mode {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.index-mode .head {
  flex: 0 0 auto;
  gap: 0.3rem 0;
  z-index: 2;
  border-bottom: 1px solid var(--border-primary);
}

.index-mode .main {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
}

#workspace {
  display: grid;
  grid-template-columns: minmax(0, var(--list-fr, 0.5fr)) 10px minmax(0, var(--map-fr, 0.5fr));
  width: 100%;
  height: 100%;
  min-height: 0;
}

.list-panel {
  container-type: inline-size;
  overflow: auto;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
}

.upload-policy {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
  min-width: 260px;
}

.upload-policy span {
  color: var(--text-tertiary);
}

.list-panel .path a {
  min-width: 180px;
  max-width: 420px;
  max-width: clamp(180px, calc(100cqw - 430px), 420px);
}

.paths-table {
  width: 100%;
  border-collapse: collapse;
}

.paths-table th {
  border-bottom: 1px solid var(--border-primary);
  padding-bottom: 0.5rem;
}

.paths-table td {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.paths-table .cell-actions {
  display: table-cell;
  width: auto;
}

.paths-table .cell-actions .action-btn {
  display: inline-block;
}

.action-delete {
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.2rem;
  line-height: 1;
  vertical-align: middle;
  padding: 0 0.25rem;
}

.action-delete:hover,
.action-delete:focus-visible {
  color: #dc2626;
}

.paths-table .cell-render {
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 0.3rem;
}

.cell-render input {
  width: 17px;
  height: 17px;
  vertical-align: middle;
  cursor: pointer;
  accent-color: #2563eb;
}

.cell-render input:disabled {
  cursor: not-allowed;
}

.cell-render input[aria-busy="true"] {
  outline: 2px dotted #d97706;
  outline-offset: 3px;
}

.uploaders-table .cell-status.upload-error {
  white-space: normal;
  min-width: 180px;
  max-width: 420px;
  color: #b42318;
  font-size: 0.85rem;
}

.upload-error .retry-btn {
  margin-left: 0.5rem;
}

#splitter {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  box-sizing: border-box;
  cursor: col-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

#splitter span {
  height: 36px;
  width: 2px;
  border-left: 1px solid var(--text-secondary);
  border-right: 1px solid var(--text-secondary);
}

#splitter:hover,
#splitter:focus-visible,
.is-resizing #splitter {
  background: #bfdbfe;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.is-resizing,
.is-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.map-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-primary);
}

.map-clear,
.upload-error button {
  font: inherit;
  font-size: 0.8rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
}

.map-clear {
  box-sizing: border-box;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  max-width: calc(100% - 1rem);
  white-space: normal;
}

.map-clear:disabled {
  cursor: default;
  opacity: 0.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.map-error,
.basemap-note {
  position: absolute;
  bottom: 3.5rem;
  left: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  font-size: 0.8rem;
  margin: 0;
  padding: 0.4rem 0.6rem;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 25%;
  border-radius: 4px;
}

.map-error {
  color: #b42318;
  background: #fff1f0;
}

.basemap-note {
  color: #854d0e;
  background: #fefce8;
}

.map-error:not([hidden]) ~ .basemap-note {
  display: none;
}

.map-status {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 2rem;
  z-index: 2;
  margin: 0;
  padding: 0.2rem 0.45rem;
  border: 0;
  border-radius: 4px;
  background: var(--map-status-bg);
  box-shadow: none;
  color: var(--text-primary);
  font-size: 0.75rem;
  line-height: 1.3;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#map {
  flex: 1 1 auto;
  min-height: 64px;
  min-width: 0;
  position: relative;
  background-color: #eef2f6;
  background-image: linear-gradient(#dce3ea 1px, transparent 1px), linear-gradient(90deg, #dce3ea 1px, transparent 1px);
  background-size: 32px 32px;
}

#map .ol-zoom {
  top: 0.5em;
  left: 0.5em;
}

#map:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}
