/* 青栀文件仓库 · Android 13 Material You（Monet）风格 */

:root {
  --primary: #2f8f83;
  --primary-strong: #1f6f66;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(16, 32, 28, .06), 0 2px 8px rgba(16, 32, 28, .05);
  --shadow-2: 0 8px 28px rgba(9, 22, 19, .14);
  --font: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
}

html[data-theme="light"] {
  --surface: #f5f9f8;
  --surface-1: #ffffff;
  --surface-2: #edf3f2;
  --surface-3: #e3ebe9;
  --on-surface: #182522;
  --on-variant: #566b66;
  --outline: #cfdad7;
  --primary-c: #e0f1ee;
  --primary-t: #0f4a44;
  --danger: #ba3a3a;
  --danger-c: #fbe6e3;
  --scrim: rgba(17, 30, 27, .34);
}

html[data-theme="dark"] {
  --surface: #0f1513;
  --surface-1: #161f1c;
  --surface-2: #1c2724;
  --surface-3: #243230;
  --on-surface: #e6efe9;
  --on-variant: #a9bcb5;
  --outline: #33423e;
  --primary: #6fd3c2;
  --primary-strong: #8ce0d1;
  --primary-c: #1c3a35;
  --primary-t: #a6ecdf;
  --danger: #f0a49e;
  --danger-c: #402828;
  --scrim: rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .1px; }
p { margin: 0; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.muted { color: var(--on-variant); font-size: 13px; }

/* ---------- 布局 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.appbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--outline);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: 4px; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary-c);
  color: var(--primary-t);
  display: grid;
  place-items: center;
}
html[data-theme="dark"] .brand-mark { color: var(--primary); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--on-variant); letter-spacing: .6px; text-transform: uppercase; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.appbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.admin-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--primary-c);
  color: var(--primary-t);
  letter-spacing: .3px;
}
html[data-theme="dark"] .admin-tag { color: var(--primary); }

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn.filled { background: var(--primary); color: #f4fdfa; }
.btn.filled:hover { background: var(--primary-strong); }
html[data-theme="dark"] .btn.filled { color: #06201c; }

.btn.tonal { background: var(--primary-c); color: var(--primary-t); }
.btn.tonal:hover { background: color-mix(in srgb, var(--primary-c) 78%, var(--primary) 22%); }
html[data-theme="dark"] .btn.tonal { color: var(--primary); }

.btn.outlined { border-color: var(--outline); color: var(--on-surface); background: var(--surface-1); }
.btn.outlined:hover { background: var(--surface-2); }

.btn.text { color: var(--on-variant); padding: 0 10px; }
.btn.text:hover { background: var(--surface-2); color: var(--on-surface); }

.btn.danger { background: var(--danger-c); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger-c) 80%, var(--danger) 20%); }

.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--on-variant);
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--on-surface); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 路径与搜索 ---------- */
.path-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--on-variant);
  min-width: 0;
}
.crumbs button {
  border: 0;
  background: transparent;
  color: var(--on-variant);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumbs button:hover { background: var(--surface-2); color: var(--on-surface); }
.crumbs button.current { color: var(--on-surface); font-weight: 600; }
.crumbs .sep { color: var(--outline); }

.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--on-variant);
  min-width: 200px;
}
.search:focus-within { border-color: var(--primary); }
.search input {
  border: 0;
  background: transparent;
  outline: 0;
  width: 100%;
  font-size: 13.5px;
  color: var(--on-surface);
}
.search input::placeholder { color: var(--on-variant); }

/* ---------- 多选条 ---------- */
.sel-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-c);
  color: var(--primary-t);
}
html[data-theme="dark"] .sel-bar { color: var(--primary); }
.sel-info { font-size: 13px; }
.sel-actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- 文件列表 ---------- */
.list-panel {
  background: var(--surface-1);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.list-head,
.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 148px 104px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.list-head .col-act { text-align: right; }

.list-head {
  height: 34px;
  font-size: 11.5px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--on-variant);
  background: var(--surface-2);
  border-bottom: 1px solid var(--outline);
}

.file-list { display: flex; flex-direction: column; padding: 6px; gap: 2px; }

.file-row {
  height: 50px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background .14s ease;
}
.file-row:hover { background: var(--surface-2); }
.file-row.is-selected { background: color-mix(in srgb, var(--primary-c) 70%, var(--surface-1) 30%); }

.file-row .name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-row .name .ico {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--on-variant);
  flex: 0 0 auto;
}
.file-row .name .ico svg { width: 17px; height: 17px; }
.file-row .name .ico.folder { background: var(--primary-c); color: var(--primary-t); }
html[data-theme="dark"] .file-row .name .ico.folder { color: var(--primary); }
.file-row .name .txt { min-width: 0; display: flex; flex-direction: column; }
.file-row .name .txt b {
  font-weight: 550;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row .name .txt small { color: var(--on-variant); font-size: 11.5px; }
.file-row.is-folder .name .txt b { cursor: pointer; }
.file-row.is-folder:hover .name .txt b { text-decoration: underline; text-underline-offset: 2px; }

.file-row .col-size,
.file-row .col-time { color: var(--on-variant); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.row-act { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.row-act .icon-btn { width: 30px; height: 30px; }
.row-act .icon-btn svg { width: 16px; height: 16px; }

.check {
  width: 20px;
  height: 20px;
  border: 1.6px solid var(--outline);
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--surface-1);
  color: transparent;
  padding: 0;
  cursor: pointer;
}
.check svg { width: 13px; height: 13px; stroke-width: 2.4; }
.file-row.is-selected .check { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .file-row.is-selected .check { color: #06201c; }

/* ---------- 空态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 54px 20px;
  text-align: center;
}
.empty-art {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--on-variant);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.empty-art svg { width: 24px; height: 24px; }
.empty h3 { font-size: 14px; }
.empty p { color: var(--on-variant); font-size: 12.5px; }

/* ---------- 底部统计 ---------- */
.storage-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--on-variant);
  font-size: 12.5px;
}
.storage-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.storage-info strong { color: var(--on-surface); font-size: 13px; font-variant-numeric: tabular-nums; }
.storage-note { font-size: 11.5px; }

/* ---------- 弹窗 ---------- */
dialog.sheet {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--on-surface);
  box-shadow: var(--shadow-2);
}
dialog.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.sheet-inner { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { font-size: 15.5px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

.field {
  position: relative;
  display: block;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .16s ease;
}
.field:focus-within { border-color: var(--primary); }
.field input {
  width: 100%;
  height: 46px;
  padding: 17px 12px 5px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  outline: 0;
  font-size: 14px;
}
.field span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13.5px;
  color: var(--on-variant);
  transition: all .14s ease;
  pointer-events: none;
}
.field input:focus + span,
.field input:not(:placeholder-shown) + span {
  top: 8px;
  transform: none;
  font-size: 10.5px;
  letter-spacing: .3px;
  color: var(--primary);
}

.form-msg { min-height: 16px; font-size: 12.5px; color: var(--danger); }
.form-msg.ok { color: var(--primary); }

.cap-question {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.geetest-holder { min-height: 44px; }

/* 极验 v4 弹层兜底：确保盖住页面自身元素（<dialog> 在 top layer 时只能靠不打开弹窗解决） */
.geetest_box,
.geetest_panel,
.geetest_popup,
.geetest_wind,
.geetest_mask,
.geetest_fullpage_click { z-index: 2147483000 !important; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--on-surface);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  animation: toast-in .18s ease;
}
.toast.ok { background: var(--primary); color: #f4fdfa; }
html[data-theme="dark"] .toast.ok { color: #06201c; }
.toast.err { background: var(--danger); color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 上传进度 ---------- */
.upload-banner {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 55;
  width: 268px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ub-text { font-size: 12.5px; color: var(--on-surface); }
.ub-bar {
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--on-surface) 12%, transparent);
  overflow: hidden;
}
.ub-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 2px;
  transition: width .18s ease;
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .appbar { padding: 10px 14px; gap: 10px; }
  .brand-text span { display: none; }
  .toolbar { order: 3; width: 100%; }
  .toolbar .btn { flex: 1; }
  .content { padding: 12px 14px 24px; }
  .search { min-width: 0; width: 100%; margin-left: 0; }
  .list-head { display: none; }
  .file-row {
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    padding: 10px;
    row-gap: 2px;
  }
  .file-row .col-size,
  .file-row .col-time { display: none; }
  .file-row .name .txt small { display: block; }
  .row-act { grid-column: 2; grid-row: 1; }
  .toast-stack { right: 12px; bottom: 78px; left: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .upload-banner { right: 12px; bottom: 12px; left: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}