:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --text-2: #8e8e93;
  --accent: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --sep: rgba(60, 60, 67, 0.1);
  --nav-bg: rgba(242, 242, 247, 0.82);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --text-2: #8e8e93;
    --accent: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --sep: rgba(84, 84, 88, 0.4);
    --nav-bg: rgba(0, 0, 0, 0.78);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* ---- 导航栏 ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding-top: env(safe-area-inset-top);
  border-bottom: 0.5px solid var(--sep);
}
.nav-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 16px 8px;
  max-width: 640px;
  margin: 0 auto;
}
.nav h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.nav-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 17px;
  font-family: inherit;
  padding: 6px 0;
  cursor: pointer;
}
.nav-btn:active { opacity: 0.4; }
.nav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}
.nav-icon {
  display: flex;
  align-items: center;
}
.nav-icon svg { display: block; }
.nav-icon.loading svg { animation: spin 0.8s linear infinite; }

/* ---- 下拉刷新 ---- */
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.25s ease;
}
.ptr.pulling { transition: none; }
.ptr.refreshing { height: 52px; }
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--sep);
  border-top-color: var(--text-2);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
}
.ptr.pulling .spinner, .ptr.refreshing .spinner { opacity: 1; transform: scale(1); }
.ptr.refreshing .spinner { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 列表 ---- */
.list {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px calc(40px + env(safe-area-inset-bottom));
}

.row {
  position: relative;
  margin-bottom: 12px;
  border-radius: 14px;
  overflow: hidden;
  transition: height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}
.row.removing { opacity: 0; height: 0 !important; margin-bottom: 0; }
.row.entering { animation: enter 0.35s ease; }
@keyframes enter {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.row-del {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 88px;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

.card {
  position: relative;
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  transition: transform 0.25s ease;
  touch-action: pan-y;
}
.card:active { filter: brightness(0.97); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.card-sender {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-time {
  font-size: 13px;
  color: var(--text-2);
  flex-shrink: 0;
}

/* 桌面端（有鼠标悬停能力）显示删除按钮，触屏用左滑 */
.card-x { display: none; }
@media (hover: hover) and (pointer: fine) {
  .card-x {
    display: block;
    border: none;
    background: none;
    color: var(--text-2);
    font-size: 16px;
    line-height: 1;
    padding: 2px 0 2px 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
  }
  .card:hover .card-x { opacity: 1; }
  .card-x:hover { color: var(--red); }
}

.card-code {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 6px;
}
.code-num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.code-copy {
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--sep);
  border-radius: 20px;
  padding: 3px 10px;
}
.card.copied .code-copy {
  color: var(--green);
  border-color: var(--green);
}

.card-content {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  word-break: break-all;
}
.card.no-code .card-content {
  color: var(--text);
  font-size: 15px;
}

/* ---- 空状态 ---- */
.empty {
  text-align: center;
  padding: 24vh 32px 0;
  color: var(--text-2);
}
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty p { font-size: 17px; font-weight: 600; color: var(--text); }
.empty .empty-sub { font-size: 14px; font-weight: 400; color: var(--text-2); margin-top: 4px; }

/* ---- Action Sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet-body {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  max-width: 500px;
  margin: 0 auto;
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-group {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
}
.sheet-title {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--sep);
}
.sheet-btn {
  display: block;
  width: 100%;
  border: none;
  background: var(--card);
  font-family: inherit;
  font-size: 20px;
  padding: 16px;
  cursor: pointer;
}
.sheet-btn:active { filter: brightness(0.92); }
.sheet-danger { color: var(--red); }
.sheet-cancel {
  color: var(--accent);
  font-weight: 600;
  border-radius: 14px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(48px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(50, 50, 54, 0.92);
  color: #fff;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 22px;
  z-index: 100;
  animation: toast-in 0.25s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
