:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e4e6eb;
  --text: #1f2329;
  --muted: #8a9099;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --danger: #e5484d;
  --ok: #12a150;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; }

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

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 17px; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.tagline { color: var(--muted); font-size: 12px; }

.wrap { max-width: 900px; margin: 0 auto; padding: 22px 16px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .count { color: var(--muted); font-weight: 400; font-size: 12px; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-ok    { background: #e9f8ef; border-color: #b7e7c9; color: #0f7a3d; }
.flash-error { background: #fdecec; border-color: #f5c2c3; color: #b3261e; }
.flash-info  { background: var(--accent-soft); border-color: #cfe0ff; color: #1c4bb8; }

input[type=text], input[type=password], input[type=number], input[type=file], select {
  font: inherit;
  color: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  max-width: 100%;
}
input[type=text]:focus, input[type=password]:focus, select:focus, input[type=number]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,111,237,.12);
}

button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  transition: .15s;
}
button:hover, .btn:hover { border-color: #c9ccd1; text-decoration: none; }
button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: #2a63d8; }
button.ghost-danger { color: var(--danger); border-color: #f0c7c8; }
button.ghost-danger:hover { background: #fdecec; }
button:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row + .row { margin-top: 10px; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 12px; }

.drop {
  border: 1.5px dashed #c7ccd4;
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  background: #fbfcfd;
  transition: .15s;
}
.drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-size: 14px; margin-bottom: 6px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: none; }
td.check { width: 34px; }
td.act { text-align: right; white-space: nowrap; width: 1%; }
td.act a + a { margin-left: 12px; }

.share-panel { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.share-panel h2 { margin-bottom: 10px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef0f3;
  color: #5c636e;
  margin: 0 4px 0 0;
}
.badge.ok { background: #e9f8ef; color: #0f7a3d; }
.badge.warn { background: #fff4e5; color: #a15c00; }
.badge.danger { background: #fdecec; color: #b3261e; }

.fname { display: flex; align-items: center; gap: 7px; }
.fname .name { word-break: break-all; }
.thumb {
  width: 30px; height: 30px; flex: none;
  object-fit: cover; border-radius: 5px; border: 1px solid var(--line);
  background: #f1f2f4;
}
.thumb-ph { display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); }

.sharebox { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-input {
  flex: 1; min-width: 220px;
  font-size: 12px; color: #4b5563;
  background: #f7f8fa;
}
.pwd-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fff4e5; color: #a15c00; border-color: #f0dcb8;
  padding: 1px 7px; border-radius: 6px; font-size: 12px;
}
.empty { color: var(--muted); padding: 14px 0; font-size: 13px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0 30px; }

/* 分享访问页 */
.gate { max-width: 380px; margin: 8vh auto; text-align: center; }
.gate .lock { font-size: 30px; margin-bottom: 8px; }
.gate input[type=password] { width: 100%; text-align: center; letter-spacing: 2px; }
.gate button { width: 100%; margin-top: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff; display: flex; flex-direction: column;
}
.tile .preview {
  height: 120px; background: #f1f2f4; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 26px; overflow: hidden;
}
.tile .preview img { width: 100%; height: 100%; object-fit: cover; }
.tile .meta { padding: 8px 10px; font-size: 12px; }
.tile .meta .name { word-break: break-all; margin-bottom: 2px; }
.tile .meta .sub { color: var(--muted); }
.tile .ops { display: flex; border-top: 1px solid var(--line); }
.tile .ops a { flex: 1; text-align: center; padding: 7px 0; font-size: 12px; }
.tile .ops a + a { border-left: 1px solid var(--line); }

/* ============================================================ 移动端适配 */
@media (max-width: 700px) {
  body { font-size: 15px; line-height: 1.65; }

  .topbar { padding: 10px 14px; }
  .brand { font-size: 16px; }
  .tagline { display: none; }
  .wrap { padding: 12px 10px 36px; }
  .card { padding: 14px; border-radius: 12px; margin-bottom: 14px; }
  .card h2 { font-size: 15px; }
  .foot { padding: 16px 0 24px; }

  /* 触控友好的控件尺寸，16px 可避免 iOS 自动放大 */
  input[type=text], input[type=password], input[type=number], input[type=file], select,
  button, .btn { font-size: 16px; }
  input[type=text], input[type=password], input[type=number], select { padding: 9px 12px; min-height: 42px; }
  button, .btn { padding: 10px 16px; min-height: 42px; }

  /* 表单行：标签与控件各占一行 */
  .row { gap: 10px; }
  .row > label {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .row > label > select,
  .row > label > input { flex: 1; min-width: 0; }
  .row > button.primary { width: 100%; }

  /* 上传区 */
  .drop { padding: 22px 12px; }
  .drop .big { font-size: 15px; }

  /* 表格 → 卡片 */
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
  }
  tr:last-child { margin-bottom: 0; }
  td { border: none; padding: 2px 0; }
  tr:last-child td { border-bottom: none; }

  /* 文件列表 */
  .files-table tr { padding-left: 42px; }
  .files-table td.check {
    position: absolute;
    left: 10px;
    top: 12px;
    width: auto;
    padding: 0;
  }
  .files-table input[type=checkbox] { width: 22px; height: 22px; margin: 0; }
  .files-table td.cell-size {
    display: inline-block;
    width: auto;
    padding: 0 10px 0 0;
    color: var(--muted);
    font-size: 12px;
  }
  .files-table td.cell-status { display: inline-block; width: auto; padding: 0; }
  .files-table td.cell-name { cursor: pointer; }
  .files-table tr.row-selected { border-color: var(--accent); background: #fbfcff; }

  /* 分享列表 */
  .shares-table td.cell-link { padding-bottom: 8px; }
  .shares-table td[data-label] {
    display: inline-block;
    width: auto;
    padding: 0 12px 0 0;
    font-size: 12px;
    color: var(--muted);
  }
  .shares-table td[data-label]::before { content: attr(data-label) " "; }

  /* 操作按钮改为可点区域 */
  td.cell-act {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    text-align: left;
    white-space: normal;
  }
  td.cell-act a {
    display: inline-block;
    padding: 7px 12px;
    margin: 0 8px 4px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
  }
  td.cell-act a + a { margin-left: 0; }
  td.cell-act a:active { background: var(--accent-soft); }

  /* 分享链接：输入框与复制按钮同一行且不溢出 */
  .sharebox { flex-wrap: nowrap; gap: 8px; }
  input.link-input { flex: 1; min-width: 0; font-size: 12px; padding: 8px 10px; }
  .sharebox button { flex: none; min-height: 36px; padding: 8px 12px; font-size: 14px; }

  /* 创建分享面板吸底 */
  .share-panel {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 14px -14px -14px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid var(--line);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 -6px 16px rgba(0, 0, 0, .07);
  }
  .share-panel .row > label { font-size: 13px; }
  #customExpire { width: 100%; display: flex; gap: 10px; }
  #customExpire input[type=number] { flex: 1; min-width: 0; }
  #customExpire select { flex: 1; min-width: 0; }

  /* 分享访问页 */
  .gate { margin: 5vh auto; padding: 20px 16px; }
  .gate .lock { font-size: 34px; }
  .gate input[type=password] { font-size: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  .tile .preview { height: 104px; }
  .tile .ops a { padding: 11px 0; font-size: 13px; }
  .tile .ops a:active { background: var(--accent-soft); }
}

