:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #dfe5ec;
  --line-strong: #cbd5e1;
  --text: #1f2937;
  --muted: #778495;
  --subtle: #a3adba;
  --primary: #0878ee;
  --primary-hover: #0068d4;
  --primary-soft: #e8f2ff;
  --danger: #d14343;
  --danger-soft: #fff1f1;
  --row-active: #e9f3ff;
  --shadow: 0 14px 42px rgba(30, 41, 59, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.login-screen {
  flex: 1;
  min-height: 0;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow: auto;
  background: var(--bg);
}

.login-panel {
  width: min(390px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 32px;
  box-shadow: 0 8px 28px rgba(30, 41, 59, 0.1);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 650;
}

.login-heading {
  margin: 30px 0 22px;
}

.login-heading h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.login-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-field {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

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

.login-field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

.login-error {
  margin: 14px 0 0;
  border: 1px solid #efb6b6;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 11px;
  line-height: 1.5;
}

.login-button {
  width: 100%;
  min-height: 42px;
  margin-top: 20px;
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-picker {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

button:hover,
.file-picker:hover {
  border-color: #9eacbc;
  background: var(--surface-soft);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.file-picker:focus-within {
  outline: 2px solid rgba(8, 120, 238, 0.28);
  outline-offset: 1px;
}

button:disabled,
.file-picker.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.danger {
  border-color: #efb6b6;
  background: var(--danger-soft);
  color: var(--danger);
}

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

.hidden {
  display: none !important;
}

.app-header {
  flex: none;
  height: 72px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 650;
}

.brand-mark {
  position: relative;
  width: 32px;
  height: 34px;
  flex: none;
}

.brand-mark i {
  position: absolute;
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
}

.brand-mark i:nth-child(1) {
  top: 1px;
  left: 7px;
  background: #139df2;
}

.brand-mark i:nth-child(2) {
  top: 11px;
  left: 0;
  background: #10b6c7;
}

.brand-mark i:nth-child(3) {
  top: 14px;
  left: 13px;
  background: #174eb8;
}

.bucket-chip {
  display: inline-flex;
  align-items: center;
  max-width: 55%;
  min-height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-content: flex-end;
}

.header-actions {
  min-width: 0;
  max-width: 65%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.header-actions .bucket-chip {
  max-width: none;
  min-width: 0;
}

.header-actions button {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
}

.breadcrumb-bar {
  flex: none;
  height: 44px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 23px;
  line-height: 1;
}

.breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--muted);
}

.breadcrumb-item {
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 7px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-item:hover {
  border: 0;
  background: transparent;
  color: var(--primary);
}

.breadcrumb-item.current {
  color: var(--text);
  cursor: default;
  font-weight: 600;
}

.breadcrumb-separator {
  color: #b2bcc8;
}

.workspace {
  flex: 1;
  min-height: 0;
  padding: 28px 24px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbar {
  min-height: 42px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar-group,
.picker-actions,
.detail-actions,
.editor-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.search-box {
  width: min(310px, 100%);
  height: 36px;
  position: relative;
}

.search-box input,
.field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search-box input {
  padding: 0 38px 0 12px;
}

.search-icon {
  position: absolute;
  z-index: 1;
  right: 12px;
  top: 5px;
  color: var(--muted);
  font-size: 22px;
  pointer-events: none;
}

.object-browser {
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  grid-template-rows: 1fr auto;
}

.table-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body.modal-open .table-scroll {
  overflow: hidden;
}

.object-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  table-layout: fixed;
}

.object-table th,
.object-table td {
  height: 49px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  text-align: left;
  vertical-align: middle;
}

.object-table th {
  height: 40px;
  background: #fbfcfe;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 2;
}

.object-table th:first-child {
  width: 50%;
}

.object-table th:nth-child(2) {
  width: 120px;
}

.object-table th:nth-child(3) {
  width: 110px;
}

.object-table th:nth-child(4) {
  width: 190px;
}

.object-table th:nth-child(5) {
  width: 270px;
}

.object-row:hover td,
.object-row.active td {
  background: var(--row-active);
}

.parent-row td {
  background: #fbfcfe;
}

.parent-row .item-name {
  font-weight: 600;
}

.name-cell {
  min-width: 0;
}

.name-button {
  width: 100%;
  min-height: 34px;
  border: 0;
  background: transparent;
  padding: 0;
  justify-content: flex-start;
  overflow: hidden;
}

.name-button:hover {
  border: 0;
  background: transparent;
  color: var(--primary);
}

.item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-content {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
}

.mobile-meta {
  display: none;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-icon,
.empty-folder {
  position: relative;
  width: 28px;
  height: 20px;
  border-radius: 2px;
  background: #82b7f7;
  flex: none;
}

.folder-icon::before,
.empty-folder::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 2px;
  width: 12px;
  height: 7px;
  border-radius: 2px 2px 0 0;
  background: #82b7f7;
}

.file-icon {
  position: relative;
  width: 23px;
  height: 28px;
  border: 1px solid #c8d2de;
  border-radius: 2px;
  background: #fff;
  flex: none;
}

.file-icon::after {
  content: "";
  position: absolute;
  left: 5px;
  bottom: 5px;
  width: 11px;
  height: 7px;
  background: #f5a742;
  clip-path: polygon(0 100%, 38% 38%, 58% 65%, 76% 30%, 100% 100%);
}

.muted-cell {
  color: var(--muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.row-action {
  width: auto;
  min-height: 34px;
  border: 0;
  background: transparent;
  padding: 0 8px;
  color: #52677f;
  font-size: 13px;
}

.row-action:hover {
  border: 0;
  background: #dbeaff;
  color: var(--primary);
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 18px 0 5px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  margin: 0;
}

.empty-folder {
  width: 58px;
  height: 41px;
  opacity: 0.68;
}

.empty-folder::before {
  top: -9px;
  width: 24px;
  height: 12px;
}

.browser-footer {
  min-height: 48px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.browser-footer button {
  min-height: 30px;
  padding: 0 12px;
}

.row-menu {
  position: fixed;
  z-index: 30;
  width: 178px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  padding: 6px;
  box-shadow: var(--shadow);
}

.row-menu button {
  width: 100%;
  min-height: 33px;
  border: 0;
  background: transparent;
  padding: 0 10px;
  justify-content: flex-start;
}

.row-menu button:hover {
  border: 0;
  background: var(--surface-soft);
}

.row-menu hr {
  margin: 5px 4px;
  border: 0;
  border-top: 1px solid var(--line);
}

.modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 5px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
  overscroll-behavior: contain;
}

.modal::backdrop {
  background: rgba(24, 33, 46, 0.52);
}

.modal-head {
  min-height: 74px;
  padding: 20px 24px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal-head h2,
.editor-head h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.modal-head p,
.editor-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.close-button {
  width: 34px;
  min-height: 34px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: 25px;
}

.close-button:hover {
  border: 0;
  background: var(--surface-soft);
}

.picker-actions {
  padding: 8px 24px 18px;
}

.file-picker {
  height: 36px;
}

.file-picker input {
  display: none;
}

.upload-queue {
  height: min(294px, 38vh);
  margin: 0 24px;
  border: 1px solid var(--line-strong);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.queue-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.queue-head,
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 64px;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.queue-head {
  color: var(--subtle);
  font-size: 13px;
}

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

.queue-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-remove {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0 6px;
  color: var(--danger);
}

.queue-empty {
  min-height: 100%;
  display: grid;
  place-content: center;
  color: var(--muted);
}

.upload-status {
  margin: 16px 24px 0;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.upload-status.has-errors {
  color: var(--danger);
}

.upload-status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

#uploadStatusText {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#uploadCount {
  flex: none;
  font-variant-numeric: tabular-nums;
}

.upload-status progress {
  width: 100%;
  height: 7px;
  border: 0;
  accent-color: var(--primary);
}

.upload-errors summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 600;
}

.upload-errors ul {
  max-height: 100px;
  margin: 6px 0 0;
  padding-left: 20px;
  overflow: auto;
  overflow-wrap: anywhere;
}

.modal-actions {
  margin-top: 18px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.policy-modal {
  width: min(520px, calc(100vw - 32px));
}

.field {
  margin: 8px 24px 22px;
  display: grid;
  gap: 8px;
}

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

.field input {
  padding: 0 11px;
}

.detail-modal {
  width: min(780px, calc(100vw - 32px));
}

.detail-title-wrap {
  min-width: 0;
}

.modal-kicker {
  font-size: 12px;
}

#detailKey {
  max-width: 650px;
  overflow-wrap: anywhere;
}

.meta-grid {
  margin: 4px 24px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.meta-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 12px;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.meta-grid dd {
  margin: 5px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions {
  padding: 0 24px 20px;
  flex-wrap: wrap;
}

.text-editor {
  border-top: 1px solid var(--line);
  padding: 18px 24px 24px;
}

.editor-head {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.text-editor textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 12px;
  outline: none;
  color: var(--text);
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  max-width: min(560px, calc(100vw - 32px));
  border-radius: 5px;
  background: #273342;
  color: #fff;
  padding: 11px 15px;
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .login-panel {
    padding: 26px 22px;
  }

  .app-header {
    height: auto;
    min-height: 68px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: 12px;
    padding-left: max(16px, env(safe-area-inset-left));
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .brand {
    font-size: 18px;
  }

  .brand-mark {
    transform: scale(0.88);
    transform-origin: left center;
  }

  .bucket-chip {
    padding-left: 0;
    font-size: 12px;
    justify-content: flex-start;
  }

  .header-actions {
    width: 100%;
    max-width: none;
  }

  .header-actions .bucket-chip {
    flex: 1;
  }

  .breadcrumb-bar {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .breadcrumbs {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

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

  .breadcrumb-item {
    flex: none;
    max-width: 160px;
  }

  .workspace {
    padding-top: 18px;
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }

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

  .toolbar-group {
    display: grid;
    grid-template-columns: 1fr 1fr 44px;
  }

  .toolbar-group button,
  .search-box,
  .search-box input {
    min-height: 44px;
  }

  .search-box {
    width: 100%;
  }

  .object-browser {
    min-height: 0;
  }

  .object-table {
    min-width: 0;
  }

  .object-table th:first-child {
    width: auto;
  }

  .object-table th:nth-child(2),
  .object-table td:nth-child(2),
  .object-table th:nth-child(3),
  .object-table td:nth-child(3),
  .object-table th:nth-child(4),
  .object-table td:nth-child(4) {
    display: none;
  }

  .object-table th:nth-child(5) {
    width: 76px;
  }

  .object-table th,
  .object-table td {
    padding-right: 12px;
    padding-left: 12px;
  }

  .object-table td {
    height: 60px;
  }

  .name-button {
    min-height: 48px;
    gap: 10px;
  }

  .mobile-meta {
    display: block;
  }

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

  .object-row:not(.folder-row):not(.parent-row) .row-action:not(.menu-trigger) {
    display: none;
  }

  .row-action {
    min-height: 44px;
    padding: 0 8px;
  }

  .row-menu {
    top: auto !important;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left)) !important;
    width: auto;
    max-height: min(70vh, 520px);
    padding: 8px;
    overflow-y: auto;
    border-radius: 7px;
  }

  .row-menu button {
    min-height: 44px;
    font-size: 15px;
  }

  .picker-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .queue-head,
  .queue-row {
    grid-template-columns: minmax(0, 1fr) 76px 52px;
    padding: 0 10px;
  }

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

  .editor-head {
    flex-direction: column;
  }

  .modal-actions button {
    flex: 1;
    min-height: 44px;
  }

  .modal {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
  }

  .toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}
