/* Seven-day result history: date-grouped gallery inside the shared shell. */

.history-page {
  padding-top: 6px;
}

.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.history-btn-clear {
  border-color: rgba(166, 59, 47, 0.34);
  background: var(--surface);
  color: #a63b2f;
}

.history-btn-clear:hover {
  border-color: #a63b2f;
  background: rgba(166, 59, 47, 0.07);
  color: #8f3227;
}

.history-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.history-tab {
  padding: 7px 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted-strong);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.history-tab:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.history-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.history-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 46px 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted-strong);
  text-align: center;
}

.history-state strong {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.history-state p {
  max-width: 440px;
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}

.history-state.is-error {
  border-color: rgba(178, 59, 47, 0.32);
  color: #a63b2f;
}

.history-grid {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.history-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-group-title {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-group-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.history-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(59, 48, 38, 0.05);
}

.history-card-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  cursor: zoom-in;
}

.history-card-thumb img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.history-card-thumb img.is-loaded {
  opacity: 1;
}

.history-card-thumb.is-missing::after {
  content: "—";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
}

.history-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
}

.history-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.history-mini {
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted-strong);
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.history-mini:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.history-mini.is-danger:hover {
  color: #a63b2f;
}

.history-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.history-dialog::backdrop {
  background: rgba(30, 24, 20, 0.58);
  backdrop-filter: blur(3px);
}

.history-dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.history-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.history-dialog-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted-strong);
  cursor: pointer;
}

.history-dialog-close:hover {
  border-color: var(--line);
  color: var(--ink);
}

.history-dialog-close svg {
  width: 18px;
  height: 18px;
}

.history-dialog-stage {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  overflow: auto;
  background: #151210;
}

.history-dialog-stage img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
}

.history-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
}

.history-confirm {
  width: min(420px, calc(100vw - 40px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(59, 48, 38, 0.18);
}

.history-confirm::backdrop {
  background: rgba(30, 24, 20, 0.58);
  backdrop-filter: blur(3px);
}

.history-confirm-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
}

.history-confirm-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.history-confirm-text {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.7;
}

.history-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.history-confirm-ok {
  border-color: #a63b2f;
  background: #a63b2f;
  color: #fff8f0;
}

.history-confirm-ok:hover {
  border-color: #8f3227;
  background: #8f3227;
}

@media (max-width: 1100px) {
  .history-group-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .history-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .history-dialog-actions .btn {
    flex: 1 1 auto;
  }
}
