.memory-gallery-window {
  background: #f7f3ec;
  color: #332f2a;
}

.memory-gallery-header {
  background: #f7f3ec;
  border-bottom: 1px solid rgba(120, 96, 70, .14);
}

.memory-gallery-title { flex: 1; text-align: center; line-height: 1; }
.memory-gallery-title h2 { margin: 0; font-family: Georgia, serif; font-size: 18px; font-weight: 600; letter-spacing: .02em; }
.memory-gallery-header .memory-gallery-settings-trigger { flex: 0 0 36px; }
.memory-gallery-settings-trigger svg { width: 20px; height: 20px; }
.memory-gallery-eyebrow, .memory-gallery-stamp { color: #9a8064; font-size: 9px; letter-spacing: .16em; font-weight: 800; }
.memory-gallery-body { padding: 14px 16px 28px; overflow-y: auto; background: #f7f3ec; }
.memory-gallery-body.is-viewer-open { padding: 0; background: transparent; }

.memory-gallery-tabs { display: flex; gap: 18px; margin: 0 0 10px; padding: 0 2px; border-bottom: 1px solid rgba(120, 96, 70, .15); }
.memory-gallery-tabs[hidden], .memory-gallery-character-filter[hidden] { display: none !important; }
.memory-gallery-tabs button { position: relative; border: 0; padding: 8px 0 10px; background: transparent; color: #978b80; font-size: 11px; cursor: pointer; }
.memory-gallery-tabs button.is-active { color: #3c3731; font-weight: 700; }
.memory-gallery-tabs button.is-active:after { content: ''; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: #3c3731; }

.memory-gallery-character-filter { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: #6e6156; font-size: 11px; }
.memory-gallery-character-filter label { flex: 0 0 auto; }
.memory-gallery-character-filter select { min-width: 0; flex: 1; border: 1px solid rgba(123, 101, 78, .2); border-radius: 9px; padding: 8px 10px; background: rgba(255,255,255,.7); color: #62564b; font: inherit; }
.memory-gallery-status { min-height: 18px; color: #8b6f53; font-size: 11px; line-height: 1.5; }
.memory-gallery-card-grid { display: grid; gap: 12px; }
.memory-gallery-card-grid[hidden], .memory-gallery-viewer[hidden], .memory-gallery-settings-sheet[hidden] { display: none !important; }

.memory-gallery-record { position: relative; overflow: hidden; border: 1px solid rgba(123, 101, 78, .18); border-radius: 15px; background: rgba(255,255,255,.7); box-shadow: 0 8px 24px rgba(106, 82, 58, .07); }
.memory-gallery-record:before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: #b9936f; }
.memory-gallery-record[data-source="online"]:before { background: #7e94a5; }
.memory-gallery-record-open { display: block; width: 100%; border: 0; padding: 15px 15px 10px 18px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.memory-gallery-record-top { display: flex; justify-content: space-between; gap: 8px; color: #a3988e; font-size: 10px; }
.memory-gallery-record-source { color: #7e94a5; font-weight: 800; letter-spacing: .08em; }
.memory-gallery-record[data-source="offline"] .memory-gallery-record-source { color: #b07d55; }
.memory-gallery-record-character { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-family: Georgia, serif; font-size: 15px; }
.memory-gallery-record-character img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.memory-gallery-record-title { display: block; margin: 4px 0; font-family: Georgia, serif; font-size: 17px; }
.memory-gallery-record-meta { display: block; color: #93867a; font-size: 11px; }
.memory-gallery-record-actions { display: flex; gap: 8px; padding: 0 15px 13px 18px; }
.memory-gallery-card-action { border: 1px solid rgba(120, 99, 77, .18); border-radius: 999px; padding: 6px 12px; background: rgba(255,255,255,.7); color: #796b5f; font-size: 11px; cursor: pointer; }
.memory-gallery-card-action.is-accent { border-color: #ad8664; color: #986a47; }
.memory-gallery-empty { display: block; padding: 34px 6px; color: #918377; text-align: left; }
.memory-gallery-empty strong { color: #62574d; font-family: Georgia, serif; font-size: 17px; }
.memory-gallery-empty small { display: block; max-width: 280px; margin-top: 8px; line-height: 1.6; }

.memory-gallery-viewer-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; padding: 0 2px; }
.memory-gallery-viewer-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 600; }
.memory-gallery-viewer-heading time { flex: 0 0 auto; color: #96887c; font-size: 10px; letter-spacing: .04em; }
.memory-gallery-body.is-viewer-open > .memory-gallery-viewer { width: 100%; min-height: 100%; box-sizing: border-box; }
.memory-gallery-viewer-messages { display: grid; gap: 10px; min-height: 0; }
.memory-gallery-viewer .companion-reader-entry { animation: none !important; opacity: 1 !important; }
.memory-gallery-viewer .companion-theme-hero { pointer-events: none; }
.memory-gallery-viewer .companion-theme-pin { display: none !important; }
.memory-gallery-archive-entry { position: relative; }
.memory-gallery-archive-entry .memory-gallery-message-media { margin: 0; }
.memory-gallery-archive-entry .memory-gallery-raw-image { display: block; max-width: 100%; max-height: 240px; border-radius: 9px; object-fit: contain; }
.memory-gallery-archive-entry .companion-reader-body p,
.memory-gallery-archive-entry .companion-user-body p { margin: 0 0 10px; }
.memory-gallery-archive-entry .companion-reader-body p:last-child,
.memory-gallery-archive-entry .companion-user-body p:last-child { margin-bottom: 0; }

.memory-gallery-viewer[data-beautification-source="online"] { background: var(--memory-gallery-online-bg, #f7f3ec); }
.memory-gallery-viewer[data-beautification-source="online"] .companion-reader-entry--char { background: var(--memory-gallery-online-char-bg, rgba(255,255,255,.7)); color: var(--memory-gallery-online-char-color, #2b2b2b); padding: var(--memory-gallery-online-char-padding, 10px 14px); border-radius: var(--memory-gallery-online-char-radius, 35%); }
.memory-gallery-viewer[data-beautification-source="online"] .companion-reader-entry--user { background: var(--memory-gallery-online-user-bg, rgba(255,255,255,.7)); color: var(--memory-gallery-online-user-color, #2b2b2b); padding: var(--memory-gallery-online-user-padding, 10px 14px); border-radius: var(--memory-gallery-online-user-radius, 35%); }

.memory-gallery-settings-sheet { z-index: 920; align-items: flex-end; justify-content: center; background: rgba(55, 47, 40, .25); }
.memory-gallery-settings-sheet[hidden] { display: none !important; }
.memory-gallery-settings-scrim { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.memory-gallery-settings-card { position: relative; width: min(360px, calc(100% - 24px)); box-sizing: border-box; margin-bottom: 12px; padding: 20px; border: 1px solid rgba(255,255,255,.72); border-radius: 20px; background: #fbf7f0; box-shadow: 0 20px 55px rgba(46, 34, 23, .2); }
.memory-gallery-settings-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.memory-gallery-settings-header h3 { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.memory-gallery-settings-close { border: 0; padding: 0 2px; background: transparent; color: #8b725b; font-size: 25px; line-height: 1; cursor: pointer; }
.memory-gallery-settings-fields { display: grid; gap: 12px; margin-top: 18px; }
.memory-gallery-settings-fields label { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 10px; color: #65584d; font-size: 12px; }
.memory-gallery-settings-fields select { width: 100%; box-sizing: border-box; border: 1px solid #d7c7b6; border-radius: 9px; padding: 9px 10px; background: #fffdf9; color: #62564b; font-size: 12px; }
.memory-gallery-settings-note { margin: 16px 0 0; color: #88796b; font-size: 11px; line-height: 1.6; }

.memory-gallery-restore-sheet { background: rgba(55, 47, 40, .25); align-items: center; justify-content: center; }
.memory-gallery-restore-sheet[hidden] { display: none !important; }
#online-archive-sheet { z-index: 900; }
.memory-gallery-restore-card { width: min(330px, calc(100% - 32px)); box-sizing: border-box; padding: 22px; border: 1px solid rgba(255,255,255,.6); border-radius: 20px; background: #fbf7f0; box-shadow: 0 20px 55px rgba(46, 34, 23, .2); }
.memory-gallery-restore-card h3 { margin: 7px 0; font-family: Georgia, serif; font-size: 22px; }
.memory-gallery-restore-card p { color: #88796b; font-size: 12px; line-height: 1.65; }
.memory-gallery-restore-card label { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; color: #65584d; font-size: 12px; }
.memory-gallery-restore-card input { width: 74px; border: 1px solid #d7c7b6; border-radius: 8px; padding: 7px; background: #fffdf9; }
.memory-gallery-restore-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.online-archive-overlay { z-index: 900; align-items: center; justify-content: center; box-sizing: border-box; padding: 20px; background: rgba(15, 23, 42, .32); }
.online-archive-overlay[hidden] { display: none !important; }
.online-archive-card { width: min(360px, 100%); box-sizing: border-box; padding: 20px; border: 1px solid rgba(255,255,255,.7); border-radius: 22px; background: var(--bg-main, #f5f7fa); color: var(--text-primary, #1e293b); box-shadow: 0 18px 45px rgba(15,23,42,.18); }
.online-archive-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.online-archive-header h3 { margin: 0; font-size: 19px; font-weight: 800; }
.online-archive-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary, #64748b); font-size: 24px; line-height: 1; cursor: pointer; }
.online-archive-days { display: grid; grid-template-columns: 1fr 90px 1fr; align-items: center; gap: 10px; color: var(--text-secondary, #64748b); font-size: 13px; }
.online-archive-days > span:last-child { text-align: right; }
.online-archive-days input { width: 100%; box-sizing: border-box; border: 1px solid var(--border, #cbd5e1); border-radius: 10px; padding: 10px 12px; background: var(--surface, #ffffff); color: var(--text-primary, #1e293b); font: inherit; text-align: center; }
.online-archive-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@media (max-width: 420px) {
  .memory-gallery-body { padding-left: 13px; padding-right: 13px; }
  .memory-gallery-viewer-heading h3 { font-size: 22px; }
  .memory-gallery-settings-card { margin-bottom: 8px; }
}
