/* 本地保存 / 读取本地存储 */

.autosave-toast {
  position: fixed;
  right: 14px;
  bottom: 40px;
  z-index: 9999;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.92);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.autosave-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.autosave-toast.is-loading::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  vertical-align: -1px;
  animation: autosave-spin 0.9s linear infinite;
}

@keyframes autosave-spin {
  to {
    transform: rotate(360deg);
  }
}

.local-storage-window__dialog {
  width: min(1100px, 96vw);
  max-height: calc(100vh - 140px);
}

.local-storage-window__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: calc(100vh - 240px);
  overflow: hidden;
}

.local-storage-window__hint {
  margin: 0;
  color: #5f6368;
  font-size: 13px;
  line-height: 1.4;
}

.local-storage-slots {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 15px 2px 2px;
  scrollbar-gutter: stable;
}

.local-slot {
  width: 100%;
  text-align: left;
  border-radius: 20px;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
}

.local-slot:hover {
  border-color: rgba(26, 115, 232, 0.55);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.local-slot.is-empty {
  border-style: dashed;
  border-color: #cfd5dd;
  background: rgba(248, 250, 252, 0.85);
}

.local-slot.is-empty:hover {
  border-color: rgba(26, 115, 232, 0.55);
}

.local-slot__badge {
  position: absolute;
  top: -15px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #E2EDF9;
  color: #1a73e8;
  border: 1px solid rgba(26, 115, 232, 0.18);
}

.local-slot__preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.local-slot__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.local-slot__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-size: 12px;
}

.local-slot__empty img {
  width: 46px;
  height: 46px;
  opacity: 0.65;
}

.local-slot__meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.local-slot__meta-title {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-slot__meta-row {
  font-size: 12px;
  color: #5f6368;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.local-slot__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.local-slot__actions .ghost-button,
.local-slot__actions .primary-button {
  width: 100%;
  border-radius: 999px;
}

body.tablet-mode .local-storage-window__dialog {
  width: min(980px, 96vw);
  max-height: calc(100vh - 160px);
}

body.tablet-mode .local-storage-window__body {
  max-height: calc(100vh - 260px);
}

body.tablet-mode .local-storage-slots {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
