:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --card: #ffffff;
  --text: #16161a;
  --text-2: #4a4d55;
  --text-3: #8a8d96;
  --border: #e3e5ea;
  --hover: rgba(22, 22, 26, .06);
  --accent: #4d6bfe;
  --accent-text: #ffffff;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .1);
  --shadow: 0 8px 30px rgba(0, 0, 0, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --bg-soft: #1f1f24;
    --card: #222228;
    --text: #ececf1;
    --text-2: #b4b6be;
    --text-3: #7d808a;
    --border: #33343b;
    --hover: rgba(255, 255, 255, .07);
    --accent: #6b85ff;
    --danger: #ff6369;
    --danger-soft: rgba(255, 99, 105, .14);
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 960px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.message { color: var(--text-3); text-align: center; padding: 48px 8px; margin: 0; }
.message.error { color: var(--danger); }
.message button { margin-top: 12px; }

/* 顶部 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 600; }
.top .actions { display: flex; gap: 8px; align-items: center; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 16px; min-height: 32px; }
.summary { color: var(--text-3); font-size: 13px; }
.links { display: flex; flex-wrap: wrap; gap: 2px; margin-right: -8px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--card); font-size: 15px;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 20px; border: 0; background: transparent; color: var(--text-2);
  text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.link { border: 0; background: none; padding: 6px 8px; border-radius: 8px; font-size: 13px; color: var(--text-3); }
.link:hover { background: var(--hover); color: var(--text); }
.link.danger:hover { background: var(--danger-soft); color: var(--danger); }
svg { display: block; }

/* 加入 / 创建 */
.card { max-width: 420px; margin: 8vh auto 0; padding: 24px 20px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; }
.card h1 { margin: 0 0 16px; font-size: 22px; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { height: 34px; padding: 0 14px; border-radius: 17px; border: 0; background: transparent; color: var(--text-3); }
.tab.active { background: var(--hover); color: var(--text); font-weight: 500; }
.intro { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.input { display: flex; align-items: center; height: 46px; padding: 0 4px 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.input:focus-within { border-color: var(--accent); }
.input input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 16px; }
.input input::placeholder { color: var(--text-3); }
.form-error { margin: -4px 0 12px; color: var(--danger); font-size: 14px; }
.card .btn.primary { width: 100%; height: 46px; border-radius: 12px; margin-top: 4px; }

/* 图片网格 */
.section-title { margin: 20px 0 8px; font-size: 13px; color: var(--text-3); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
.thumb { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--bg-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 文件列表 */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 4px 8px 8px; border-radius: 12px; }
.row:hover { background: var(--hover); }
.badge {
  flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--bg-soft); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; letter-spacing: .02em; overflow: hidden;
}
.row .main { flex: 1; min-width: 0; border: 0; background: none; padding: 0; text-align: left; }
.name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 12px; color: var(--text-3); }
.meta.error { color: var(--danger); }
.progress { height: 3px; margin-top: 5px; border-radius: 2px; background: var(--border); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 大图查看 */
.viewer { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; color: #fff; }
.viewer-top, .viewer-bottom { display: flex; align-items: center; gap: 8px; padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
.viewer-top { padding-top: max(8px, env(safe-area-inset-top)); }
.viewer-bottom { justify-content: center; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; touch-action: pan-y pinch-zoom; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body audio { width: min(480px, 100%); }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer .icon-btn.danger:hover { background: rgba(255, 99, 105, .2); color: #ff8a8e; }
.viewer-hint { font-size: 12px; color: rgba(255, 255, 255, .55); text-align: center; padding-bottom: 4px; }

/* 拖拽、提示 */
.drop { position: fixed; inset: 12px; z-index: 5; border: 2px dashed var(--accent); border-radius: 18px; background: var(--bg); opacity: .94; display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 17px; pointer-events: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  .row .row-actions { opacity: 0; transition: opacity .15s; }
  .row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }
}
