
/* =========================================
   HISTORY PAGE LOADER
========================================= */

html.history-loading,
body.history-loading {
  overflow: hidden;
}

body.history-loading > .history-page {
  visibility: hidden !important;
}

body.history-loading > .topbar {
  visibility: hidden !important;
}

#historyPageLoader {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  overflow: auto;
  background: #f6f8fc;
  -webkit-overflow-scrolling: touch;
}

html.dark #historyPageLoader {
  background: #0b0b0b;
}

html.dark .history-loader-skeleton {
  background: #151b23;
}

html.dark .history-loader-skeleton::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.06) 50%,
    transparent 100%
  );
}

.history-loader-shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 120px;
  box-sizing: border-box;
}

.history-loader-skeleton {
  position: relative;
  overflow: hidden;
  background: #e9edf3;
}

.history-loader-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.52) 50%, transparent 100%);
  animation: historyLoaderShimmer 1.45s ease-in-out infinite;
}

@keyframes historyLoaderShimmer {
  100% { transform: translateX(100%); }
}

.history-loader-topbar {
  height: 76px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  border-radius: 24px;
}

.history-loader-brand { display:flex; align-items:center; gap:10px; }
.history-loader-logo { width:42px; height:42px; border-radius:12px; }
.history-loader-brand-text { width:105px; display:flex; flex-direction:column; gap:7px; }
.history-loader-brand-title { width:72px; height:14px; border-radius:5px; }
.history-loader-brand-subtitle { width:92px; height:10px; border-radius:5px; }
.history-loader-back { width:92px; height:46px; border-radius:14px; }
.history-loader-main { padding-top:112px; }
.history-loader-heading {
  min-height:116px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:14px;
}
.history-loader-heading-title { width:min(390px,70%); height:36px; border-radius:9px; }
.history-loader-heading-text { width:min(600px,82%); height:18px; border-radius:7px; }
.history-loader-arrows {
  position:relative;
  width:min(940px,100%);
  height:0;
  margin:-116px auto 116px;
}
.history-loader-arrow {
  position:absolute;
  top:0;
  width:58px;
  height:58px;
  border-radius:17px;
}
.history-loader-arrow-left { left:0; }
.history-loader-arrow-right { right:0; }
.history-loader-overview {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:22px;
}
.history-loader-overview-card {
  min-height:126px;
  padding:24px 30px;
  box-sizing:border-box;
  border-radius:22px;
}
.history-loader-overview-label {
  width:105px;
  height:11px;
  margin-bottom:15px;
  border-radius:5px;
}
.history-loader-overview-value { width:72px; height:30px; border-radius:7px; }
.history-loader-cards {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:20px;
  margin-top:34px;
}
.history-loader-card {
  min-height:170px;
  padding:18px;
  box-sizing:border-box;
  display:flex;
  align-items:center;
  gap:20px;
  border-radius:26px;
}
.history-loader-thumb {
  width:180px;
  height:104px;
  flex:0 0 180px;
  border-radius:18px;
}
.history-loader-card-body { flex:1; min-width:0; }
.history-loader-line { height:11px; border-radius:5px; margin-bottom:12px; }
.history-loader-line.small { width:95px; }
.history-loader-line.title { width:70%; height:20px; }
.history-loader-line.text { width:55%; height:12px; }
.history-loader-line.meta { width:120px; height:12px; margin-top:25px; margin-bottom:0; }
.history-loader-card-arrow { width:46px; height:46px; flex:0 0 46px; border-radius:15px; }

@media (max-width:900px) {
  .history-loader-overview { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .history-loader-cards { grid-template-columns:1fr; }
}

@media (max-width:560px) {
  .history-loader-shell { width:min(100% - 24px,1500px); padding-top:12px; }
  .history-loader-topbar { height:64px; padding:0 14px; border-radius:20px; }
  .history-loader-main { padding-top:94px; }
  .history-loader-arrow { width:46px; height:46px; border-radius:14px; }
  .history-loader-overview { gap:12px; }
  .history-loader-overview-card { min-height:105px; padding:18px; border-radius:18px; }
  .history-loader-cards { gap:14px; margin-top:24px; }
  .history-loader-card { min-height:145px; padding:12px; gap:12px; border-radius:20px; }
  .history-loader-thumb { width:110px; height:82px; flex-basis:110px; border-radius:14px; }
  .history-loader-card-arrow { width:40px; height:40px; flex-basis:40px; border-radius:13px; }
}


:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --background: #f6f8fc;
  --surface: #ffffff;
  --border: #e6edf8;
  --text: #0f172a;
  --muted: #64748b;
  --soft: #f7faff;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--text);
  font-family: "Inter", sans-serif;
}


/* =========================================
   TOPBAR
========================================= */

.topbar {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;

  width: calc(100% - 40px);
  max-width: 1500px;
  height: 76px;

  transform: translateX(-50%);

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 24px;

  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 24px;

  box-shadow:
    0 15px 45px rgba(15, 23, 42, 0.06);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;

  text-decoration: none;
}

.logo-icon {
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 42px;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text h2 {
  margin: 0;

  color: var(--text);

  font-size: 16px;
  line-height: 1.1;
  font-weight: 800;
}

.brand-text span {
  margin-top: 4px;

  color: var(--muted);

  font-size: 13px;
  line-height: 1.1;
}

.dashboard-btn {
  height: 46px;
  padding: 0 24px;

  border: 0;
  border-radius: 14px;

  background: #eef4ff;
  color: var(--primary);

  font: inherit;
  font-size: 14px;
  font-weight: 700;

  cursor: pointer;

  transition:
    background .2s ease,
    transform .2s ease;
}

.dashboard-btn:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.dashboard-btn:active {
  transform: scale(.97);
}


/* =========================================
   PAGE
========================================= */

.history-page {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;

  padding-top: 130px;
  padding-bottom: 120px;
}

.history-content {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.history-section-header {
  width: 100%;
}

.history-title-row {
  position: relative;

  width: 100%;
  min-height: 116px;

  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.history-title-content {
  width: min(760px, calc(100% - 170px));

  margin: 0 auto;

  text-align: center;
}

.history-title-content h1,
.history-title-content h2 {
  margin: 0 0 12px;

  color: var(--text);

  font-size: 34px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -1.15px;
}

.history-title-content p {
  width: min(640px, 100%);
  margin: 0 auto;

  color: var(--muted);

  font-size: 18px;
  line-height: 1.6;
  font-weight: 400;

  text-align: center;
}


/* =========================================
   FIXED MODE ARROWS
========================================= */

.history-mode-arrow {
  position: absolute;
  top: 0;

  width: 58px;
  height: 58px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 1px solid #e3eaf4;
  border-radius: 17px;

  background: #ffffff;
  color: #64748b;

  cursor: pointer;

  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.045);

  transition:
    background .2s ease,
    border-color .2s ease,
    color .2s ease,
    box-shadow .2s ease,
    transform .2s ease;
}

/* LEFT ALWAYS LEFT */

.history-mode-arrow-left {
  left: max(0px, calc(50% - 470px));
}

/* RIGHT ALWAYS RIGHT */

.history-mode-arrow-right {
  right: max(0px, calc(50% - 470px));
}

.history-mode-arrow svg {
  width: 23px;
  height: 23px;

  display: block;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;

  transform: none !important;
}

.history-mode-arrow:hover {
  background: #f7faff;
  border-color: #cddcf2;
  color: var(--primary);

  transform: translateY(-2px);

  box-shadow:
    0 10px 24px rgba(37, 99, 235, 0.09);
}

.history-mode-arrow:active {
  transform: scale(.95);
}

.history-mode-arrow:disabled {
  cursor: default;
  opacity: .72;
}


/* =========================================
   OVERVIEW
========================================= */

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

.overview-card {
  min-width: 0;

  min-height: 126px;

  display: flex;
  flex-direction: column;
  justify-content: center;

  gap: 10px;

  padding: 24px 30px;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 22px;

  box-shadow:
    0 5px 18px rgba(15, 23, 42, 0.02);

  transition:
    transform .25s ease,
    box-shadow .25s ease;
}

.overview-card:hover {
  transform: translateY(-4px);

  box-shadow:
    0 20px 45px rgba(15, 23, 42, 0.06);
}

.overview-label {
  color: var(--muted);

  font-size: 13px;
  line-height: 1.2;
  font-weight: 600;

  text-transform: uppercase;
  letter-spacing: .08em;
}

.overview-card strong {
  color: var(--text);

  font-size: 2.2rem;
  line-height: 1;

  font-weight: 800;
  letter-spacing: -1.5px;

  white-space: nowrap;
}


/* =========================================
   CARDS GRID
========================================= */

.history-cards {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 20px;

  align-items: stretch;
}

.history-card {
  min-width: 0;
  min-height: 170px;

  display: flex;
  align-items: center;

  gap: 20px;

  padding: 18px;

  background: #ffffff;

  border: 1px solid #e8eef8;
  border-radius: 26px;

  cursor: pointer;

  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.035);

  transition:
    transform .3s cubic-bezier(.22,1,.36,1),
    box-shadow .3s ease,
    border-color .25s ease;
}

.history-card:hover {
  transform: translateY(-5px);

  border-color: #d8e5fb;

  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.06);
}

.history-card-thumbnail {
  position: relative;

  width: 180px;
  height: 104px;

  flex: 0 0 180px;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  border-radius: 18px;

  background: #f2f6fc;
}

.history-thumbnail {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: cover;

  transition:
    transform .45s cubic-bezier(.22,1,.36,1);
}

.history-card:hover .history-thumbnail {
  transform: scale(1.035);
}

.history-thumbnail-placeholder {
  width: 100%;
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #2563eb;

  font-size: 18px;
  font-weight: 800;
}

.history-status {
  position: absolute;
  top: 9px;
  right: 9px;

  padding: 6px 10px;

  border-radius: 999px;

  background: rgba(255, 255, 255, .95);

  color: #15803d;

  font-size: 11px;
  line-height: 1;
  font-weight: 700;

  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  box-shadow:
    0 3px 12px rgba(15, 23, 42, 0.05);
}

.history-card-body {
  min-width: 0;
  flex: 1;
  align-self: stretch;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.history-card-top {
  min-width: 0;

  display: flex;
  align-items: flex-start;
}

.history-card-label {
  display: inline-block;

  margin-bottom: 7px;

  color: #94a3b8;

  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;

  letter-spacing: .16em;
  text-transform: uppercase;
}

.history-card-title {
  margin: 0 0 8px;

  color: var(--text);

  font-size: 20px;
  line-height: 1.28;
  font-weight: 800;

  letter-spacing: -.03em;

  overflow-wrap: anywhere;
}

.history-card-subtitle {
  margin: 0;

  color: var(--muted);

  font-size: 14px;
  line-height: 1.45;
}

.history-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  margin-top: 16px;
}

.history-meta {
  min-width: 0;

  display: flex;
  flex-wrap: wrap;
  align-items: center;

  gap: 20px;

  color: var(--muted);

  font-size: 14px;
  line-height: 1.2;
  font-weight: 600;
}


/* =========================================
   CARD ARROW
========================================= */

.history-arrow-button {
  width: 46px;
  height: 46px;

  flex: 0 0 46px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 1px solid #e4eaf3;
  border-radius: 15px;

  background: #f8fafc;
  color: #475569;

  cursor: pointer;

  transition:
    background .22s ease,
    border-color .22s ease,
    color .22s ease,
    transform .25s cubic-bezier(.22,1,.36,1),
    box-shadow .25s ease;
}

.history-arrow-button svg {
  width: 20px;
  height: 20px;

  display: block;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;

  transition:
    transform .25s cubic-bezier(.22,1,.36,1);
}

.history-card:hover .history-arrow-button {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;

  transform: translateX(2px);

  box-shadow:
    0 8px 20px rgba(37, 99, 235, .16);
}

.history-card:hover .history-arrow-button svg {
  transform: translateX(2px);
}

.history-arrow-button:active {
  transform: scale(.94);
}


/* =========================================
   EMPTY STATE
========================================= */

.empty-history {
  grid-column: 1 / -1;

  min-height: 210px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 50px 30px;

  background: #ffffff;

  border: 1px dashed #dfe7f2;
  border-radius: 26px;

  color: var(--muted);

  font-size: 16px;
  font-weight: 600;
  text-align: center;
}


/* =========================================
   FILE PREVIEW
========================================= */

.file-history-thumbnail {
  background: #f2f6fc;
}

.file-history-paper {
  position: relative;

  width: 86px;
  height: 108px;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  background: #ffffff;

  border: 1px solid #dde6f2;
  border-radius: 11px;

  box-shadow:
    0 8px 22px rgba(15, 23, 42, .08);
}

.file-history-paper span {
  color: #2563eb;

  font-size: 15px;
  line-height: 1;
  font-weight: 800;

  letter-spacing: .04em;
}

.file-preview-container {
  width: 100%;
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  background: #f2f6fc;
}

.history-file-preview {
  display: block;

  max-width: 100%;
  max-height: 100%;

  object-fit: contain;
}

.history-file-preview:not(canvas) {
  width: 100%;
  height: 100%;

  object-fit: cover;
}

canvas.history-file-preview {
  width: auto !important;
  height: 100% !important;

  max-width: 100%;

  background: #ffffff;

  object-fit: contain;

  box-shadow:
    0 5px 16px rgba(15, 23, 42, .08);
}

.history-file-preview-fallback {
  width: 78px;
  height: 94px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #ffffff;

  border: 1px solid #dce5f2;
  border-radius: 12px;

  color: #2563eb;

  font-size: 15px;
  font-weight: 800;

  box-shadow:
    0 8px 18px rgba(15,23,42,.08);
}


/* =========================================
   MODAL
========================================= */

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 24px;

  background: rgba(15, 23, 42, .45);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity .25s ease,
    visibility .25s ease;
}

.history-modal.show {
  opacity: 1;
  visibility: visible;
}

.history-modal-card {
  position: relative;

  width: min(560px, 92vw);
  max-height: min(760px, 90vh);

  overflow-y: auto;

  padding: 28px;

  background: #ffffff;

  border: 1px solid #e6edf8;
  border-radius: 32px;

  box-shadow:
    0 24px 60px rgba(15, 23, 42, .08),
    0 40px 90px rgba(15, 23, 42, .12);

  transform: translateY(24px) scale(.96);
  opacity: 0;

  transition:
    transform .28s cubic-bezier(.22,1,.36,1),
    opacity .25s ease;
}

.history-modal-card {
  width: 494px;
  max-width: calc(100vw - 32px);

  box-sizing: border-box;

  padding: 27px 26px 25px;

  border-radius: 32px;
}

.history-modal.show .history-modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.history-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;

  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  border-radius: 14px;

  background: #f8fafc;
  color: #64748b;

  font: inherit;
  font-size: 24px;
  line-height: 1;

  cursor: pointer;

  transition:
    background .2s ease,
    color .2s ease;
}

.history-modal-close:hover {
  background: #eef4ff;
  color: var(--primary);
}

.history-success-icon {
  width: 56px;
  height: 56px;

  margin: 0 auto 14px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 18px;

  background: #eef4ff;
  color: var(--primary);
}

.history-success-svg {
  width: 28px;
  height: 28px;
}

.history-modal-heading {
  margin: 8px 0 0;

  color: var(--text);

  font-size: 32px;
  line-height: 1.15;
  font-weight: 800;

  text-align: center;
  letter-spacing: -.7px;
}

.history-modal-title {
  margin: 10px 0 22px;

  color: var(--muted);

  font-size: 15px;
  line-height: 1.5;

  text-align: center;
}

.history-modal-grid {
  display: grid;

  grid-template-columns: repeat(2, 1fr);

  gap: 14px;

  width: 100%;

  margin: 0 0 20px;
}

.history-stat {
  width: 100%;
  min-width: 0;

  height: 88px;

  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  justify-content: center;

  padding: 16px 18px;

  background: #fafcff;

  border: 1px solid #edf2f7;
  border-radius: 16px;

  box-shadow: none;
}

.history-stat span {
  display: block;

  margin: 0 0 8px;

  color: #64748b;

  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;

  letter-spacing: .08em;
  text-transform: uppercase;
}

.history-stat strong {
  display: block;

  margin: 0;

  color: #0f172a;

  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;

  white-space: nowrap;
}

.history-copy-link {
  width: 100%;
  height: 52px;

  margin: 0 0 14px;

  border: 1px solid var(--primary);
  border-radius: 16px;

  background: #ffffff;
  color: var(--primary);

  font: inherit;
  font-size: 15px;
  font-weight: 700;

  cursor: pointer;

  transition:
    background .2s ease,
    transform .2s ease;
}

.history-copy-link:hover {
  background: #f8fbff;
}

.history-copy-link:active {
  transform: scale(.98);
}

.history-close-button {
  width: 100%;
  height: 56px;

  border: 0;
  border-radius: 18px;

  background: var(--primary);
  color: #ffffff;

  font: inherit;
  font-size: 15px;
  font-weight: 700;

  cursor: pointer;

  transition:
    background .2s ease,
    transform .2s ease;
}

.history-close-button:hover {
  background: var(--primary-dark);
}

.history-close-button:active {
  transform: scale(.98);
}

.history-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 10000;

  padding: 14px 22px;

  background: #0f172a;
  color: #ffffff;

  border-radius: 14px;

  font-size: 14px;
  font-weight: 600;

  opacity: 0;
  visibility: hidden;

  transform:
    translateX(-50%)
    translateY(20px);

  transition:
    opacity .25s ease,
    transform .25s ease,
    visibility .25s ease;
}

.history-toast.show {
  opacity: 1;
  visibility: visible;

  transform:
    translateX(-50%)
    translateY(0);
}


/* =========================================
   SCROLLBAR
========================================= */

html,
body {
  scrollbar-gutter: auto;
}

::-webkit-scrollbar {
  width: 11px;
}

::-webkit-scrollbar-track {
  background: #edf2f7;
}

::-webkit-scrollbar-thumb {
  background: #b9c8dc;
  border: 3px solid #edf2f7;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a8c2;
}


/* =========================================
   DARK MODE
========================================= */

html.dark body {
  background: #080d14;
  color: #f8fafc;
}

html.dark .topbar {
  background: rgba(12, 17, 24, .9);

  border-color: #1c2633;

  box-shadow:
    0 25px 70px rgba(0,0,0,.3),
    inset 0 1px rgba(255,255,255,.02);
}

html.dark .brand-text h2,
html.dark .history-title-content h1,
html.dark .history-title-content h2,
html.dark .overview-card strong,
html.dark .history-card-title,
html.dark .history-modal-heading,
html.dark .history-stat strong {
  color: #f8fafc;
}

html.dark .brand-text span,
html.dark .history-title-content p,
html.dark .overview-label,
html.dark .history-card-subtitle,
html.dark .history-meta,
html.dark .history-card-label,
html.dark .history-modal-title,
html.dark .history-stat span {
  color: #94a3b8;
}

html.dark .dashboard-btn {
  background: #111923;
  color: #60a5fa;
  border: 1px solid #1c2633;
}

html.dark .dashboard-btn:hover {
  background: #182334;
}

html.dark .history-mode-arrow {
  background: #111923;
  border-color: #263344;
  color: #94a3b8;
}

html.dark .history-mode-arrow:hover {
  background: #182334;
  border-color: #31445c;
  color: #60a5fa;
}

html.dark .overview-card,
html.dark .history-card,
html.dark .empty-history {
  background: #0c1118;
  border-color: #1c2633;

  box-shadow:
    0 25px 70px rgba(0,0,0,.25),
    inset 0 1px rgba(255,255,255,.02);
}

html.dark .history-card:hover,
html.dark .overview-card:hover {
  border-color: #31445c;
}

html.dark .history-arrow-button {
  background: #111923;
  border-color: #263344;
  color: #cbd5e1;
}

html.dark .history-card:hover .history-arrow-button {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

html.dark .history-status {
  background: rgba(17,25,35,.94);
  color: #4ade80;
  border: 1px solid rgba(74,222,128,.1);
}

html.dark .file-history-thumbnail,
html.dark .file-preview-container {
  background: #111923;
}

html.dark .file-history-paper,
html.dark .history-file-preview-fallback {
  background: #17202b;
  border-color: #2a394d;
}

html.dark .history-file-preview {
  background: #17202b;
}

html.dark .history-modal {
  background: rgba(2,6,12,.7);
}

html.dark .history-modal-card {
  background: #0c1118;
  border-color: #1c2633;
  box-shadow:
    0 30px 80px rgba(0,0,0,.48),
    inset 0 1px rgba(255,255,255,.02);
}

html.dark .history-modal-close {
  background: #111923;
  color: #94a3b8;
}

html.dark .history-modal-close:hover {
  background: #182334;
  color: #60a5fa;
}

html.dark .history-success-icon {
  background: rgba(37,99,235,.12);
  color: #60a5fa;
}

html.dark .history-stat {
  background: #111923;
  border-color: #1c2633;
}

html.dark .history-copy-link {
  background: #111923;
  border-color: #2563eb;
  color: #60a5fa;
}

html.dark .history-copy-link:hover {
  background: #162238;
}

html.dark .history-close-button {
  background: #2563eb;
}

html.dark .history-toast {
  background: #111923;
  border: 1px solid #263548;
  color: #f8fafc;
}

html.dark ::-webkit-scrollbar-track {
  background: #0c1118;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #263548;
  border-color: #0c1118;
}


/* =========================================
   RESPONSIVE
========================================= */

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

  .history-cards {
    grid-template-columns:
      1fr;
  }

  .history-mode-arrow-left {
    left: 0;
  }

  .history-mode-arrow-right {
    right: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    top: 10px;

    width: calc(100% - 20px);
    height: 68px;

    padding: 0 14px;

    border-radius: 20px;
  }

  .brand {
    gap: 8px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-text h2 {
    font-size: 15px;
  }

  .brand-text span {
    font-size: 11px;
  }

  .dashboard-btn {
    height: 42px;
    padding: 0 17px;
  }

  .history-page {
    width: calc(100% - 24px);

    padding-top: 104px;
    padding-bottom: 70px;
  }

  .history-title-row {
    min-height: 100px;
    padding: 0 46px;
  }

  .history-title-content {
    width: 100%;
  }

  .history-title-content h1,
  .history-title-content h2 {
    font-size: 27px;
    letter-spacing: -.8px;
  }

  .history-title-content p {
    font-size: 14px;
    line-height: 1.55;
  }

  .history-mode-arrow {
    width: 44px;
    height: 44px;

    border-radius: 14px;
  }

  .history-mode-arrow-left {
    left: 0;
  }

  .history-mode-arrow-right {
    right: 0;
  }

  .history-mode-arrow svg {
    width: 19px;
    height: 19px;
  }

  .history-overview {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .overview-card {
    min-height: 108px;
    padding: 20px 22px;
  }

  .overview-card strong {
    font-size: 2rem;
  }

  .history-card {
    min-height: 0;

    flex-direction: column;
    align-items: stretch;

    padding: 14px;

    border-radius: 22px;
  }

  .history-card-thumbnail {
    width: 100%;
    height: 170px;
    flex-basis: 170px;
  }

  .history-card-body {
    min-height: 180px;
  }

  .history-card-title {
    font-size: 19px;
  }

  .history-card-bottom {
    align-items: flex-end;
  }

  .history-meta {
    gap: 12px;
  }

  .history-modal {
    padding: 14px;
  }

  .history-modal-card {
    width: 100%;
    max-height: 92vh;

    padding: 24px 18px;

    border-radius: 26px;
  }

  .history-modal-heading {
    font-size: 27px;
  }

  .history-modal-grid {
    gap: 10px;
  }

  .history-stat {
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .topbar-right .dashboard-btn {
    padding: 0 14px;
    font-size: 13px;
  }

  .history-title-row {
    padding: 0 40px;
  }

  .history-title-content h1,
  .history-title-content h2 {
    font-size: 24px;
  }

  .history-title-content p {
    font-size: 13px;
  }

  .history-card-thumbnail {
    height: 150px;
    flex-basis: 150px;
  }

  .history-modal-grid {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   BAC TRUTH — UNIVERSAL PAGE SCROLLBAR
   Matches the Quran page exactly.
   ========================================================= */
html,
body {
  scrollbar-width: thin;
  scrollbar-color: #b8bec8 transparent;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 5px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: #b8bec8;
  border-radius: 999px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: #aab1bc;
}
