/* -- Core Animations -- */
@keyframes blink {

  from,
  25%,
  to {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(720deg);
  }

  to {
    transform: rotate(1440deg);
  }
}

/* -- Global -- */
body {
  margin: 0px;
  overflow-x: hidden;
  padding: 0px;
}

body::-webkit-scrollbar-track {
  background-color: #1e1e1e;
}

body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 100px;
}

body::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}

body input,
body h1,
body h3,
body a,
body span {
  color: #5a5a5a;
  font-family: "Rubik", sans-serif;
  font-weight: 400;
  margin: 0px;
  padding: 0px;
}

.background-image {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* -- App States -- */
#app {
  background-color: #1e1e1e;
}

#app.logged-out #app-background {
  cursor: pointer;
}

#app.logged-out #sign-in-button-wrapper {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -40px);
}

#app.logging-in #app-background #app-background-image,
#app.verifying-log-in #app-background #app-background-image,
#app.log-in-error #app-background #app-background-image {
  filter: blur(8px) brightness(0.4);
  transform: scale(1.1);
}

#app.logging-in #app-pin-wrapper,
#app.log-in-error #app-pin-wrapper {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

#app.verifying-log-in #app-loading-icon {
  opacity: 1;
  transform: translate(-50%, -50%);
}

#app.log-in-error #app-pin-wrapper #app-pin .app-pin-digit {
  background-color: rgba(239, 83, 80, 0.05);
  border-color: rgba(239, 83, 80, 0.5);
}

#app.logged-in #app-menu {
  height: auto;
  overflow: initial;
  opacity: 1;
  pointer-events: all;
  transform: translateY(0%);
}

/* -- Background -- */
#app #app-background {
  height: 100%;
  left: 0px;
  overflow: hidden;
  position: fixed;
  top: 0px;
  width: 100%;
  z-index: 1;
}

#app #app-background #app-background-image {
  height: 100%;
  width: 100%;
  background-position: center;
  background-size: cover;
  filter: brightness(0.6);
  transition: filter 250ms, transform 250ms;
}

/* -- Loading -- */
#app #app-loading-icon {
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, 0%);
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
}

#app #app-loading-icon i {
  animation: 2s spin ease-in-out infinite;
  color: white;
  font-size: 2em;
}

/* -- Sign In Wrapper -- */
#app #sign-in-button-wrapper {
  bottom: 0px;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, 40px);
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
}

/* -- PIN Input -- */
#app #app-pin-wrapper {
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -30%) scale(0.8);
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
  width: 90vw;
  max-width: 800px;
}

#app #app-pin-wrapper #app-pin {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

#app #app-pin-wrapper #app-pin .app-pin-digit {
  width: 35px;
  height: 50px;
  font-size: 1.5em;
  border-radius: 5px;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.06);
  display: inline-flex;
  justify-content: center;
  position: relative;
  transition: background-color 250ms, border-color 250ms;
}

#app #app-pin-wrapper #app-pin .app-pin-digit:before {
  background-color: whitesmoke;
  border-radius: 10px;
  bottom: 0px;
  height: 3px;
  left: 15%;
  opacity: 0;
  transform: translateY(0px);
  width: 70%;
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.06);
  content: "";
  position: absolute;
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
}

#app #app-pin-wrapper #app-pin .app-pin-digit:after {
  background-color: whitesmoke;
  border-radius: 20px;
  height: 20px;
  opacity: 0;
  transform: scale(0.25);
  width: 20px;
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.06);
  content: "";
  position: absolute;
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
}

#app #app-pin-wrapper #app-pin .app-pin-digit.focused:before {
  animation: blink 2s ease-in-out infinite;
  opacity: 1;
  transform: translateY(-10px);
}

#app #app-pin-wrapper #app-pin .app-pin-digit.hidden:after {
  opacity: 1;
  transform: scale(1);
}

#app #app-pin-wrapper #app-pin .app-pin-digit.hidden .app-pin-digit-value {
  opacity: 0;
  transform: scale(0.25);
}

#app #app-pin-wrapper #app-pin .app-pin-digit .app-pin-digit-value {
  color: whitesmoke;
  transition: opacity 250ms, transform 250ms;
}

#app #app-pin-wrapper #app-pin-hidden-input {
  background-color: transparent;
  border: none;
  height: 0px;
  outline: none;
  pointer-events: none;
  position: absolute;
  width: 0px;
}

.app-pin-paste-btn {
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 100px;
  color: whitesmoke;
  cursor: pointer;
  display: flex;
  font-family: "Rubik", sans-serif;
  font-size: 0.82em;
  gap: 8px;
  justify-content: center;
  margin: 18px auto 0;
  padding: 10px 18px;
  transition: all 150ms;
  width: fit-content;
}

#app #app-pin-wrapper .app-pin-paste-btn {
  color: whitesmoke;
}

.app-pin-paste-btn:hover {
  background: rgba(66, 165, 245, 0.16);
  border-color: rgba(66, 165, 245, 0.4);
  color: #42a5f5;
}

#app #app-pin-wrapper #app-pin-label {
  color: whitesmoke;
  font-size: 0.9em;
  margin: 10px;
  text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
}

#app #app-pin-wrapper #app-pin-label #app-pin-error-text {
  color: #ef5350;
}

.key-separator {
  color: whitesmoke;
  font-size: 1.5em;
  font-weight: bold;
  margin: 0 2px;
}

/* -- Top Bar (liquid glass) -- */
#app #app-topbar {
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  left: 16px;
  opacity: 0;
  padding: 12px 18px;
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 16px;
  transform: translateY(-14px);
  transition: opacity 250ms, transform 250ms;
  z-index: 5;
}

#app.logged-in #app-topbar {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0px);
}

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

.app-topbar-brand i {
  color: #42a5f5 !important;
  font-size: 1.05em !important;
}

.app-topbar-brand span {
  color: whitesmoke !important;
  font-size: 1em !important;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.app-topbar-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.topbar-logout-btn {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: flex;
  height: 34px;
  justify-content: center;
  transition: all 150ms;
  width: 34px;
}

.topbar-logout-btn i {
  font-size: 0.85em;
}

.topbar-logout-btn:hover {
  background: rgba(239, 83, 80, 0.14);
  border-color: rgba(239, 83, 80, 0.4);
  color: #ef5350;
}

@media (max-width: 600px) {
  .app-topbar-brand span {
    display: none;
  }

  #app #app-topbar {
    padding: 10px 14px;
  }
}

/* -- Menu Layout -- */
#app #app-menu {
  height: 100vh;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  position: relative;
  transform: translateY(-10%);
  transition: opacity 250ms, transform 250ms;
  z-index: 2;
}

#app #app-menu #app-menu-content-wrapper {
  background: linear-gradient(to bottom, transparent, #1e1e1e);
  margin-top: 30vh;
  min-height: 80vh;
  padding: 80px;
  padding-top: 0px;
}

/* -- Menu Section -- */
#app .menu-section {
  margin-top: 60px;
}

#app .menu-section .menu-section-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
}

#app .menu-section .menu-section-title .menu-section-title-main {
  align-items: center;
  display: flex;
  gap: 8px;
}

#app .menu-section .menu-section-title i,
#app .menu-section .menu-section-title span {
  color: whitesmoke;
}

#app .menu-section .menu-section-title .menu-section-title-main i {
  font-size: 0.95em;
  color: #42a5f5;
}

#app .menu-section .menu-section-title .menu-section-title-text {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.3em;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#app .menu-section .menu-section-content {
  margin-top: 20px;
  padding-top: 5px;
}

/* -- Stat Chips -- */
.tools-stats {
  align-items: center;
  display: flex;
  gap: 10px;
}

.stat-chip {
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 100px;
  display: flex;
  gap: 8px;
  padding: 7px 14px 7px 12px;
}

.stat-chip i {
  color: rgba(255, 255, 255, 0.35) !important;
  font-size: 0.72em !important;
}

.stat-chip .stat-value {
  color: whitesmoke !important;
  font-size: 0.85em !important;
  font-weight: 500;
}

.stat-chip .stat-label {
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 0.78em !important;
}

.stat-dot {
  background: #5ddc8a;
  border-radius: 50%;
  display: inline-block;
  height: 7px;
  width: 7px;
}

.stat-dot.pulse {
  animation: statPulse 2s ease-out infinite;
}

@keyframes statPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(93, 220, 138, 0.55);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(93, 220, 138, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(93, 220, 138, 0);
  }
}

/* -- Tool Cards Grid -- */
#app #tools-section .menu-section-content {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

#app #tools-section .menu-section-content .tool-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 22px;
  justify-content: space-between;
  min-height: 128px;
  overflow: hidden;
  padding: 18px;
  position: relative;
  transition: transform 220ms, border-color 220ms, background 220ms;
}

#app #tools-section .menu-section-content .tool-card:hover {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-4px);
}

.tool-card-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.tool-card-icon-wrap {
  align-items: center;
  background: var(--accent-soft, rgba(66, 165, 245, 0.14));
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: flex;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.tool-card-icon-wrap i {
  color: var(--accent, #42a5f5) !important;
  font-size: 1.05em !important;
}

.tool-card-arrow {
  color: rgba(255, 255, 255, 0.15) !important;
  font-size: 0.75em !important;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 220ms, transform 220ms;
}

.tool-card:hover .tool-card-arrow {
  color: var(--accent, #42a5f5) !important;
  opacity: 1;
  transform: translateX(0);
}

.tool-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-card-name {
  color: whitesmoke !important;
  font-size: 1.02em !important;
  font-weight: 500;
}

.tool-card-queue {
  align-items: center;
  color: rgba(255, 255, 255, 0.35) !important;
  display: flex;
  font-size: 0.78em !important;
  gap: 6px;
}

.tool-card-queue .queue-dot {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: inline-block;
  height: 6px;
  width: 6px;
}

.tool-card-queue.active .queue-dot {
  background: var(--accent, #42a5f5);
}

.tool-card-queue.active {
  color: var(--accent, #42a5f5) !important;
}

/* -- Tool Card Hover Glow -- */
#tools-section .tool-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 250ms;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 0 20px var(--accent-soft, rgba(66, 165, 245, 0.15)), 0 8px 24px rgba(0, 0, 0, 0.2);
}

#tools-section .tool-card:hover::after {
  opacity: 1;
}

/* -- Tool View (Inline Form) -- */
.tool-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tool-back-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-family: "Rubik", sans-serif;
  font-size: 0.9em;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 150ms;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tool-back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: whitesmoke;
  border-color: rgba(255, 255, 255, 0.2);
}

.tool-view-title {
  color: whitesmoke;
  font-size: 1.25em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}

.tool-view-icon-badge {
  align-items: center;
  background: var(--accent-soft, rgba(66, 165, 245, 0.14));
  border-radius: 10px;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.tool-view-icon-badge i {
  color: var(--accent, #42a5f5) !important;
  font-size: 0.9em !important;
}

.tool-view-body {
  max-width: 600px;
}

/* -- Segment Control -- */
.segment-control {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 20px;
}

.segment-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-family: "Rubik", sans-serif;
  font-size: 0.88em;
  cursor: pointer;
  transition: all 200ms;
  padding: 0;
  margin: 0;
  line-height: 38px;
  text-align: center;
}

.segment-btn.active {
  background: rgba(66, 165, 245, 0.14);
  color: #42a5f5;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(66, 165, 245, 0.08);
}

.segment-btn:hover:not(.active) {
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.03);
}

/* -- Form Fields -- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82em;
  margin-bottom: 7px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  color: #fff;
  font-family: "Rubik", sans-serif;
  font-size: 0.92em;
  outline: none;
  transition: border-color 200ms, box-shadow 200ms, background 200ms;
  box-sizing: border-box;
}

.form-group input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.form-group input:focus {
  border-color: rgba(66, 165, 245, 0.5);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.1);
}

/* -- Custom Checkbox -- */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 0.92em !important;
  margin-bottom: 0 !important;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 150ms;
  position: relative;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
  background: #42a5f5;
  border-color: #42a5f5;
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* -- Character Grid -- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  cursor: pointer;
  transition: all 200ms;
  user-select: none;
}

.char-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.char-card.selected {
  background: rgba(66, 165, 245, 0.08);
  border-color: rgba(66, 165, 245, 0.45);
  box-shadow: 0 0 0 2px rgba(66, 165, 245, 0.12);
}

.char-card img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.char-card span {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75em;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.char-card.selected span {
  color: #42a5f5;
}

.char-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #42a5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 200ms;
}

.char-card.selected .char-check {
  opacity: 1;
  transform: scale(1);
}

.char-check i {
  color: #fff !important;
  font-size: 0.6em !important;
}

.char-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(66, 165, 245, 0.12);
  border-radius: 100px;
  color: #42a5f5;
  font-size: 0.78em;
  margin-top: 10px;
}

/* -- Submit Button -- */
.btn-submit {
  width: 100%;
  padding: 13px 20px;
  margin-top: 8px;
  background: linear-gradient(135deg, #42a5f5, #1e88e5);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: "Rubik", sans-serif;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-submit:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(66, 165, 245, 0.25);
}

.btn-submit:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

.btn-submit.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn-submit .btn-spinner {
  display: none;
  animation: spin 0.8s linear infinite;
}

.btn-submit.loading .btn-spinner {
  display: inline-block;
}

.btn-submit.loading .btn-text {
  display: none;
}

.btn-submit .btn-loading-text {
  display: none;
}

.btn-submit.loading .btn-loading-text {
  display: inline;
}

/* -- Responsive -- */
@media (max-width: 1300px) {
  #app #app-menu #app-menu-content-wrapper {
    padding: 30px;
  }
}

@media (max-width: 600px) {
  #app #app-pin-wrapper #app-pin .app-pin-digit {
    width: 18px;
    height: 35px;
    font-size: 1em;
  }

  .key-separator {
    font-size: 0.8em;
    margin: 0 1px;
  }

  #app #tools-section .menu-section-content {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .char-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
  }
}



/* -- ปรับปรุง Layout หลัก -- */
#app #app-menu {
  position: fixed;
  top: 90px;
  /* เว้นที่ให้ TopBar */
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* สไตล์กระจกแบบเดียวกับ TopBar */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(25px) saturate(160%);
  -webkit-backdrop-filter: blur(25px) saturate(160%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  /* ให้ Scroll แค่ข้างใน */
}

#app.logged-in #app-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0px);
}

/* เนื้อหาข้างในที่ Scroll ได้ */
#app-menu-content-inner {
  height: 100%;
  overflow-y: auto;
  padding: 30px;
  box-sizing: border-box;
}

/* ปรับแต่ง Scrollbar ในเมนู */
#app-menu-content-inner::-webkit-scrollbar {
  width: 6px;
}

#app-menu-content-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* -- ตารางคิว (Queue Table) -- */
.queue-table-container {
  margin-top: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  color: whitesmoke;
  font-size: 0.9em;
}

.queue-table th {
  text-align: left;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.75em;
}

.queue-table td {
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.8em;
  text-transform: capitalize;
}

.status-badge.idle {
  background: rgba(93, 220, 138, 0.15);
  color: #5ddc8a;
}

.status-badge.working {
  background: rgba(66, 165, 245, 0.15);
  color: #42a5f5;
}

.table-footer-note {
  padding: 15px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.8em;
  text-align: center;
}

/* ปรับ Menu Section ให้ดูสะอาดขึ้น */
#app .menu-section {
  margin-top: 0;
  margin-bottom: 40px;
}

#app .menu-section:last-child {
  margin-bottom: 0;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  #app #app-menu {
    top: 80px;
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  #app-menu-content-inner {
    padding: 15px;
  }

  .queue-table th:nth-child(3),
  .queue-table td:nth-child(3) {
    display: none;
    /* ซ่อนช่อง Job ID บนมือถือ */
  }
}

/* -- ปรับปรุง Top Bar (Darker Glass) -- */
#app #app-topbar {
  align-items: center;
  /* ปรับให้มืดลงเหมือน Tool Cards */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);

  display: flex;
  gap: 16px;
  justify-content: space-between;
  left: 20px;
  opacity: 0;
  padding: 10px 20px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  top: 20px;
  transform: translateY(-14px);
  transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

#app.logged-in #app-topbar {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0px);
}

/* ปรับ Stat Chip (ตัวเลข workers) ให้ดูเข้ากัน */
.stat-chip {
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  gap: 8px;
  padding: 6px 14px;
}

.stat-chip .stat-value {
  color: #42a5f5 !important;
  /* เน้นตัวเลขให้เด่นด้วยสีฟ้า */
  font-weight: 700 !important;
  font-size: 0.95em !important;
}

.stat-chip .stat-label {
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 0.75em !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ปรับปุ่ม Logout ให้ดูเป็นส่วนหนึ่งของบาร์ */
.topbar-logout-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
}

.topbar-logout-btn:hover {
  background: rgba(239, 83, 80, 0.1);
  border-color: rgba(239, 83, 80, 0.3);
  color: #ef5350;
}

/* -- Premium Splash Loading Screen -- */
#app-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0e0e0e;
  /* พื้นหลังมืดสนิทป้องกันแสงขาว */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 500ms ease;
}

.loader-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* วงแหวนหมุนซ้อนกัน 2 ชั้น */
.loader-ring {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 50%;
  border-top-color: #42a5f5;
  animation: spin 2s linear infinite;
}

.loader-ring:nth-child(1) {
  width: 120px;
  height: 120px;
  border-top-color: #42a5f5;
  box-shadow: 0 0 20px rgba(66, 165, 245, 0.2);
}

.loader-ring:nth-child(2) {
  width: 140px;
  height: 140px;
  border-bottom-color: rgba(66, 165, 245, 0.3);
  animation: spin 3s linear reverse infinite;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.loader-icon {
  font-size: 2.5em;
  color: #42a5f5;
  filter: drop-shadow(0 0 10px rgba(66, 165, 245, 0.5));
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

.loader-status {
  color: whitesmoke;
  font-family: "Rubik", sans-serif;
  font-size: 0.9em;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.8;
}

/* จุดกระพริบ (...) */
.loader-dots span {
  width: 3px;
  height: 3px;
  background: #42a5f5;
  display: inline-block;
  border-radius: 50%;
  margin-left: 2px;
  animation: dotBlink 1.4s infinite both;
}

.loader-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotBlink {

  0%,
  80%,
  100% {
    opacity: 0;
  }

  40% {
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}

/* ลบ loading แบบเก่าออกถ้ามี */
#app #app-loading-icon {
  display: none;
}

/* -- Premium Footer -- */
.app-footer {
  margin-top: 60px;
  padding-bottom: 20px;
}

.footer-divider {
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  margin-bottom: 30px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-copyright {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85em;
  font-weight: 500;
}

.footer-version {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.7em;
  margin-top: 4px;
  letter-spacing: 1px;
}

/* Discord Card Button */
.discord-card-btn {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 20px;
  border-radius: 16px;
  text-decoration: none;
  transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.discord-card-btn:hover {
  background: rgba(88, 101, 242, 0.1);
  border-color: rgba(88, 101, 242, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.discord-icon-box {
  width: 40px;
  height: 40px;
  background: #5865f2;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

.discord-icon-box i {
  color: white !important;
  font-size: 1.4em !important;
}

.discord-info {
  display: flex;
  flex-direction: column;
}

.discord-title {
  color: whitesmoke !important;
  font-size: 0.9em !important;
  font-weight: 600;
}

.discord-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.discord-count {
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 0.75em !important;
}

.discord-external {
  color: rgba(255, 255, 255, 0.15) !important;
  font-size: 0.8em !important;
  margin-left: 5px;
}

.discord-card-btn:hover .discord-external {
  color: #5865f2 !important;
}

/* จุดเขียวออนไลน์แบบพรีเมียม */
.status-dot-pulse {
  width: 8px;
  height: 8px;
  background: #5ddc8a;
  border-radius: 50%;
  position: relative;
}

.status-dot-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #5ddc8a;
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  70% {
    transform: scale(2.5);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .discord-card-btn {
    width: 100%;
    justify-content: center;
  }
}

/* -- ปรับปรุงส่วน Background -- */
#app-background {
  height: 100%;
  left: 0px;
  overflow: hidden;
  position: fixed;
  top: 0px;
  width: 100%;
  z-index: 1;
  background-color: #0e0e0e;
  /* สีพื้นหลังสำรองระหว่างโหลดรูป */
}

#app-background-image {
  height: 100%;
  width: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;

  /* ย้าย URL มาไว้ที่นี่ */
  background-image: url("https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExcjhqZmRtazI1aHEzdTdyNHFibzY0OHA0d3FqMTljNGQwMnA5enM5dyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/TxVVB6PfWMjE4/giphy.gif");

  filter: brightness(0.6);
  transition: filter 250ms, transform 250ms;
}

/* -- Table Container (Liquid Glass) -- */
.queue-table-container {
  width: 100%;
  overflow-x: auto;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: border-color 220ms ease, background 220ms ease;
}

.queue-table-container:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* -- Table Elements -- */
.queue-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-family: "Rubik", sans-serif;
  font-size: 0.85rem;
}

.queue-table th {
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.queue-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
  color: rgba(255, 255, 255, 0.85);
}

.queue-table tbody tr {
  transition: background 220ms ease;
}

.queue-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.queue-table tbody tr:last-child td {
  border-bottom: none;
}

/* -- Liquid Glass Progress Bar -- */
.progress-container {
  width: 100%;
  min-width: 120px;
  height: 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 100px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.8), rgba(52, 211, 153, 0.8));
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.progress-bar.complete {
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.85), rgba(16, 185, 129, 0.9));
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  z-index: 2;
}

/* -- Liquid Glass Badges -- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
}

.type-badge {
  background: linear-gradient(160deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.04));
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.priority-badge {
  background: linear-gradient(160deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.04));
  color: #fde047;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.member-info {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  font-family: monospace;
}

.in-flight-badge {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.78rem;
}

.in-flight-badge.active {
  color: #7dd3fc;
}

.duration-tag {
  color: #34d399;
  font-weight: 600;
  font-family: monospace;
  font-size: 0.8rem;
}

.stat-badge {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  font-family: monospace;
}