/* 色彩集中管理，文件列表与弹窗共用，深色模式保持同样的层次。 */
:root {
  color-scheme: light;
  --bg: #f3f7fd; --elev: #fff; --soft: #edf3fc;
  --line: #c8d6e8; --line-soft: #e0e8f3; --text: #14233d; --muted: #53657e;
  --accent: #0b63ce; --accent-soft: #e9f2ff; --danger: #c6444e;
  --radius: 18px; --shadow: 0 20px 70px rgba(20, 51, 94, .14);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c1729; --elev: #14233b; --soft: #1c2f4c;
    --line: #49627f; --line-soft: #293e5b; --text: #f0f6ff;
    --muted: #b9cce4; --accent: #80b8ff; --accent-soft: #203d63; --danger: #ff8590;
    --shadow: 0 20px 70px rgba(0, 0, 0, .4);
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
body.preview-open { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, input, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.hidden { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 19px; height: 19px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 76px; padding: 16px max(28px, calc((100vw - 1440px) / 2));
  background: var(--elev); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; border: 0; padding: 0; background: none; font-size: 17px; font-weight: 700; letter-spacing: -.4px; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--accent); background: var(--accent-soft); }
.brand-icon .icon { width: 22px; height: 22px; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }
.appbar-actions .btn { border: 0; background: transparent; padding: 8px 11px; color: var(--muted); }
.appbar-actions .btn:hover { background: var(--soft); color: var(--text); }
.appbar-home { text-decoration: none; }
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); background: var(--elev); white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover, .icon-btn:hover { background: var(--soft); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #0c2344; }
.btn.primary:hover { filter: brightness(.94); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn:disabled, .icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 42px; height: 42px; padding: 0; flex-shrink: 0; }
.btn-short { display: none; }
body:not(.is-admin) .admin-only { display: none !important; }
.wrap { max-width: 1496px; margin: 0 auto; padding: 44px 28px calc(40px + env(safe-area-inset-bottom)); }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.heading-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.role-badge { background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 20px; font-size: 11px; }
h1 { margin: 9px 0 8px; font-size: 30px; font-weight: 650; letter-spacing: -1px; overflow-wrap: anywhere; }
.folder-summary { margin: 0; color: var(--muted); font-size: 13px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.file-panel { background: var(--elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 20px rgba(20, 51, 94, .025); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; }
.path-nav { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.crumbs { display: flex; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.crumbs::-webkit-scrollbar, .picker-crumbs::-webkit-scrollbar { display: none; }
.crumb { flex-shrink: 0; border: 0; background: none; padding: 8px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.crumb:hover { background: var(--soft); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.crumb-sep { color: var(--muted); opacity: .5; flex-shrink: 0; }
.list-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; color: var(--muted); height: 42px; width: 240px; }
.search-box:focus-within { border-color: var(--accent); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; height: 100%; font-size: 13px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box input::placeholder { color: var(--muted); }
.search-clear { display: grid; place-items: center; width: 26px; height: 32px; border: 0; padding: 0; background: transparent; color: var(--muted); flex-shrink: 0; }
.search-clear .icon { width: 15px; height: 15px; }
#sort-select { height: 42px; padding: 0 9px; background: var(--elev); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.list { min-height: 240px; }
.list-heading, .row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 110px 168px 90px; column-gap: 16px; align-items: center; padding-inline: 28px; }
.list-heading { min-height: 42px; color: var(--muted); font-size: 12px; background: var(--bg); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.list-heading span:first-child { grid-column: 1 / 3; }
.list-heading span:not(:first-child) { text-align: right; }
.row { min-height: 68px; padding-block: 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.row:last-child { border-bottom: 0; }
@media (hover: hover) { .row:hover { background: var(--soft); } }
.row-icon { display: grid; place-items: center; width: 40px; height: 44px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.row-icon.folder { background: #fff3d9; color: #ad7923; }
.row-icon.image { background: #edf0ff; color: #6978ba; }
.row-icon.media { background: #ffeef2; color: #b46b7e; }
.row-icon.archive { background: #eef3f8; color: #6e8bad; }
:root[data-theme="dark"] .row-icon.folder { background: #3b3220; color: #e1bc69; }:root[data-theme="dark"] .row-icon.image { background: #2c2d43; color: #a6aff0; }:root[data-theme="dark"] .row-icon.media { background: #412b35; color: #e8a6bd; }:root[data-theme="dark"] .row-icon.archive { background: #273242; color: #a0bfde; }

.row-icon .icon { width: 23px; height: 23px; }
.row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-btn, .name-link { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 0; border: 0; background: none; font: inherit; font-weight: 550; text-align: left; color: var(--text); text-decoration: none; }
.name-btn:hover, .name-link:hover { color: var(--accent); }
.row-meta { display: contents; }
.row-size, .row-time { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.row-more, .row-download { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; background: none; border-radius: 9px; color: var(--muted); }
.row-more:hover, .row-download:hover { background: var(--accent-soft); color: var(--accent); }
.empty { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty .icon { display: block; width: 36px; height: 36px; margin: 0 auto 16px; opacity: .6; }
.empty.small { padding: 28px 12px; }
.empty-hint { display: block; margin-top: 8px; font-size: 12px; }
.panel-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 28px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.usage { display: flex; align-items: center; gap: 12px; }
.usage-track { width: 90px; height: 4px; border-radius: 8px; background: var(--line); overflow: hidden; }
.usage-fill { width: 0; height: 100%; background: var(--accent); transition: width .3s; }
.usage-fill.warn { background: var(--danger); }
.usage-text { white-space: nowrap; font-variant-numeric: tabular-nums; }
.gate { display: flex; justify-content: center; padding: 13vh 20px 40px; }
.gate-card { width: 100%; max-width: 420px; padding: 40px 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--elev); text-align: center; box-shadow: var(--shadow); }
.gate-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 24px; color: var(--accent); background: var(--accent-soft); border-radius: 18px; }
.gate-icon .icon { width: 28px; height: 28px; }
.gate-title { margin: 0 0 12px; font-size: 23px; font-weight: 650; }
.gate-sub { margin: 0 0 26px; color: var(--muted); line-height: 1.9; }
.gate-hint { margin-bottom: 16px; color: var(--danger); }
.gate-submit { width: 100%; }
/* ---------- 拖拽上传 ---------- */
.drop-hint {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 99, 206, .16);
  pointer-events: none;
}
.drop-hint-box {
  padding: 22px 30px;
  background: var(--elev);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  box-shadow: var(--shadow);
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 上传进度 ---------- */
.upload-box {
  position: fixed;
  left: 50%;
  top: calc(66px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 70;
  width: min(92vw, 420px);
  padding: 10px 14px;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.upload-text {
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.upload-track { height: 5px; border-radius: 6px; background: var(--line-soft); overflow: hidden; }
.upload-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(90vw, 440px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1f2933;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: min(80vh, 620px);
  padding: 18px;
  background: var(--elev);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: modal-in .16s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-box, .modal.sheet .modal-box { animation: none; }
}
.modal-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; word-break: break-all; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* 底部动作面板：手机贴底，桌面居中 */
.modal.sheet { align-items: flex-end; padding: 0; }
.modal.sheet .modal-box {
  width: 100%;
  max-width: none;
  max-height: 80vh;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  animation: sheet-in .18s ease-out;
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}
.sheet-list { display: flex; flex-direction: column; }
.sheet-item {
  min-height: 50px;
  padding: 0 6px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  font-size: 15px;
  text-align: left;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item:hover { color: var(--accent); }
.sheet-item.danger { color: var(--danger); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label, .field-hint { color: var(--muted); font-size: 12px; }
.input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.modal-text { margin: 0; color: var(--muted); word-break: break-all; }

/* ---------- 目录选择器 ---------- */
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-crumbs { display: flex; align-items: center; gap: 2px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.picker-crumbs::-webkit-scrollbar { display: none; }
.picker-list {
  min-height: 120px;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  text-align: left;
}
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--soft); }
.picker-item-icon { flex: 0 0 auto; }

/* 目录名和搜索框各占一行，避免手机上的可点控件挤成很小的图标。 */
@media (max-width: 820px) {
  .toolbar { flex-wrap: wrap; gap: 12px; }
  .path-nav { flex-basis: 100%; }
  .list-controls { width: 100%; }
  .search-box { flex: 1; width: auto; }
  .list-heading, .row { grid-template-columns: 40px minmax(0, 1fr) 80px 134px 84px; column-gap: 10px; padding-inline: 18px; }
}
@media (min-width: 641px) {
  .modal.sheet { align-items: center; padding: 24px; }
  .modal.sheet .modal-box { max-width: 400px; border-radius: 18px; animation: modal-in .16s ease-out; }
}
@media (max-width: 640px) {
  .appbar { min-height: 64px; padding: 12px 16px; gap: 8px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-icon { width: 30px; height: 32px; border-radius: 9px; }
  .appbar-actions { gap: 0; }
  .appbar-actions .btn { padding: 8px; font-size: 12px; min-height: 40px; }
  .wrap { padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }
  .workspace-heading { flex-wrap: wrap; gap: 18px; margin-bottom: 20px; }
  h1 { font-size: 26px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .toolbar { padding: 12px; }
  .list-controls { gap: 8px; }
  .search-box { padding-inline: 8px; }
  .search-box input { font-size: 16px; }
  #sort-select { width: 102px; font-size: 12px; padding-inline: 4px; }
  .path-nav { gap: 4px; }
  .crumb { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
  .list-heading { display: none; }
  .list { min-height: 200px; border-top: 1px solid var(--line-soft); }
  .row { grid-template-columns: 34px minmax(0, 1fr) 80px; grid-template-rows: auto auto; row-gap: 0; padding: 12px; column-gap: 10px; min-height: 82px; }
  .row-icon { width: 34px; height: 40px; grid-column: 1; grid-row: 1 / 3; }
  .row-icon .icon { width: 20px; height: 20px; }
  .row-name { grid-column: 2; grid-row: 1; }
  .name-btn, .name-link { padding: 2px 0 4px; }
  .row-meta { display: flex; gap: 8px; grid-column: 2; grid-row: 2; overflow: hidden; white-space: nowrap; }
  .row-size, .row-time { font-size: 10px; text-align: left; }
  .row-actions { grid-column: 3; grid-row: 1 / 3; gap: 0; }
  .panel-footer { align-items: flex-start; padding: 14px 12px; gap: 10px; font-size: 11px; }
  .usage { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .usage-track { width: 64px; }
  .modal-box { padding: 22px; }
  .input { font-size: 16px; }
  .sheet-item { min-height: 54px; }
  .gate-card { padding: 32px 24px; }
}
@media (max-width: 360px) {
  .appbar { padding-inline: 12px; }
  .brand-icon { display: none; }
  .wrap { padding-inline: 10px; }
  .row-time { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 图片占据弹窗剩余空间；缩放与拖动限制在画布内。 */
.image-dialog { width:min(1120px,calc(100vw - 32px)); height:min(850px,calc(100dvh - 32px)); max-width:none; max-height:none; padding:18px; border:1px solid var(--line); border-radius:18px; background:var(--elev); color:var(--text); box-shadow:var(--shadow); }
.image-dialog[open] { display:flex; flex-direction:column; gap:12px; }
.image-dialog::backdrop { background:rgba(10,25,48,.6); }
.image-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; flex:none; }
.image-heading>div { min-width:0; }
.image-heading h2 { margin:0; font-size:16px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
#image-counter { color:var(--muted); font-size:12px; }
.image-toolbar { display:flex; flex-wrap:wrap; gap:6px; flex:none; }
.image-toolbar .btn { min-height:36px; padding:6px 10px; font-size:12px; }
.image-stage { position:relative; flex:1; min-height:0; overflow:hidden; border:1px solid #d0d8e2; border-radius:12px; background-color:#fff; background-image:repeating-conic-gradient(#eef2f7 0% 25%,#fff 0% 50%); background-size:20px 20px; touch-action:none; user-select:none; }
.image-stage[data-background="dark"] { background-color:#172437; background-image:repeating-conic-gradient(#26364b 0% 25%,#172437 0% 50%); border-color:#43546b; }
.image-stage[data-zoomed="true"] { cursor:grab; }
.image-stage[data-zoomed="true"]:active { cursor:grabbing; }
#image-content { position:absolute; left:50%; top:50%; max-width:none; max-height:none; object-fit:contain; transform-origin:center; }
#image-status { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); margin:0; width:90%; text-align:center; color:#465c78; font-size:14px; }
.image-stage[data-background="dark"] #image-status { color:#e0ebfa; }
.image-footer { display:flex; justify-content:space-between; gap:8px; font-size:11px; color:var(--muted); flex:none; }
@media (max-width:600px) {
  .image-dialog { width:calc(100vw - 16px); height:calc(100dvh - 16px); padding:12px; border-radius:14px; }
  .image-heading h2 { font-size:14px; }
  .image-toolbar .btn { min-height:40px; padding:7px 9px; }
  .image-footer { flex-wrap:wrap; }
}
@media (max-height:450px) {
  .image-dialog { padding:10px; gap:6px; }
  .image-toolbar .btn { min-height:30px; padding:3px 8px; }
  .image-heading .icon-btn { height:30px; min-height:30px; width:30px; }
  .image-footer { font-size:10px; }
}
