.mail-button-corner {
  display: flex;
  align-items: center;
  gap: 10px;
}

#signinNotification {
  display: none;
}

#signinNotification.show {
  display: flex;
}

.signin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px 12px 70px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-sizing: border-box;
}

.signin-overlay.show {
  display: flex;
}

.signin-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 20px 20px;
  background: linear-gradient(135deg, rgba(10, 10, 30, 0.98) 0%, rgba(20, 20, 50, 0.98) 100%);
  border: 2px solid rgba(0, 255, 255, 0.3);
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 255, 255, 0.2);
  font-family: 'Orbitron', sans-serif;
  color: #fff;
  animation: signinPanelIn 0.35s ease-out;
}

@keyframes signinPanelIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.signin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.signin-title {
  margin: 0;
  color: #00ffff;
  font-size: 1.15em;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.6);
}

.signin-month {
  color: #ffd93d;
  font-size: 0.8em;
  font-weight: 700;
  margin-left: 8px;
  text-shadow: 0 0 8px rgba(255, 217, 61, 0.5);
}

.signin-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85em;
  color: #b8e6ff;
}

.signin-count {
  color: #fff;
  font-weight: 700;
}

.signin-count strong {
  color: #00ffff;
  font-size: 1.2em;
}

.signin-legend {
  display: flex;
  gap: 12px;
}

.signin-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -1px;
}

.signin-legend .legend-sign::before {
  border: 2px solid #ff3d3d;
}

.signin-legend .legend-makeup::before {
  border: 2px solid #3d8bff;
}

.signin-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.signin-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: linear-gradient(135deg, rgba(15, 15, 35, 0.8) 0%, rgba(25, 25, 55, 0.6) 100%);
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.signin-cell-no {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 0.65em;
  font-weight: 700;
  color: #b8e6ff;
}

.signin-cell-icon {
  width: 52%;
  height: 52%;
  object-fit: contain;
  pointer-events: none;
}

.signin-cell-qty {
  display: flex;
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  font-size: 0.65em;
  font-weight: 700;
  color: #fff;
}

.signin-cell-mini {
  width: 1.5em;
  height: 1.5em;
  object-fit: contain;
  pointer-events: none;
}

.signin-cell.is-final {
  border-color: rgba(255, 217, 61, 0.7);
  box-shadow: inset 0 0 12px rgba(255, 217, 61, 0.25);
}

.signin-cell.is-final .signin-cell-no {
  color: #ffd93d;
}

.signin-cell.is-pending {
  filter: grayscale(1);
  opacity: 0.4;
}

.signin-cell.is-next {
  border-color: #00ffff;
  animation: signinNextGlow 1.6s ease-in-out infinite alternate;
}

@keyframes signinNextGlow {
  from { box-shadow: 0 0 4px rgba(0, 255, 255, 0.3); }
  to { box-shadow: 0 0 14px rgba(0, 255, 255, 0.8); }
}

.signin-stamp {
  position: absolute;
  inset: 12%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px double currentColor;
  font-size: 1.15em;
  font-weight: 900;
  transform: rotate(-14deg);
  background: rgba(10, 10, 30, 0.6);
  pointer-events: none;
}

.signin-stamp.stamp-sign {
  color: #ff3d3d;
  text-shadow: 0 0 6px rgba(255, 61, 61, 0.6);
  box-shadow: 0 0 10px rgba(255, 61, 61, 0.45);
}

.signin-stamp.stamp-makeup {
  color: #3d8bff;
  text-shadow: 0 0 6px rgba(61, 139, 255, 0.6);
  box-shadow: 0 0 10px rgba(61, 139, 255, 0.45);
}

.signin-cell.is-stamping .signin-stamp {
  animation: signinStampDrop 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.signin-cell.is-stamping {
  animation: signinCellShake 0.35s ease-out 0.3s;
}

@keyframes signinStampDrop {
  0% { opacity: 0; transform: scale(2.6) rotate(-40deg); }
  60% { opacity: 1; transform: scale(0.9) rotate(-10deg); }
  100% { opacity: 1; transform: scale(1) rotate(-14deg); }
}

@keyframes signinCellShake {
  0%, 100% { transform: none; }
  30% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
}

.signin-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.signin-message {
  min-height: 1.2em;
  white-space: pre-line;
  font-size: 0.85em;
  color: #ffd93d;
  text-align: center;
}

.signin-message.is-error {
  color: #ff6b6b;
}

.signin-rule {
  font-size: 0.72em;
  color: #b8e6ff;
  opacity: 0.8;
  text-align: center;
  line-height: 1.5;
}

.signin-action-btn {
  min-width: 160px;
  min-height: 44px;
  padding: 10px 22px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
  border: 2px solid rgba(0, 255, 255, 0.5);
  border-radius: 12px;
  color: #00ffff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95em;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  touch-action: manipulation;
}

.signin-action-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.25) 0%, rgba(139, 92, 246, 0.15) 100%);
  border-color: rgba(0, 255, 255, 0.8);
  transform: translateY(-1px);
}

.signin-action-btn.is-makeup {
  color: #3d8bff;
  border-color: rgba(61, 139, 255, 0.6);
  background: linear-gradient(135deg, rgba(61, 139, 255, 0.18) 0%, rgba(0, 255, 255, 0.06) 100%);
}

.signin-action-btn:disabled {
  background: linear-gradient(135deg, rgba(108, 117, 125, 0.2) 0%, rgba(90, 98, 104, 0.1) 100%);
  border-color: rgba(108, 117, 125, 0.4);
  color: rgba(108, 117, 125, 0.8);
  cursor: not-allowed;
}

.signin-tip {
  position: absolute;
  z-index: 5;
  display: none;
  width: min(260px, calc(100% - 16px));
  box-sizing: border-box;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(10, 10, 30, 0.98) 0%, rgba(25, 25, 55, 0.98) 100%);
  border: 1px solid rgba(0, 255, 255, 0.5);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 255, 255, 0.25);
  cursor: default;
}

.signin-tip.show {
  display: block;
}

.signin-tip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  color: #ffd93d;
  font-size: 0.85em;
  font-weight: 700;
}

.signin-tip-state {
  font-size: 0.85em;
  color: #b8e6ff;
}

.signin-tip-state.is-sign {
  color: #ff3d3d;
}

.signin-tip-state.is-makeup {
  color: #3d8bff;
}

.signin-tip-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.signin-tip-row + .signin-tip-row {
  margin-top: 8px;
}

.signin-tip-row img {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.signin-tip-name {
  color: #00ffff;
  font-size: 0.85em;
  font-weight: 700;
}

.signin-tip-desc {
  margin-top: 2px;
  color: #b8e6ff;
  font-size: 0.72em;
  line-height: 1.5;
  white-space: pre-line;
}

.signin-busy {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.55);
  cursor: wait;
}

.signin-busy.show {
  display: flex;
}

.signin-busy-ring {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(0, 255, 255, 0.2);
  border-top-color: #00ffff;
  border-radius: 50%;
  animation: signinBusySpin 0.9s linear infinite;
}

@keyframes signinBusySpin {
  to { transform: rotate(360deg); }
}

.signin-busy-text {
  color: #00ffff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

/* 手機佈局 */
@media (max-width: 768px) {
  .mail-button-corner {
    gap: 6px;
  }

  .signin-overlay {
    padding: 10px 8px 80px;
  }

  .signin-panel {
    padding: 14px 12px 16px;
    border-radius: 12px;
  }

  .signin-title {
    font-size: 1em;
  }

  .signin-grid {
    gap: 6px;
  }

  .signin-stamp {
    font-size: 1em;
    border-width: 2px;
  }
}

@media (max-width: 380px) {
  .signin-grid {
    gap: 4px;
  }

  .signin-cell-no,
  .signin-cell-qty {
    font-size: 0.58em;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .signin-overlay {
    padding: 8px 8px 50px;
  }

  .signin-panel {
    max-width: 440px;
  }
}

.perf-mode-low .signin-panel,
.perf-mode-low .signin-cell.is-next,
.battery-saver .signin-panel,
.battery-saver .signin-cell.is-next {
  animation: none !important;
}

.perf-mode-low .signin-overlay,
.battery-saver .signin-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
