/* DOC90 workspace refinement: clear hierarchy without changing any behavior. */

body {
  gap: 0;
  padding: 0;
  background:
    radial-gradient(760px 420px at 72% -8%, rgba(31, 111, 235, 0.08), transparent 62%),
    linear-gradient(145deg, #e9f0f8 0%, #f5f8fc 48%, #e8eef6 100%);
}

body::before {
  display: none;
}

.sidebar {
  width: 84px;
  min-width: 84px;
  padding: 20px 10px;
  align-items: center;
  border: none;
  border-radius: 0 22px 22px 0;
  background: linear-gradient(180deg, #122c46 0%, #0f2439 100%);
  box-shadow: 14px 0 42px rgba(15, 23, 42, 0.18);
  backdrop-filter: none;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.sidebar-item {
  width: 64px;
  min-height: 66px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  color: #cbd5e1;
  border: 1px solid transparent;
  background: transparent;
  text-align: center;
}

.sidebar-item span {
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  transform: translateX(2px);
}

.sidebar-item:hover img {
  opacity: 1;
  filter: brightness(0) invert(1) drop-shadow(0 0 7px rgba(126, 190, 255, .48));
}

.sidebar-item:active,
.sidebar-toggle:active {
  transform: translateY(1px) scale(0.98);
}

.sidebar-item img {
  filter: brightness(0) invert(1);
  opacity: 0.86;
}

.sidebar.collapsed .sidebar-item img {
  filter: brightness(0) invert(1);
}

.main-content {
  min-width: 0;
  padding: clamp(14px, 2vw, 28px);
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

#moduleSection,
#processingSection {
  min-height: 100%;
  width: min(1240px, 100%);
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 30px;
  background: rgba(255, 255, 255, .76);
  box-shadow: 0 30px 80px rgba(16, 40, 68, 0.14), inset 0 1px 0 rgba(255,255,255,.9);
  backdrop-filter: blur(22px) saturate(1.08);
  overflow: hidden;
}

#moduleSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(54px, 8vh, 92px) clamp(22px, 4vw, 46px) clamp(36px, 6vh, 64px);
  background:
    radial-gradient(720px 330px at 50% -4%, rgba(31, 111, 235, 0.13), transparent 72%),
    radial-gradient(520px 420px at 103% 78%, rgba(38, 173, 221, .075), transparent 68%),
    linear-gradient(rgba(148, 163, 184, .038) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .038) 1px, transparent 1px),
    #ffffff;
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  isolation: isolate;
}

#moduleSection::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -140px;
  right: -120px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(31, 111, 235, .09);
  border-radius: 50%;
  box-shadow: inset 0 0 80px rgba(31, 111, 235, .035), 0 0 0 48px rgba(31,111,235,.018);
}

#moduleSection .top-bar {
  width: min(900px, 100%);
  min-height: 68px;
  padding: 0 0 18px;
  border: none;
  border-bottom: 1px solid rgba(182, 201, 220, .62);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  margin-bottom: clamp(36px, 5vh, 58px);
}

#moduleSection .top-bar h1 {
  font-size: clamp(24px, 3vw, 32px);
  color: #17212d;
}

.hero-intro {
  width: min(900px, 100%);
  margin-bottom: 24px;
  text-align: center;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  color: #3970aa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.hero-kicker span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2d8cff;
  box-shadow: 0 0 0 5px rgba(45,140,255,.1), 0 0 16px rgba(45,140,255,.42);
}

.hero-intro h2 {
  margin: 0;
  color: #102a46;
  font-size: clamp(34px, 4.6vw, 58px);
  font-weight: 780;
  line-height: 1.08;
  letter-spacing: -.045em;
}

.hero-intro p {
  max-width: 660px;
  margin: 18px auto 0;
  color: #63778e;
  font-size: clamp(14px, 1.3vw, 17px);
  line-height: 1.7;
}

#moduleSection .main-input-container {
  width: min(900px, 100%);
  position: relative;
  border-radius: 22px;
  border-color: rgba(177, 198, 220, .78);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 22px 54px rgba(17, 45, 75, 0.14), inset 0 1px 0 #ffffff;
  overflow: hidden;
}

.drag-overlay.dragging {
  z-index: 14000;
  inset: 18px;
  width: auto;
  height: auto;
  border: 2px dashed rgba(104, 174, 255, .8);
  border-radius: 28px;
  background: rgba(12, 39, 68, .78);
  box-shadow: inset 0 0 70px rgba(50, 143, 255, .14), 0 28px 70px rgba(4,15,30,.28);
  backdrop-filter: blur(16px);
}

.drag-overlay.dragging .drag-content {
  padding: 34px 42px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  background: rgba(255,255,255,.08);
}

.drag-overlay.dragging .drag-text {
  color: #ffffff;
  font-size: clamp(22px, 3vw, 34px);
}

.drag-overlay.dragging .drag-subtext {
  color: #bfd7ef;
}

#moduleSection .main-input-container::before {
  content: "";
  position: absolute;
  inset: 0 18% auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, #5b9ff0, transparent);
  opacity: .65;
}

#moduleSection .main-input-container:hover,
#moduleSection .main-input-container:focus-within {
  border-color: rgba(89, 143, 205, .72);
  box-shadow: 0 28px 68px rgba(17, 45, 75, .17), 0 0 0 4px rgba(31,111,235,.055);
  transform: translateY(-1px);
}

#moduleSection .DOC90-input-container {
  background: transparent;
}

#moduleSection .toolbar {
  padding: 10px 14px 14px;
  border-top: 1px solid #eef2f7;
  background: rgba(240, 246, 252, .78);
}

#moduleSection .icon-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(128px, 1fr));
  gap: 8px;
}

#moduleSection .link-btn,
#moduleSection .file-btn {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 15px;
  background: rgba(255,255,255,.84);
}

#moduleSection .link-btn {
  color: #0f5fc2;
  border-color: rgba(75, 139, 213, .36);
  background: linear-gradient(180deg, #f4f9ff, #e7f2ff);
  box-shadow: inset 0 1px 0 #ffffff, 0 5px 12px rgba(31,111,235,.08);
}

#moduleSection .link-btn:hover,
#moduleSection .file-btn:hover {
  color: #1558c0;
  border-color: #8fb4dc;
  background: #f5faff;
}

/* Ambient particle field: deliberately sparse and behind all product surfaces. */
.ambient-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient-particle {
  position: absolute;
  width: var(--particle-size, 3px);
  height: var(--particle-size, 3px);
  left: var(--particle-x);
  top: 108%;
  border-radius: 50%;
  background: rgba(43, 123, 211, var(--particle-alpha, .2));
  box-shadow: 0 0 10px rgba(43, 123, 211, .2);
  animation: particleDrift var(--particle-speed, 22s) linear infinite;
  animation-delay: var(--particle-delay, 0s);
}

.sidebar,
.main-content {
  position: relative;
  z-index: 1;
}

@keyframes particleDrift {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: .7; }
  100% { transform: translate3d(var(--particle-drift, 28px), -118vh, 0); opacity: 0; }
}

/* Shared tactile states for all real controls. */
.popup-close,
.language-toggle,
.model-select,
.avatar,
.link-btn,
.file-btn,
.template-call-btn,
.export-report-btn,
.clear-history-btn,
.apply-filter-btn,
.reset-filter-btn,
.login-btn,
.confirm-btn,
.btn,
.help-btn {
  transition: transform 130ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.popup-close:active,
.language-toggle:active,
.model-select:active,
.avatar:active,
.link-btn:active,
.file-btn:active,
.template-call-btn:active,
.export-report-btn:active,
.clear-history-btn:active,
.apply-filter-btn:active,
.reset-filter-btn:active,
.login-btn:active,
.confirm-btn:active,
.btn:active,
.help-btn:active {
  transform: translateY(1px) scale(.975) !important;
  box-shadow: none !important;
}

#moduleSection .toolbar-right {
  margin-left: auto;
}

.drop-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 12px;
  color: #74869a;
  font-size: 12px;
  white-space: nowrap;
}

.drop-hint i {
  color: #4d82bd;
  font-size: 10px;
}

.language-toggle {
  width: 48px;
  height: 44px;
  flex: 0 0 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd8e6;
  border-radius: 15px;
  background: rgba(255,255,255,.86);
  color: #31506f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.language-toggle:hover {
  border-color: #8eaccb;
  background: #edf5ff;
  color: #1558c0;
}

.model-select {
  min-height: 44px;
  padding-inline: 17px;
  border-radius: 15px;
  box-shadow: inset 0 1px 0 #ffffff, 0 4px 12px rgba(19,52,86,.05);
}

.send-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.46);
  box-shadow: 0 10px 22px rgba(31,111,235,.3), inset 0 1px 0 rgba(255,255,255,.35);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(31,111,235,.34), inset 0 1px 0 rgba(255,255,255,.42);
}

.export-report-btn,
.apply-filter-btn,
.template-call-btn,
.login-btn,
.confirm-btn.confirm {
  border: 1px solid rgba(255,255,255,.28);
  background: linear-gradient(180deg, #3288f3 0%, #1f6feb 100%);
  box-shadow: 0 8px 18px rgba(31,111,235,.2), inset 0 1px 0 rgba(255,255,255,.32);
}

.clear-history-btn,
.reset-filter-btn,
.confirm-btn.cancel {
  border-radius: 14px;
  background: rgba(255,255,255,.86);
  box-shadow: inset 0 1px 0 #ffffff, 0 4px 10px rgba(15,35,60,.04);
}

.language-toggle:active {
  transform: translateY(1px) scale(.98);
}

.language-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd8e6;
  border-radius: 15px;
  background: rgba(255,255,255,.86);
  color: #31506f;
  cursor: pointer;
  box-shadow: inset 0 1px 0 #ffffff, 0 4px 12px rgba(19,52,86,.05);
  transition: transform 130ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.theme-toggle:hover {
  border-color: #8eaccb;
  color: #1558c0;
  background: #edf5ff;
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(1px) scale(.96);
  box-shadow: none;
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 600;
    width: 74px;
    min-width: 74px;
    padding: 16px 7px;
    border-radius: 0 18px 18px 0;
  }

  .sidebar-item {
    width: 58px;
    min-height: 60px;
  }

  .main-content {
    margin-left: 74px;
    padding: 10px;
  }

  #moduleSection,
  #processingSection {
    border-radius: 20px;
  }

  #moduleSection {
    padding: clamp(30px, 6vh, 54px) 18px 32px;
  }

  #moduleSection .top-bar {
    padding-bottom: 12px;
  }

  #moduleSection .icon-group {
    width: 100%;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 66px;
  }

  .sidebar,
  .sidebar.collapsed {
    inset: auto 0 0;
    width: 100%;
    min-width: 0;
    height: 66px;
    padding: 7px 8px;
    flex-direction: row;
    justify-content: space-between;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.16);
  }

  .sidebar-item {
    width: auto;
    min-width: 44px;
    min-height: 50px;
    flex: 1 1 0;
    padding: 7px 5px;
    gap: 0;
  }

  .sidebar.collapsed .sidebar-item {
    width: auto;
    min-width: 44px;
    flex: 1 1 0;
  }

  .sidebar-item span {
    display: none;
  }

  .sidebar-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    margin: 0 3px 0 0;
  }

  .main-content {
    margin-left: 0;
    padding: 8px 8px 0;
    min-height: calc(100vh - 66px);
  }

  #moduleSection,
  #processingSection {
    min-height: calc(100vh - 82px);
  }

  #moduleSection {
    padding: 28px 16px 30px;
  }

  #moduleSection .top-bar {
    margin-bottom: 28px;
  }

  #moduleSection .toolbar {
    align-items: stretch;
  }

  #moduleSection .toolbar-right {
    margin-left: 0;
  }

  #moduleSection .icon-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .sidebar,
  .sidebar.collapsed {
    width: 100%;
    min-width: 0;
  }

  .main-content {
    margin-left: 0;
  }
}

/* Competition presentation pass: compose the workspace and overlays as one product. */
.mask-layer,
.login-mask,
.confirm-mask {
  padding: clamp(14px, 3vw, 34px);
  background: rgba(9, 22, 38, 0.62) !important;
  backdrop-filter: blur(12px) saturate(0.82);
}

@keyframes modalBackdropIn {
  from { opacity: 0; backdrop-filter: blur(0) saturate(.9); }
  to { opacity: 1; backdrop-filter: blur(12px) saturate(.82); }
}

@keyframes modalBackdropOut {
  from { opacity: 1; backdrop-filter: blur(12px) saturate(.82); }
  to { opacity: 0; backdrop-filter: blur(0) saturate(.9); }
}

@keyframes modalPanelIn {
  0% { opacity: 0; transform: translateY(18px) scale(.965); filter: blur(5px); }
  62% { opacity: 1; transform: translateY(-2px) scale(1.004); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes modalPanelOut {
  from { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  to { opacity: 0; transform: translateY(10px) scale(.978); filter: blur(3px); }
}

.mask-layer.ui-modal-open,
.login-mask.ui-modal-open,
.confirm-mask.ui-modal-open {
  animation: modalBackdropIn 240ms cubic-bezier(.2, .8, .2, 1) both;
}

.mask-layer.ui-modal-closing,
.login-mask.ui-modal-closing,
.confirm-mask.ui-modal-closing {
  pointer-events: none;
  animation: modalBackdropOut 220ms ease-in both;
}

.ui-modal-open > .template-popup,
.ui-modal-open > .login-box,
.ui-modal-open > .confirm-box {
  transform-origin: 50% 42%;
  animation: modalPanelIn 360ms cubic-bezier(.16, 1, .3, 1) both;
}

.ui-modal-closing > .template-popup,
.ui-modal-closing > .login-box,
.ui-modal-closing > .confirm-box {
  animation: modalPanelOut 210ms cubic-bezier(.4, 0, 1, 1) both;
}

.help-controls.ui-help-open {
  animation: helpBackdropIn 220ms ease-out both;
}

.help-controls.ui-help-closing {
  pointer-events: none !important;
  animation: helpBackdropOut 200ms ease-in both;
}

@media (prefers-reduced-motion: reduce) {
  .mask-layer.ui-modal-open,
  .login-mask.ui-modal-open,
  .confirm-mask.ui-modal-open,
  .mask-layer.ui-modal-closing,
  .login-mask.ui-modal-closing,
  .confirm-mask.ui-modal-closing,
  .ui-modal-open > .template-popup,
  .ui-modal-open > .login-box,
  .ui-modal-open > .confirm-box,
  .ui-modal-closing > .template-popup,
  .ui-modal-closing > .login-box,
  .ui-modal-closing > .confirm-box,
  .help-controls.ui-help-open,
  .help-controls.ui-help-closing {
    animation-duration: 1ms !important;
  }
}

#maskLayer { z-index: 12000; }
#loginMask,
#changePasswordMask,
#changeUsernameMask { z-index: 13000; }
#historyMaskLayer { z-index: 13200; }
#statsMaskLayer { z-index: 13300; }
#cacheMaskLayer { z-index: 13400; }
#confirmMask { z-index: 15000; }
#helpMaskLayer { z-index: 16000 !important; }
#helpControls { z-index: 16010 !important; }
.user-card { z-index: 12500; }
.model-menu { z-index: 3000; }

.mask-layer::before,
.login-mask::before,
.confirm-mask::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(650px 360px at 50% 8%, rgba(79, 146, 255, 0.18), transparent 68%);
}

.template-popup,
.login-box,
.confirm-box {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: #f8fafc;
  box-shadow: 0 30px 90px rgba(4, 15, 30, 0.34), 0 2px 8px rgba(4, 15, 30, 0.12);
}

.template-popup {
  width: min(1180px, 94vw);
  height: min(760px, 86vh);
  border-radius: 28px;
}

.template-list-section {
  padding: 28px;
  background: #f8fafc;
  border-right-color: #dce5ef;
}

.template-preview-section {
  min-width: 340px;
  padding: 28px 24px 22px;
  background: #eef3f8;
  border-left: 1px solid rgba(203, 213, 225, 0.72);
}

.popup-head {
  min-height: 42px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #dce5ef;
}

.popup-head h3,
.template-preview-section h4 {
  margin: 0;
  color: #10243a;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.popup-close {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dce5ef;
  border-radius: 14px;
  background: #ffffff;
  color: #6b7e93;
  font-size: 21px;
}

.popup-close:hover {
  border-color: #bac9d9;
  background: #edf2f7;
  color: #10243a;
}

.template-list-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  margin-bottom: 10px;
}

.search-input {
  margin: 0;
  min-height: 48px;
  border-radius: 15px;
  border-color: #cdd9e6;
  background: #ffffff;
}

.template-filter select {
  width: 100%;
  min-height: 48px;
  border-radius: 15px;
}

.upload-new-tpl {
  display: none;
}

.template-drop-area {
  margin: 0 0 16px !important;
  min-height: 108px;
  padding: 22px !important;
  display: grid;
  place-items: center;
  border: 1px dashed #9db1c8 !important;
  border-radius: 18px !important;
  background: #f1f5f9 !important;
}

.template-drop-area:hover {
  border-color: #4d82c2 !important;
  background: #eaf2fc !important;
}

.history-tpl-list {
  gap: 10px;
  margin-top: 0;
}

.history-tpl-item {
  min-height: 68px;
  padding: 12px 14px;
  border-color: #dce5ef;
  border-radius: 18px;
  background: #ffffff;
}

.history-tpl-item.selected {
  background: #edf5ff;
  border-color: #75a7e6;
  box-shadow: inset 3px 0 0 #1f6feb;
}

.template-preview-content {
  min-height: 0;
  margin: 14px 0 16px;
  padding: 18px;
  border-color: #d5e0eb;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
  border-radius: 18px;
}

.template-preview-content > p {
  margin: auto;
  max-width: 220px;
  color: #708196;
  line-height: 1.7;
  text-align: center;
}

.template-call-btn {
  min-height: 50px;
  border-radius: 16px;
}

/* Login: stronger hierarchy, less generic form-card appearance. */
.login-box {
  width: min(460px, 100%);
  padding: 38px 38px 30px;
  border-radius: 28px;
  overflow: hidden;
}

.login-box::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #1f6feb, #65a6f5 55%, #9cc9ff);
}

.modal-badge {
  margin-bottom: 18px;
  color: #1859ad;
  background: #eaf3ff;
  border-color: #cfe2fa;
}

.login-title-container {
  margin-bottom: 22px;
  background: #e9eff6;
  border-color: #d8e1eb;
  border-radius: 17px;
}

.login-title.active {
  color: #123154;
  box-shadow: 0 3px 10px rgba(15, 35, 60, 0.09);
  border-radius: 14px;
}

.modal-subtitle {
  margin-bottom: 20px;
  color: #60738a;
}

.login-input {
  min-height: 50px;
  border-color: #cedae7;
  background: #ffffff;
  border-radius: 16px;
}

.login-btn {
  min-height: 50px;
  background: #1f6feb;
  box-shadow: 0 10px 24px rgba(31, 111, 235, 0.22);
  border-radius: 16px;
}

/* History: compact operational surface instead of an oversized blank sheet. */
#historyMaskLayer .template-popup {
  width: min(1180px, 94vw);
  height: min(720px, 84vh);
}

#historyMaskLayer .history-section {
  padding: 24px;
  background: #f6f8fb;
}

#historyMaskLayer .popup-head {
  margin-bottom: 14px;
}

.history-filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(3, auto) auto;
  align-items: end;
  padding: 14px;
  border: 1px solid #dce5ef;
  border-radius: 18px;
  background: #ffffff;
}

.history-filter-group {
  display: grid;
  gap: 5px;
}

.history-filter-label {
  color: #6b7e93;
  font-size: 11px;
  font-weight: 700;
}

.history-table-wrapper {
  margin-top: 14px;
  border: 1px solid #dce5ef;
  border-radius: 18px;
  background: #ffffff;
  overflow: hidden;
}

.history-table thead {
  background: #edf2f7;
}

.history-list-container {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(180deg, transparent 0 48px, #eef2f6 48px 49px);
}

#historyTableBody td[colspan] {
  height: 300px;
  vertical-align: middle;
  color: #8493a5;
  font-size: 14px;
}

/* Statistics: dense dashboard treatment, overriding the legacy inline rules. */
#statsMaskLayer .template-popup {
  width: min(960px, 94vw) !important;
  height: min(780px, 88vh);
}

#statsMaskLayer .template-list-section {
  padding: 24px !important;
  background: #f6f8fb;
}

#statsMaskLayer .template-list-section > div:last-child {
  padding: 0 !important;
}

#statsMaskLayer .stats-filters {
  margin-bottom: 16px !important;
  padding: 12px 14px;
  border: 1px solid #dce5ef;
  border-radius: 18px;
  background: #ffffff;
}

#statsMaskLayer .stats-overview {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 10px !important;
  margin-bottom: 18px !important;
}

#statsMaskLayer .stat-card {
  min-height: 96px;
  padding: 16px !important;
  border: 1px solid #dce5ef;
  border-radius: 18px !important;
  background: #ffffff !important;
  box-shadow: none !important;
}

#statsMaskLayer .stat-value {
  color: #10243a;
  font-size: 25px !important;
}

#statsMaskLayer .stats-section {
  margin-bottom: 14px !important;
  padding: 16px;
  border: 1px solid #dce5ef;
  background: #ffffff;
  box-shadow: none;
  border-radius: 18px;
}

#statsMaskLayer .stats-section h4 {
  margin: 0 0 12px !important;
  color: #38506a;
  font-size: 14px;
}

#statsMaskLayer .stats-table th {
  padding: 10px 12px !important;
  border-color: #dce5ef !important;
  background: #edf2f7;
  color: #38506a;
  font-size: 12px;
}

/* Cache is a focused destructive-action dialog, not a full workspace. */
#cacheMaskLayer .template-popup {
  width: min(580px, 92vw);
  height: auto;
  min-height: 0;
  border-radius: 26px;
}

#cacheMaskLayer .template-list-section {
  padding: 26px !important;
  background: #ffffff;
}

#cacheMaskLayer .template-list-section > div:last-child {
  padding: 2px 0 0 !important;
}

#cacheMaskLayer p {
  margin: 0 0 20px !important;
  padding: 14px 16px;
  border-left: 3px solid #f59e0b;
  border-radius: 0 10px 10px 0;
  background: #fff8e8;
  color: #5c4930;
}

#cacheMaskLayer #confirmClearCache {
  width: 100%;
  min-height: 46px;
  background: #c2413b !important;
  box-shadow: 0 9px 20px rgba(194, 65, 59, 0.2) !important;
}

#cacheMaskLayer #cacheResult:empty {
  display: none;
}

/* Help controls become one coherent floating control rail. */
#helpControls .help-close {
  top: 22px !important;
  right: 24px !important;
  padding: 9px 15px !important;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 10px;
  background: rgba(10, 27, 45, .72);
  font-size: 14px !important;
}

#helpControls .help-btn {
  bottom: 22px !important;
  min-width: 98px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 11px;
  background: rgba(255,255,255,.94);
  color: #17324f;
  box-shadow: 0 10px 28px rgba(4, 15, 30, .2);
}

#helpControls .help-step {
  bottom: 26px !important;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 27, 45, .78);
  font-weight: 700;
}

@media (max-width: 760px) {
  .template-popup {
    width: calc(100vw - 20px);
    height: calc(100vh - 86px);
    border-radius: 18px;
  }

  .template-list-section,
  .template-preview-section {
    min-width: 0;
    padding: 18px;
  }

  .template-preview-section {
    display: none;
  }

  .template-list-header,
  .history-filter-bar {
    grid-template-columns: 1fr;
  }

  #historyMaskLayer .template-popup,
  #statsMaskLayer .template-popup {
    width: calc(100vw - 20px) !important;
    height: calc(100vh - 86px);
  }

  #historyMaskLayer .history-section,
  #statsMaskLayer .template-list-section {
    padding: 16px !important;
  }

  .history-toolbar {
    gap: 6px;
  }

  .history-toolbar .export-report-btn,
  .history-toolbar .clear-history-btn {
    width: auto;
    padding-inline: 10px;
  }

  #statsMaskLayer .stats-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .login-box {
    padding: 32px 24px 24px;
  }

  .hero-intro {
    margin-bottom: 18px;
  }

  .hero-intro h2 {
    font-size: clamp(30px, 10vw, 42px);
  }

  .hero-intro p {
    margin-top: 12px;
  }

  .drop-hint {
    display: none;
  }
}

/* Layout correction: equal card inset and Codex-like navigation rail. */
@media (min-width: 901px) {
  .sidebar {
    width: 228px;
    min-width: 228px;
    padding: 18px 12px;
    align-items: stretch;
    border-right: 1px solid #d9e0e8;
    border-radius: 0;
    background: rgba(244, 246, 249, .96);
    box-shadow: none;
    color: #273444;
  }

  .sidebar-toggle {
    width: 38px;
    height: 38px;
    margin: 0 0 20px 2px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
  }

  .sidebar-toggle:hover {
    border-color: #d8dee7;
    background: #e8ecf1;
  }

  .sidebar-toggle img,
  .sidebar-item img,
  .sidebar.collapsed .sidebar-item img {
    filter: none;
    opacity: .72;
  }

  .sidebar-item {
    width: 100%;
    min-height: 42px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 10px;
    color: #354354;
    text-align: left;
  }

  .sidebar-item span {
    font-size: 13px;
    font-weight: 550;
  }

  .sidebar-item:hover {
    color: #182433;
    border-color: transparent;
    background: #e6eaf0;
    transform: none;
  }

  .sidebar-item:hover img {
    filter: none;
    opacity: 1;
  }

  #newTaskBtn {
    margin-bottom: 10px;
    color: #182433;
    background: #e8ecf2;
  }

  .sidebar.collapsed {
    width: 64px;
    min-width: 64px;
    padding-inline: 10px;
  }

  .sidebar.collapsed .sidebar-item {
    width: 42px;
    min-width: 42px;
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar.collapsed .sidebar-item span {
    display: none;
  }
}

/* High-clarity interaction pass for sidebar tools and their four work surfaces. */
@media (min-width: 901px) {
  .sidebar-item {
    position: relative;
    border: 1px solid transparent;
    border-radius: 14px;
    color: #465568;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    transition: color 160ms ease, background 180ms ease, border-color 180ms ease, box-shadow 200ms ease, transform 160ms cubic-bezier(.2,.8,.2,1);
  }

  .sidebar-item::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 50%;
    width: 3px;
    height: 0;
    border-radius: 99px;
    background: #2d7fe5;
    box-shadow: 0 0 12px rgba(45,127,229,.42);
    transform: translateY(-50%);
    transition: height 180ms cubic-bezier(.2,.8,.2,1);
  }

  .sidebar-item:hover {
    color: #172b43;
    border-color: rgba(133,161,193,.18);
    background: rgba(255,255,255,.72);
    box-shadow: 0 8px 22px rgba(37,58,83,.08), inset 0 1px 0 rgba(255,255,255,.8);
    transform: translateX(3px);
  }

  .sidebar-item:hover::before { height: 22px; }

  .sidebar-item:active {
    color: #195fae;
    background: rgba(222,237,253,.9);
    box-shadow: inset 0 2px 5px rgba(39,84,133,.1);
    transform: translateX(2px) scale(.985);
    transition-duration: 70ms;
  }

  .sidebar-item img {
    opacity: .7;
    transition: opacity 160ms ease, filter 180ms ease, transform 180ms cubic-bezier(.2,.8,.2,1);
  }

  .sidebar-item:hover img {
    opacity: 1;
    filter: brightness(0) saturate(100%) invert(42%) sepia(86%) saturate(1112%) hue-rotate(184deg) brightness(92%);
    transform: scale(1.07);
  }

  .sidebar-item:active img { transform: scale(.96); }
}

/* Shared button grammar for History, Help, Analytics and Clear cache. */
#historyMaskLayer button,
#statsMaskLayer button,
#cacheMaskLayer button,
#helpControls button,
#historyMaskLayer .popup-close,
#statsMaskLayer .popup-close,
#cacheMaskLayer .popup-close {
  position: relative;
  overflow: hidden;
  border-radius: 13px !important;
  cursor: pointer;
  transition: color 150ms ease, background 170ms ease, border-color 170ms ease, box-shadow 190ms ease, transform 120ms cubic-bezier(.2,.8,.2,1) !important;
}

#historyMaskLayer button:hover,
#statsMaskLayer button:hover,
#cacheMaskLayer button:hover,
#helpControls button:hover,
#historyMaskLayer .popup-close:hover,
#statsMaskLayer .popup-close:hover,
#cacheMaskLayer .popup-close:hover {
  transform: translateY(-2px);
}

#historyMaskLayer button:active,
#statsMaskLayer button:active,
#cacheMaskLayer button:active,
#helpControls button:active,
#historyMaskLayer .popup-close:active,
#statsMaskLayer .popup-close:active,
#cacheMaskLayer .popup-close:active {
  transform: translateY(0) scale(.965);
  box-shadow: inset 0 2px 6px rgba(12,35,62,.16) !important;
  transition-duration: 60ms !important;
}

#historyMaskLayer .export-report-btn,
#historyMaskLayer .apply-filter-btn,
#statsMaskLayer #statsRefreshBtn,
#statsMaskLayer #statsError .btn {
  color: #fff !important;
  border: 1px solid #2778d8 !important;
  background: linear-gradient(180deg, #3a90ef, #2375d5) !important;
  box-shadow: 0 8px 18px rgba(37,118,214,.2), inset 0 1px 0 rgba(255,255,255,.24) !important;
}

#historyMaskLayer .export-report-btn:hover,
#historyMaskLayer .apply-filter-btn:hover,
#statsMaskLayer #statsRefreshBtn:hover,
#statsMaskLayer #statsError .btn:hover {
  border-color: #1764bf !important;
  background: linear-gradient(180deg, #469bf4, #196bc9) !important;
  box-shadow: 0 12px 25px rgba(37,118,214,.28), inset 0 1px 0 rgba(255,255,255,.28) !important;
}

#historyMaskLayer .reset-filter-btn,
#historyMaskLayer .clear-history-btn,
#cacheMaskLayer #confirmClearCache {
  min-height: 42px;
  padding-inline: 16px !important;
  border: 1px solid #d6e0ea !important;
  color: #40536a !important;
  background: rgba(255,255,255,.9) !important;
  box-shadow: 0 5px 14px rgba(31,53,79,.06) !important;
}

#historyMaskLayer .reset-filter-btn:hover {
  color: #1765bb !important;
  border-color: #9cc2ee !important;
  background: #f0f7ff !important;
}

#historyMaskLayer .clear-history-btn:hover,
#cacheMaskLayer #confirmClearCache:hover {
  color: #bd3d32 !important;
  border-color: #efb8b2 !important;
  background: #fff4f2 !important;
  box-shadow: 0 10px 22px rgba(190,61,50,.1) !important;
}

#historyMaskLayer .popup-close,
#statsMaskLayer .popup-close,
#cacheMaskLayer .popup-close {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #d8e1ea;
  color: #65768a;
  background: rgba(255,255,255,.78);
}

#historyMaskLayer .popup-close:hover,
#statsMaskLayer .popup-close:hover,
#cacheMaskLayer .popup-close:hover {
  color: #243950;
  border-color: #aabed3;
  background: #fff;
  box-shadow: 0 8px 20px rgba(30,54,82,.1);
}

/* One native-select appearance everywhere these surfaces expose choices. */
#historyMaskLayer select,
#statsMaskLayer select,
#maskLayer select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 116px;
  height: 42px !important;
  padding: 0 40px 0 13px !important;
  border: 1px solid #d5dfe9 !important;
  border-radius: 13px !important;
  color: #30445b;
  background-color: #f8fafc !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2365778b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 15px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  cursor: pointer;
  outline: none;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 180ms ease, transform 120ms ease;
}

#historyMaskLayer select:hover,
#statsMaskLayer select:hover,
#maskLayer select:hover {
  border-color: #a9bfd6 !important;
  background-color: #fff !important;
  box-shadow: 0 5px 15px rgba(31,63,99,.07);
}

#historyMaskLayer select:focus,
#statsMaskLayer select:focus,
#maskLayer select:focus {
  border-color: #5b9ee9 !important;
  background-color: #fff !important;
  box-shadow: 0 0 0 4px rgba(49,132,228,.11), 0 7px 18px rgba(31,81,137,.08);
}

#historyMaskLayer select:active,
#statsMaskLayer select:active,
#maskLayer select:active { transform: scale(.985); }

html[data-theme="dark"] .sidebar-item:hover {
  color: #f0f3f6;
  border-color: #333942;
  background: #22262c;
  box-shadow: 0 8px 22px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.035);
}

html[data-theme="dark"] .sidebar-item:active { color: #8bbcf1; background: #252c34; }

html[data-theme="dark"] #historyMaskLayer select,
html[data-theme="dark"] #statsMaskLayer select,
html[data-theme="dark"] #maskLayer select {
  color: #d9e0e8;
  border-color: #3a414b !important;
  background-color: #202329 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ba8b7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}

html[data-theme="dark"] #historyMaskLayer select:hover,
html[data-theme="dark"] #statsMaskLayer select:hover,
html[data-theme="dark"] #maskLayer select:hover,
html[data-theme="dark"] #historyMaskLayer select:focus,
html[data-theme="dark"] #statsMaskLayer select:focus,
html[data-theme="dark"] #maskLayer select:focus { background-color: #272b31 !important; }

/* DOC90 notification center. */
.toast-container {
  position: fixed;
  z-index: 18000;
  top: 20px;
  right: 20px;
  width: min(390px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  --toast-accent: #3b82f6;
  --toast-soft: rgba(59,130,246,.11);
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 32px;
  align-items: start;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 14px 13px 16px 14px;
  overflow: hidden;
  border: 1px solid rgba(170,187,205,.52);
  border-radius: 18px;
  color: #27394e;
  background: rgba(250,252,255,.94);
  box-shadow: 0 18px 50px rgba(20,42,68,.16), inset 0 1px 0 rgba(255,255,255,.94);
  backdrop-filter: blur(18px) saturate(1.08);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(28px) scale(.97);
  transform-origin: right top;
  transition: opacity 260ms ease, transform 340ms cubic-bezier(.16,1,.3,1), box-shadow 180ms ease;
}

.toast::before { display: none; }
.toast.show { opacity: 1; transform: translateX(0) scale(1); }
.toast:hover { box-shadow: 0 22px 58px rgba(20,42,68,.21), inset 0 1px 0 rgba(255,255,255,.96); }
.toast.toast-leaving { opacity: 0; transform: translateX(34px) scale(.96); }

.toast-success { --toast-accent: #16a36a; --toast-soft: rgba(22,163,106,.11); }
.toast-warning { --toast-accent: #dc8b17; --toast-soft: rgba(220,139,23,.12); }
.toast-error { --toast-accent: #dc4b47; --toast-soft: rgba(220,75,71,.11); }

.toast-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--toast-accent) 22%, transparent);
  border-radius: 12px;
  color: var(--toast-accent);
  background: var(--toast-soft);
  font-size: 14px;
}

.toast-copy { min-width: 0; padding-top: 1px; }

.toast-title {
  margin-bottom: 3px;
  color: #192c43;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
}

.toast-content {
  color: #62758b;
  font-size: 12.5px;
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.toast-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #8391a1;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 100ms ease;
}

.toast-close:hover { color: #30445b; background: rgba(97,119,144,.1); }
.toast-close:active { transform: scale(.9); }

.toast-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--toast-accent);
  transform-origin: left;
  animation: toastCountdown var(--toast-duration, 3200ms) linear forwards;
}

.toast.toast-paused .toast-progress { animation-play-state: paused; }

@keyframes toastCountdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

html[data-theme="dark"] .toast {
  color: #e7ebf0;
  border-color: #363c45;
  background: rgba(28,31,36,.95);
  box-shadow: 0 20px 56px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.035);
}

html[data-theme="dark"] .toast-title { color: #f1f3f6; }
html[data-theme="dark"] .toast-content { color: #aab4c0; }
html[data-theme="dark"] .toast-close { color: #8994a1; }
html[data-theme="dark"] .toast-close:hover { color: #fff; background: rgba(255,255,255,.08); }

@media (max-width: 640px) {
  .toast-container { top: auto; right: 16px; bottom: 18px; left: 16px; width: auto; }
  .toast { grid-template-columns: 36px minmax(0, 1fr) 30px; padding: 13px 12px 15px; border-radius: 17px; }
  .toast-icon { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition-duration: 1ms !important; }
  .toast-progress { animation: none; }
}

/* Complete dark treatment for the History workspace. */
html[data-theme="dark"] #historyMaskLayer .template-popup,
html[data-theme="dark"] #historyMaskLayer .history-section {
  color: #e6e9ee;
  border-color: #343942 !important;
  background: #181b20 !important;
}

html[data-theme="dark"] #historyMaskLayer .popup-head {
  border-bottom-color: #343a43;
}

html[data-theme="dark"] #historyMaskLayer .history-filter-bar {
  border-color: #363c45 !important;
  background: #202328 !important;
  box-shadow: 0 12px 30px rgba(0,0,0,.16);
}

html[data-theme="dark"] #historyMaskLayer .history-filter-label {
  color: #8996a5;
}

html[data-theme="dark"] #historyMaskLayer .search-input,
html[data-theme="dark"] #historyMaskLayer select {
  color: #dce2e9 !important;
  border-color: #3c424c !important;
  background-color: #1b1e23 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}

html[data-theme="dark"] #historyMaskLayer .search-input::placeholder {
  color: #778391;
}

html[data-theme="dark"] #historyMaskLayer .search-input:hover,
html[data-theme="dark"] #historyMaskLayer select:hover {
  border-color: #505965 !important;
  background-color: #22262c !important;
}

html[data-theme="dark"] #historyMaskLayer .search-input:focus,
html[data-theme="dark"] #historyMaskLayer select:focus {
  border-color: #568fcf !important;
  background-color: #22262c !important;
  box-shadow: 0 0 0 4px rgba(65,137,218,.12) !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table-wrapper {
  border-color: #363c45 !important;
  background: #1b1e23 !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table,
html[data-theme="dark"] #historyMaskLayer .history-list-container,
html[data-theme="dark"] #historyMaskLayer .history-table-body,
html[data-theme="dark"] #historyMaskLayer #historyTableBody {
  color: #cbd3dc;
  background: #1b1e23 !important;
  background-image: none !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table thead,
html[data-theme="dark"] #historyMaskLayer .history-table-header thead {
  color: #cdd6e0 !important;
  background: #24282e !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table th {
  color: #cdd6e0 !important;
  border-color: #363c45 !important;
  background: #24282e !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table td {
  color: #b8c2ce;
  border-color: #30353d !important;
  background: #1b1e23 !important;
}

html[data-theme="dark"] #historyMaskLayer .history-table tbody tr:hover td {
  background: #22262c !important;
}

html[data-theme="dark"] #historyMaskLayer #historyTableBody td[colspan] {
  color: #7f8a97;
  background: #1b1e23 !important;
}

html[data-theme="dark"] #historyMaskLayer input[type="checkbox"] {
  accent-color: #438bdd;
}

html[data-theme="dark"] #historyMaskLayer .reset-filter-btn,
html[data-theme="dark"] #historyMaskLayer .clear-history-btn,
html[data-theme="dark"] #historyMaskLayer .popup-close {
  color: #c4ccd5 !important;
  border-color: #3a414a !important;
  background: #25292f !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025) !important;
}

html[data-theme="dark"] #historyMaskLayer .reset-filter-btn:hover,
html[data-theme="dark"] #historyMaskLayer .popup-close:hover {
  color: #f2f4f7 !important;
  border-color: #505966 !important;
  background: #2d3239 !important;
}

html[data-theme="dark"] #historyMaskLayer .clear-history-btn:hover {
  color: #ffaaa3 !important;
  border-color: #70433f !important;
  background: #352422 !important;
}

html[data-theme="dark"] #historyMaskLayer .history-action-btn {
  color: #c8d1dc;
  border-color: #3b424c;
  background: #24282e;
}

html[data-theme="dark"] #historyMaskLayer .history-action-btn:hover {
  color: #ffffff;
  border-color: #4e77a5;
  background: #29394b;
}

/* Bring runtime-generated legacy subviews into the same component system. */
.preview-sidebar,
.question-dialog,
.result-output-block,
.result-file-card,
.user-message .message-content,
.bot-message .message-content {
  border-radius: 18px;
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.toolbar-btn,
.header-btn,
.history-action-btn,
.btn-result-icon,
.btn-result-download,
.btn-result-preview,
.btn-result-saveas {
  min-height: 38px;
  border: 1px solid #d3dde8;
  border-radius: 12px;
  background: #ffffff;
  color: #2c4055;
  transition: transform 130ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.toolbar-btn:hover,
.header-btn:hover,
.history-action-btn:hover,
.btn-result-icon:hover,
.btn-result-download:hover,
.btn-result-preview:hover,
.btn-result-saveas:hover {
  border-color: #9cb6d2;
  background: #f2f7fc;
  box-shadow: 0 6px 15px rgba(15,35,60,.08);
  transform: translateY(-1px);
}

.toolbar-btn:active,
.header-btn:active,
.history-action-btn:active,
.btn-result-icon:active,
.btn-result-download:active,
.btn-result-preview:active,
.btn-result-saveas:active {
  transform: translateY(1px) scale(.97);
  box-shadow: none;
}

html[data-theme="dark"] .preview-sidebar,
html[data-theme="dark"] .question-dialog,
html[data-theme="dark"] .result-output-block,
html[data-theme="dark"] .result-file-card,
html[data-theme="dark"] .user-message .message-content,
html[data-theme="dark"] .bot-message .message-content {
  color: #e5e7eb;
  border-color: #383d45;
  background: #1b1e23;
}

html[data-theme="dark"] .toolbar-btn,
html[data-theme="dark"] .header-btn,
html[data-theme="dark"] .history-action-btn,
html[data-theme="dark"] .btn-result-icon,
html[data-theme="dark"] .btn-result-download,
html[data-theme="dark"] .btn-result-preview,
html[data-theme="dark"] .btn-result-saveas {
  color: #d8dce2;
  border-color: #3b4048;
  background: #23262b;
}

#moduleSection {
  padding: clamp(28px, 3.2vw, 48px);
}

#moduleSection .top-bar {
  width: 100%;
  min-height: 48px;
  margin-bottom: clamp(48px, 7vh, 74px);
  padding: 0 0 18px;
}

#moduleSection .top-left {
  align-self: flex-start;
}

#moduleSection .top-left .logo,
#processingSection .top-left .logo {
  display: block;
  width: 44px;
  height: 44px;
  padding: 5px;
  border: 1px solid rgba(151, 183, 218, .46);
  border-radius: 14px;
  object-fit: contain;
  background: rgba(255,255,255,.9);
  box-shadow: 0 7px 18px rgba(31,111,235,.13), inset 0 1px 0 #ffffff;
  cursor: pointer;
  transition: transform 140ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#moduleSection .top-left .logo:hover,
#processingSection .top-left .logo:hover {
  transform: translateY(-2px);
  border-color: rgba(61, 132, 211, .62);
  background: #ffffff;
  box-shadow: 0 11px 24px rgba(31,111,235,.18), 0 0 0 4px rgba(31,111,235,.06);
}

#moduleSection .top-left .logo:active,
#processingSection .top-left .logo:active {
  transform: translateY(1px) scale(.96);
  box-shadow: 0 3px 8px rgba(31,111,235,.12);
}

#moduleSection .top-left h1,
#processingSection .top-left h1 {
  display: block;
  position: relative;
  margin: 0;
  padding: 1px 1px 5px 0;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .025em;
  background: linear-gradient(105deg, #10233b 0 48%, #246fca 74%, #10233b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 7px 18px rgba(22, 67, 116, .12);
  transform: skewX(-5deg) scaleY(1.04);
  transform-origin: left center;
}

#moduleSection .top-left h1::after,
#processingSection .top-left h1::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 1px;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f6feb, rgba(31,111,235,0));
  opacity: .7;
}

#moduleSection .top-right {
  align-self: flex-start;
  gap: 10px;
}

@media (max-width: 640px) {
  #moduleSection {
    padding: 22px;
  }

  #moduleSection .top-bar,
  #processingSection .top-bar {
    width: 100%;
    margin-bottom: 38px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  #moduleSection .top-left h1,
  #processingSection .top-left h1 {
    font-size: 23px;
  }

  #moduleSection .top-left .logo,
  #processingSection .top-left .logo {
    width: 38px;
    height: 38px;
    padding: 4px;
    border-radius: 12px;
  }

  #moduleSection .top-right,
  #processingSection .top-right {
    width: auto;
    flex: 0 1 auto;
    gap: 6px;
  }

  .language-toggle {
    width: 36px;
    height: 38px;
    flex-basis: 36px;
    border-radius: 13px;
    font-size: 11px;
  }

  .model-dropdown {
    min-width: 0;
    width: min(104px, 30vw);
    flex: 0 1 104px;
  }

  .model-select {
    min-height: 40px;
    padding-inline: 12px;
    border-radius: 13px;
    font-size: 12px;
  }

  .avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .theme-toggle {
    width: 36px;
    height: 38px;
    flex-basis: 36px;
    border-radius: 13px;
  }

  #moduleSection .link-btn,
  #moduleSection .file-btn {
    padding-inline: 9px;
    font-size: 12px;
  }

  #moduleSection .link-text,
  #moduleSection .file-text {
    overflow: visible;
    text-overflow: clip;
  }
}

/* Complete dark theme surface system. */
html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  color: #e7edf5;
  background: linear-gradient(145deg, #090a0c, #111317 52%, #0a0b0d);
}

@media (min-width: 901px) {
  html[data-theme="dark"] .sidebar {
    color: #d4dce7;
    border-right-color: #26292e;
    background: #121417;
  }

  html[data-theme="dark"] .sidebar-item {
    color: #b7c2cf;
  }

  html[data-theme="dark"] .sidebar-item:hover,
  html[data-theme="dark"] #newTaskBtn {
    color: #f4f7fb;
    background: #24272c;
  }

  html[data-theme="dark"] .sidebar-toggle:hover {
    border-color: #34383e;
    background: #24272c;
  }

  html[data-theme="dark"] .sidebar-toggle img,
  html[data-theme="dark"] .sidebar-item img {
    filter: brightness(0) invert(1);
    opacity: .72;
  }
}

html[data-theme="dark"] #moduleSection,
html[data-theme="dark"] #processingSection {
  border-color: #292d33;
  background:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px),
    rgba(18, 20, 24, .96);
  background-size: 42px 42px, 42px 42px, auto;
  box-shadow: 0 30px 90px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.035);
}

html[data-theme="dark"] #moduleSection .top-bar,
html[data-theme="dark"] #processingSection .top-bar {
  border-bottom-color: #2a394a;
}

html[data-theme="dark"] #moduleSection .top-left h1,
html[data-theme="dark"] #processingSection .top-left h1 {
  background: linear-gradient(105deg, #f0f5fb 0 48%, #68a9f4 74%, #dbe8f6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html[data-theme="dark"] .hero-intro h2 { color: #f2f6fb; }
html[data-theme="dark"] .hero-intro p { color: #9fb0c3; }
html[data-theme="dark"] .hero-kicker { color: #73a9e3; }

html[data-theme="dark"] #moduleSection .main-input-container {
  border-color: #383d45;
  background: #191c21;
  box-shadow: 0 24px 64px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.05);
}

html[data-theme="dark"] .input-area textarea,
html[data-theme="dark"] .fixed-input-area textarea {
  color: #e6edf5;
}

html[data-theme="dark"] .input-area textarea::placeholder,
html[data-theme="dark"] .fixed-input-area textarea::placeholder { color: #8295aa; }

html[data-theme="dark"] #moduleSection .toolbar { background: #20242a; }
html[data-theme="dark"] .drop-hint { color: #8498ae; }

html[data-theme="dark"] .language-toggle,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .model-select,
html[data-theme="dark"] .avatar,
html[data-theme="dark"] #moduleSection .file-btn {
  color: #d9e3ee;
  border-color: #393e46;
  background: #202328;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}

html[data-theme="dark"] .language-toggle:hover,
html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .model-select:hover,
html[data-theme="dark"] #moduleSection .file-btn:hover {
  color: #ffffff;
  border-color: #575d66;
  background: #2b2f35;
}

html[data-theme="dark"] .model-menu,
html[data-theme="dark"] .template-popup,
html[data-theme="dark"] .login-box,
html[data-theme="dark"] .confirm-box,
html[data-theme="dark"] .user-card {
  color: #e4ebf3;
  border-color: #343941;
  background: #181b20;
}

html[data-theme="dark"] .template-list-section,
html[data-theme="dark"] .template-preview-section,
html[data-theme="dark"] #historyMaskLayer .history-section,
html[data-theme="dark"] #statsMaskLayer .template-list-section {
  color: #dfe8f2;
  border-color: #343941;
  background: #181b20;
}

html[data-theme="dark"] .popup-head,
html[data-theme="dark"] .template-preview-section { border-color: #35465a; }
html[data-theme="dark"] .popup-head h3,
html[data-theme="dark"] .template-preview-section h4 { color: #edf3f9; }

html[data-theme="dark"] .search-input,
html[data-theme="dark"] select,
html[data-theme="dark"] .login-input,
html[data-theme="dark"] .template-preview-content,
html[data-theme="dark"] .history-tpl-item,
html[data-theme="dark"] .history-filter-bar,
html[data-theme="dark"] .history-table-wrapper,
html[data-theme="dark"] #statsMaskLayer .stats-filters,
html[data-theme="dark"] #statsMaskLayer .stat-card,
html[data-theme="dark"] #statsMaskLayer .stats-section {
  color: #dfe8f2;
  border-color: #383d45 !important;
  background: #202328 !important;
}

html[data-theme="dark"] .model-menu-item { color: #b8c5d3; }
html[data-theme="dark"] .model-menu-item:hover { color: #ffffff; background: #26384b; }
html[data-theme="dark"] .model-menu-item.active { color: #77b2f5; background: rgba(47,128,219,.16); }
html[data-theme="dark"] .history-table thead,
html[data-theme="dark"] #statsMaskLayer .stats-table th { background: #263545; color: #c9d6e4; }

/* Theme-aware cinematic startup with a layered orbital loader. */
.logo-animation {
  --intro-bg: #f4f7fb;
  --intro-bg-deep: #e9eff6;
  --intro-ink: #182230;
  --intro-muted: #6a788a;
  --intro-line: rgba(37, 99, 235, .18);
  --intro-ring: #287ce7;
  --intro-ring-soft: rgba(40, 124, 231, .22);
  --intro-card: rgba(255, 255, 255, .72);
  --intro-shadow: rgba(34, 76, 122, .18);
  overflow: hidden;
  background:
    linear-gradient(var(--intro-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--intro-line) 1px, transparent 1px),
    radial-gradient(520px 360px at 50% 46%, var(--intro-ring-soft), transparent 70%),
    linear-gradient(145deg, var(--intro-bg), var(--intro-bg-deep));
  background-size: 56px 56px, 56px 56px, auto, auto;
  animation: introCameraExit 620ms cubic-bezier(.65,0,.35,1) 1450ms forwards;
  perspective: 1000px;
}

html[data-theme="dark"] .logo-animation {
  --intro-bg: #0e1013;
  --intro-bg-deep: #171a1f;
  --intro-ink: #f3f5f7;
  --intro-muted: #9ba3ad;
  --intro-line: rgba(255, 255, 255, .035);
  --intro-ring: #f0f3f6;
  --intro-ring-soft: rgba(255, 255, 255, .09);
  --intro-card: rgba(31, 34, 39, .82);
  --intro-shadow: rgba(0, 0, 0, .42);
}

.logo-animation::before,
.logo-animation::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.logo-animation::before {
  width: min(64vw, 760px);
  aspect-ratio: 1;
  border: 1px solid var(--intro-line);
  box-shadow: 0 0 0 70px color-mix(in srgb, var(--intro-ring) 3%, transparent), 0 0 0 150px color-mix(in srgb, var(--intro-ring) 2%, transparent);
  animation: introOrbit 1100ms cubic-bezier(.2,.8,.2,1) both;
}

.logo-animation::after {
  width: 280px;
  height: 100px;
  background: var(--intro-ring-soft);
  filter: blur(60px);
  animation: introLightSweep 1000ms ease both;
}

.intro-ring {
  position: relative;
  z-index: 1;
  width: 174px;
  height: 174px;
  display: grid;
  place-items: center;
  animation: introLensFocus 800ms cubic-bezier(.16,1,.3,1) both;
}

.intro-ring-track {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--intro-ring-soft);
}

.ring-outer {
  border-top: 2px solid var(--intro-ring);
  border-right-color: transparent;
  animation: introSpin 1.35s cubic-bezier(.65,.05,.35,1) infinite;
}

.ring-middle {
  inset: 13px;
  border-left: 2px solid color-mix(in srgb, var(--intro-ring) 72%, transparent);
  border-bottom-color: transparent;
  animation: introSpinReverse 1.05s linear infinite;
}

.ring-inner {
  inset: 26px;
  border-top-color: transparent;
  border-right: 2px solid var(--intro-ring);
  animation: introSpin 1.8s linear infinite;
}

.intro-orbit-dot {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  animation: introSpin 1.35s cubic-bezier(.65,.05,.35,1) infinite;
}

.intro-orbit-dot::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--intro-ring);
  box-shadow: 0 0 18px var(--intro-ring);
}

.logo-animation .logo-container {
  z-index: 1;
  width: 92px;
  height: 92px;
  padding: 14px;
  border: 1px solid var(--intro-ring-soft);
  border-radius: 28px;
  background: var(--intro-card);
  box-shadow: 0 28px 70px var(--intro-shadow), inset 0 1px 0 rgba(255,255,255,.22);
  backdrop-filter: blur(18px);
}

.logo-animation .welcome-text {
  z-index: 1;
  margin-top: 24px;
  color: var(--intro-ink);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 650;
  letter-spacing: -.025em;
  animation: introCaption 500ms cubic-bezier(.2,.8,.2,1) 300ms both;
}

.intro-loading-label {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: var(--intro-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  animation: introCaption 500ms ease 480ms both;
}

.intro-loading-label span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--intro-ring);
  box-shadow: 0 0 12px var(--intro-ring);
  animation: introPulse 900ms ease-in-out infinite;
}

.logo-animation .welcome-text::before { display: none; }

@keyframes introLensFocus {
  0% { opacity: 0; transform: translateZ(-260px) scale(.72); filter: blur(18px); }
  55% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: translateZ(0) scale(1); filter: blur(0); }
}

@keyframes introCaption {
  from { opacity: 0; transform: translateY(14px); letter-spacing: .08em; }
  to { opacity: 1; transform: translateY(0); letter-spacing: -.025em; }
}

@keyframes introSpin { to { transform: rotate(360deg); } }
@keyframes introSpinReverse { to { transform: rotate(-360deg); } }
@keyframes introPulse { 50% { opacity: .35; transform: scale(.72); } }

@keyframes introOrbit {
  from { opacity: 0; transform: scale(.62) rotate(-9deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes introLightSweep {
  from { opacity: 0; transform: translateX(-260px) rotate(-12deg); }
  50% { opacity: 1; }
  to { opacity: 0; transform: translateX(280px) rotate(10deg); }
}

@keyframes introCameraExit {
  from { opacity: 1; transform: scale(1); filter: blur(0); }
  to { opacity: 0; transform: scale(1.08); filter: blur(10px); visibility: hidden; }
}

/* Final workspace polish: edge-aligned header, quiet guidance and responsive drop target. */
#moduleSection {
  position: relative;
}

#moduleSection .top-bar {
  position: absolute;
  top: 22px;
  left: 24px;
  right: 24px;
  width: auto;
  margin: 0;
}

#moduleSection .hero-intro {
  margin-top: clamp(78px, 10vh, 112px);
}

#moduleSection .hero-intro h2 {
  max-width: 980px;
  margin-inline: auto;
  font-size: clamp(34px, 4.15vw, 56px);
}

.hero-intro.greeting-refresh h2,
.hero-intro.greeting-refresh p {
  animation: greetingRefresh 480ms cubic-bezier(.2,.8,.2,1) both;
}

.hero-intro.greeting-refresh p { animation-delay: 60ms; }

@keyframes greetingRefresh {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

#moduleSection .main-input-container {
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), border-color 180ms ease, box-shadow 220ms ease;
}

#moduleSection .main-input-container:hover {
  transform: translateY(-2px);
  border-color: rgba(72,139,222,.72);
  box-shadow: 0 28px 66px rgba(17,45,75,.18), inset 0 1px 0 #fff;
}

#dropZone {
  position: relative;
  transition: background 180ms ease, box-shadow 180ms ease;
}

#dropZone.is-dragging {
  background: rgba(224,240,255,.78);
  box-shadow: inset 0 0 0 2px rgba(39,123,229,.48), inset 0 0 60px rgba(39,123,229,.1);
}

.drop-hint {
  padding: 8px 12px;
  border-radius: 999px;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.main-input-container:hover .drop-hint {
  color: #286eBA;
  background: rgba(39,123,229,.07);
  transform: translateY(-1px);
}

.main-input-container:hover .drop-hint i {
  animation: dropHintFloat 1.1s ease-in-out infinite;
}

@keyframes dropHintFloat { 50% { transform: translateY(3px); } }

/* Modern product tour fitted to the current workspace. */
#helpMaskLayer {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#helpMaskLayer.ui-modal-open {
  animation: helpBackdropIn 220ms ease-out both;
}

#helpMaskLayer.ui-modal-closing {
  animation: helpBackdropOut 200ms ease-in both;
}

@keyframes helpBackdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes helpBackdropOut { from { opacity: 1; } to { opacity: 0; } }

#helpMaskLayer .help-overlay {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#helpMaskLayer .help-blur-panel {
  position: fixed;
  z-index: 0;
  background: rgba(28,38,50,.22);
  backdrop-filter: blur(7px) saturate(.78);
  -webkit-backdrop-filter: blur(7px) saturate(.78);
  animation: helpPanelIn 220ms ease-out both;
}

@keyframes helpPanelIn {
  from { opacity: 0; backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(7px) saturate(.78); -webkit-backdrop-filter: blur(7px) saturate(.78); }
}

#helpMaskLayer .help-overlay > div {
  border: 2px solid rgba(107,174,255,.95) !important;
  border-radius: 18px !important;
  background: transparent !important;
  box-shadow: 0 0 0 7px rgba(64,145,238,.14), 0 12px 36px rgba(36,112,200,.2);
  animation: helpFocusPulse 1.8s ease-in-out infinite;
  transition: inset 240ms ease, width 240ms ease, height 240ms ease;
}

#helpMaskLayer .help-overlay > .help-blur-panel {
  border: 0 !important;
  border-radius: 0 !important;
  background: rgba(28,38,50,.22) !important;
  box-shadow: none !important;
  animation: helpPanelIn 220ms ease-out both !important;
}

.sidebar,
.sidebar-toggle,
.sidebar-item,
.sidebar-item span,
.sidebar-item img {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes helpFocusPulse {
  50% { box-shadow: 0 0 0 11px rgba(64,145,238,.07), 0 16px 42px rgba(36,112,200,.24); }
}

#helpMaskLayer .help-tooltip,
#helpControls .help-tooltip {
  width: min(340px, calc(100vw - 32px));
  max-width: 340px !important;
  padding: 20px !important;
  border: 1px solid rgba(255,255,255,.8) !important;
  border-radius: 22px !important;
  background: rgba(250,252,255,.96) !important;
  box-shadow: 0 26px 80px rgba(2,12,27,.28) !important;
  backdrop-filter: blur(20px);
  animation: modalPanelIn 300ms cubic-bezier(.16,1,.3,1) both;
}

#helpMaskLayer .help-tooltip h4,
#helpControls .help-tooltip h4 {
  margin: 0 0 10px !important;
  color: #172b43 !important;
  font-size: 18px;
}

#helpMaskLayer .help-tooltip div,
#helpControls .help-tooltip div {
  color: #60748b !important;
  font-size: 13px;
  line-height: 1.65;
}

#helpMaskLayer .help-tooltip p,
#helpControls .help-tooltip p { margin: 6px 0; }

#helpControls .help-tooltip {
  pointer-events: auto;
  z-index: 16020 !important;
}

/* Watercolor help card: theme blue and soft mint diffuse from its center. */
#helpControls .help-tooltip {
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.9) !important;
  outline: 1px solid rgba(82,153,228,.2);
  outline-offset: 1px;
  background: rgba(245,250,255,.62) !important;
  box-shadow:
    0 28px 80px rgba(31,62,98,.2),
    0 0 0 4px rgba(255,255,255,.12),
    inset 0 1px 0 rgba(255,255,255,1),
    inset 1px 0 0 rgba(255,255,255,.52),
    inset -1px 0 0 rgba(89,157,224,.13),
    inset 0 -1px 0 rgba(72,136,202,.18) !important;
  backdrop-filter: blur(24px) saturate(1.28) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.28) !important;
}

#helpControls .help-tooltip::before,
#helpControls .help-tooltip::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

#helpControls .help-tooltip::before {
  inset: -24%;
  background:
    radial-gradient(ellipse at center, rgba(44,132,239,.72) 0 24%, rgba(44,132,239,.42) 42%, transparent 69%) 42% 48% / 42% 48% no-repeat,
    radial-gradient(ellipse at center, rgba(115,231,174,.7) 0 22%, rgba(115,231,174,.4) 43%, transparent 68%) 59% 53% / 39% 51% no-repeat,
    radial-gradient(ellipse at center, rgba(65,164,235,.42) 0 18%, transparent 67%) 52% 61% / 32% 38% no-repeat,
    radial-gradient(ellipse at center, rgba(165,243,202,.46) 0 18%, transparent 66%) 49% 40% / 29% 33% no-repeat;
  filter: blur(11px) saturate(1.12);
  will-change: background-position, background-size, opacity;
  animation: helpSeparatedPigments 11.7s linear infinite;
}

#helpControls .help-tooltip::after {
  inset: 0;
  opacity: .62;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,.34) 0 9%, transparent 56%) 47% 47% / 38% 42% no-repeat,
    radial-gradient(ellipse at center, rgba(38,128,233,.16) 0 16%, transparent 62%) 57% 56% / 35% 41% no-repeat,
    radial-gradient(ellipse at center, rgba(106,222,164,.18) 0 15%, transparent 64%) 45% 55% / 34% 38% no-repeat;
  mix-blend-mode: normal;
  filter: blur(5px);
  will-change: background-position, background-size, opacity;
  animation: helpPigmentEddies 14.3s linear infinite;
}

#helpControls .help-tooltip > * {
  position: relative;
  z-index: 1;
}

@keyframes helpSeparatedPigments {
  0% { background-position: 42% 48%, 59% 53%, 52% 61%, 49% 40%; background-size: 42% 48%, 39% 51%, 32% 38%, 29% 33%; opacity: .78; }
  17% { background-position: 44% 45%, 57% 55%, 50% 59%, 52% 42%; background-size: 47% 42%, 35% 55%, 29% 43%, 34% 29%; opacity: .92; }
  39% { background-position: 40% 51%, 61% 50%, 54% 58%, 47% 43%; background-size: 39% 55%, 43% 45%, 36% 35%, 27% 38%; opacity: .84; }
  64% { background-position: 45% 50%, 56% 51%, 49% 63%, 53% 39%; background-size: 45% 46%, 36% 52%, 30% 40%, 33% 31%; opacity: .96; }
  83% { background-position: 41% 46%, 60% 56%, 53% 57%, 48% 41%; background-size: 40% 51%, 41% 47%, 35% 36%, 28% 36%; opacity: .86; }
  100% { background-position: 42% 48%, 59% 53%, 52% 61%, 49% 40%; background-size: 42% 48%, 39% 51%, 32% 38%, 29% 33%; opacity: .78; }
}

@keyframes helpPigmentEddies {
  0% { background-position: 47% 47%, 57% 56%, 45% 55%; background-size: 38% 42%, 35% 41%, 34% 38%; }
  23% { background-position: 50% 45%, 55% 58%, 47% 52%; background-size: 33% 47%, 39% 35%, 30% 43%; }
  51% { background-position: 46% 50%, 60% 53%, 43% 57%; background-size: 42% 36%, 31% 44%, 39% 34%; }
  76% { background-position: 49% 48%, 56% 55%, 48% 58%; background-size: 35% 44%, 37% 38%, 32% 41%; }
  100% { background-position: 47% 47%, 57% 56%, 45% 55%; background-size: 38% 42%, 35% 41%, 34% 38%; }
}

html[data-theme="dark"] #helpControls .help-tooltip {
  border: 1px solid rgba(104,166,232,.42) !important;
  outline-color: rgba(35,92,153,.34);
  background: rgba(11,16,23,.7) !important;
  box-shadow:
    0 28px 90px rgba(0,0,0,.5),
    0 0 0 4px rgba(35,102,177,.08),
    inset 0 1px 0 rgba(202,229,255,.18),
    inset 1px 0 0 rgba(116,180,240,.1),
    inset -1px 0 0 rgba(28,76,127,.2),
    inset 0 -1px 0 rgba(20,56,96,.32) !important;
  backdrop-filter: blur(24px) saturate(1.2) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.2) !important;
}

html[data-theme="dark"] #helpControls .help-tooltip::before {
  background:
    radial-gradient(ellipse at center, rgba(38,118,222,.62) 0 24%, rgba(38,118,222,.32) 42%, transparent 69%) 42% 48% / 42% 48% no-repeat,
    radial-gradient(ellipse at center, rgba(75,204,143,.46) 0 22%, rgba(75,204,143,.24) 43%, transparent 68%) 59% 53% / 39% 51% no-repeat,
    radial-gradient(ellipse at center, rgba(31,106,183,.4) 0 18%, transparent 67%) 52% 61% / 32% 38% no-repeat,
    radial-gradient(ellipse at center, rgba(117,223,165,.3) 0 18%, transparent 66%) 49% 40% / 29% 33% no-repeat;
}

html[data-theme="dark"] #helpControls .help-tooltip h4 { color: #f0f5f3 !important; }
html[data-theme="dark"] #helpControls .help-tooltip div { color: #b8c8c4 !important; }

@media (prefers-reduced-motion: reduce) {
  #helpControls .help-tooltip::before,
  #helpControls .help-tooltip::after { animation: none !important; }
}

/* Fine pigment revision: smaller streams, quicker eddies, 60% glass base. */
#helpControls .help-tooltip {
  background: rgba(245,250,255,.6) !important;
}

#helpControls .help-tooltip::before {
  inset: -12%;
  opacity: .9;
  background:
    radial-gradient(ellipse at center, rgba(42,128,238,.72) 0 16%, rgba(42,128,238,.25) 38%, transparent 68%) 44% 49% / 28% 31% no-repeat,
    radial-gradient(ellipse at center, rgba(106,228,166,.72) 0 15%, rgba(106,228,166,.24) 39%, transparent 69%) 56% 52% / 26% 30% no-repeat,
    radial-gradient(ellipse at center, rgba(60,158,235,.5) 0 12%, transparent 65%) 51% 43% / 19% 25% no-repeat,
    radial-gradient(ellipse at center, rgba(150,240,194,.54) 0 12%, transparent 66%) 48% 58% / 21% 23% no-repeat,
    radial-gradient(ellipse at center, rgba(45,121,220,.38) 0 10%, transparent 63%) 58% 45% / 16% 21% no-repeat,
    radial-gradient(ellipse at center, rgba(91,214,153,.4) 0 10%, transparent 64%) 42% 55% / 17% 20% no-repeat;
  filter: blur(8px) saturate(1.16);
  mix-blend-mode: multiply;
  animation: helpInkInWater 4.6s cubic-bezier(.42,0,.24,1) infinite;
}

#helpControls .help-tooltip::after {
  inset: -5%;
  opacity: .7;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,.46) 0 8%, transparent 57%) 50% 48% / 27% 24% no-repeat,
    radial-gradient(ellipse at center, rgba(51,139,237,.23) 0 11%, transparent 62%) 46% 54% / 22% 27% no-repeat,
    radial-gradient(ellipse at center, rgba(105,226,166,.25) 0 11%, transparent 63%) 55% 47% / 23% 24% no-repeat,
    radial-gradient(ellipse at center, rgba(255,255,255,.26) 0 7%, transparent 58%) 53% 57% / 18% 19% no-repeat;
  filter: blur(4px);
  mix-blend-mode: screen;
  animation: helpInkFilaments 3.8s cubic-bezier(.36,.03,.2,1) infinite reverse;
}

@keyframes helpInkInWater {
  0% { background-position: 44% 49%,56% 52%,51% 43%,48% 58%,58% 45%,42% 55%; background-size: 28% 31%,26% 30%,19% 25%,21% 23%,16% 21%,17% 20%; }
  14% { background-position: 46% 47%,54% 54%,49% 45%,51% 56%,56% 43%,44% 57%; background-size: 23% 35%,30% 25%,16% 29%,25% 19%,19% 17%,14% 24%; }
  31% { background-position: 43% 51%,58% 49%,53% 44%,46% 56%,56% 48%,45% 53%; background-size: 31% 24%,22% 35%,23% 18%,17% 27%,14% 23%,21% 16%; }
  49% { background-position: 47% 50%,53% 51%,49% 41%,52% 60%,59% 46%,41% 52%; background-size: 24% 34%,31% 23%,17% 27%,24% 18%,18% 20%,15% 25%; }
  68% { background-position: 42% 48%,57% 55%,52% 46%,47% 55%,55% 42%,46% 58%; background-size: 30% 26%,24% 33%,22% 20%,18% 28%,15% 24%,20% 17%; }
  86% { background-position: 46% 52%,55% 48%,48% 44%,51% 57%,60% 48%,40% 54%; background-size: 25% 32%,29% 26%,16% 30%,26% 17%,20% 16%,14% 23%; }
  100% { background-position: 44% 49%,56% 52%,51% 43%,48% 58%,58% 45%,42% 55%; background-size: 28% 31%,26% 30%,19% 25%,21% 23%,16% 21%,17% 20%; }
}

@keyframes helpInkFilaments {
  0% { background-position: 50% 48%,46% 54%,55% 47%,53% 57%; background-size: 27% 24%,22% 27%,23% 24%,18% 19%; }
  21% { background-position: 48% 51%,49% 52%,53% 50%,55% 54%; background-size: 22% 28%,27% 20%,19% 29%,21% 15%; }
  45% { background-position: 52% 46%,44% 56%,57% 45%,50% 59%; background-size: 30% 20%,18% 31%,26% 18%,15% 23%; }
  73% { background-position: 49% 50%,48% 51%,54% 52%,56% 56%; background-size: 24% 27%,25% 22%,20% 28%,22% 16%; }
  100% { background-position: 50% 48%,46% 54%,55% 47%,53% 57%; background-size: 27% 24%,22% 27%,23% 24%,18% 19%; }
}

html[data-theme="dark"] #helpControls .help-tooltip {
  background: rgba(10,15,22,.6) !important;
}

html[data-theme="dark"] #helpControls .help-tooltip::before {
  opacity: .82;
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse at center, rgba(35,113,220,.7) 0 16%, rgba(35,113,220,.23) 38%, transparent 68%) 44% 49% / 28% 31% no-repeat,
    radial-gradient(ellipse at center, rgba(75,205,143,.52) 0 15%, rgba(75,205,143,.18) 39%, transparent 69%) 56% 52% / 26% 30% no-repeat,
    radial-gradient(ellipse at center, rgba(33,103,181,.46) 0 12%, transparent 65%) 51% 43% / 19% 25% no-repeat,
    radial-gradient(ellipse at center, rgba(110,220,162,.36) 0 12%, transparent 66%) 48% 58% / 21% 23% no-repeat,
    radial-gradient(ellipse at center, rgba(26,76,143,.42) 0 10%, transparent 63%) 58% 45% / 16% 21% no-repeat,
    radial-gradient(ellipse at center, rgba(62,172,119,.32) 0 10%, transparent 64%) 42% 55% / 17% 20% no-repeat;
}

#helpControls .help-btn,
#helpControls .help-close,
#helpControls .help-step {
  border: 1px solid rgba(255,255,255,.22) !important;
  border-radius: 999px !important;
  background: rgba(20,27,36,.84) !important;
  color: #f5f7fa !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  backdrop-filter: blur(14px);
}

/* Noise-driven ink layer: many small streams, with only a density bias near centre. */
#helpControls .help-tooltip::before,
#helpControls .help-tooltip::after {
  display: none !important;
}

#helpControls .help-tooltip {
  background: rgba(242,248,253,.74) !important;
  backdrop-filter: blur(46px) saturate(.62) contrast(.86) brightness(1.06) !important;
  -webkit-backdrop-filter: blur(46px) saturate(.62) contrast(.86) brightness(1.06) !important;
}

html[data-theme="dark"] #helpControls .help-tooltip {
  background: rgba(10,15,22,.76) !important;
  backdrop-filter: blur(46px) saturate(.55) contrast(.84) brightness(.7) !important;
  -webkit-backdrop-filter: blur(46px) saturate(.55) contrast(.84) brightness(.7) !important;
}

#helpControls .help-ink-canvas {
  position: absolute !important;
  inset: 0;
  z-index: 0 !important;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .98;
  filter: blur(6px) saturate(.96);
  mix-blend-mode: normal;
  transform: scale(1.06);
}

html[data-theme="dark"] #helpControls .help-ink-canvas {
  opacity: .92;
  filter: blur(7px) saturate(.88);
  mix-blend-mode: normal;
}

#helpControls .help-tooltip > *:not(.help-ink-canvas) {
  position: relative;
  z-index: 1;
}

#helpControls .help-btn { min-width: 96px; min-height: 44px; }
#helpControls .help-close { padding: 9px 16px !important; font-size: 13px !important; }
#helpControls .help-step { padding: 7px 14px; }

/* One control language across history and analytics. */
#historyMaskLayer .search-input,
#historyMaskLayer select,
#statsMaskLayer select {
  height: 42px !important;
  min-width: 112px;
  padding: 0 38px 0 13px !important;
  border: 1px solid #d7e0ea !important;
  border-radius: 13px !important;
  color: #26394f;
  background: #f8fafc !important;
  font-size: 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#historyMaskLayer .search-input:focus,
#historyMaskLayer select:focus,
#statsMaskLayer select:focus {
  border-color: #6aa7ed !important;
  background: #fff !important;
  box-shadow: 0 0 0 4px rgba(54,135,228,.1);
}

/* Analytics rebuilt as a compact glass dashboard. */
#statsMaskLayer .template-popup {
  width: min(1120px, 95vw) !important;
  height: min(820px, 90vh) !important;
  border-radius: 28px !important;
  overflow: hidden;
}

#statsMaskLayer .template-list-section {
  padding: 26px !important;
  background: linear-gradient(145deg, #f8fafc, #eef3f8) !important;
  overflow-y: auto;
}

#statsMaskLayer .popup-head h3::before {
  content: "\f080";
  margin-right: 10px;
  color: #2c7dde;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
}

#statsMaskLayer .stats-filters {
  display: grid !important;
  grid-template-columns: auto minmax(130px, 190px) auto minmax(130px, 190px) 1fr auto;
  gap: 10px 12px !important;
  align-items: center !important;
  padding: 14px !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.8) !important;
  box-shadow: 0 10px 30px rgba(32,58,87,.06);
}

#statsMaskLayer #statsRefreshBtn,
#statsMaskLayer #statsError .btn {
  min-height: 42px;
  padding: 0 18px !important;
  border-radius: 13px !important;
  background: #287de2 !important;
  box-shadow: 0 8px 18px rgba(40,125,226,.22);
}

#statsMaskLayer .stat-card {
  position: relative;
  min-height: 112px;
  padding: 18px !important;
  border-radius: 20px !important;
  background: rgba(255,255,255,.88) !important;
  box-shadow: 0 12px 32px rgba(31,58,89,.07) !important;
  overflow: hidden;
}

#statsMaskLayer .stat-card::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -28px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(49,132,230,.08);
}

#statsMaskLayer .stat-label { color: #718196 !important; font-weight: 650; }
#statsMaskLayer .stat-value { margin-top: 10px; font-size: 28px !important; letter-spacing: -.035em; }

#statsMaskLayer .stats-section {
  padding: 0 !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.82) !important;
  overflow: hidden;
}

#statsMaskLayer .stats-section h4 { padding: 16px 18px 0; }
#statsMaskLayer .stats-table { border-collapse: separate !important; border-spacing: 0; }
#statsMaskLayer .stats-table th,
#statsMaskLayer .stats-table td {
  padding: 11px 14px !important;
  border: 0 !important;
  border-bottom: 1px solid #e7edf3 !important;
}

html[data-theme="dark"] #dropZone.is-dragging { background: rgba(51,112,181,.13); box-shadow: inset 0 0 0 2px rgba(103,167,239,.5); }
html[data-theme="dark"] #historyMaskLayer .search-input,
html[data-theme="dark"] #historyMaskLayer select,
html[data-theme="dark"] #statsMaskLayer select { color: #dbe2ea; border-color: #39404a !important; background: #202329 !important; }
html[data-theme="dark"] #statsMaskLayer .template-list-section { background: linear-gradient(145deg, #17191d, #111316) !important; }
html[data-theme="dark"] #statsMaskLayer .stats-filters,
html[data-theme="dark"] #statsMaskLayer .stat-card,
html[data-theme="dark"] #statsMaskLayer .stats-section { background: #1d2025 !important; border-color: #343941 !important; }
html[data-theme="dark"] #statsMaskLayer .stats-table td { border-bottom-color: #343941 !important; }

@media (max-width: 760px) {
  #moduleSection .top-bar { top: 16px; left: 16px; right: 16px; }
  #statsMaskLayer .stats-filters { grid-template-columns: 1fr 1fr !important; }
  #statsMaskLayer .stats-filters label { display: none; }
  #statsMaskLayer #statsRefreshBtn { grid-column: 1 / -1; }
}

/* Synchronized Codex-style rail motion. */
@media (min-width: 901px) {
  .sidebar {
    overflow: hidden;
    transition: width 300ms cubic-bezier(.2,.8,.2,1), min-width 300ms cubic-bezier(.2,.8,.2,1), background 180ms ease, border-color 180ms ease;
  }

  .sidebar-item {
    overflow: hidden;
    transition: width 300ms cubic-bezier(.2,.8,.2,1), padding 300ms cubic-bezier(.2,.8,.2,1), background 150ms ease, color 150ms ease;
  }

  .sidebar-item span,
  .sidebar.collapsed .sidebar-item span {
    display: block;
    max-width: 140px;
    opacity: 1;
    transform: translateX(0);
    overflow: hidden;
    transition: max-width 240ms cubic-bezier(.2,.8,.2,1), opacity 150ms ease, transform 240ms cubic-bezier(.2,.8,.2,1);
  }

  .sidebar.collapsed .sidebar-item span {
    max-width: 0;
    opacity: 0;
    transform: translateX(-8px);
  }

  .sidebar-toggle img {
    transition: transform 300ms cubic-bezier(.2,.8,.2,1), opacity 160ms ease;
  }

  .sidebar.collapsed .sidebar-toggle img {
    transform: rotate(180deg);
  }
}
