:root {
  color-scheme: light;
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --text: #172033;
  --muted: #697386;
  --line: #e4e9f2;
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-soft: #e8f0fe;
  --danger: #d93025;
  --green: #188038;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(26, 115, 232, 0.16), transparent 34rem),
    linear-gradient(135deg, #fbfdff 0%, var(--bg) 48%, #eef4ff 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.app-shell,
.sidebar,
.main,
.panel,
.folder-card,
.file-row,
.context-menu,
.modal,
.viewer {
  min-width: 0;
}

.app-shell,
button,
.folder-card,
.file-row,
.nav-item,
.small-action,
.context-item,
.viewer-nav {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input,
select,
textarea,
.text-preview,
.admin-output {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  padding: 28px 20px;
  border-right: 1px solid rgba(228, 233, 242, 0.75);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 10px 22px rgba(18, 56, 255, 0.18);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.primary-action,
.ghost,
.lang-toggle {
  border: 0;
  border-radius: 999px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 14px 26px rgba(26, 115, 232, 0.22);
}

.primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.primary-action span:first-child {
  font-size: 22px;
  line-height: 1;
}

.primary-action.compact {
  width: auto;
  padding: 11px 16px;
}

.ghost,
.lang-toggle {
  padding: 10px 15px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost:hover,
.lang-toggle:hover {
  background: var(--surface-soft);
}

.danger-text {
  color: var(--danger);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.quota-card {
  margin-top: 30px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
}

.quota-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.quota-header.mini {
  margin-top: 16px;
  font-size: 13px;
}

.quota-bar {
  height: 9px;
  margin: 14px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef8;
}

.quota-bar span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #34a853);
}

.quota-bar.minio span {
  background: linear-gradient(90deg, #fbbc04, #f97316);
}

.quota-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.quota-card .quota-usage {
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 700;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.sidebar-actions .ghost {
  width: 100%;
}

.compact-lang {
  display: grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
  font-size: 18px;
}

.main {
  padding: 26px clamp(20px, 4vw, 48px) 46px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 26px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(620px, 100%);
  padding: 13px 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.drive-search {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.drive-search-basic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.drive-search .search-box {
  width: 100%;
  box-shadow: none;
  background: #f8fbff;
}

.search-toggle {
  min-width: 42px;
  font-size: 18px;
}

.search-toggle[aria-expanded="true"] {
  transform: rotate(180deg);
}

.advanced-search-fields.hidden,
.search-summary.hidden,
.grid.hidden,
.file-list.hidden {
  display: none;
}

.search-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: auto;
  margin-left: 10px;
  padding: 7px 12px;
  border: 1px solid #c9d8f7;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.selection-bar.hidden {
  display: none;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.panel {
  border: 1px solid rgba(228, 233, 242, 0.85);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel.hidden {
  display: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel h2 {
  margin: 0;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.path-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-height: 38px;
  overflow: hidden;
  margin-top: 10px;
}

.path-back {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 20px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  flex-wrap: nowrap;
  gap: 6px;
}

.crumb {
  border: 0;
  border-radius: 10px;
  padding: 5px 7px;
  background: transparent;
  color: var(--text);
  font-size: 28px;
}

.crumb:hover {
  background: var(--surface-soft);
}

.crumb-separator {
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  min-height: 82px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  text-align: left;
}

.folder-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-card:hover,
.file-row:hover {
  border-color: #c9d8f7;
  background: #f8fbff;
}

.folder-card.selected,
.file-row.selected {
  border-color: var(--primary);
  background: #dbeafe;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.13);
}

.folder-card.selected:hover,
.file-row.selected:hover {
  background: #dbeafe;
}

.folder-card.processing {
  color: var(--text);
  opacity: 1;
  pointer-events: none;
}

.folder-card.processing > * {
  opacity: 0.35;
}

.folder-card.processing::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.72);
  z-index: 1;
}

.folder-card.processing::after {
  content: attr(data-processing-label);
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--primary-dark);
  font-weight: 700;
}

.folder-card.processing[aria-busy="true"]::after {
  background-image: radial-gradient(circle, currentColor 48%, transparent 52%);
  background-repeat: no-repeat;
  background-size: 8px 8px;
  background-position: calc(50% - 52px) center;
  animation: processingPulse 1s ease-in-out infinite;
}

@keyframes processingPulse {
  0%,
  100% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
}

.folder-card.drag-over,
.file-row.drag-over,
.crumb.drag-over,
.panel.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}

.folder-icon {
  display: block;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-list.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: stretch;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px 110px auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.file-list.grid-view .file-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  row-gap: 8px;
  min-height: 210px;
}

.file-list.grid-view .file-main {
  display: contents;
}

.file-list.grid-view .file-row > .muted {
  display: none;
}

.file-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.file-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.file-thumb {
  position: relative;
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb img.loading {
  opacity: 0;
}

.file-list.grid-view .file-thumb {
  grid-column: 1 / -1;
  width: 100%;
  height: 128px;
  border-radius: 16px;
  background: #eef4ff;
}

.file-list.grid-view .file-title {
  grid-column: 1;
  min-width: 0;
}

.file-list.grid-view .row-actions {
  grid-column: 2;
  align-self: end;
}

.file-list.grid-view .file-name {
  margin-top: 10px;
}

.file-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.tag {
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2fb;
  color: #3c4a5f;
  font-size: 12px;
}

.file-card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.small-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}

.small-action:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.small-action.danger {
  color: var(--danger);
}

.small-action.success {
  color: var(--green);
}

.context-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  min-width: 210px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
}

.context-menu.hidden {
  display: none;
}

.context-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 11px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.context-item:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.context-item:disabled {
  background: transparent;
  color: var(--muted);
  opacity: 0.45;
}

.context-item.danger {
  color: var(--danger);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.filter-grid input,
.filter-grid select {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  outline: 0;
}

.filter-grid input:focus,
.filter-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.admin-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.admin-card button {
  justify-self: start;
}

.danger-card {
  border-color: #f2c8c5;
}

.admin-output {
  min-height: 180px;
  max-height: 520px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.admin-kv {
  display: grid;
  gap: 8px;
}

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

.admin-kv-row:last-child {
  border-bottom: 0;
}

.admin-kv-row > span {
  color: var(--muted);
  font-weight: 700;
}

.admin-result-list {
  display: grid;
  gap: 10px;
}

.admin-result-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

.empty {
  padding: 28px;
  border: 1px dashed #cbd6e6;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 16px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.transfer-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 22;
  width: min(420px, calc(100vw - 48px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.transfer-panel.hidden {
  display: none;
}

.transfer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.transfer-head-actions {
  display: flex;
  gap: 8px;
}

.transfer-head button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}

.transfer-list {
  display: grid;
  max-height: 320px;
  overflow: auto;
}

.transfer-panel.collapsed {
  width: min(260px, calc(100vw - 48px));
}

.transfer-panel.collapsed .transfer-head {
  border-bottom: 0;
}

.transfer-panel.collapsed .transfer-list {
  display: none;
}

.transfer-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.transfer-item:last-child {
  border-bottom: 0;
}

.transfer-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.transfer-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transfer-meta {
  color: var(--muted);
  white-space: nowrap;
}

.transfer-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.transfer-cancel {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: #feeceb;
  color: var(--danger);
  font-size: 12px;
}

.transfer-cancel:hover {
  background: #fbd2cf;
}

.transfer-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef8;
}

.transfer-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #34a853);
  transition: width 0.16s ease;
}

.transfer-item.error .transfer-progress span {
  background: var(--danger);
}

.drop-overlay {
  position: fixed;
  inset: 16px;
  z-index: 25;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(26, 115, 232, 0.72);
  border-radius: 30px;
  background: rgba(232, 240, 254, 0.82);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.drop-overlay.hidden {
  display: none;
}

.drop-overlay div {
  display: grid;
  gap: 8px;
  padding: 26px 34px;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.drop-overlay strong {
  color: var(--primary-dark);
  font-size: clamp(24px, 4vw, 38px);
}

.drop-overlay span {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(10px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(480px, 100%);
  padding: 22px;
  border: 1px solid rgba(228, 233, 242, 0.9);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.24);
}

.folder-picker-modal {
  width: min(560px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 22px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
}

.modal-field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.modal-field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: 0;
}

.modal-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.folder-picker-path {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text) !important;
  font-weight: 700;
}

.folder-picker-list {
  display: grid;
  gap: 8px;
  max-height: min(420px, 48vh);
  overflow: auto;
}

.folder-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
}

.folder-picker-item:hover {
  border-color: #c9d8f7;
  background: #f8fbff;
}

.viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(12px);
}

.viewer-backdrop.hidden {
  display: none;
}

.viewer {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(1120px, 100%);
  height: min(820px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid rgba(228, 233, 242, 0.9);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  display: grid;
  width: 48px;
  height: 72px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.56);
  color: #fff;
  font-size: 46px;
  line-height: 1;
}

.viewer-nav:hover {
  background: rgba(15, 23, 42, 0.72);
}

.viewer-nav:disabled {
  display: none;
}

.viewer-prev {
  left: 18px;
}

.viewer-next {
  right: 18px;
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.viewer-head > div {
  min-width: 0;
}

.viewer-head h3,
.viewer-head p {
  margin: 0;
}

.viewer-head h3 {
  max-width: min(620px, 54vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer-body {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: 18px;
  background: #f8fafc;
}

.viewer-body > img,
.viewer-body > video {
  width: auto;
  height: auto;
  max-width: calc(100vw - 90px);
  max-height: calc(100vh - 170px);
  border-radius: 14px;
  background: #000;
  object-fit: contain;
}

.image-preview {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.image-preview-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  touch-action: none;
}

.image-preview-stage.pannable {
  cursor: grab;
}

.image-preview-stage.pannable:active {
  cursor: grabbing;
}

.image-preview-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 86px);
  background: transparent;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.12s ease;
  will-change: transform;
}

.image-zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(228, 233, 242, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
}

.viewer-body audio {
  width: min(680px, 100%);
}

.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 14px;
  background: #fff;
}

.text-preview {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: #172033;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.unsupported-preview {
  max-width: 460px;
  text-align: center;
}

.unsupported-preview strong {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}

.unsupported-preview p {
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --radius: 18px;
  }

  body {
    min-width: 0;
    overscroll-behavior-x: none;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
  }

  .sidebar {
    position: relative;
    padding: 16px 14px;
    overflow: visible;
  }

  .brand {
    min-height: 44px;
    padding-right: 156px;
    margin-bottom: 14px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .primary-action {
    padding: 12px 14px;
  }

  .nav {
    margin-top: 14px;
    gap: 8px;
  }

  .nav-item {
    justify-content: center;
    min-width: max-content;
    padding: 10px 12px;
    text-align: center;
  }

  .nav-item span:last-child {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .quota-card {
    margin-top: 14px;
    padding: 14px;
  }

  .sidebar-actions {
    position: absolute;
    top: 16px;
    right: 14px;
    grid-template-columns: minmax(0, 104px) 44px;
    width: 156px;
    margin-top: 0;
    padding-top: 0;
  }

  .sidebar-actions .ghost {
    overflow: hidden;
    padding-inline: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main {
    padding: 18px 14px 30px;
  }

  .panel {
    width: 100%;
    padding: 16px;
    overflow: hidden;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    justify-content: stretch;
  }

  .panel-actions > * {
    flex: 1 1 auto;
  }

  .path-row {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .path-row::-webkit-scrollbar {
    display: none;
  }

  .breadcrumbs {
    overflow: visible;
  }

  .crumb {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 22px;
  }

  .crumb-separator {
    font-size: 24px;
  }

  .drive-search-basic {
    grid-template-columns: 1fr auto;
  }

  .drive-search-basic .primary-action {
    grid-column: 1 / -1;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .file-list.grid-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-list.grid-view .file-row {
    min-height: 178px;
  }

  .file-list.grid-view .file-thumb {
    height: 104px;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 11px 12px;
  }

  .file-row > .muted {
    display: none;
  }

  .file-main {
    gap: 10px;
  }

  .file-thumb {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .file-name {
    font-weight: 600;
  }

  .row-actions {
    justify-content: flex-end;
  }

  .small-action {
    padding: 7px 9px;
  }

  .context-menu {
    min-width: 0;
    max-width: calc(100vw - 24px);
  }

  .modal-backdrop,
  .viewer-backdrop {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .modal-backdrop {
    place-items: stretch;
  }

  .viewer-backdrop {
    place-items: center;
  }

  .modal,
  .folder-picker-modal {
    width: 100%;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions > * {
    flex: 1 1 auto;
  }

  .viewer {
    width: min(90vw, 520px);
    max-width: calc(100vw - 16px);
    height: min(80dvh, 760px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }

  .viewer-head {
    align-items: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  .viewer-head > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  .viewer-head h3 {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.25;
  }

  .viewer-head p {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .viewer-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto 40px;
    justify-content: stretch;
    gap: 6px;
  }

  .viewer-actions > * {
    flex: 0 0 auto;
  }

  #viewerDownloadButton {
    max-width: 96px;
    padding-inline: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #viewerCloseButton {
    width: 40px;
    height: 40px;
  }

  .viewer-body {
    padding: 8px;
    overflow: hidden;
  }

  .viewer-body.image-mode {
    padding: 0;
  }

  .viewer-body > img,
  .viewer-body > video {
    max-width: 100%;
    max-height: calc(100dvh - 180px);
  }

  .image-preview-stage img {
    width: auto;
    height: auto;
    max-width: calc(100% - 18px);
    max-height: calc(100% - 82px);
  }

  .image-zoom-controls {
    right: 50%;
    bottom: 10px;
    transform: translateX(50%);
    max-width: calc(100vw - 40px);
    overflow-x: auto;
  }

  .viewer-nav {
    width: 38px;
    height: 58px;
    font-size: 36px;
  }

  .viewer-prev {
    left: 8px;
  }

  .viewer-next {
    right: 8px;
  }

  .transfer-panel {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
  }

  .transfer-panel.compact.collapsed {
    right: 14px;
    bottom: 14px;
    left: auto;
    display: grid;
    width: 58px;
    height: 58px;
    border-radius: 999px;
    overflow: visible;
  }

  .transfer-panel.compact.collapsed .transfer-head {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 0;
    place-items: center;
    border-bottom: 0;
  }

  .transfer-panel.compact.collapsed .transfer-head > strong,
  .transfer-panel.compact.collapsed #transferClearButton {
    display: none;
  }

  .transfer-panel.compact.collapsed .transfer-head-actions {
    display: contents;
  }

  .transfer-panel.compact.collapsed #transferCollapseButton {
    width: 58px;
    height: 58px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 14px 30px rgba(26, 115, 232, 0.28);
    font-weight: 700;
  }
}
