:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f9fa;
  --line: #d9e0e4;
  --text: #172026;
  --muted: #65737c;
  --accent: #1f7a8c;
  --accent-strong: #145f70;
  --accent-soft: #e5f3f5;
  --green: #2b8a5f;
  --orange: #bd6b18;
  --danger: #b84234;
  --shadow: 0 22px 70px rgba(21, 32, 38, 0.12);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
a.primary-button,
a.ghost-button {
  min-height: 38px;
}

.page {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.16;
}

h2 {
  margin-bottom: 6px;
  font-size: 17px;
}

.field,
.search-box,
.select-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.search-box input,
.select-box select,
.user-form input,
.user-form select,
.user-row select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.field input:focus,
.search-box input:focus,
.select-box select:focus,
.user-form input:focus,
.user-form select:focus,
.user-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.14);
}

.workspace {
  position: fixed;
  inset: 0;
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  height: 100%;
  max-height: 100vh;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #172026;
  color: #f8fbfc;
}

.brand-block h1 {
  font-size: 23px;
}

.category-nav {
  display: grid;
  gap: 7px;
}

.category-nav button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #d5dee2;
  cursor: pointer;
  text-align: left;
}

.category-nav button:hover,
.category-nav button.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.category-nav strong {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  text-align: center;
  font-size: 12px;
}

.storage-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.storage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #c9d4d9;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #55c2a1;
}

.storage-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.storage-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.storage-card dt {
  color: #aab8bf;
}

.storage-card dd {
  margin: 0;
  font-weight: 700;
}

.main-panel {
  min-width: 0;
  height: 100%;
  max-height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.main-panel > * {
  flex-shrink: 0;
}

.topbar,
.toolbar,
.file-surface,
.upload-zone,
.folder-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.path-block {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.breadcrumbs button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.breadcrumbs span,
.storage-path {
  color: var(--muted);
  font-size: 13px;
}

.storage-path {
  margin: 0;
  max-width: 72vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-chip {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.stat-card strong {
  font-size: 24px;
  line-height: 1;
}

.upload-zone {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-style: dashed;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone.disabled-zone {
  opacity: 0.72;
}

.upload-copy p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

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

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

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover {
  border-color: #aebbc2;
  background: var(--panel-soft);
}

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

.danger-button:hover {
  background: #fff2f0;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--text);
  font-size: 22px;
}

.disabled,
button:disabled {
  pointer-events: none;
  opacity: 0.55;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.queue {
  display: grid;
  gap: 8px;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.queue-status {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.progress {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  background: var(--panel-soft);
  border-radius: 999px;
}

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

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

.folder-section {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.section-head,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
}

.section-head span,
.table-head span {
  color: var(--muted);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.folder-card {
  position: relative;
  display: grid;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.folder-open {
  display: grid;
  align-content: center;
  gap: 8px;
  width: 100%;
  min-height: 84px;
  padding: 12px 42px 12px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

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

.folder-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
}

.file-surface {
  overflow: hidden;
}

.table-head {
  min-height: 50px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.file-table th,
.file-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.file-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfd;
}

.file-table td {
  font-size: 14px;
}

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

.folder-path {
  color: var(--muted);
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.file-actions button,
.file-actions a {
  min-height: 32px;
  padding: 6px 9px;
}

.empty-state {
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(980px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(16, 27, 34, 0.42);
}

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

.modal-head h2 {
  margin: 0;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  min-height: 360px;
  max-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
  padding: 14px;
  background: #101820;
}

.preview-media {
  max-width: 100%;
  max-height: calc(100vh - 170px);
}

.preview-audio {
  width: min(620px, 100%);
}

.preview-frame {
  width: 100%;
  height: min(680px, calc(100vh - 160px));
  border: 0;
  border-radius: 6px;
  background: #fff;
}

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

.admin-page {
  min-height: 100vh;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 22px;
}

.admin-topbar,
.admin-panel,
.admin-create {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.admin-content {
  display: grid;
  gap: 16px;
}

.admin-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.admin-panel p {
  margin: 0;
  color: var(--muted);
}

.admin-create {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 130px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 120px auto;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.users-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 120px auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.user-row div {
  display: grid;
  gap: 4px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 40px));
  padding: 12px 14px;
  background: #162229;
  color: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 14px;
  word-break: break-word;
  z-index: 20;
}

.share-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.share-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.share-panel h1 {
  overflow-wrap: anywhere;
}

.share-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.share-meta div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.share-meta dt {
  color: var(--muted);
}

.share-meta dd {
  margin: 0;
  text-align: right;
}

@media (max-width: 1040px) {
  .workspace {
    position: static;
    inset: auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .sidebar {
    height: auto;
    min-height: auto;
    overflow: visible;
    grid-template-columns: minmax(160px, 1fr) minmax(260px, 2fr) minmax(220px, 1fr);
    align-items: start;
  }

  .main-panel {
    height: auto;
    overflow: visible;
  }

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

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

  .admin-create {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .main-panel,
  .sidebar {
    padding: 14px;
  }

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

  .topbar,
  .upload-zone {
    align-items: stretch;
    flex-direction: column;
  }

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

  .stat-grid,
  .toolbar,
  .admin-create,
  .user-form,
  .user-row {
    grid-template-columns: 1fr;
  }

  .storage-path {
    max-width: 82vw;
  }

  .file-table {
    min-width: 820px;
  }
}
