/* 囍贴 —— 样式（囍红暖色主题，含 dataviz 状态色） */
:root {
  color-scheme: light dark;

  /* 表面 / 墨色（暖调） */
  --surface-1: #ffffff;
  --page: #faf6f4;
  --text-primary: #2a2320;
  --text-secondary: #6f655e;
  --text-muted: #a2988d;
  --gridline: #f0e9e5;
  --baseline: #e3d9d2;
  --border: rgba(74, 45, 38, 0.10);

  /* 状态色（固定，不随主题变化） */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  /* 囍红强调色 */
  --accent: #d64541;
  --accent-ink: #b2352f;
  --accent-soft: rgba(214, 69, 65, 0.10);
  --danger: #d03b3b;

  --shadow: 0 1px 2px rgba(74, 45, 38, 0.05), 0 4px 14px rgba(74, 45, 38, 0.06);
  --shadow-lg: 0 6px 18px rgba(74, 45, 38, 0.10), 0 2px 6px rgba(74, 45, 38, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #241e1c;
    --page: #171313;
    --text-primary: #f4eeea;
    --text-secondary: #c7bcb4;
    --text-muted: #8d8178;
    --gridline: #322a27;
    --baseline: #40342f;
    --border: rgba(255, 232, 224, 0.12);
    --accent: #e0635f;
    --accent-ink: #ef8b87;
    --accent-soft: rgba(224, 99, 95, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 22px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a, button, input, select, textarea, .card, .file-chip { touch-action: manipulation; }

.muted { color: var(--text-muted); font-size: 13px; }

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 300px at 20% -5%, var(--accent-soft), transparent 60%),
    radial-gradient(500px 260px at 85% 0%, var(--accent-soft), transparent 55%),
    var(--page);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-mark {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-ink));
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(214, 69, 65, 0.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 1px; }
.login-sub { margin: 0 0 24px; color: var(--text-secondary); font-size: 14px; }
.login-card .field { text-align: left; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.field input, .field textarea, .select {
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 18px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-1);
  color: var(--text-primary);
  transition: filter .15s ease, background .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(150deg, var(--accent), var(--accent-ink));
  color: #fff;
  box-shadow: 0 3px 10px rgba(214, 69, 65, 0.30);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn.ghost:hover { background: var(--gridline); color: var(--text-primary); }
.btn.danger-ghost {
  background: transparent;
  border-color: rgba(208, 59, 59, 0.4);
  color: var(--danger);
}
.btn.danger-ghost:hover { background: rgba(208, 59, 59, 0.08); }
.btn.full { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--gridline); color: var(--text-primary); }
.error-text { color: var(--danger); font-size: 13px; margin: 14px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 18px; letter-spacing: 1px;
}
.brand-mark {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-ink));
  border-radius: 9px;
  box-shadow: 0 3px 8px rgba(214, 69, 65, 0.3);
}
.search { flex: 1; max-width: 440px; }
.search input {
  width: 100%;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.me-name { font-size: 13px; color: var(--text-muted); margin-right: 2px; }

/* ---------- 主体容器 ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 22px 24px 70px; }

/* ---------- 存储仪表盘 ---------- */
.storage-dash {
  display: flex; align-items: center; gap: 34px;
  padding: 26px 30px;
  margin-bottom: 22px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.gauge-wrap { flex-shrink: 0; }
.drop { width: 148px; height: 178px; display: block; }
.drop-outline { fill: none; stroke: var(--baseline); stroke-width: 2; }
#drop-liquid, #drop-wave { transition: y .6s ease, height .6s ease, cy .6s ease, fill .3s ease; }
.drop-shine { fill: rgba(255, 255, 255, 0.4); }

.gauge-meta { flex: 1; min-width: 0; }
.gauge-title { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.hero { display: flex; align-items: baseline; gap: 6px; }
.hero-value {
  font-size: 48px; font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.hero-unit { font-size: 16px; color: var(--text-secondary); }
.hero-label { font-size: 14px; color: var(--text-muted); margin-left: 4px; }

.gauge-status { display: flex; align-items: center; gap: 7px; margin: 10px 0 14px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
#status-text { font-size: 14px; color: var(--text-secondary); }

.gauge-lines { display: flex; gap: 30px; margin-bottom: 14px; flex-wrap: wrap; }
.gauge-line { display: flex; flex-direction: column; }
.gauge-line span { font-size: 12px; color: var(--text-muted); }
.gauge-line b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.meter { height: 10px; background: var(--gridline); border-radius: 999px; overflow: hidden; }
.meter-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: var(--text-muted);
  transition: width .6s ease, background .3s ease;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar .select { width: auto; min-width: 150px; }
.toolbar-spacer { flex: 1; }

/* ---------- 卡片列表 ---------- */
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  animation: rise .3s ease both;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.card-body { padding: 15px 17px 10px; }
.card-title {
  margin: 0 0 6px; font-size: 15.5px; font-weight: 650;
  overflow-wrap: anywhere;
}
.card-content {
  margin: 0; font-size: 13.5px; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.inl-link { color: var(--accent-ink); text-decoration: none; overflow-wrap: anywhere; }
.inl-link:hover { text-decoration: underline; }

.card-foot {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 9px 17px 13px; margin-top: auto;
}
.badge {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  background: var(--gridline); color: var(--text-secondary);
}
.cat { font-size: 12px; color: var(--accent-ink); }
.time { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* 卡片附件缩略条 */
.att-strip {
  display: flex; gap: 6px;
  padding: 12px 14px 0;
}
.att-thumb {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--gridline);
}
.att-more {
  width: 64px; height: 64px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-muted);
  background: var(--gridline);
  border-radius: 10px;
}

.empty { text-align: center; color: var(--text-muted); padding: 60px 0; font-size: 14px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 18, 15, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 24px;
  animation: fade .18s ease both;
}
.modal-card {
  width: 100%; max-width: 500px;
  max-height: 86vh; overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease both;
}
.modal-card h3 { margin: 0 0 18px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.upload-status { text-align: center; color: var(--text-secondary); font-size: 14px; margin: 12px 0 0; }

/* ---------- 查看浮窗 ---------- */
.view-card { max-width: 640px; }
.view-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
}
.view-head h3 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.view-meta {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--gridline);
}
.view-content {
  font-size: 15px; color: var(--text-primary);
  white-space: pre-wrap; overflow-wrap: anywhere;
  margin-bottom: 6px;
}
.view-atts {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 12px;
}
.v-img {
  max-width: 150px; max-height: 150px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform .15s ease, box-shadow .15s ease;
}
.v-img:hover { transform: scale(1.03); box-shadow: var(--shadow-lg); }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--page);
  text-decoration: none; color: var(--text-primary);
  transition: border-color .15s ease, background .15s ease;
}
.file-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip-ic { font-size: 17px; }
.chip-name { font-size: 13.5px; overflow-wrap: anywhere; }
.chip-size { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------- 编辑弹窗附件 ---------- */
.m-atts {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px; min-height: 8px;
}
.att-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
  background: var(--gridline);
  border-radius: 999px;
  color: var(--text-secondary);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.att-item.staged { background: var(--accent-soft); color: var(--accent-ink); }
.att-x {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, 0.12); color: var(--text-secondary);
  cursor: pointer; flex-shrink: 0;
}
.att-x:hover { background: var(--danger); color: #fff; }

/* ---------- 图片预览 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.86);
  padding: 32px;
  animation: fade .15s ease both;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  width: 42px; height: 42px; font-size: 18px;
  background: rgba(255, 255, 255, 0.12); color: #fff;
  border: none; border-radius: 50%; cursor: pointer;
  transition: background .15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

/* ---------- 用户管理 ---------- */
.users-card { max-width: 560px; }
.user-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--page);
  flex-wrap: wrap;
}
.user-main { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.user-main b { font-size: 14.5px; }
.user-ops { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.u-quota-edit {
  width: 66px; padding: 5px 8px;
  font-size: 13px; font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px; outline: none;
}
.u-sub { margin: 18px 0 10px; font-size: 14px; color: var(--text-secondary); }
.u-form { display: flex; gap: 8px; flex-wrap: wrap; }
.u-form input {
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
}
.u-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#u-name { flex: 1; min-width: 110px; }
#u-pass { flex: 1; min-width: 110px; }
#u-quota { width: 80px; }

.mini {
  font-size: 12px; font-family: inherit;
  padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
  transition: background .15s ease;
}
.mini:hover { background: var(--gridline); }
.mini.danger { color: var(--danger); border-color: rgba(208, 59, 59, 0.35); }
.mini.danger:hover { background: rgba(208, 59, 59, 0.08); }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand { font-size: 17px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-actions { gap: 6px; }
  .me-name { display: none; }

  .container { padding: 14px 14px 96px; }

  .storage-dash { flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; }
  .gauge-wrap { display: flex; justify-content: center; }
  .drop { width: 122px; height: 146px; }
  .hero-value { font-size: 40px; }
  .gauge-lines { gap: 20px; }

  .toolbar { gap: 10px; }
  .toolbar .select { flex: 1; min-width: 0; }
  .toolbar-spacer { display: none; }

  .items { grid-template-columns: 1fr; gap: 14px; }
  .att-thumb, .att-more { width: 72px; height: 72px; }

  /* 触控目标放大 */
  .btn { padding: 11px 18px; font-size: 15px; }
  .icon-btn { width: 42px; height: 42px; font-size: 18px; }
  .mini { padding: 8px 12px; font-size: 13px; }
  .att-x { width: 22px; height: 22px; }

  /* iOS 输入框字号 ≥16px，避免聚焦时自动放大整页 */
  .field input, .field textarea, .select,
  .search input, .u-form input, .u-quota-edit { font-size: 16px; }

  /* 弹窗改成底部抽屉，操作按钮常驻底部 */
  .modal { padding: 10px; align-items: flex-end; }
  .modal-card {
    max-width: none;
    max-height: 92vh;
    max-height: calc(100dvh - 20px);
    border-radius: 18px 18px 12px 12px;
    padding: 20px 16px;
  }
  .modal-actions {
    position: sticky; bottom: 0; z-index: 1;
    background: var(--surface-1); padding-top: 12px; margin-top: 4px;
  }

  .view-card { max-width: none; }
  .v-img { max-width: 100%; max-height: 260px; }
  .file-chip { width: 100%; }

  .users-card { max-width: none; }
  .user-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .user-ops { justify-content: flex-end; }
  .u-form { flex-direction: column; }
  #u-name, #u-pass { min-width: 0; }
  #u-quota { width: 100%; }

  .lightbox { padding: 16px; }
  .lightbox-close { top: 12px; right: 14px; }
}

@media (max-width: 380px) {
  .login-card { padding: 28px 20px 24px; }
  .gauge-lines { gap: 14px; }
}
