:root {
  color-scheme: light;
  --bg: #e9eef1;
  --surface: #ffffff;
  --surface-2: #f4f7f8;
  --surface-3: #e4eaed;
  --text: #1d2932;
  --muted: #62717c;
  --line: #d2dbe0;
  --header: #1f2a32;
  --header-2: #26343e;
  --header-text: #eef4f6;
  --accent: #2d7f68;
  --accent-strong: #226451;
  --accent-soft: #dcefe9;
  --warning: #b7791f;
  --danger: #bd3d45;
  --danger-soft: #f9e2e4;
  --shadow: 0 12px 32px rgba(20, 33, 42, 0.16);
  --sidebar-width: 278px;
  --dark-form-border: rgba(255, 255, 255, 0.6);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151c21;
  --surface: #202a31;
  --surface-2: #263139;
  --surface-3: #303d46;
  --text: #edf2f4;
  --muted: #a9b4ba;
  --line: #3a4851;
  --header: #10171c;
  --header-2: #182229;
  --header-text: #f5f7f8;
  --accent: #57ae91;
  --accent-strong: #78c8ad;
  --accent-soft: #1d4439;
  --warning: #e1a74c;
  --danger: #ef747b;
  --danger-soft: #49282c;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.sidebar-collapsed .app {
  grid-template-columns: minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--header-text);
  background: var(--header);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand strong {
  font-size: 15px;
}

.sidebar-brand span {
  margin-top: 3px;
  color: #aebcc5;
  font-size: 12px;
}

.sidebar-close {
  display: grid;
}

.folder-tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 9px 8px 20px;
}

.tree-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 35px;
  padding: 6px 8px;
  color: #c9d4da;
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}

.tree-row:hover,
.tree-row.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.tree-row.active {
  box-shadow: inset 3px 0 var(--accent);
}

.tree-row svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

.tree-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children {
  padding-left: 0;
}

.tree-line {
  display: flex;
  align-items: center;
  min-width: 0;
}

.tree-line .tree-row {
  flex: 1;
  min-width: 0;
}

.tree-toggle,
.tree-toggle-spacer {
  flex: 0 0 26px;
  width: 26px;
  height: 32px;
}

.tree-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--header-text);
}

.tree-toggle:hover,
.tree-toggle:focus-visible {
  color: #78c8ad;
  background: rgba(255, 255, 255, 0.1);
}

.tree-toggle svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  color: #9eacb4;
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #66bd82;
  border-radius: 50%;
}

.workspace {
  display: grid;
  grid-template-rows: 58px 45px auto minmax(0, 1fr);
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar,
.pathbar,
.commandbar {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar {
  gap: 8px;
  padding: 8px 12px;
  color: var(--header-text);
  background: var(--header-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-spacer {
  flex: 1;
}

.topbar,
.sidebar,
.preview-panel,
:root[data-theme="dark"] {
  --form-border: var(--dark-form-border);
}

:is(.search-box, .segmented, .select-control, .drop-zone),
:is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  transition: border-color 160ms ease;
}

:where(input, select, textarea) {
  border-color: var(--form-border, var(--line));
}

:where(input, select, textarea):is(:hover, :focus-visible) {
  border-color: var(--accent);
}

.icon-button,
.account-button,
.command-button,
.button {
  border: 0;
  border-radius: 5px;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: inherit;
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(127, 145, 156, 0.18);
  outline: none;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button.compact {
  width: 28px;
  height: 28px;
}

.icon-button.danger {
  color: var(--danger);
}

.search-box {
  display: flex;
  align-items: center;
  width: min(420px, 36vw);
  min-width: 180px;
  height: 38px;
  padding: 0 8px 0 11px;
  color: #c9d4da;
  background: rgba(3, 10, 14, 0.28);
  border: 1px solid var(--form-border, var(--line));
  border-radius: 5px;
}

.search-box:hover,
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(73, 163, 132, 0.18);
}

.search-box > svg {
  width: 18px;
  height: 18px;
  margin-right: 8px;
}

.search-box input {
  flex: 1;
  width: 100%;
  min-width: 0;
  color: #fff;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: #90a0aa;
}

.segmented {
  display: flex;
  height: 38px;
  padding: 2px;
  background: rgba(3, 10, 14, 0.25);
  border: 1px solid var(--form-border, var(--line));
  border-radius: 6px;
}

.segmented .icon-button {
  width: 34px;
  height: 32px;
}

.segmented .active {
  color: #fff;
  background: var(--accent);
}

.select-control {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  color: #cbd5da;
  background: rgba(3, 10, 14, 0.25);
  border: 1px solid var(--form-border, var(--line));
  border-radius: 5px;
}

.select-control svg {
  position: absolute;
  left: 9px;
  width: 16px;
  pointer-events: none;
}

.select-control select {
  height: 100%;
  padding: 0 10px 0 32px;
  color: inherit;
  background: transparent;
  border: 0;
  outline: 0;
}

.select-control option {
  color: var(--text);
  background: var(--surface);
}

.account-button {
  display: flex;
  gap: 7px;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  color: inherit;
  background: rgba(255, 255, 255, 0.08);
}

.account-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.account-button svg {
  width: 18px;
}

.pathbar {
  gap: 14px;
  justify-content: space-between;
  padding: 0 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.breadcrumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  overflow: hidden;
}

.crumb {
  display: flex;
  min-width: 0;
  align-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  white-space: nowrap;
}

.crumb:hover,
.crumb:last-child {
  color: var(--text);
}

.crumb svg {
  width: 15px;
  margin: 0 5px;
}

.crumb span {
  overflow: hidden;
  max-width: 190px;
  text-overflow: ellipsis;
}

.folder-summary {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.commandbar {
  display: grid;
  gap: 6px;
  min-height: 58px;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.gallery-heading {
  display: block;
  min-width: 0;
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
}

.command-primary,
.selection-commands {
  display: flex;
  gap: 5px;
  align-items: center;
}

.command-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  color: var(--text);
  background: transparent;
}

.command-button:hover {
  background: var(--surface-3);
}

.command-button svg {
  width: 17px;
}

.selection-count {
  padding: 0 8px;
  color: var(--accent-strong);
  font-weight: 600;
}

.gallery-shell {
  position: relative;
  container-type: inline-size;
  container-name: gallery;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 14px;
}

.folder-tree,
.gallery-shell,
.preview-stage.image-scroll {
  scrollbar-color: #728690 rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

.folder-tree::-webkit-scrollbar,
.gallery-shell::-webkit-scrollbar,
.preview-stage.image-scroll::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

.folder-tree::-webkit-scrollbar-track,
.gallery-shell::-webkit-scrollbar-track,
.preview-stage.image-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}

.folder-tree::-webkit-scrollbar-thumb,
.gallery-shell::-webkit-scrollbar-thumb,
.preview-stage.image-scroll::-webkit-scrollbar-thumb {
  background: #728690;
  border: 2px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
}

.gallery {
  min-width: 0;
}

.gallery.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@container gallery (min-width: 600px) {
  .gallery.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@container gallery (min-width: 800px) {
  .gallery.grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@container gallery (min-width: 1000px) {
  .gallery.grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@container gallery (min-width: 1200px) {
  .gallery.grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.file-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  user-select: none;
}

.file-card:hover {
  border-color: #9fb0b9;
  box-shadow: 0 5px 16px rgba(24, 38, 47, 0.09);
}

.file-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.file-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: var(--preview-ratio, 1);
  place-items: center;
  overflow: hidden;
  color: #71818c;
  background: var(--surface-2);
  border: 0;
  cursor: pointer;
}

.file-preview img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-preview .type-icon {
  width: 54px;
  height: 54px;
  color: #7d909b;
}

.file-card[data-type="folder"] .file-preview {
  color: #76a5c7;
  background: #edf4f7;
}

:root[data-theme="dark"] .file-card[data-type="folder"] .file-preview {
  background: #26343d;
}

.file-card[data-type="folder"] .type-icon {
  width: 74px;
  height: 74px;
  fill: currentColor;
  stroke-width: 1.4;
}

.type-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 6px;
  color: #fff;
  background: rgba(29, 41, 50, 0.78);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.select-check {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: rgba(20, 30, 38, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 4px;
  opacity: 0;
}

.file-card:hover .select-check,
.file-card.selected .select-check,
.selection-active .select-check {
  opacity: 1;
}

.file-card.selected .select-check {
  background: var(--accent);
  border-color: var(--accent);
}

.select-check svg {
  width: 15px;
}

.file-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  padding: 9px 10px;
}

.file-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 40px;
  max-height: 40px;
  line-height: 20px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
}

.file-card[data-type="image"] .file-name {
  font-weight: 400;
}

.file-meta {
  overflow: hidden;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta:empty {
  display: none;
}

.gallery.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery.list .file-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 58px;
  border-radius: 4px;
}

.gallery.list .file-preview {
  width: 58px;
  height: 58px;
  aspect-ratio: 1;
}

.gallery.list .file-preview .type-icon {
  width: 28px;
  height: 28px;
}

.gallery.list .file-info {
  min-height: 58px;
  align-content: center;
}

.gallery.list .type-badge {
  display: none;
}

.empty-state,
.loading-state {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state svg {
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal {
  max-width: none;
  max-height: none;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(10, 18, 23, 0.68);
  backdrop-filter: blur(2px);
}

.modal-panel {
  width: min(94vw, 470px);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.modal-panel.medium {
  width: min(94vw, 720px);
}

.modal-panel.large {
  width: min(95vw, 960px);
}

.modal-panel > header,
.modal-panel > footer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
}

.modal-panel > header {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.modal-panel > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.modal-panel h2 {
  margin: 0;
  font-size: 18px;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  gap: 14px;
  padding: 17px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.form-grid label,
.user-form label,
#promptDialog label,
#destinationDialog label {
  display: grid;
  gap: 6px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.form-grid label {
  padding: 0;
}

.span-two {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  min-width: 0;
}

.form-grid input,
.form-grid select,
.user-form input,
.user-form select,
#promptDialog input,
#destinationDialog input {
  width: 100%;
  height: 39px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--form-border, var(--line));
  border-radius: 4px;
  outline: 0;
}

.form-grid input:hover,
.form-grid select:hover,
.user-form input:hover,
.user-form select:hover,
#promptDialog input:hover,
#destinationDialog input:hover,
.form-grid input:focus,
.form-grid select:focus,
.user-form input:focus,
.user-form select:focus,
#promptDialog input:focus,
#destinationDialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.segmented:hover,
.segmented:focus-within,
.select-control:hover,
.select-control:focus-within {
  border-color: var(--accent);
}

.toggle-row {
  display: flex !important;
  grid-template-columns: none !important;
  flex-direction: row;
  align-items: center;
  min-height: 39px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.button {
  min-height: 38px;
  padding: 0 15px;
  font-weight: 600;
}

.button.primary {
  color: #fff;
  background: var(--accent);
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.secondary {
  color: var(--text);
  background: var(--surface-3);
}

.button.danger-solid {
  color: #fff;
  background: var(--danger);
}

.confirm-message {
  min-height: 70px;
  margin: 0;
  padding: 20px 16px;
  color: var(--muted);
  line-height: 1.6;
}

.drop-zone {
  display: grid;
  min-height: 175px;
  margin: 16px;
  place-items: center;
  align-content: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 2px dashed var(--form-border, var(--line));
  border-radius: 6px;
}

.drop-zone:hover,
.drop-zone:focus-within,
.drop-zone.dragging {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.drop-zone svg {
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-list {
  max-height: 260px;
  overflow: auto;
  padding: 0 16px 14px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.upload-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-row span {
  color: var(--muted);
  font-size: 12px;
}

.progress {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 3px;
}

.progress > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: var(--accent);
}

.preview-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 58px minmax(0, 1fr) auto;
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #0e1418;
  border: 0;
  border-radius: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.preview-header {
  min-width: 0;
  color: #edf3f5;
  background: #182128;
  border: 0 !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

.preview-supplier {
  max-height: min(24dvh, 180px);
  padding: 12px 18px;
  overflow: auto;
  overscroll-behavior: contain;
  border-top: 1px solid #36434c;
  color: #edf3f5;
  background: #182128;
  font-size: 13px;
  user-select: text;
}

.supplier-contact + .supplier-contact {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #36434c;
}

.supplier-contact strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.supplier-contact dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 6px 0;
}

.supplier-contact dt {
  color: #b7c4ca;
}

.supplier-contact dd {
  margin: 0 16px 0 0;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.supplier-contact p {
  margin: 6px 0;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.supplier-contact a {
  color: #78c8ad;
}

@media (min-width: 901px) {
  .preview-supplier {
    max-height: 96px;
    padding: 10px 14px;
  }

  .supplier-contact {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 20px;
    min-width: 0;
  }

  .supplier-contact strong,
  .supplier-contact dl,
  .supplier-contact p {
    margin: 0;
  }

  .supplier-contact p {
    flex: 1 1 240px;
  }

  .supplier-contact a {
    flex-shrink: 0;
  }
}

.preview-title {
  display: flex;
  min-width: 0;
  flex-direction: column;
  flex: 1;
}

.preview-title strong,
.preview-title span {
  overflow: hidden;
  max-width: 64vw;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-title span {
  margin-top: 3px;
  color: #9eabb3;
  font-size: 11px;
}

.preview-tools {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.preview-position {
  margin-right: 10px;
  color: #b7c4ca;
  font-size: 12px;
  white-space: nowrap;
}

.preview-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.image-album .preview-content {
  grid-template-columns: 102px minmax(0, 1fr);
}

.preview-filmstrip {
  display: none;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #728690 #182128;
  scrollbar-width: thin;
  background: #182128;
}

.image-album .preview-filmstrip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
}

.preview-thumbnail {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: #0e1418;
  touch-action: manipulation;
}

.preview-thumbnail[aria-pressed="true"] {
  border-color: #78c8ad;
}

.preview-thumbnail:hover,
.preview-thumbnail:focus-visible {
  border-color: #ffffff;
}

.preview-thumbnail img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.preview-viewport {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.preview-viewport:has(> .image-fit) {
  touch-action: none;
}

.image-album .preview-image-canvas {
  cursor: grab;
}

.preview-viewport.preview-dragging,
.preview-dragging .preview-image-canvas {
  cursor: grabbing;
}

.preview-loading {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  padding: 12px;
  place-items: center;
  border-radius: 50%;
  background: rgba(14, 20, 24, 0.82);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.preview-loading .spinner {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
}

.preview-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: none;
  width: 40px;
  height: 48px;
  transform: translateY(-50%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(14, 20, 24, 0.8);
}

.image-album .preview-nav {
  display: grid;
}

.preview-nav.previous {
  left: 12px;
}

.preview-nav.next {
  right: 18px;
}

.preview-nav:hover {
  background: rgba(38, 52, 62, 0.95);
}

.preview-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.preview-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
}

.preview-outgoing {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.preview-transitioning,
.preview-outgoing {
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.preview-stage video,
.preview-stage iframe {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 0;
}

.preview-stage.image-scroll {
  display: block;
  scrollbar-gutter: stable both-edges;
}

.preview-image-canvas {
  display: grid;
  width: max-content;
  min-width: 100%;
  height: max-content;
  min-height: 100%;
  place-items: center;
}

.preview-image-canvas img {
  display: block;
  max-width: none;
  max-height: none;
  border: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.preview-stage.image-fit {
  display: block;
  overflow: hidden;
  touch-action: none;
}

.image-fit .preview-image-canvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.image-fit .preview-image-canvas img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-stage.image-scroll {
  touch-action: manipulation;
}

.preview-stage.panorama-view {
  overflow: hidden;
  scrollbar-gutter: auto;
}

.preview-stage video {
  width: min(100%, 1280px);
  height: min(100%, 760px);
}

.preview-stage audio {
  width: min(88vw, 680px);
}

.preview-stage iframe {
  width: 100%;
  height: 100%;
  background: #fff;
}

.file-document {
  display: grid;
  width: min(90vw, 720px);
  justify-items: center;
  color: #c7d1d6;
}

.file-document svg {
  width: 76px;
  height: 76px;
  margin-bottom: 16px;
}

.panorama-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.panorama-canvas:active {
  cursor: grabbing;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(96vw, 1180px);
  height: min(92vh, 820px);
  overflow: hidden;
}

.editor-panel .CodeMirror {
  height: 100%;
  font: 13px/1.6 Consolas, "Cascadia Code", monospace;
}

.editor-status {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
}

.user-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  min-height: 430px;
}

.user-list {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.user-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}

.user-row:hover,
.user-row.active {
  background: var(--surface-2);
}

.user-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  font-weight: 700;
}

.user-row strong,
.user-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.role-badge {
  padding: 3px 7px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 4px;
  font-size: 11px;
}

.user-form {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 4px 16px 0;
}

.account-menu {
  position: fixed;
  z-index: 90;
  top: 52px;
  right: 10px;
  width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.account-menu button {
  display: flex;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 4px;
  text-align: left;
}

.account-menu button:hover {
  background: var(--surface-2);
}

.account-menu svg {
  width: 17px;
}

.toast-stack {
  position: fixed;
  z-index: 120;
  right: 16px;
  bottom: 16px;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  gap: 8px;
}

.toast {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 5px;
  box-shadow: var(--shadow);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast svg {
  width: 19px;
}

@media (max-width: 900px) {
  .image-album .preview-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 82px;
  }

  .image-album .preview-viewport {
    grid-row: 1;
  }

  .image-album .preview-filmstrip {
    grid-row: 2;
    flex-direction: row;
    min-width: 0;
    padding: 8px;
    overflow-y: hidden;
    overflow-x: auto;
  }

  .image-album .preview-thumbnail {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, var(--sidebar-width));
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    background: rgba(7, 12, 16, 0.5);
  }

  .sidebar-close {
    display: grid;
  }

  .workspace {
    grid-template-rows: 56px 44px auto minmax(0, 1fr);
  }

  .search-box {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .topbar-spacer {
    display: none;
  }

  .select-control,
  .desktop-only,
  .account-button span {
    display: none;
  }

  .account-button {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .gallery.grid {
    gap: 14px;
  }

  .user-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-list {
    max-height: 230px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .preview-nav {
    width: 32px;
    height: 40px;
  }

  .preview-nav.previous {
    left: 6px;
  }

  .preview-nav.next {
    right: 14px;
  }

  .preview-position {
    margin-right: 4px;
    font-size: 11px;
  }

  .topbar {
    gap: 4px;
    padding: 7px 6px;
  }

  .topbar > .icon-button,
  .account-button {
    width: 36px;
    height: 36px;
  }

  .search-box {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .segmented .icon-button {
    width: 31px;
  }

  .pathbar {
    padding: 0 9px;
  }

  .folder-summary {
    display: none;
  }

  .commandbar {
    padding: 8px;
  }

  .gallery-heading {
    font-size: 20px;
  }

  .command-primary,
  .selection-commands {
    min-width: 0;
    overflow-x: auto;
  }

  .command-button {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .command-button span {
    display: none;
  }

  .gallery-shell {
    padding: 8px;
  }

  .gallery.grid {
    gap: 12px;
  }

  .file-info {
    min-height: 55px;
    padding: 8px;
  }

  .form-grid.two {
    grid-template-columns: minmax(0, 1fr);
  }

  .span-two {
    grid-column: auto;
  }

  .preview-title strong,
  .preview-title span {
    max-width: 100%;
  }

  .modal-panel > header,
  .modal-panel > footer {
    padding: 12px;
  }

  .editor-panel {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
