/* ==============================================================
   轻量网盘 · Fixed Sidebar 设计系统
   令牌：zinc 中性色 + blue 强调色，只有亮色一套（与风格规范一致）
   交互统一 duration 150ms，无弹跳 / 无旋转 / 无渐变
   ============================================================== */

:root {
  --bg:            #fafafa;  /* zinc-50   页面底色 */
  --surface:       #ffffff;  /* white     侧边栏 / 卡片 */
  --surface-2:     #f4f4f5;  /* zinc-100  输入框 / 次级按钮底色 */
  --border:        #e4e4e7;  /* zinc-200  边框 */
  --border-strong: #d4d4d8;  /* zinc-300 */
  --text:          #18181b;  /* zinc-900  标题 / 强文本 */
  --text-2:        #3f3f46;  /* zinc-700  次级按钮文本 */
  --text-3:        #52525b;  /* zinc-600  次要文本 */
  --text-muted:    #71717a;  /* zinc-500  弱化文本（下限色，满足 AA） */
  --accent:        #3b82f6;  /* blue-500  主按钮 / 激活锚点线 */
  --accent-strong: #2563eb;  /* blue-600  文字级强调（AA 达标） */
  --accent-soft:   #eff6ff;  /* blue-50   激活底色 */
  --danger:        #dc2626;  /* red-600 */
  --danger-deep:   #b91c1c;  /* red-700   小号红字（AA 达标） */
  --danger-soft:   #fef2f2;  /* red-50 */
  --ok:            #047857;  /* emerald-700 */
  --ok-bar:        #10b981;  /* emerald-500 进度条 */
  --ok-soft:       #ecfdf5;  /* emerald-50 */
  --warn:          #b45309;  /* amber-700 */
  --warn-soft:     #fffbeb;  /* amber-50 */

  --radius:    8px;   /* rounded-lg  按钮 / 输入框 */
  --radius-xl: 12px;  /* rounded-xl  卡片 */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 6px -1px rgba(16, 24, 40, .07), 0 2px 4px -2px rgba(16, 24, 40, .05);

  --sidebar-w: 256px;   /* w-64，规范上限 280px */
  --rail-w:    64px;    /* 桌面收起后的图标栏 */
}

* { box-sizing: border-box; }

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

/* 手机横屏时 Safari 会自动放大正文，别让它动 */
html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }

button:focus-visible, .btn:focus-visible, a:focus-visible, .node:focus-visible,
.tile:focus-visible, table.files tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ 通用按钮 */

button, .btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);           /* 次级按钮：bg-zinc-100 text-zinc-700 */
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* 触屏上关掉双击缩放，点击不再等 300ms */
  touch-action: manipulation;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
button:hover:not(:disabled), .btn:hover { background: var(--border); color: var(--text); }
button:active:not(:disabled), .btn:active { transform: scale(.95); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary, .btn.primary { background: var(--accent); color: #fff; }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--accent-strong); }

button.ghost, .btn.ghost { background: transparent; color: var(--text-3); }
button.ghost:hover:not(:disabled), .btn.ghost:hover { background: var(--surface-2); color: var(--text); }

button.danger, .btn.danger { background: transparent; color: var(--danger); }
button.danger:hover:not(:disabled), .btn.danger:hover { background: var(--danger-soft); color: var(--danger-deep); }

button.tiny, .btn.tiny { padding: 2px 8px; font-size: 12px; }

.btn-block { display: flex; width: 100%; }

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  flex: none;
  font-size: 15px;
  background: transparent;
  color: var(--text-3);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------ 表单 */

input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  transition: box-shadow .15s, background-color .15s;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .35);   /* ring-2 blue-500/35 */
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--text-3); margin-bottom: 4px; }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
}
.badge.ok   { color: var(--ok);      background: var(--ok-soft);      border-color: #a7f3d0; }
.badge.warn { color: var(--warn);    background: var(--warn-soft);    border-color: #fde68a; }
.badge.err  { color: var(--danger-deep); background: var(--danger-soft); border-color: #fecaca; }

.alert {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert.error { background: var(--danger-soft); color: var(--danger-deep); border-color: #fecaca; }
.alert.info  { background: var(--accent-soft); color: var(--accent-strong); border-color: #bfdbfe; }
.alert:empty { display: none; }

/* ------------------------------------------------------------ 固定侧边栏 */
/* 移动端（<1024px）为离屏抽屉；桌面端常驻，可收起为 64px 图标栏 */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform .15s ease, width .15s ease;
}
body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(24, 24, 27, .4);
  display: none;
}
@media (max-width: 1023px) {
  body.sidebar-open .sidebar-overlay { display: block; }
  .btn-collapse, .btn-expand { display: none !important; }
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 10px 16px;
}
.brand-logo { font-size: 20px; line-height: 1; flex: none; }
.brand-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-collapse, .btn-expand { display: none; }

.sidebar-search { padding: 2px 12px 10px; }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 8px 12px;
}

.nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.nav-add {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.nav-item {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  padding: 7px 8px;
  border-radius: var(--radius);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item .ico { flex: none; transition: transform .15s; }
.nav-item:hover .ico { transform: translateX(2px); }   /* 图标轻微右移，引导视线进主区 */
.nav-item .txt { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ 目录树 */

.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }

.node {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-3);
  position: relative;
}
.node:hover { background: var(--surface-2); color: var(--text); }

/* 激活锚点：稳定的左侧强调线 + 浅蓝底，不用浮动动画 */
.node.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 500; }
.node.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
}
.node.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.node .twist {
  width: 16px; height: 16px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 10px;
  transition: transform .15s;
}
.node .twist.leaf { visibility: hidden; }
.node .node-icon { flex: none; font-size: 14px; transition: transform .15s; }
.node:hover .node-icon { transform: translateX(2px); }
.node .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .count { font-size: 11px; color: var(--text-muted); }
.node.active .count { color: var(--accent-strong); }
.node .acts { display: none; gap: 2px; }
.node:hover .acts, .node:focus-within .acts { display: flex; }
@media (hover: none) {
  /* 触屏没有 hover，操作按钮常显（收起态由更高优先级规则隐藏） */
  .node .acts { display: flex; }
}
.node .acts button { padding: 0 4px; font-size: 11px; line-height: 18px; }

/* ------------------------------------------------------------ 侧边栏用户区 */

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-stats { font-size: 12px; color: var(--text-muted); }
.user-actions { display: flex; gap: 6px; }

/* 桌面端：侧边栏常驻，可收起为图标栏 */

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: none; }
  .main-wrap { margin-left: var(--sidebar-w); }
  .hamburger { display: none; }
  .btn-collapse { display: inline-flex; }

  body.sidebar-collapsed .sidebar { width: var(--rail-w); }
  body.sidebar-collapsed .main-wrap { margin-left: var(--rail-w); }
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .sidebar-search,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .node .label,
  body.sidebar-collapsed .node .count,
  body.sidebar-collapsed .node .acts,
  body.sidebar-collapsed .node .twist,
  body.sidebar-collapsed .nav-item .txt,
  body.sidebar-collapsed .user-meta,
  body.sidebar-collapsed .user-actions { display: none; }
  body.sidebar-collapsed .brand-row,
  body.sidebar-collapsed .user-row { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .tree ul { padding-left: 0; }
  body.sidebar-collapsed .node,
  body.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .node .node-icon { font-size: 16px; }
  body.sidebar-collapsed .btn-collapse { display: none; }
  body.sidebar-collapsed .btn-expand { display: inline-flex; }
}

/* ------------------------------------------------------------ 主内容区 */

.main-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .15s ease;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hamburger { display: inline-flex; }

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.crumbs > span { flex: none; }
.crumbs a, .crumbs b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumbs a { color: var(--text); }
.crumbs a:hover { color: var(--accent-strong); text-decoration: none; }

.main { flex: 1; min-width: 0; padding: 16px 16px 120px; }
@media (min-width: 768px)  { .main { padding: 24px 24px 120px; } }
@media (min-width: 1024px) { .main { padding: 24px 32px 120px; } }

/* ------------------------------------------------------------ 卡片与表格 */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table.files { width: 100%; border-collapse: collapse; }
table.files th, table.files td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.files th {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg);
  white-space: nowrap;
}
table.files tbody tr:last-child td { border-bottom: none; }
table.files tbody tr:hover { background: var(--bg); }
table.files tbody tr.dragging { opacity: .4; }
table.files .fname { display: flex; align-items: center; gap: 8px; min-width: 0; }
table.files .fname .ico { flex: 0 0 auto; font-size: 15px; }
table.files .fname .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.files .note-hint { color: var(--text-muted); font-size: 12px; }
table.files .ops { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

.empty { padding: 56px 20px; text-align: center; color: var(--text-muted); }
.empty .big { font-size: 28px; margin-bottom: 8px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--border); }
table.plain th { color: var(--text-muted); font-weight: 500; font-size: 12px; background: var(--bg); }

/* ------------------------------------------------------------ 布局切换 */

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  flex: none;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.seg .icon-btn { width: 28px; height: 28px; font-size: 13px; border-radius: 6px; }
.seg .icon-btn.on {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------ 网格视图 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; padding: 10px; }
}

.tile {
  position: relative;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background-color .15s, border-color .15s;
}
.tile:hover { background: var(--bg); border-color: var(--border-strong); }
.tile.entry-selected { background: var(--accent-soft); border-color: var(--accent); }
.tile.dragging { opacity: .4; }

.tile .thumb {
  height: 92px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-2);
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .big-ico { font-size: 34px; line-height: 1; }
.tile .tile-name {
  font-size: 13px;
  line-height: 1.4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile .tile-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .tile-more {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-more, .tile:focus-within .tile-more { opacity: 1; }
@media (hover: none) { .tile .tile-more { opacity: 1; } }

/* 列表行的选中态；要排在 tr:hover 之后才能盖住它 */
table.files tbody tr { user-select: none; }
table.files tbody tr.entry-selected { background: var(--accent-soft); }
table.files tbody tr.entry-selected td { border-bottom-color: #bfdbfe; }

/* 网格卡片的「更多」菜单 */
.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-list .action { justify-content: flex-start; padding: 9px 12px; background: var(--surface-2); }
.action-list .action.danger { background: var(--danger-soft); color: var(--danger-deep); }
.action-list .action.danger:hover { background: #fee2e2; }

/* ------------------------------------------------------------ 上传面板 */

.dock {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  z-index: 45;
  overflow: hidden;
}
.dock-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px; font-weight: 600;
}
.dock-body { max-height: 300px; overflow: auto; }
.up-item { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.up-item:last-child { border-bottom: none; }
.up-item .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin: 6px 0 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.up-item.done .bar > i { background: var(--ok-bar); }
.up-item.error .bar > i { background: var(--danger); }
.up-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }

.dropzone-hint {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(59, 130, 246, .08);
  border: 3px dashed var(--accent);
  display: none; align-items: center; justify-content: center;
  font-size: 18px; color: var(--accent-strong); font-weight: 500;
  pointer-events: none;
}
body.dragging-file .dropzone-hint { display: flex; }

/* ------------------------------------------------------------ 弹窗 */

.modal-back {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(24, 24, 27, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal.wide { max-width: 720px; }
.modal.preview-modal { max-width: 900px; }
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
}
.modal-body { padding: 18px; overflow: auto; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg);
}

.share-result {
  margin-top: 14px; padding: 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
}
.copyline { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.copyline .val {
  flex: 1; min-width: 0;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-big {
  font-size: 22px; font-weight: 700; letter-spacing: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.share-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.share-row:last-child { border-bottom: none; }
.share-row .u { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ 登录页 */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 28px 24px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 22px; color: var(--text-muted); font-size: 13px; }
.login-card .btn-block { padding: 10px; font-size: 14px; margin-top: 4px; }

/* ------------------------------------------------------------ 分享页（外链落地页） */
/* 访客几乎都在手机上打开（多数来自微信），所以这一块按手机来写，桌面只是「大一号」。
   服务端按 UA 在 <html> 上打 is-mobile / is-desktop（见 src/util.js）：手机横屏能有
   800px 宽，光靠宽度断点会把它当桌面，按设备排版才稳。 */

.share-page {
  min-height: 100vh;
  min-height: 100svh;                          /* 手机地址栏收起/展开时高度不跳 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  /* 刘海 / 圆角 / 底部小横条：内容不落进安全区（不支持 env() 的浏览器用上一行 12px） */
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom))
           max(12px, env(safe-area-inset-left));
}
/* 宽屏（含手机横屏）留白大一点，但安全区照样要留——横屏时刘海正好在左右两侧 */
@media (min-width: 700px) {
  .share-page {
    padding: 24px;
    padding: max(24px, env(safe-area-inset-top))
             max(24px, env(safe-area-inset-right))
             max(24px, env(safe-area-inset-bottom))
             max(24px, env(safe-area-inset-left));
  }
}

.share-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  /* 文件名可能是一长串没有空格的英文，窄屏上不许撑破卡片 */
  overflow-wrap: anywhere;
}
.share-card .file-ico { font-size: 32px; line-height: 1; margin-bottom: 12px; }
.share-card h1 { font-size: 17px; margin: 0 0 6px; word-break: break-all; line-height: 1.45; }
.share-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.share-note {
  margin: 0 0 18px; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow: auto;
}
.share-card .actions { display: flex; flex-direction: column; gap: 10px; }
.share-card .actions .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  /* 44px 是手指能稳定点中的下限，别用桌面的按钮高度 */
  min-height: 46px;
  padding: 11px;
  border-radius: var(--radius);
  font-size: 15px;
}
.share-card .field input[type=text] {
  text-align: center;
  letter-spacing: 6px;
  font-size: 20px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  text-transform: uppercase;
}
.preview-box { margin-top: 16px; text-align: center; }
.preview-box img, .preview-box video {
  max-width: 100%; max-height: 68vh; margin: 0 auto;
  border-radius: var(--radius); display: block;
}
.preview-box audio { width: 100%; }
.preview-box iframe { width: 100%; height: 68vh; border: 1px solid var(--border); border-radius: var(--radius); }
.preview-box pre {
  max-height: 65vh; overflow: auto; padding: 12px; margin: 0; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
}
.preview-box .preview-text { min-height: 84px; }
/* 弹窗正文自带内边距，预览块不用再顶一段空白 */
.modal-body .preview-box { margin-top: 0; }
.preview-meta { margin-top: 12px; text-align: center; }
.center-note { text-align: center; color: var(--text-muted); }

/* 手机：卡片铺满屏宽、预览别把整屏占死（留出返回/滚动的手势空间） */

html.is-mobile .share-card {
  max-width: 560px;
  padding: 20px 16px;
  border-radius: 14px;
}
html.is-mobile .share-card h1 { font-size: 18px; }
html.is-mobile .share-card .file-ico { font-size: 34px; margin-bottom: 10px; }
html.is-mobile .share-card .actions { gap: 12px; }
html.is-mobile .preview-box img,
html.is-mobile .preview-box video { max-height: 58svh; }
html.is-mobile .preview-box iframe { height: 62svh; }
html.is-mobile .preview-box pre { max-height: 48svh; font-size: 13px; }
html.is-mobile .share-note { max-height: 200px; }

/* 复制失败时的兜底：把地址摊成可长按选中的只读输入框。
   微信内置浏览器 + HTTP 下 navigator.clipboard 不可用，execCommand 也常被拦，
   「长按 → 复制」是手机上唯一稳的路径，所以得真给出能选中的文本。 */
.copy-fallback { margin-top: 12px; }
.copy-fallback input {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
}

/* ------------------------------------------------------------ 响应式微调 */

@media (max-width: 820px) {
  table.files th:nth-child(3), table.files td:nth-child(3),
  table.files th:nth-child(4), table.files td:nth-child(4) { display: none; }
  .dock {
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    /* 别压到全面屏底部的小横条上 */
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
  }
  .main { padding-bottom: 140px; }
}

/* ------------------------------------------------------------ 触屏与移动端 */

/* iOS 上输入框字号小于 16px 时，一聚焦就自动把整页放大；窄屏统一提到 16px */
@media (max-width: 820px) {
  input[type=text], input[type=password], input[type=search], select, textarea { font-size: 16px; }
  /* 横屏带刘海的机器：顶栏与正文不钻到圆角/刘海底下 */
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .main {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* 手指没有鼠标准，触屏上把可点目标放大一号（默认那些是给鼠标设计的尺寸） */
@media (pointer: coarse) {
  .node .acts { gap: 4px; }
  .node .acts button { padding: 3px 8px; font-size: 12px; line-height: 22px; }
  .nav-add { width: 28px; height: 28px; }
  .icon-btn { width: 36px; height: 36px; }
  .seg .icon-btn { width: 34px; height: 34px; }
  table.files .ops { gap: 6px; }
  table.files .ops button { min-height: 34px; padding: 6px 10px; }
  .tile .tile-more { padding: 4px 10px; }
}

/* ------------------------------------------------------------ 动效降级 */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
  .node:hover .node-icon,
  .nav-item:hover .ico { transform: none; }
  button:active:not(:disabled), .btn:active { transform: none; }
}
