.viewing-gift { overflow:hidden; }
.gift-viewer { position:fixed; inset:0; margin:auto; padding:0; border:1px solid #c8c0b3; border-radius:15px; color:#333b35; background:#faf8f2; width:min(1120px,94vw); height:min(880px,94dvh); max-width:none; max-height:none; box-shadow:0 24px 90px #1d211d3b; overscroll-behavior:none; }
.gift-viewer[open],.gift-viewer[data-closing] { display:grid; grid-template-rows:51px minmax(0,1fr); }
.gift-viewer::backdrop { background:#272b2782; }
.viewer-bar { display:flex; align-items:center; gap:8px; padding:0 16px; border-bottom:1px solid #d9d5ca; font:13px -apple-system,"PingFang SC",sans-serif; background:#fdfbf6; }
.viewer-bar strong { margin-right:auto; font-weight:600; }
.viewer-bar button { font:inherit; min-height:40px; border:0; background:transparent; color:#47554a; padding:0 10px; cursor:pointer; }
.viewer-bar .leave { border:1px solid #c9cec4; min-height:34px; border-radius:7px; }
.gift-viewer iframe { display:block; width:100%; height:100%; border:0; background:#f8f5ef; }
@media(max-width:700px) { .gift-viewer{margin:0;inset:0;width:100%;height:100dvh;border:0;border-radius:0} }
.viewer-status { position:absolute; top:48%; inset-inline:12px; margin:0; text-align:center; color:inherit; font:14px var(--sans,sans-serif); }
.gift-viewer iframe { grid-row:2; transition:opacity var(--motion-content); }
.gift-viewer iframe.loading { opacity:0; }
.gift-viewer::backdrop,.keepsake::backdrop { transition:background-color var(--motion-quick); }
.gift-viewer[data-closing] { z-index:10; pointer-events:none; }
.gift-viewer[data-closing]::backdrop { background-color:transparent; }
@starting-style { .gift-viewer[open]::backdrop { background-color:transparent; } }
@media(prefers-color-scheme:dark) {
  .gift-viewer,.viewer-bar,.viewer-bar button { color:#eee7d9; background-color:#2d2a25; border-color:#5c564c; }
  .gift-viewer iframe { background:#201e1b; }
}

.history-dialog {
  position:fixed; inset:0; margin:auto; padding:0; width:min(520px,92vw); max-height:min(82dvh,680px);
  max-width:none; border:1px solid #cfc5b4; border-radius:16px; background:#fbf7ef; color:#30372f;
  box-shadow:0 24px 72px rgba(24,20,16,.38); overscroll-behavior:contain;
  font:14px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
}
.history-dialog::backdrop { background:rgba(28,24,20,.56); backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px); }
.history-dialog[open] { display:flex; flex-direction:column; }
.history-sheet { display:flex; flex-direction:column; min-height:0; max-height:inherit; }
.history-head {
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  padding:16px 18px 12px; border-bottom:1px solid #dfd7c7;
}
.history-head strong { font-size:16px; font-weight:600; }
.history-sub { margin:3px 0 0; font-size:12px; color:#6b6a5d; }
.history-close {
  flex:none; min-height:34px; padding:0 12px; border-radius:999px;
  border:1px solid #ccc4b4; background:#fffdf8; color:#444b42; font:inherit; font-size:13px; cursor:pointer;
}
.history-list { overflow-y:auto; padding:12px 16px 18px; display:grid; gap:10px; overscroll-behavior:contain; }
.history-empty { margin:18px 4px; text-align:center; color:#747062; font-size:13px; }
.history-item {
  padding:12px 13px; border:1px solid #ddd5c5; border-radius:12px; background:#fffdf8;
  display:grid; gap:8px; min-width:0;
}
.history-meta { display:flex; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; }
.history-meta strong { font-size:14.5px; color:#362d26; overflow-wrap:anywhere; }
.history-meta time { flex:none; font-size:12px; color:#7c7769; font-variant-numeric:tabular-nums; }
.history-url {
  margin:0; font-size:12px; color:#6c6a5e; font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.history-actions { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.history-actions button, .history-actions a {
  display:inline-flex; align-items:center; justify-content:center; min-height:32px; padding:0 10px;
  border-radius:999px; font-size:12.5px; text-decoration:none; cursor:pointer; border:1px solid transparent;
}
.history-btn-primary { background:#2e483c; color:#fffdf4; }
.history-btn-soft { background:#f2eee3; border-color:#d4cbb8 !important; color:#3c433a; }
.history-btn-ghost { background:transparent; color:#8d4a3f; margin-left:auto; }
.history-qr {
  margin-top:4px; padding-top:10px; border-top:1px dashed #dcd4c4;
  display:grid; justify-items:center; gap:8px; text-align:center;
}
.history-qr img { width:min(220px,100%); height:auto; border-radius:8px; border:1px solid #dcd3c2; }
.history-qr p { margin:0; font-size:12px; color:#6d695c; }
@media(max-width:560px) {
  .history-dialog { width:100%; max-height:86dvh; margin:auto 0 0; border-radius:16px 16px 0 0; border-bottom:0; }
  .history-list { padding-bottom:max(18px,env(safe-area-inset-bottom)); }
}
@media(prefers-color-scheme:dark) {
  .history-dialog { background:#292622; color:#eee7d9; border-color:#575147; }
  .history-head { border-color:#464139; }
  .history-sub,.history-empty,.history-meta time,.history-url,.history-qr p { color:#bfb6a6; }
  .history-close,.history-item { background:#332f29; border-color:#544e44; color:#eee7d9; }
  .history-meta strong { color:#f4ede0; }
  .history-btn-primary { background:#a8ceaf; color:#18261a; }
  .history-btn-soft { background:#3d3a33; border-color:#5a5449 !important; color:#eee7d9; }
  .history-btn-ghost { color:#e5a496; }
  .history-qr { border-color:#4b453c; }
}
